[meld] preferences: Move VC file order setting to GSettings



commit 3180345b6bcf154be3f0f608ccda038be92383ac
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Fri Dec 6 07:41:48 2013 +1000

    preferences: Move VC file order setting to GSettings

 data/org.gnome.meld.gschema.xml |    5 +++++
 data/ui/preferences.ui          |   10 +++++-----
 meld/preferences.py             |   17 +++++++++--------
 meld/vcview.py                  |    5 ++++-
 4 files changed, 23 insertions(+), 14 deletions(-)
---
diff --git a/data/org.gnome.meld.gschema.xml b/data/org.gnome.meld.gschema.xml
index 29c75d2..051d0c7 100644
--- a/data/org.gnome.meld.gschema.xml
+++ b/data/org.gnome.meld.gschema.xml
@@ -149,6 +149,11 @@
           <summary>Show the version control console output</summary>
           <description>If true, a console output section will be shown in version control views, showing the 
commands run for version control operations.</description>
       </key>
+      <key name="vc-left-is-local" type="b">
+          <default>false</default>
+          <summary>Present version comparisons as left-local/right-remote</summary>
+          <description>If true, version control comparisons will use a left-is-local, right-is-remote scheme 
to determine what order to present files in panes. Otherwise, a left-is-theirs, right-is-mine scheme is 
used.</description>
+      </key>
       <key name="vc-show-commit-margin" type="b">
           <default>true</default>
           <summary>Show margin in commit message editor</summary>
diff --git a/data/ui/preferences.ui b/data/ui/preferences.ui
index 3851a13..e941e46 100644
--- a/data/ui/preferences.ui
+++ b/data/ui/preferences.ui
@@ -18,17 +18,17 @@
   <object class="GtkListStore" id="fileorderstore">
     <columns>
       <!-- column-name id -->
-      <column type="gint"/>
+      <column type="gboolean"/>
       <!-- column-name label -->
       <column type="gchararray"/>
     </columns>
     <data>
       <row>
-        <col id="0">0</col>
+        <col id="0">False</col>
         <col id="1" translatable="yes">Left is remote, right is local</col>
       </row>
       <row>
-        <col id="0">1</col>
+        <col id="0">True</col>
         <col id="1" translatable="yes">Left is local, right is remote</col>
       </row>
     </data>
@@ -924,12 +924,12 @@
                                   </packing>
                                 </child>
                                 <child>
-                                  <object class="GtkComboBox" id="combo_file_order">
+                                  <object class="GSettingsBoolComboBox" 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"/>
+                                    <property name="gsettings-column">0</property>
                                     <child>
                                       <object class="GtkCellRendererText" id="file_order_renderer"/>
                                       <attributes>
diff --git a/meld/preferences.py b/meld/preferences.py
index ba12819..4cfb4fd 100644
--- a/meld/preferences.py
+++ b/meld/preferences.py
@@ -161,6 +161,14 @@ class GSettingsIntComboBox(GSettingsComboBox):
     gsettings_value = GObject.property(type=int)
 
 
+class GSettingsBoolComboBox(GSettingsComboBox):
+
+    __gtype_name__ = "GSettingsBoolComboBox"
+
+    gsettings_column = GObject.property(type=int, default=1)
+    gsettings_value = GObject.property(type=bool, default=False)
+
+
 class PreferencesDialog(gnomeglade.Component):
 
     def __init__(self, parent, prefs):
@@ -235,9 +243,7 @@ class PreferencesDialog(gnomeglade.Component):
         self.combo_timestamp.add_attribute(cell, 'text', 0)
         self.combo_timestamp.bind_to('folder-time-resolution')
 
-        self.combo_file_order.set_active(
-            1 if self.prefs.vc_left_is_local else 0)
-
+        self.combo_file_order.bind_to('vc-left-is-local')
 
         self.widget.show()
 
@@ -254,10 +260,6 @@ class PreferencesDialog(gnomeglade.Component):
         value = GtkSource.DrawSpacesFlags.ALL if widget.get_active() else 0
         settings.set_flags('draw-spaces', value)
 
-    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()
 
@@ -266,7 +268,6 @@ class MeldPreferences(prefs.Preferences):
     defaults = {
         "window_size_x": prefs.Value(prefs.INT, 600),
         "window_size_y": prefs.Value(prefs.INT, 600),
-        "vc_left_is_local": prefs.Value(prefs.BOOL, False),
     }
 
     def __init__(self):
diff --git a/meld/vcview.py b/meld/vcview.py
index a5bcd72..b3b5633 100644
--- a/meld/vcview.py
+++ b/meld/vcview.py
@@ -141,6 +141,7 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
         blurb="Files with these statuses will be shown by the comparison.",
     )
     console_visible = GObject.property(type=bool, default=False)
+    left_is_local = GObject.property(type=bool, default=False)
 
     # Map action names to VC commands and required arguments list
     action_vc_cmds_map = {
@@ -233,6 +234,8 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
                       Gio.SettingsBindFlags.DEFAULT)
         settings.bind('vc-console-visible', self, 'console-visible',
                       Gio.SettingsBindFlags.DEFAULT)
+        settings.bind('vc-left-is-local', self, 'left-is-local',
+                      Gio.SettingsBindFlags.DEFAULT)
 
         self.bind_property(
             'console-visible', self.console_hbox, 'visible',
@@ -465,7 +468,7 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
             self.emit("create-diff", [path], {})
             return
 
-        left_is_local = self.prefs.vc_left_is_local
+        left_is_local = self.props.left_is_local
 
         if self.vc.get_entry(path).state == tree.STATE_CONFLICT and \
                 hasattr(self.vc, 'get_path_for_conflict'):


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