meld r1276 - in trunk: . glade2 vc
- From: vincele svn gnome org
- To: svn-commits-list gnome org
- Subject: meld r1276 - in trunk: . glade2 vc
- Date: Fri, 20 Mar 2009 00:19:28 +0000 (UTC)
Author: vincele
Date: Fri Mar 20 00:19:28 2009
New Revision: 1276
URL: http://svn.gnome.org/viewvc/meld?rev=1276&view=rev
Log:
Multiple VC in the same directory
This patch further enhance the user experience in case of
multiple VC in the same directory, by replacing the use
of a dialog window with a combobox in the location bar.
The combobox is greyed in case of a single VC and allows
user to switch between multiple options.
Modified:
trunk/glade2/vcview.glade
trunk/vc/__init__.py
trunk/vcview.py
Modified: trunk/glade2/vcview.glade
==============================================================================
--- trunk/glade2/vcview.glade (original)
+++ trunk/glade2/vcview.glade Fri Mar 20 00:19:28 2009
@@ -45,6 +45,20 @@
</packing>
</child>
+ <child>
+ <widget class="GtkComboBox" id="combobox_vcs">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="active">0</property>
+ <property name="tooltip" translatable="no">Version Control</property>
+ <signal name="changed" handler="on_vc_change"/>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
</widget>
<packing>
<property name="padding">0</property>
Modified: trunk/vc/__init__.py
==============================================================================
--- trunk/vc/__init__.py (original)
+++ trunk/vc/__init__.py Fri Mar 20 00:19:28 2009
@@ -34,11 +34,7 @@
return ret
_plugins = load_plugins()
-def default_plugin_order(vcs):
- # Pick the Vc with the longest repo root
- return max(vcs, key=lambda repo: len(repo.root))
-
-def Vc(location, ordering_func = default_plugin_order):
+def get_vcs(location):
vcs = []
for plugin in _plugins:
try:
@@ -48,12 +44,6 @@
if not vcs:
# No plugin recognized that location, fallback to _null
- vc = _null.Vc(location)
- elif len(vcs) == 1:
- # No need to launch a potentially GUI/interactive chooser
- vc = vcs[0]
- else:
- # User gets to pick one, eventually
- vc = ordering_func(vcs)
+ vcs.append(_null.Vc(location))
- return vc
+ return vcs
Modified: trunk/vcview.py
==============================================================================
--- trunk/vcview.py (original)
+++ trunk/vcview.py Fri Mar 20 00:19:28 2009
@@ -189,35 +189,41 @@
size = self.fileentry.size_request()[1]
if not self.prefs.vc_console_visible:
self.on_console_view_toggle(self.console_hide_box)
+ self.vc = None
+ # VC ComboBox
+ self.combobox_vcs.lock = True
+ self.combobox_vcs.set_model(gtk.ListStore(str, object))
+ cell = gtk.CellRendererText()
+ self.combobox_vcs.pack_start(cell, False)
+ self.combobox_vcs.add_attribute(cell, 'text', 0)
+ self.combobox_vcs.lock = False
def choose_vc(self, vcs):
- """Callback from vc.Vc to choose when there are multiple plugins able to handle one location"""
- d = gtk.Dialog(_('VC chooser'),
- None,
- gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
- (gtk.STOCK_OK, gtk.RESPONSE_OK))
-
- indexMap = {}
- cb = gtk.combo_box_new_text()
- for i, avc in enumerate(vcs):
- cb.append_text(avc.NAME)
- indexMap[avc.NAME] = i
- cb.set_active(0)
- lb = gtk.Label(_('Pick one source control plugin'))
- d.vbox.set_spacing(12)
- d.vbox.pack_start(lb, True, True, 12)
- d.vbox.pack_start(cb, False, False)
- cb.show()
- lb.show()
- d.run()
- d.destroy()
- return vcs[indexMap[cb.get_active_text()]]
+ """Display VC plugin(s) that can handle the location"""
+ self.combobox_vcs.lock = True
+ self.combobox_vcs.get_model().clear()
+ tooltip_texts = [_("Choose one Version Control"),
+ _("Only one Version Control in this directory")]
+ for avc in vcs:
+ 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)
+ def on_vc_change(self, cb):
+ if not cb.lock:
+ self.vc = cb.get_model()[cb.get_active_iter()][1]
+ self._set_location(self.vc.root)
+
def set_location(self, location):
- self.model.clear()
self.location = location = os.path.abspath(location or ".")
+ self.choose_vc(vc.get_vcs(location))
+
+ def _set_location(self, location):
+ self.model.clear()
self.fileentry.gtk_entry.set_text(location)
- self.vc = vc.Vc(location, self.choose_vc)
it = self.model.add_entries( None, [location] )
self.treeview.grab_focus()
self.treeview.get_selection().select_iter(it)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]