conduit r1301 - in trunk: . conduit conduit/gtkui



Author: jstowers
Date: Tue Feb 12 12:02:55 2008
New Revision: 1301
URL: http://svn.gnome.org/viewvc/conduit?rev=1301&view=rev

Log:
2008-02-13  John Stowers  <john stowers gmail com>

	* conduit/Settings.py:
	* conduit/gtkui/Tree.py:
	* conduit/gtkui/UI.py: Save and restore expanded dataprovider treeview
	categories. Disabled by default until it gets more testing.



Modified:
   trunk/ChangeLog
   trunk/conduit/Settings.py
   trunk/conduit/gtkui/Tree.py
   trunk/conduit/gtkui/UI.py

Modified: trunk/conduit/Settings.py
==============================================================================
--- trunk/conduit/Settings.py	(original)
+++ trunk/conduit/Settings.py	Tue Feb 12 12:02:55 2008
@@ -85,7 +85,8 @@
         'enable_removable_devices'  :   True,           #Should conduit support iPods, USB keys, etc
         'default_policy_conflict'   :   "ask",          #Default conflict policy for new Conduits, ask,replace,skip
         'default_policy_deleted'    :   "ask",          #Default deleted policy for new Conduits, ask,replace,skip
-        'gui_expanded_columns'      :   [],             #list of expanded column paths in the treeview
+        'gui_expanded_rows'         :   [],             #list of expanded column paths in the treeview
+        'gui_restore_expanded_rows' :   False,          #Shoud we expand columns at startup
         'gui_hpane_postion'         :   250,            #The hpane seperating the canvas and treeview position
         'gui_window_size'           :   [],             #W,H
         'gui_minimize_to_tray'      :   False,          #Behaviour when one minimizes the main window, should it iconify?
@@ -161,7 +162,10 @@
         elif vtype is int:
             return value.get_int()
         elif vtype in [list, tuple]:
-            return value.get_list()
+            l = []
+            for i in value.get_list():
+                l.append(i.get_string())
+            return l
             
         log.warn("Unknown gconf key: %s" % key)
         return None

Modified: trunk/conduit/gtkui/Tree.py
==============================================================================
--- trunk/conduit/gtkui/Tree.py	(original)
+++ trunk/conduit/gtkui/Tree.py	Tue Feb 12 12:02:55 2008
@@ -32,6 +32,8 @@
                             module_type="category",
                             category=category
                             )
+    def get_UID(self):
+        return self.name
        
 class DataProviderTreeModel(gtk.GenericTreeModel):
     """
@@ -359,9 +361,34 @@
         #self.connect('drag-begin', self.on_drag_begin)
         self.connect('drag-data-get', self.on_drag_data_get)
         self.connect('drag-data-delete', self.on_drag_data_delete)
+        
+    def get_expanded_rows(self):
+        model = self.get_model()
+        expanded = []
+        for c in model.cats:
+            try:
+                path = model.on_get_path(c)
+                if self.row_expanded(model.on_get_path(c)):
+                    expanded.append(c.get_UID())
+            except KeyError: pass
+        return expanded
 
-    def expand_all(self):
-        #FIXME: Work around a (py)gtk 2.8 bug
+    def set_expand_rows(self):
+        if conduit.GLOBALS.settings.get("gui_restore_expanded_rows") == True:
+            model = self.get_model()
+            cols = conduit.GLOBALS.settings.get("gui_expanded_rows")
+            for c in model.cats:
+                try:
+                    path = model.on_get_path(c)
+                    if c.get_UID() in cols:
+                        self.expand_row(path, False)
+                    else:
+                        self.collapse_row(path)
+                except KeyError:
+                    #expand all
+                    break
+            return
+        #Work around a (py)gtk 2.8 bug
         if gtk.pygtk_version >= (2,10,0):
             gtk.TreeView.expand_all(self)
         
@@ -392,11 +419,5 @@
         self.emit_stop_by_name('drag-data-delete')      
         #context.finish(True, True, etime)        
         
-    def get_expanded_rows(self):
-        def map_expanded_rows_func(treeview, path):
-            expanded.append(path)
 
-        expanded = []
-        self.map_expanded_rows(map_expanded_rows_func)
-        return expanded
 

Modified: trunk/conduit/gtkui/UI.py
==============================================================================
--- trunk/conduit/gtkui/UI.py	(original)
+++ trunk/conduit/gtkui/UI.py	Tue Feb 12 12:02:55 2008
@@ -139,7 +139,7 @@
 
         #final GUI setup
         self.hpane.set_position(conduit.GLOBALS.settings.get("gui_hpane_postion"))
-        self.dataproviderTreeView.expand_all()
+        self.dataproviderTreeView.set_expand_rows()
         self.window_state = 0
         
         #if running a development version, add some developer specific links
@@ -464,8 +464,15 @@
         self.syncSet.save_to_xml()
 
         #GUI settings
-        conduit.GLOBALS.settings.set("gui_hpane_postion", self.hpane.get_position())
-        conduit.GLOBALS.settings.set("gui_window_size", self.mainWindow.get_size())
+        conduit.GLOBALS.settings.set(
+                            "gui_hpane_postion",
+                            self.hpane.get_position())
+        conduit.GLOBALS.settings.set(
+                            "gui_window_size",
+                            self.mainWindow.get_size())
+        conduit.GLOBALS.settings.set(
+                            "gui_expanded_rows",
+                            self.dataproviderTreeView.get_expanded_rows())        
 
 class SplashScreen:
     """



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