[hamster-applet] reusing same low-urgency level notification everywhere



commit f57202c57d5991ebb979766608a85c227ba17281
Author: Toms Bauģis <toms baugis gmail com>
Date:   Sun Jan 17 18:32:47 2010 +0000

    reusing same low-urgency level notification everywhere

 hamster/applet.py |   22 +++++++++++++---------
 1 files changed, 13 insertions(+), 9 deletions(-)
---
diff --git a/hamster/applet.py b/hamster/applet.py
index 8037d19..fa68366 100755
--- a/hamster/applet.py
+++ b/hamster/applet.py
@@ -263,6 +263,12 @@ class HamsterApplet(object):
         if self.workspace_tracking:
             self.init_workspace_tracking()
 
+        self.notification = None
+        if PYNOTIFY:
+            self.notification = pynotify.Notification("Oh hi",
+                                                      "Greetings from hamster!")
+            self.notification.set_urgency(pynotify.URGENCY_LOW) # lower than grass
+
         self._gui.connect_signals(self)
 
 
@@ -297,7 +303,7 @@ class HamsterApplet(object):
 
 
     def check_user(self):
-        if not PYNOTIFY: #no interval means "never"
+        if not self.notification:
             return
 
         if self.notify_interval <= 0 or self.notify_interval >= 121:
@@ -319,10 +325,7 @@ class HamsterApplet(object):
 
 
         if message:
-            notification = pynotify.Notification(_("Time Tracker"),
-                                                 message,
-                                                 "hamster-applet")
-            notification.set_urgency(pynotify.URGENCY_LOW)
+            self.notification.update(_("Time Tracker"), message, "hamster-applet")
             notification.show()
 
 
@@ -603,10 +606,11 @@ class HamsterApplet(object):
                                      category_name = activity['category'],
                                      description = activity['description'])
 
-            if PYNOTIFY:
-                pynotify.Notification(_("Changed activity"),
-                                      _("Switched to '%s'") % activity['name'],
-                                      "hamster-applet").show()
+            if self.notification:
+                self.notification.update(_("Changed activity"),
+                                         _("Switched to '%s'") % activity['name'],
+                                         "hamster-applet")
+                self.notification.show()
 
     """global shortcuts"""
     def on_keybinding_activated(self, event, data):



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]