Remove redundant Glib::Timeout call.
[picture-display.git] / lib / Display / Plugins / Clock.pm
1 package Display::Plugins::Clock;
2
3 use Clutter;
4 use POSIX qw/strftime/;
5 use base ('Display::Plugin');
6
7 sub new {
8   my $proto = shift;
9   my $class = ref($proto) || $proto;
10
11   my $self = $class->SUPER::new(@_);
12
13   bless ($self, $class);
14   $self->init();
15   return $self;
16 }
17
18 sub display {
19   my $self = shift;
20
21   $self->{'clock'}->set_text(strftime("%H:%M %d/%m/%Y", localtime(time)));
22
23   $self->{'kernel'}->delay_set(clock_display, 60 - strftime(%s, localtime()));
24 }
25
26 sub init {
27   my $self = shift;
28
29   $self->{'kernel'}->state('clock_display', $self, 'display');
30
31   $self->{'clock'} = Clutter::Label->new('Sans 20', strftime("%H:%M %d/%m/%Y", localtime(time)));
32   $self->{'clock'}->set_anchor_point($self->{'clock'}->get_width(), 1);
33   $self->{'clock'}->set_position($self->{'stage'}->get_width() - 20, 15);
34   $self->{'clock'}->set_color(Clutter::Color->parse('White'));
35
36   $self->{'bg'} = Clutter::Rectangle->new(Clutter::Color->parse('Black'));
37   $self->{'bg'}->set_width($self->{'clock'}->get_width() + 20);
38   $self->{'bg'}->set_height($self->{'clock'}->get_height() + 10);
39   $self->{'bg'}->set_anchor_point($self->{'bg'}->get_width(), 1);
40   $self->{'bg'}->set_position($self->{'stage'}->get_width() - 10, 10);
41   $self->{'bg'}->set_opacity(100);
42
43   $self->{'stage'}->add($self->{'bg'});
44   $self->{'stage'}->add($self->{'clock'});
45
46   $self->{'kernel'}->delay_set(clock_display, 60 - strftime(%s, localtime()));
47 }
48
49 1;