[gnome-clocks] Timer: Only update time label when needed



commit a31dd297608a9aebf88f2b7cec99477ec46be6af
Author: Volker Sobek <reklov live com>
Date:   Thu Nov 29 04:50:33 2012 +0100

    Timer: Only update time label when needed
    
    Don't update the time label when it would show the same time again,
    this reduces the CPU usage quite a bit.

 gnomeclocks/timer.py |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/gnomeclocks/timer.py b/gnomeclocks/timer.py
index b873681..f71bbcd 100644
--- a/gnomeclocks/timer.py
+++ b/gnomeclocks/timer.py
@@ -156,6 +156,8 @@ class Timer(Clock):
         Clock.__init__(self, _("Timer"))
         self.state = Timer.State.STOPPED
         self.timeout_id = 0
+        self._last_set_time = None
+        self._ui_is_frozen = False
 
         self.notebook = Gtk.Notebook()
         self.notebook.set_show_tabs(False)
@@ -175,8 +177,6 @@ class Timer(Clock):
 
         self.alert = Alert("complete", "Ta Da !")
 
-        self._ui_is_frozen = False
-
     @GObject.Signal
     def alarm_ringing(self):
         self.alert.show()
@@ -239,7 +239,9 @@ class Timer(Clock):
             display_time = math.ceil(self.deadline - t)
             m, s = divmod(display_time, 60)
             h, m = divmod(m, 60)
-            self.timer_screen.set_time(h, m, s)
+            if (h, m, s) != self._last_set_time:
+                self.timer_screen.set_time(h, m, s)
+                self._last_set_time = (h, m, s)
         return True
 
     def _ui_freeze(self, widget):



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