From: morty Date: Thu, 8 Jul 2010 06:47:08 +0000 (+0200) Subject: Added tray and icon X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/snom-frontend/commitdiff_plain/a56262448a11bb90d558c3f69e955cf595896398?ds=sidebyside Added tray and icon --- diff --git a/snom.ico b/snom.ico new file mode 100644 index 0000000..7639919 Binary files /dev/null and b/snom.ico differ diff --git a/snom.pl b/snom.pl index 6f580ab..3ee79da 100755 --- 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();