[caribou] Deregister of gconf listeners when object is destroyed



commit 856bda2463660e6cdb6b0f004cf75dddc1f4d6a9
Author: David Pellicer <davidpellicermartin gmail com>
Date:   Tue Dec 7 09:16:48 2010 -0800

    Deregister of gconf listeners when object is destroyed

 caribou/ui/keyboard.py |   31 +++++++++++++++++++++----------
 1 files changed, 21 insertions(+), 10 deletions(-)
---
diff --git a/caribou/ui/keyboard.py b/caribou/ui/keyboard.py
index ec1aac4..ace93b0 100644
--- a/caribou/ui/keyboard.py
+++ b/caribou/ui/keyboard.py
@@ -415,18 +415,24 @@ class CaribouKeyboard(gtk.Notebook):
         self.key_size = 30
         self.current_mask = 0
         self.current_page = 0
+        self._gconf_connections = []
         self.client = gconf.client_get_default()
 
-        self.client.notify_add(const.CARIBOU_GCONF + "/normal_color",
-                               self._colors_changed)
-        self.client.notify_add(const.CARIBOU_GCONF + "/mouse_over_color",
-                               self._colors_changed)
-        self.client.notify_add(const.CARIBOU_GCONF + "/default_colors",
-                               self._colors_changed)
-        self.client.notify_add(const.CARIBOU_GCONF + "/default_font",
-                               self._key_font_changed)
-        self.client.notify_add(const.CARIBOU_GCONF + "/key_font",
-                               self._key_font_changed)
+        self._gconf_connections.append(self.client.notify_add(
+                            const.CARIBOU_GCONF + "/normal_color",
+                            self._colors_changed))
+        self._gconf_connections.append(self.client.notify_add(
+                            const.CARIBOU_GCONF + "/mouse_over_color",
+                            self._colors_changed))
+        self._gconf_connections.append(self.client.notify_add(
+                            const.CARIBOU_GCONF + "/default_colors",
+                            self._colors_changed))
+        self._gconf_connections.append(self.client.notify_add(
+                            const.CARIBOU_GCONF + "/default_font",
+                            self._key_font_changed))
+        self._gconf_connections.append(self.client.notify_add(
+                            const.CARIBOU_GCONF + "/key_font",
+                            self._key_font_changed))
 
         self.connect('size-allocate', self._on_size_allocate)
 
@@ -548,6 +554,11 @@ class CaribouKeyboard(gtk.Notebook):
     def _pressed_preferences_key(self, key):
         self.keyboard_preferences.window.show_all()
 
+    def destroy(self):
+        for id in self._gconf_connections:
+            self.client.notify_remove(id)
+        super(gtk.Notebook, self).destroy()
+
     def _switch_to_layout(self, name):
         n_pages = self.get_n_pages()
         for i in range(n_pages):



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