]> git.zerfleddert.de Git - snom-frontend/commitdiff
Added tray and icon
authormorty <morty@cs.fau.de>
Thu, 8 Jul 2010 06:47:08 +0000 (08:47 +0200)
committermorty <morty@cs.fau.de>
Thu, 8 Jul 2010 06:47:08 +0000 (08:47 +0200)
snom.ico [new file with mode: 0644]
snom.pl

diff --git a/snom.ico b/snom.ico
new file mode 100644 (file)
index 0000000..7639919
Binary files /dev/null and b/snom.ico differ
diff --git a/snom.pl b/snom.pl
index 6f580ab3da4a1ee726cedc76a0265081ef337f75..3ee79daad211a548ffc900bc3c2716871df6c86c 100755 (executable)
--- a/snom.pl
+++ b/snom.pl
@@ -201,7 +201,55 @@ $mainbox->show();
 
 
 
+#########################################################
+#
+#     Tray Icon
+#
+#########################################################
+sub quit_cb {
+   my ($widget, $status_icon) = @_;
+   $status_icon->set_visible(0) if $status_icon;
+   Gtk2->main_quit();
+}
+
+sub popup_menu_cb {
+   my ($widget, $button, $time, $menu) = @_;
+
+   if ($button == 3) {
+         my ($x, $y, $push_in)
+         = Gtk2::StatusIcon::position_menu($menu, $widget);
+
+       $menu->show_all();
+       $menu->popup( undef, undef,
+             sub{return ($x,$y,0)} ,
+             undef, 0, $time );
+   }
+}
+
+sub activate_icon_cb {
+       if ($window->visible){
+               $window->hide();
+       } else {
+               $window->show();
+       }
+}
+
+my $status_icon = Gtk2::StatusIcon->new_from_file('snom.ico');
+my $menu = Gtk2::Menu->new();
+
+my $menuItem = Gtk2::ImageMenuItem->new_from_stock('gtk-quit');
+$menuItem->signal_connect('activate', \&quit_cb, $status_icon);
+$menu->append($menuItem);
+
+$status_icon->set_tooltip(" Snom Tray ");
+$status_icon->signal_connect('activate', \&activate_icon_cb);
+$status_icon->signal_connect('popup-menu', \&popup_menu_cb, $menu);
+$status_icon->set_visible(1);
+########################################################################333
+
 $window->add($mainbox);
+$window->set_icon_from_file('snom.ico');
 $window->show();
 
 $g_key{OK}->grab_focus();
Impressum, Datenschutz