[meld] Add preference to swap VC pane order (closes bgo#379160, bgo#699030)



commit 70bdd041f405341e9ce50b966b948f6b2804040b
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sun Jul 14 08:04:04 2013 +1000

    Add preference to swap VC pane order (closes bgo#379160, bgo#699030)
    
    Maybe it would have been better if Meld always used the left=local
    model, but given that it's been the opposite way forever, we can't just
    swap panes around on people.
    
    This commit adds a preference for whether left or right is local,
    defaulting to the current behaviour. This also applies to conflict
    comparisons.

 data/ui/preferences.ui |  140 +++++++++++++++++++++++++++++++++++++++++++++---
 meld/preferences.py    |   11 ++++-
 meld/vcview.py         |   12 +++-
 3 files changed, 152 insertions(+), 11 deletions(-)
---
diff --git a/data/ui/preferences.ui b/data/ui/preferences.ui
index 567bffe..d269cea 100644
--- a/data/ui/preferences.ui
+++ b/data/ui/preferences.ui
@@ -16,6 +16,24 @@
     <property name="step_increment">1</property>
     <property name="page_increment">10</property>
   </object>
+  <object class="GtkListStore" id="fileorderstore">
+    <columns>
+      <!-- column-name id -->
+      <column type="gint"/>
+      <!-- column-name label -->
+      <column type="gchararray"/>
+    </columns>
+    <data>
+      <row>
+        <col id="0">0</col>
+        <col id="1" translatable="yes">Left is remote, right is local</col>
+      </row>
+      <row>
+        <col id="0">1</col>
+        <col id="1" translatable="yes">Left is local, right is remote</col>
+      </row>
+    </data>
+  </object>
   <object class="GtkDialog" id="preferencesdialog">
     <property name="can_focus">False</property>
     <property name="border_width">5</property>
@@ -853,7 +871,7 @@
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="xalign">0</property>
-                        <property name="label" translatable="yes">Commit Messages</property>
+                        <property name="label" translatable="yes">Version Comparisons</property>
                         <property name="use_markup">True</property>
                         <attributes>
                           <attribute name="weight" value="bold"/>
@@ -887,7 +905,118 @@
                             <property name="can_focus">False</property>
                             <property name="spacing">6</property>
                             <child>
-                              <object class="GtkHBox" id="hbox6">
+                              <object class="GtkHBox" id="file_order_hbox1">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="spacing">6</property>
+                                <child>
+                                  <object class="GtkLabel" id="label12">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="xalign">0</property>
+                                    <property name="label" translatable="yes">_When comparing file 
revisions:</property>
+                                    <property name="use_underline">True</property>
+                                    <property name="mnemonic_widget">combo_file_order</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">False</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkComboBox" id="combo_file_order">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="model">fileorderstore</property>
+                                    <property name="active">0</property>
+                                    <signal name="changed" handler="on_combo_file_order_changed" 
swapped="no"/>
+                                    <child>
+                                      <object class="GtkCellRendererText" id="file_order_renderer"/>
+                                      <attributes>
+                                        <attribute name="text">1</attribute>
+                                      </attributes>
+                                    </child>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">True</property>
+                                    <property name="fill">True</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkVBox" id="vbox7">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="spacing">6</property>
+                    <child>
+                      <object class="GtkLabel" id="label10">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">Commit Messages</property>
+                        <property name="use_markup">True</property>
+                        <attributes>
+                          <attribute name="weight" value="bold"/>
+                        </attributes>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkHBox" id="hbox7">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <child>
+                          <object class="GtkLabel" id="label11">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="xpad">12</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkVBox" id="vbox8">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="spacing">6</property>
+                            <child>
+                              <object class="GtkHBox" id="hbox8">
                                 <property name="visible">True</property>
                                 <property name="can_focus">False</property>
                                 <property name="spacing">6</property>
@@ -931,7 +1060,7 @@
                               </packing>
                             </child>
                             <child>
-                              <object class="GtkAlignment" id="alignment2">
+                              <object class="GtkAlignment" id="alignment3">
                                 <property name="visible">True</property>
                                 <property name="can_focus">False</property>
                                 <property name="left_padding">18</property>
@@ -973,15 +1102,12 @@
                   <packing>
                     <property name="expand">False</property>
                     <property name="fill">True</property>
-                    <property name="position">0</property>
+                    <property name="position">1</property>
                   </packing>
                 </child>
                 <child>
                   <placeholder/>
                 </child>
-                <child>
-                  <placeholder/>
-                </child>
               </object>
               <packing>
                 <property name="position">2</property>
diff --git a/meld/preferences.py b/meld/preferences.py
index e1c5027..0f723be 100644
--- a/meld/preferences.py
+++ b/meld/preferences.py
@@ -144,7 +144,7 @@ class PreferencesDialog(gnomeglade.Component):
     def __init__(self, parent, prefs):
         gnomeglade.Component.__init__(self, paths.ui_dir("preferences.ui"),
                                       "preferencesdialog",
-                                      ["adjustment1", "adjustment2"])
+                                      ["adjustment1", "adjustment2", "fileorderstore"])
         self.widget.set_transient_for(parent)
         self.prefs = prefs
         if not self.prefs.use_custom_font:
@@ -221,6 +221,9 @@ class PreferencesDialog(gnomeglade.Component):
         self.combo_timestamp.set_active(active_idx)
         self.combo_timestamp.lock = False
 
+        self.combo_file_order.set_active(
+            1 if self.prefs.vc_left_is_local else 0)
+
         if srcviewer.gsv is not None:
             self.checkbutton_show_commit_margin.set_active(
                 self.prefs.vc_show_commit_margin)
@@ -318,6 +321,10 @@ class PreferencesDialog(gnomeglade.Component):
             resolution = combo.get_model()[combo.get_active_iter()][1]
             self.prefs.dirdiff_time_resolution_ns = resolution
 
+    def on_combo_file_order_changed(self, combo):
+        file_order = combo.get_model()[combo.get_active_iter()][0]
+        self.prefs.vc_left_is_local = True if file_order else False
+
     def on_response(self, dialog, response_id):
         self.widget.destroy()
 
@@ -381,6 +388,8 @@ class MeldPreferences(prefs.Preferences):
         "vc_show_commit_margin": prefs.Value(prefs.BOOL, True),
         "vc_commit_margin": prefs.Value(prefs.INT, 72),
         "vc_break_commit_message": prefs.Value(prefs.BOOL, False),
+
+        "vc_left_is_local": prefs.Value(prefs.BOOL, False),
     }
 
     def __init__(self):
diff --git a/meld/vcview.py b/meld/vcview.py
index c5f6db1..b211148 100644
--- a/meld/vcview.py
+++ b/meld/vcview.py
@@ -496,12 +496,18 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
             self.emit("create-diff", [path], {})
             return
 
+        left_is_local = self.prefs.vc_left_is_local
+
         if self.vc.get_entry(path).state == tree.STATE_CONFLICT and \
                 hasattr(self.vc, 'get_path_for_conflict'):
             # We create new temp files for other, base and this, and
             # then set the output to the current file.
-            conflicts = (tree.CONFLICT_OTHER, tree.CONFLICT_MERGED,
-                         tree.CONFLICT_THIS)
+            if left_is_local:
+                conflicts = (tree.CONFLICT_THIS, tree.CONFLICT_MERGED,
+                             tree.CONFLICT_OTHER)
+            else:
+                conflicts = (tree.CONFLICT_OTHER, tree.CONFLICT_MERGED,
+                             tree.CONFLICT_THIS)
             diffs = [self.vc.get_path_for_conflict(path, conflict=c)
                      for c in conflicts]
             temps = [p for p, is_temp in diffs if is_temp]
@@ -513,7 +519,7 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
         else:
             comp_path = self.vc.get_path_for_repo_file(path)
             temps = [comp_path]
-            diffs = [comp_path, path]
+            diffs = [path, comp_path] if left_is_local else [comp_path, path]
             kwargs = {}
 
         for temp_file in temps:


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