line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SystemTray::Applet::Gnome; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
27818
|
use warnings; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
40
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
44
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use base qw( SystemTray::Applet ); |
|
1
|
|
|
|
|
16
|
|
|
1
|
|
|
|
|
603
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
427
|
use Gtk2; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Gtk2::TrayIcon; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
SystemTray::Applet::Gnome - Gnome support for SystemTray::Applet |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 VERSION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Version 0.02 |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 SYNOPSIS |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
This module provides gnome support for SystemTray::Applet. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
use SystemTray::Applet::Gnome; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $foo = SystemTray::Applet::CmdLine->create( "text" => "hello world" ); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 FUNCTIONS |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head2 init |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
$self->init(); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Initialize the toolkit env. Sets up Gtk2 and creates a tray icon. |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=cut |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub init |
46
|
|
|
|
|
|
|
{ |
47
|
|
|
|
|
|
|
my ( $self ) = @_; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Gtk2->init(); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
$self->{"gnome"}->{"applet"} = Gtk2::TrayIcon->new(""); |
52
|
|
|
|
|
|
|
unless( $self->{"gnome"}->{"applet"} ) |
53
|
|
|
|
|
|
|
{ |
54
|
|
|
|
|
|
|
warn( "Unable to create gnome tray icon" ); |
55
|
|
|
|
|
|
|
return undef; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
$self->{"gnome"}->{"eventbox"} = Gtk2::EventBox->new(); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
my $button_release = sub { |
61
|
|
|
|
|
|
|
my ( $self , $e ) = @_; |
62
|
|
|
|
|
|
|
if( $e->button() == 3 ) |
63
|
|
|
|
|
|
|
{ |
64
|
|
|
|
|
|
|
my $menu = Gtk2::Menu->new(); |
65
|
|
|
|
|
|
|
my $menu_item = Gtk2::MenuItem->new_with_label("Quit"); |
66
|
|
|
|
|
|
|
$menu_item->signal_connect( "activate" => sub { Gtk2->main_quit; } ); |
67
|
|
|
|
|
|
|
$menu_item->show(); |
68
|
|
|
|
|
|
|
$menu->append($menu_item); |
69
|
|
|
|
|
|
|
$menu->popup( undef , undef , undef , undef , $e->button() , $e->time() ); |
70
|
|
|
|
|
|
|
print "Done\n"; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
}; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
$self->{"gnome"}->{"eventbox"}->signal_connect( "button_release_event" => $button_release ); |
75
|
|
|
|
|
|
|
$self->{"gnome"}->{"applet"}->add($self->{"gnome"}->{"eventbox"}); |
76
|
|
|
|
|
|
|
$self->{"gnome"}->{"applet"}->show_all(); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
return $self; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 start |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
$self->start(); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Start the gui up by starting the gtk mainloop. Never returns. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub start |
91
|
|
|
|
|
|
|
{ |
92
|
|
|
|
|
|
|
Gtk2->main(); |
93
|
|
|
|
|
|
|
exit(0); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 create_icon |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
$self->create_icon("an_icon.jpg" ); |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Create an icon from a file and return it. Supports whatever gtk2::Image does. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=cut |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub create_icon |
106
|
|
|
|
|
|
|
{ |
107
|
|
|
|
|
|
|
my ( $self , $icon ) = @_; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
if( defined( $icon ) ) |
110
|
|
|
|
|
|
|
{ |
111
|
|
|
|
|
|
|
return Gtk2::Image->new_from_file($icon); |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
else |
114
|
|
|
|
|
|
|
{ |
115
|
|
|
|
|
|
|
return undef; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head2 display |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
$self->display(); |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Display the icon with the text as hovertext if we have an icon or just the text if not. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=cut |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub display |
129
|
|
|
|
|
|
|
{ |
130
|
|
|
|
|
|
|
my ( $self ) = @_; |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
my @children = $self->{"gnome"}->{"eventbox"}->get_children(); |
133
|
|
|
|
|
|
|
foreach my $child( @children ) |
134
|
|
|
|
|
|
|
{ |
135
|
|
|
|
|
|
|
$self->{"gnome"}->{"eventbox"}->remove($child); |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
if( $self->{"icon"} ) |
139
|
|
|
|
|
|
|
{ |
140
|
|
|
|
|
|
|
$self->{"gnome"}->{"eventbox"}->add( $self->{"icon"} ); |
141
|
|
|
|
|
|
|
my $tooltip = Gtk2::Tooltips->new(); |
142
|
|
|
|
|
|
|
$tooltip->enable(); |
143
|
|
|
|
|
|
|
$tooltip->set_tip( $self->{"gnome"}->{"eventbox"} , $self->{"text"} ); |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
else |
146
|
|
|
|
|
|
|
{ |
147
|
|
|
|
|
|
|
my $label = Gtk2::Label->new($self->{"text"}); |
148
|
|
|
|
|
|
|
$self->{"gnome"}->{"eventbox"}->add($label); |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
$self->{"gnome"}->{"applet"}->show_all(); |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head2 schedule |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
$self->schedule(); |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Schedule the callbackusing Glib::Timeout |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=cut |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
sub schedule |
165
|
|
|
|
|
|
|
{ |
166
|
|
|
|
|
|
|
my ( $self ) = @_; |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
if( $self->{"frequency"} != -1 ) |
169
|
|
|
|
|
|
|
{ |
170
|
|
|
|
|
|
|
if($self->{"gnome"}->{"timeout"}) |
171
|
|
|
|
|
|
|
{ |
172
|
|
|
|
|
|
|
Glib::Source->remove($self->{"gnome"}->{"timeout"}) |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
$self->{"gnome"}->{"timeout"} = Glib::Timeout->add ( $self->{"frequency"} * 1000 , sub { $self->{"callback"}->( $self) } ); |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head2 _order |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
This specifies the priority used by SystemTray::Applet->new when loading plugin. Gnome is 2 as if it is installed we should probably use it. |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=cut |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
sub _order |
187
|
|
|
|
|
|
|
{ |
188
|
|
|
|
|
|
|
return 2; |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=head1 AUTHOR |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
Peter Sinnott, C<< >> |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=head1 BUGS |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
198
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
199
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=head1 SUPPORT |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
perldoc SystemTray::Applet::Gnome |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
You can also look for information at: |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=over 4 |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
L |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
L |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=item * CPAN Ratings |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
L |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=item * Search CPAN |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
L |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=back |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
Copyright 2008 Peter Sinnott, all rights reserved. |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
242
|
|
|
|
|
|
|
under the same terms as Perl itself. |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
=cut |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
1; # End of SystemTray::Applet::Gnome |