close notification only when needed

This commit is contained in:
Chris Cromer 2017-10-03 11:07:12 -03:00
parent 0d88b1e660
commit 949d640eb8

View File

@ -132,7 +132,7 @@ namespace Pamac {
set_tooltip (noupdate_info); set_tooltip (noupdate_info);
var pamac_config = new Pamac.Config ("/etc/pamac.conf"); var pamac_config = new Pamac.Config ("/etc/pamac.conf");
set_icon_visible (!pamac_config.no_update_hide_icon); set_icon_visible (!pamac_config.no_update_hide_icon);
close_notification(); close_notification ();
} else { } else {
string info = ngettext ("%u available update", "%u available updates", updates_nb).printf (updates_nb); string info = ngettext ("%u available update", "%u available updates", updates_nb).printf (updates_nb);
set_icon (update_icon_name); set_icon (update_icon_name);
@ -149,7 +149,7 @@ namespace Pamac {
void show_notification (string info) { void show_notification (string info) {
try { try {
close_notification(); close_notification ();
notification = new Notify.Notification (_("Package Manager"), info, "system-software-update"); notification = new Notify.Notification (_("Package Manager"), info, "system-software-update");
notification.add_action ("default", _("Details"), execute_updater); notification.add_action ("default", _("Details"), execute_updater);
notification.show (); notification.show ();
@ -161,7 +161,7 @@ namespace Pamac {
void update_notification (string info) { void update_notification (string info) {
try { try {
if (notification != null) { if (notification != null) {
if (notification.get_closed_reason() == -1 && notification.body != info) { if (notification.get_closed_reason () == -1 && notification.body != info) {
notification.update (_("Package Manager"), info, "system-software-update"); notification.update (_("Package Manager"), info, "system-software-update");
notification.show (); notification.show ();
} }
@ -175,9 +175,9 @@ namespace Pamac {
void close_notification () { void close_notification () {
try { try {
if (notification != null) { if (notification != null && notification.get_closed_reason () == -1) {
notification.close(); notification.close ();
notification = null; notification = null;
} }
} catch (Error e) { } catch (Error e) {
stderr.printf ("Notify Error: %s", e.message); stderr.printf ("Notify Error: %s", e.message);