[meld] Multivc is changed by toggling buttons like flatten,



commit eaf703dd7786984600d89c6d3cacdab7d0c7c8d7
Author: Vincent Legoll <vincent legoll gmail com>
Date:   Tue Apr 21 20:28:05 2009 +0200

    Multivc is changed by toggling buttons like flatten,
    modified, normal...
    
    Toggling VC filtering buttons change multiVC combobox
    back to the first VC plugin, which is counter intuitive.
    
    Because of toggled->refresh->set_location->choose_vc
    
    Keep the same VC plugin if it can handle the new
    location else use the first in the new list...
---
 vcview.py |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/vcview.py b/vcview.py
index f0aab7a..abff0e4 100644
--- a/vcview.py
+++ b/vcview.py
@@ -227,13 +227,18 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
         self.combobox_vcs.get_model().clear()
         tooltip_texts = [_("Choose one Version Control"),
                          _("Only one Version Control in this directory")]
-        for avc in vcs:
+        default_active = 0
+        # Try to keep the same VC plugin active on refresh()
+        for idx, avc in enumerate(vcs):
+            if (self.vc is not None and
+                self.vc.__class__ == avc.__class__):
+                default_active = idx
             self.combobox_vcs.get_model().append([avc.NAME, avc])
         if gtk.pygtk_version >= (2, 12, 0):
             self.combobox_vcs.set_tooltip_text(tooltip_texts[len(vcs) == 1])
         self.combobox_vcs.set_sensitive(len(vcs) > 1)
         self.combobox_vcs.lock = False
-        self.combobox_vcs.set_active(0)
+        self.combobox_vcs.set_active(default_active)
   
     def on_vc_change(self, cb):
         if not cb.lock:



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