# HG changeset patch # User Guido Berhoerster # Date 1425983405 -3600 # Node ID ba1005429c76494c70a3109cfc47db95e5edbd25 # Parent dfe10c951e217a4af0df23db0820efbda437e464 Reset the status icon if the notification is closed diff -r dfe10c951e21 -r ba1005429c76 notification.py --- a/notification.py Tue Mar 10 11:27:22 2015 +0100 +++ b/notification.py Tue Mar 10 11:30:05 2015 +0100 @@ -222,6 +222,10 @@ def on_activate(self, widget): self.reset() + def on_notification_closed(self, notification): + if notification.get_closed_reason() == 2: + self.reset() + def notify(self, summary, message, icon): if self.status_icon: self.status_icon.set_tooltip_text('%s: %s' % (APPLICATION, @@ -246,6 +250,7 @@ notification = pynotify.Notification(summary, body, icon_name) if icon_pixbuf is not None: notification.set_image_from_pixbuf(icon_pixbuf) + notification.connect('closed', self.on_notification_closed) notification.show() def reset(self): @@ -330,6 +335,10 @@ self.update_icon() return True + def on_notification_closed(self, notification): + if notification.get_closed_reason() == 2: + self.reset() + def notify(self, summary, message, icon): if self.status_icon: self.status_icon.set_tooltip_text('%s: %s' % (APPLICATION, @@ -356,6 +365,7 @@ notification = Notify.Notification.new(summary, body, icon_name) if icon_pixbuf is not None: notification.set_image_from_pixbuf(icon_pixbuf) + notification.connect('closed', self.on_notification_closed) notification.show() def reset(self): @@ -408,6 +418,7 @@ self.update_icon() self.status_icon.setVisible(True) self.status_icon.activated.connect(self.on_activated) + self.status_icon.messageClicked.connect(self.on_message_clicked) else: self.status_icon = None @@ -423,6 +434,9 @@ def on_activated(self, reason): self.reset() + def on_message_clicked(self): + self.reset() + def on_blink_timeout(self): self.blink_on = not self.blink_on self.update_icon()