Mageia Bugzilla – Attachment 6723 Details for
Bug 16014
net_applet shows "down" notification when interface comes up (Gtk3::Notify::Queue always displays the 1st msg)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
New Account
|
Forgot Password
[patch]
fix always displaying 1st bubble
0002-stop-using-Gtk3-Notify-Queue-as-it-s-broken.patch (text/plain), 2.67 KB, created by
Thierry Vignaud
on 2015-06-09 13:16:33 CEST
(
hide
)
Description:
fix always displaying 1st bubble
Filename:
MIME Type:
Creator:
Thierry Vignaud
Created:
2015-06-09 13:16:33 CEST
Size:
2.67 KB
patch
obsolete
>From bf7380a603c4d7818259d68a8ce12722d89f9044 Mon Sep 17 00:00:00 2001 >From: Thierry Vignaud <thierry.vignaud@gmail.com> >Date: Tue, 9 Jun 2015 07:14:41 -0400 >Subject: [PATCH 2/2] 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 >--- > bin/net_applet | 29 ++++++++++++++++++++--------- > 1 file changed, 20 insertions(+), 9 deletions(-) > >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; > } > >-- >2.3.2 >
From bf7380a603c4d7818259d68a8ce12722d89f9044 Mon Sep 17 00:00:00 2001 From: Thierry Vignaud <thierry.vignaud@gmail.com> Date: Tue, 9 Jun 2015 07:14:41 -0400 Subject: [PATCH 2/2] 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 --- bin/net_applet | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) 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; } -- 2.3.2
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 16014
:
6621
|
6722
| 6723