File: clock.e

package info (click to toggle)
entity 1.0.1-8
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 5,604 kB
  • ctags: 5,394
  • sloc: ansic: 64,242; sh: 7,377; makefile: 776; perl: 319
file content (47 lines) | stat: -rw-r--r-- 1,131 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env entity

<object>
  <window ondelete="entity:exit" title="Clock">
    <valign>
      <object onbuttonpress="context_menu" name="clock" dragable="true" expand="false">
        <popupmenu name="context">
	  <menuitem label="Remove" onselect="entity:exit"/>
	</popupmenu>
	<label name="time" text = "00:00:00"/>
	<timer interval = "100" action="update_clock"/>
        <timer interval = "6000" action="update_tooltip"/>
	<perl>
	    use Time::localtime;
	    
	    sub update_clock
	      {
	        my $str = sprintf ("%02d:%02d:%02d", localtime->hour(), 
		                   localtime->min(), localtime->sec());
		
		my $label = enode ("label.time");
		$label->attrib("text" => $str);
		
	      }
	    update_clock ();
	    
	    sub update_tooltip
	      {
	        my $datestr = ctime();
		enode ("object")->attrib ("tooltip" => $datestr);
	      }
	    update_tooltip ();
	    
	    sub context_menu
	      {
	        my ($node, $button) = @_;
				
		if ($button == 3) {
		  enode ("popupmenu.context")->attrib ("popup" => "true");
		}
	      }
	      
	</perl>
      </object>
    </valign>
  </window>
</object>