Commits

Peter Ruibal committed 82d2784

synch: Persist advanced options

Comments (0)

Files changed (1)

         revbox.pack_end(self._use_proxy, False, False)
         vbox.pack_start(revbox, False, False, 2)
 
-        expander = gtk.Expander('Advanced Options')
+        self.expander = expander = gtk.Expander('Advanced Options')
         expander.set_expanded(False)
+        expander.connect_after('activate', self._expanded)
         hbox = gtk.HBox()
         expander.add(hbox)
 
         vbox.pack_start(self.stbar, False, False, 2)
         self.connect('map', self.update_buttons)
         self._last_drop_time = None
+        
+        self.load_settings()
 
     def fill_path_combo(self):
         self.pathlist.clear()
             gtk.main_quit()
         
     def _save_settings(self):
+        self.update_settings()
         pullstate = 0
         for i in xrange(0, len(self._pull_menu_items)):
             if self._pull_menu_items[i].get_active(): pullstate = i
             if self.hgthread.return_code() is None:
                 self.write("[command interrupted]")
             return False # Stop polling this function
+    
+    AdvancedDefaults = {
+        'expander.expanded': False, 
+        '_reventry.text': '', 
+        '_force.active': False,
+        '_showpatch.active': False, 
+        '_newestfirst.active': False, 
+        '_nomerge.active': False,}
+
+    def _expanded(self, expander):
+        if not expander.get_expanded():
+            self.load_settings(SynchDialog.AdvancedDefaults.get)
+
+    def load_settings(self, get_value = None):
+        get_value = get_value or self._settings.get_value
+        for key, default in SynchDialog.AdvancedDefaults.iteritems():
+            member, attr = key.split('.')
+            value = get_value(key, default)
+            getattr(getattr(self, member), 'set_%s'%attr)(value)
+        
+    def update_settings(self, set_value = None):
+        set_value = set_value or self._settings.set_value
+        for key, default in SynchDialog.AdvancedDefaults.iteritems():
+            member, attr = key.split('.')
+            value = getattr(getattr(self, member), 'get_%s'%attr)()
+            set_value(key, value)
 
 def run(cwd='', root='', files=[], pushmode=False, **opts):
     dialog = SynchDialog(cwd, root, files, pushmode)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.