[gnome-clocks] Remove the update timeout when deleting clocks



commit baa88b68dfa760fec2d1f8aaa00f425985fc5287
Author: Paolo Borelli <pborelli gnome org>
Date:   Sun Aug 26 16:18:55 2012 +0200

    Remove the update timeout when deleting clocks
    
    Also change the code to store a TreePath instead of a TreeIter since the
    latter can get invalidated

 gnomeclocks/clocks.py  |    4 +++-
 gnomeclocks/widgets.py |   17 ++++++++++-------
 2 files changed, 13 insertions(+), 8 deletions(-)
---
diff --git a/gnomeclocks/clocks.py b/gnomeclocks/clocks.py
index 9da3751..69f1763 100644
--- a/gnomeclocks/clocks.py
+++ b/gnomeclocks/clocks.py
@@ -144,11 +144,13 @@ class World(Clock):
                                            d.get_pixbuf(),
                                            "<b>" + name + "</b>",
                                            d])
-        d.set_iter(self.liststore, view_iter)
+        path = self.liststore.get_path(view_iter)
+        d.set_path(self.liststore, path)
         self.notify("can-select")
 
     def delete_clocks(self, clocks):
         for d in clocks:
+            d.stop_update()
             self.clocks.remove(d._location)
         worldclockstorage.save_clocks(self.clocks)
         self.iconview.unselect_all()
diff --git a/gnomeclocks/widgets.py b/gnomeclocks/widgets.py
index 9ed6dab..17e451b 100644
--- a/gnomeclocks/widgets.py
+++ b/gnomeclocks/widgets.py
@@ -102,7 +102,7 @@ class DigitalClock():
         self.sunset = self._last_sunset
         self.get_sunrise_sunset()
 
-        self.view_iter = None
+        self.path = None
         self.list_store = None
 
         self.id = location.id
@@ -114,7 +114,11 @@ class DigitalClock():
         self.standalone =\
             DigitalClockStandalone(self.location, self.sunrise, self.sunset)
         self.update()
-        GObject.timeout_add(1000, self.update)
+        self.timeout = GObject.timeout_add(1000, self.update)
+
+    def stop_update(self):
+        GObject.source_remove(self.timeout)
+        self.timeout = 0
 
     def get_local_time(self, secs):
          t = secs + time.timezone + self.offset
@@ -149,9 +153,8 @@ class DigitalClock():
                 self.drawing.render(t, img, isDay)
             else:
                 self.drawing.render(t, img, isDay, day)
-            if self.view_iter and self.list_store:
-                self.list_store.set_value(
-                    self.view_iter, 1, self.drawing.pixbuf)
+            if self.path and self.list_store:
+                self.list_store[self.path][1] = self.drawing.pixbuf
             self.standalone.update(img, t, systemClockFormat,
                                    self.sunrise, self.sunset)
 
@@ -221,8 +224,8 @@ class DigitalClock():
             else:
                 return False
 
-    def set_iter(self, list_store, view_iter):
-        self.view_iter = view_iter
+    def set_path(self, list_store, path):
+        self.path = path
         self.list_store = list_store
 
 



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