[caribou] Add ability to add more than one settings manager



commit 39ded91b1ab0cd88a2700c3391a4dfc1d20bb1ed
Author: Eitan Isaacson <eitan monotonous org>
Date:   Tue May 3 16:29:57 2011 -0700

    Add ability to add more than one settings manager

 caribou/settings/preferences_window.py |   21 +++++++++++----------
 1 files changed, 11 insertions(+), 10 deletions(-)
---
diff --git a/caribou/settings/preferences_window.py b/caribou/settings/preferences_window.py
index 9ca57de..2b6d3ca 100644
--- a/caribou/settings/preferences_window.py
+++ b/caribou/settings/preferences_window.py
@@ -25,17 +25,16 @@ from gi.repository import Gdk
 from gi.repository import Gtk
 
 class AbstractPreferencesUI:
-    def populate_settings(self, groups):
-        notebook = Gtk.Notebook()
-        self._populate_settings(notebook, groups)
-        if notebook.get_n_pages() == 1:
-            notebook.set_show_tabs(False)
-            
-        return notebook
+    def populate_settings(self, settings_manager):
+        if getattr(self, "notebook", None) is None:
+            self.notebook = Gtk.Notebook()
+        self._populate_settings(self.notebook, settings_manager.groups)
+        self.notebook.set_show_tabs(self.notebook.get_n_pages() != 1)
+
+        return self.notebook
 
     def _populate_settings(self, parent, setting, level=0):
         if level == 0:
-            self.set_title(setting.label)
             for s in setting:
                 vbox = Gtk.VBox()
                 parent.append_page(vbox, Gtk.Label(label=s.label))
@@ -234,8 +233,9 @@ class PreferencesDialog(Gtk.Dialog, AbstractPreferencesUI):
         gobject.GObject.__init__(self)
         self.add_button(Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE)
         self.set_border_width(6)
+        self.set_title(settings_manager.groups.label)
 
-        notebook = self.populate_settings(settings_manager.groups)
+        notebook = self.populate_settings(settings_manager)
         vbox = self.get_content_area()
         vbox.add(notebook)
 
@@ -245,8 +245,9 @@ class PreferencesWindow(Gtk.Window, AbstractPreferencesUI):
     def __init__(self, settings_manager):
         gobject.GObject.__init__(self)
         self.set_border_width(6)
+        self.set_title(settings_manager.groups.label)
 
-        notebook = self.populate_settings(settings_manager.groups)
+        notebook = self.populate_settings(settings_manager)
         self.add(notebook)
 
 if __name__ == "__main__":



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