[hamster-applet] dropping the pref and firing idle notifications with priority low



commit e2b7bda172aa77320e4df366046d31336e6fdbf1
Author: Toms Bauģis <toms baugis gmail com>
Date:   Wed May 6 13:06:55 2009 +0100

    dropping the pref and firing idle notifications with priority low
    
    priority low works fine on the new ubuntu notification system by not displaying popups when
    watching movies and others.
---
 data/hamster-applet.schemas.in |   14 ------------
 data/preferences.ui            |   47 +++++++--------------------------------
 hamster/Configuration.py       |    9 -------
 hamster/applet.py              |   28 ++++++++++-------------
 hamster/preferences.py         |    5 ----
 5 files changed, 21 insertions(+), 82 deletions(-)

diff --git a/data/hamster-applet.schemas.in b/data/hamster-applet.schemas.in
index edf5d93..4d7525e 100644
--- a/data/hamster-applet.schemas.in
+++ b/data/hamster-applet.schemas.in
@@ -51,19 +51,5 @@
                 </long>
             </locale>
         </schema>
-        <schema>
-            <key>/schemas/apps/hamster-applet/general/notify_on_idle</key>
-            <applyto>/apps/hamster-applet/general/notify_on_idle</applyto>
-            <owner>hamster-applet</owner>
-            <type>bool</type>
-            <default>false</default>
-            <locale name="C">
-                <short>Remind also when no activity is set</short>
-                <long>
-                    Remind every notify_interval minutes also if no activity
-                    has been started.
-                </long>
-            </locale>
-        </schema>
     </schemalist>
 </gconfschemafile>
diff --git a/data/preferences.ui b/data/preferences.ui
index 6607f36..eaa8661 100644
--- a/data/preferences.ui
+++ b/data/preferences.ui
@@ -437,45 +437,16 @@
                             <property name="visible">True</property>
                             <property name="left_padding">12</property>
                             <child>
-                              <object class="GtkVBox" id="vbox2">
+                              <object class="GtkHScale" id="notify_interval">
                                 <property name="visible">True</property>
-                                <property name="orientation">vertical</property>
-                                <child>
-                                  <object class="GtkHScale" id="notify_interval">
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">True</property>
-                                    <property name="adjustment">adjustment1</property>
-                                    <property name="show_fill_level">True</property>
-                                    <property name="restrict_to_fill_level">False</property>
-                                    <property name="digits">0</property>
-                                    <property name="value_pos">bottom</property>
-                                    <signal name="value_changed" handler="on_notify_interval_value_changed"/>
-                                    <signal name="format_value" handler="on_notify_interval_format_value"/>
-                                  </object>
-                                  <packing>
-                                    <property name="position">0</property>
-                                  </packing>
-                                </child>
-                                <child>
-                                  <object class="GtkAlignment" id="alignment2">
-                                    <property name="visible">True</property>
-                                    <property name="top_padding">8</property>
-                                    <property name="left_padding">4</property>
-                                    <child>
-                                      <object class="GtkCheckButton" id="notify_on_idle">
-                                        <property name="label" translatable="yes">remind also when no activity is set</property>
-                                        <property name="visible">True</property>
-                                        <property name="can_focus">True</property>
-                                        <property name="receives_default">False</property>
-                                        <property name="draw_indicator">True</property>
-                                        <signal name="toggled" handler="on_notify_on_idle_toggled"/>
-                                      </object>
-                                    </child>
-                                  </object>
-                                  <packing>
-                                    <property name="position">1</property>
-                                  </packing>
-                                </child>
+                                <property name="can_focus">True</property>
+                                <property name="adjustment">adjustment1</property>
+                                <property name="show_fill_level">True</property>
+                                <property name="restrict_to_fill_level">False</property>
+                                <property name="digits">0</property>
+                                <property name="value_pos">bottom</property>
+                                <signal name="value_changed" handler="on_notify_interval_value_changed"/>
+                                <signal name="format_value" handler="on_notify_interval_format_value"/>
                               </object>
                             </child>
                           </object>
diff --git a/hamster/Configuration.py b/hamster/Configuration.py
index 99c0392..9720193 100644
--- a/hamster/Configuration.py
+++ b/hamster/Configuration.py
@@ -34,7 +34,6 @@ class GconfStore(object):
     GCONF_ENABLE_TIMEOUT = GCONF_DIR + "/enable_timeout"
     GCONF_STOP_ON_SHUTDOWN = GCONF_DIR + "/stop_on_shutdown"  
     GCONF_NOTIFY_INTERVAL = GCONF_DIR + "/notify_interval" 
-    GCONF_NOTIFY_ON_IDLE = GCONF_DIR + "/notify_on_idle"
 
     __instance = None
         
@@ -59,8 +58,6 @@ class GconfStore(object):
         self._client.notify_add(self.GCONF_ENABLE_TIMEOUT, lambda x, y, z, a: dispatcher.dispatch("gconf_timeout_enabled_changed", z.value.get_bool()))
         self._client.notify_add(self.GCONF_STOP_ON_SHUTDOWN, lambda x, y, z, a: dispatcher.dispatch("gconf_stop_on_shutdown_changed", z.value.get_bool()))
         self._client.notify_add(self.GCONF_NOTIFY_INTERVAL, lambda x, y, z, a: dispatcher.dispatch("gconf_notify_interval_changed", z.value.get_int()))
-        self._client.notify_add(self.GCONF_NOTIFY_ON_IDLE, lambda x, y, z, a: dispatcher.dispatch("gconf_notify_on_idle_changed", z.value.get_bool()))
-
     
     def get_keybinding(self):
         return self._client.get_string(self.GCONF_KEYBINDING) or ""
@@ -74,9 +71,6 @@ class GconfStore(object):
     def get_notify_interval(self):
     	return self._client.get_int(self.GCONF_NOTIFY_INTERVAL) or 27
 
-    def get_notify_on_idle(self):
-    	return self._client.get_bool(self.GCONF_NOTIFY_ON_IDLE) or False
-
     #------------------------    
     def set_keybinding(self, binding):
         self._client.set_string(self.GCONF_KEYBINDING, binding)
@@ -90,6 +84,3 @@ class GconfStore(object):
     def set_notify_interval(self, interval):
     	return self._client.set_int(self.GCONF_NOTIFY_INTERVAL, interval)
 
-    def set_notify_on_idle(self, enabled):
-        self._client.set_bool(self.GCONF_NOTIFY_ON_IDLE, enabled)
-        
diff --git a/hamster/applet.py b/hamster/applet.py
index 1e5b173..e0fdfc4 100755
--- a/hamster/applet.py
+++ b/hamster/applet.py
@@ -62,23 +62,27 @@ class Notifier(object):
     def __init__(self, app_name, icon, attach):
         self._icon = icon
         self._attach = attach
-        self._notify = None
-        # Title of reminder baloon
+        # Title of reminder notification
         self.summary = _("Time Tracker")
       
         if not pynotify.is_initted():
             pynotify.init(app_name)
 
     def msg(self, body, edit_cb, switch_cb):
-        self._notify = pynotify.Notification(self.summary, body, self._icon, self._attach)
+        notify = pynotify.Notification(self.summary, body, self._icon, self._attach)
 
         if "actions" in pynotify.get_server_caps():
             #translators: this is edit activity action in the notifier bubble
-            self._notify.add_action("edit", _("Edit"), edit_cb)
+            notify.add_action("edit", _("Edit"), edit_cb)
             #translators: this is switch activity action in the notifier bubble
-            self._notify.add_action("switch", _("Switch"), switch_cb)
+            notify.add_action("switch", _("Switch"), switch_cb)
             
-        self._notify.show()
+        notify.show()
+    
+    def msg_low(self, message):
+        notify = pynotify.Notification(self.summary, message, self._icon, self._attach)
+        notify.set_urgency(pynotify.URGENCY_LOW)
+        notify.show()
 
 
 class PanelButton(gtk.ToggleButton):
@@ -279,9 +283,6 @@ class HamsterApplet(object):
         # init idle check
         dispatcher.add_handler('gconf_timeout_enabled_changed', self.on_timeout_enabled_changed)
         self.timeout_enabled = self.config.get_timeout_enabled()
-
-        dispatcher.add_handler('gconf_notify_on_idle_changed', self.on_notify_on_idle_changed)
-        self.notify_on_idle = self.config.get_notify_on_idle()
         
         
         # init nagging timeout
@@ -469,11 +470,10 @@ Now, start tracking!
                 # activity reminder
                 msg = _(u"Working on <b>%s</b>") % self.last_activity['name']
                 self.notify.msg(msg, self.edit_cb, self.switch_cb)
-        elif self.notify_on_idle:
+        else:
             #if we have no last activity, let's just calculate duration from 00:00
             if (now.minute + now.hour *60) % self.notify_interval == 0:
-                msg = _(u"No activity")
-                self.notify.msg(msg, self.edit_cb, self.switch_cb)
+                self.notify.msg_low(_(u"No activity"))
 
     def edit_cb(self, n, action):
         custom_fact = CustomFactController(self, None, self.last_activity['id'])
@@ -772,10 +772,6 @@ Now, start tracking!
         # if enabled, set to value, otherwise set to zero, which means disable
         self.timeout_enabled = enabled
 
-    def on_notify_on_idle_changed(self, event, enabled):
-        # if enabled, set to value, otherwise set to zero, which means disable
-        self.notify_on_idle = enabled
-
     def on_notify_interval_changed(self, event, new_interval):
         if PYNOTIFY and 0 < new_interval < 121:
             self.notify_interval = new_interval
diff --git a/hamster/preferences.py b/hamster/preferences.py
index 543dcb7..9d71421 100755
--- a/hamster/preferences.py
+++ b/hamster/preferences.py
@@ -179,7 +179,6 @@ class PreferencesEditor:
         self.get_widget("idle_track").set_active(self.config.get_timeout_enabled())
         self.get_widget("notify_interval").set_value(self.config.get_notify_interval())
         self.get_widget("keybinding").set_text(self.config.get_keybinding())
-        self.get_widget("notify_on_idle").set_active(self.config.get_notify_on_idle())
 
 
     def drag_data_get_data(self, treeview, context, selection, target_id,
@@ -619,9 +618,6 @@ class PreferencesEditor:
     def on_idle_track_toggled(self, checkbox):
         self.config.set_timeout_enabled(checkbox.get_active())
 
-    def on_notify_on_idle_toggled(self, checkbox):
-        self.config.set_notify_on_idle(checkbox.get_active())
-
     def on_notify_interval_format_value(self, slider, value):
         if value <=120:
             # notify interval slider value label
@@ -635,7 +631,6 @@ class PreferencesEditor:
     def on_notify_interval_value_changed(self, scale):
         value = int(scale.get_value())
         self.config.set_notify_interval(value)
-        self.get_widget("notify_on_idle").set_sensitive(value <= 120)
     
     def on_keybinding_changed(self, textbox):
         self.config.set_keybinding(textbox.get_text())



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