summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Vignaud <thierry.vignaud@gmail.com>2015-06-09 07:14:41 -0400
committerThierry Vignaud <thierry.vignaud@gmail.com>2015-09-03 06:45:20 +0200
commitd0fe77265c37dc39ad8c7fbfccc204e1c6d5f4ad (patch)
treef3350316547f58bf2fd9261b7498e15f9c68af3f
parent4e285a0a6f56c7e213ee0334c9d2856162d11b38 (diff)
downloaddrakx-net-d0fe77265c37dc39ad8c7fbfccc204e1c6d5f4ad.tar
drakx-net-d0fe77265c37dc39ad8c7fbfccc204e1c6d5f4ad.tar.gz
drakx-net-d0fe77265c37dc39ad8c7fbfccc204e1c6d5f4ad.tar.bz2
drakx-net-d0fe77265c37dc39ad8c7fbfccc204e1c6d5f4ad.tar.xz
drakx-net-d0fe77265c37dc39ad8c7fbfccc204e1c6d5f4ad.zip
stop using Gtk3::Notify::Queue as it's broken
rationale: 'closed' signal is never sent by libnotify and thus queue is never popped and thus net_applet always shows the same first message, the others are never shown
-rw-r--r--NEWS1
-rwxr-xr-xbin/net_applet29
2 files changed, 21 insertions, 9 deletions
diff --git a/NEWS b/NEWS
index 8484f4f..476f251 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,6 @@
- fix "unescaped left brace" warnings in perl-5.22+.
- log dbus errors
+- stop using Gtk3::Notify::Queue as it's broken
2.22
- draknfs, draksambashare:
diff --git a/bin/net_applet b/bin/net_applet
index 1762309..2f0e0ba 100755
--- a/bin/net_applet
+++ b/bin/net_applet
@@ -39,7 +39,7 @@ use mygtk3 qw(gtknew gtkset);
use common;
our ($current_state, $current_interface);
-our ($icon, $notification_queue);
+our $icon;
our $dbus;
our ($interactive_cb, $ifw, $ifw_alert);
@@ -251,8 +251,6 @@ if ($dbus) {
dbus_object::set_gtk3_watch_helper($dbus);
}
-$notification_queue = Gtk3::Notify::Queue->new($icon);
-
$icon->signal_connect(activate => sub {
my ($_icon, $button, $time) = @_;
if ($ifw_alert) {
@@ -438,14 +436,27 @@ sub go2State {
$current_interface = $interface;
$need_update = 1;
}
+ my $show;
if ($current_state ne $state_type) {
- my $show = defined $current_state && $state_type ne 'connecting'; # don't show notification at applet startup and when establishing a connection
+ $show = defined $current_state && $state_type ne 'connecting'; # don't show notification at applet startup and when establishing a connection
$current_state = $state_type;
- $notification_queue->add({
- title => $old_description || $current_description || N("Network connection"),
- pixbuf => network::net_applet::get_state_pixbuf(1) || network::net_applet::get_state_pixbuf(),
- message => get_state_message($old_interface || $current_interface),
- }) if $show;
+ }
+ if ($show) {
+ my $msg;
+ my $ic = $icon; # fix stringification (WTF????)
+ my $bubble = Gtk3::Notify::Notification->new(
+ $old_description || $current_description || N("Network connection"),
+ get_state_message($old_interface || $current_interface),
+ $ic);
+ my $pixbuf = network::net_applet::get_state_pixbuf(1) || network::net_applet::get_state_pixbuf();
+ $bubble->set_icon_from_pixbuf($pixbuf) if $pixbuf;
+
+ my $timeout = 5000;
+ $bubble->set_timeout($timeout);
+ # both need to be in a eval block in case notification daemon isn't running:
+ Glib::Timeout->add($timeout, sub { eval { $bubble->close }; 0 });
+ eval { $bubble->show };
+ warn ">> ERR:$@" if $@;
$need_update = 1;
}