Anonymous avatar Anonymous committed 56b35d7

hggtk/thgconfig: add new data to drop-down lists

Comments (0)

Files changed (1)

hggtk/thgconfig.py

 
         # Force dialog into clean state in the beginning
         self._btn_apply.set_sensitive(False)
+        self._refresh_vlist()
         self.dirty = False
 
     def _delete(self, widget, event):
             combo.set_row_separator_func(lambda model, iter: model[iter][1])
             widgets.append(combo)
 
-            # Get currently configured value from this config file
-            curvalue = self.get_ini_config(cpath)
-
-            if cpath == 'tortoisehg.vdiff':
-                # Special case, add extdiff.cmd.* to possible values
-                for name, value in self.ui.configitems('extdiff'):
-                    if name.startswith('cmd.'):
-                        values.append(name[4:])
-            elif cpath == 'ui.merge':
-                # Special case, add [merge-tools] to possible values
-                try:
-                    from mercurial import filemerge
-                    tools = []
-                    for key, value in self.ui.configitems('merge-tools'):
-                        t = key.split('.')[0]
-                        if t not in tools:
-                            tools.append(t)
-                    for t in tools:
-                        # Ensure the tool is installed
-                        if filemerge._findtool(self.ui, t):
-                            values.append(t)
-                except ImportError:
-                    pass
-
-            currow = None
-            vlist.append([_unspecstr, False])
-            if values:
-                vlist.append(['Suggested', True])
-                for v in values:
-                    vlist.append([v, False])
-                    if v == curvalue:
-                        currow = len(vlist) - 1
-            if cpath in self.history.get_keys():
-                separator = False
-                for v in self.history.mrul(cpath):
-                    if v in values: continue
-                    if not separator:
-                        vlist.append(['History', True])
-                        separator = True
-                    vlist.append([v, False])
-                    if v == curvalue:
-                        currow = len(vlist) - 1
-
-            if curvalue is None:
-                combo.set_active(0)
-            elif currow is None:
-                combo.child.set_text(curvalue)
-            else:
-                combo.set_active(currow)
-
-
             lbl = gtk.Label(label + ':')
             lbl.set_alignment(1.0, 0.0)
             eventbox = gtk.EventBox()
         self.pages.append((vbox, info, widgets))
         return vbox
         
+    def _refresh_vlist(self):
+        for vbox, info, widgets in self.pages:
+            for row, (label, cpath, values, tooltip) in enumerate(info):
+                combo = widgets[row]
+                vlist = combo.get_model()
+                vlist.clear()
+
+                # Get currently configured value from this config file
+                curvalue = self.get_ini_config(cpath)
+
+                if cpath == 'tortoisehg.vdiff':
+                    # Special case, add extdiff.cmd.* to possible values
+                    for name, value in self.ui.configitems('extdiff'):
+                        if name.startswith('cmd.') and name[4:] not in values:
+                            values.append(name[4:])
+                elif cpath == 'ui.merge':
+                    # Special case, add [merge-tools] to possible values
+                    try:
+                        from mercurial import filemerge
+                        tools = []
+                        for key, value in self.ui.configitems('merge-tools'):
+                            t = key.split('.')[0]
+                            if t not in tools:
+                                tools.append(t)
+                        for t in tools:
+                            # Ensure the tool is installed
+                            if filemerge._findtool(self.ui, t):
+                                values.append(t)
+                    except ImportError:
+                        pass
+
+                currow = None
+                vlist.append([_unspecstr, False])
+                if values:
+                    vlist.append(['Suggested', True])
+                    for v in values:
+                        vlist.append([v, False])
+                        if v == curvalue:
+                            currow = len(vlist) - 1
+                if cpath in self.history.get_keys():
+                    separator = False
+                    for v in self.history.mrul(cpath):
+                        if v in values: continue
+                        if not separator:
+                            vlist.append(['History', True])
+                            separator = True
+                        vlist.append([v, False])
+                        if v == curvalue:
+                            currow = len(vlist) - 1
+
+                if curvalue is None:
+                    combo.set_active(0)
+                elif currow is None:
+                    combo.child.set_text(curvalue)
+                else:
+                    combo.set_active(currow)
+
     def add_page(self, notebook, tab):
         frame = gtk.Frame()
         frame.set_border_width(10)
                 self.record_new_value(cpath, newvalue)
 
         self.history.write()
+        self._refresh_vlist()
+        
         try:
             f = open(self.fn, "w")
             f.write(str(self.ini))
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.