[meld] vcview: Update VC console visibility setting to GSettings



commit 8e90b073d464d042a98efc0efd785c30ca02a2a6
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Wed Dec 4 07:24:47 2013 +1000

    vcview: Update VC console visibility setting to GSettings

 data/org.gnome.meld.gschema.xml |    5 +++++
 meld/preferences.py             |    1 -
 meld/vcview.py                  |   30 +++++++++++++-----------------
 3 files changed, 18 insertions(+), 18 deletions(-)
---
diff --git a/data/org.gnome.meld.gschema.xml b/data/org.gnome.meld.gschema.xml
index b933d0a..29c75d2 100644
--- a/data/org.gnome.meld.gschema.xml
+++ b/data/org.gnome.meld.gschema.xml
@@ -144,6 +144,11 @@
       </key>
 
       <!-- Version control properties -->
+      <key name="vc-console-visible" type="b">
+          <default>false</default>
+          <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-show-commit-margin" type="b">
           <default>true</default>
           <summary>Show margin in commit message editor</summary>
diff --git a/meld/preferences.py b/meld/preferences.py
index 2297b4a..ba12819 100644
--- a/meld/preferences.py
+++ b/meld/preferences.py
@@ -266,7 +266,6 @@ class MeldPreferences(prefs.Preferences):
     defaults = {
         "window_size_x": prefs.Value(prefs.INT, 600),
         "window_size_y": prefs.Value(prefs.INT, 600),
-        "vc_console_visible": prefs.Value(prefs.BOOL, 0),
         "vc_left_is_local": prefs.Value(prefs.BOOL, False),
     }
 
diff --git a/meld/vcview.py b/meld/vcview.py
index 02ea394..a5bcd72 100644
--- a/meld/vcview.py
+++ b/meld/vcview.py
@@ -140,6 +140,7 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
         nick="File status filters",
         blurb="Files with these statuses will be shown by the comparison.",
     )
+    console_visible = GObject.property(type=bool, default=False)
 
     # Map action names to VC commands and required arguments list
     action_vc_cmds_map = {
@@ -219,8 +220,6 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
         self.consolestream = ConsoleStream(self.consoleview)
         self.location = None
         self.treeview_column_location.set_visible(self.actiongroup.get_action("VcFlatten").get_active())
-        if not self.prefs.vc_console_visible:
-            self.on_console_view_toggle(self.console_hide_box)
         self.vc = None
         self.valid_vc_actions = tuple()
 
@@ -232,6 +231,16 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
 
         settings.bind('vc-status-filters', self, 'status-filters',
                       Gio.SettingsBindFlags.DEFAULT)
+        settings.bind('vc-console-visible', self, 'console-visible',
+                      Gio.SettingsBindFlags.DEFAULT)
+
+        self.bind_property(
+            'console-visible', self.console_hbox, 'visible',
+            GObject.BindingFlags.SYNC_CREATE | GObject.BindingFlags.DEFAULT)
+        self.bind_property(
+            'console-visible', self.console_show_box, 'visible',
+            GObject.BindingFlags.SYNC_CREATE |
+            GObject.BindingFlags.INVERT_BOOLEAN)
 
         self.state_filters = []
         for s in self.state_actions:
@@ -606,7 +615,7 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
 
         returncode = next(readiter)
         if returncode:
-            self.set_console_view_visible(True)
+            self.props.console_visible = True
 
         if refresh:
             self.refresh_partial(workdir)
@@ -763,20 +772,7 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
         return None
 
     def on_console_view_toggle(self, box, event=None):
-        if box == self.console_hide_box:
-            self.set_console_view_visible(False)
-        else:
-            self.set_console_view_visible(True)
-
-    def set_console_view_visible(self, visible):
-        if not visible:
-            self.prefs.vc_console_visible = 0
-            self.console_hbox.hide()
-            self.console_show_box.show()
-        else:
-            self.prefs.vc_console_visible = 1
-            self.console_hbox.show()
-            self.console_show_box.hide()
+        self.props.console_visible = box != self.console_hide_box
 
     def on_consoleview_populate_popup(self, textview, menu):
         buf = textview.get_buffer()


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