Re: Applets
- From: "Chas Owens" <chas owens gmail com>
- To: "Juan José 'Peco' San Martín" <peco microbotica es>
- Cc: gtk-perl Mailing List <gtk-perl-list gnome org>
- Subject: Re: Applets
- Date: Thu, 1 Feb 2007 16:42:25 -0500
On 2/1/07, Juan José 'Peco' San Martín <peco microbotica es> wrote:
snip
Is PerlPanel currently the best approach to deploy Applets?. Do you have
another solution?.
snip
Depending on what you want to do Gtk2::TrayIcon may suit your needs.
It acts as a container for widgets in the Notification Area. I use
the following code to turn my vpn connection on and off.
#!/usr/bin/perl
use strict;
use Gtk2::TrayIcon;
Gtk2->init;
my $current;
if (grep { /vpnc/ } `ps -ef`) {
$current = 'connect';
} else {
$current = 'disconnect';
}
my $size = 'small-toolbar';
my $icon = Gtk2::TrayIcon->new("vpn control");
my $ev = Gtk2::EventBox->new;
my $img = Gtk2::Image->new_from_stock("gtk-$current", $size);
$icon->add($ev);
$ev->add($img);
$ev->signal_connect('button_release_event', sub {
if ($current eq 'connect') {
$current = 'disconnect';
system "gksudo vpnc-disconnect";
} else {
$current = 'connect';
system "gksudo vpnc /home/cowens/.vpn.conf";
}
$img->set_from_stock("gtk-$current", $size);
});
$icon->show_all;
Gtk2->main;
- References:
- Applets
- From: Juan =?ISO-8859-1?Q?Jos=E9?= 'Peco' San =?ISO-8859-1?Q?Mart=EDn?=
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]