[meld] vcview: Move file status filters to GSettings



commit 94dd4b7cc36ab4a3fab9eb5f2dcd9fc643754932
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sun Nov 24 06:33:13 2013 +1000

    vcview: Move file status filters to GSettings

 data/org.gnome.meld.gschema.xml |    5 +++++
 meld/preferences.py             |    2 --
 meld/vcview.py                  |   37 ++++++++++++++++++++++++-------------
 3 files changed, 29 insertions(+), 15 deletions(-)
---
diff --git a/data/org.gnome.meld.gschema.xml b/data/org.gnome.meld.gschema.xml
index d57907d..8401f2a 100644
--- a/data/org.gnome.meld.gschema.xml
+++ b/data/org.gnome.meld.gschema.xml
@@ -101,5 +101,10 @@
           <summary>Automatically hard-wrap commit messages</summary>
           <description>If true, the version control commit message editor will hard-wrap (i.e., insert line 
breaks) at the defined commit margin before commit.</description>
       </key>
+      <key name="vc-status-filters" type="as">
+          <default>['flatten', 'modified']</default>
+          <summary>Version control status filters</summary>
+          <description>List of statuses used to filter visible files in version control 
comparison.</description>
+      </key>
   </schema>
 </schemalist>
diff --git a/meld/preferences.py b/meld/preferences.py
index fc159ae..5d9ac89 100644
--- a/meld/preferences.py
+++ b/meld/preferences.py
@@ -330,8 +330,6 @@ class MeldPreferences(prefs.Preferences):
         "ignore_blank_lines" : prefs.Value(prefs.BOOL, False),
         "toolbar_visible" : prefs.Value(prefs.BOOL, True),
         "statusbar_visible" : prefs.Value(prefs.BOOL, True),
-        "vc_status_filters": prefs.Value(prefs.LIST,
-                                         ['flatten', 'modified']),
         # Currently, we're using a quite simple format to store the columns:
         # each line contains a column name followed by a 1 or a 0
         # depending on whether the column is visible or not.
diff --git a/meld/vcview.py b/meld/vcview.py
index 83c9855..02ea394 100644
--- a/meld/vcview.py
+++ b/meld/vcview.py
@@ -28,6 +28,7 @@ from gettext import gettext as _
 
 from gi.repository import GLib
 from gi.repository import Gio
+from gi.repository import GObject
 from gi.repository import Gtk
 from gi.repository import Pango
 
@@ -39,6 +40,8 @@ from . import vc
 from .ui import emblemcellrenderer
 from .ui import gnomeglade
 from .ui import vcdialogs
+
+from meld.settings import settings
 from meld.vc import _null
 
 
@@ -127,12 +130,17 @@ entry_normal   = lambda x: (x.state == tree.STATE_NORMAL)
 entry_nonvc    = lambda x: (x.state == tree.STATE_NONE) or (x.isdir and (x.state > tree.STATE_IGNORED))
 entry_ignored  = lambda x: (x.state == tree.STATE_IGNORED) or x.isdir
 
-################################################################################
-#
-# VcView
-#
-################################################################################
+
 class VcView(melddoc.MeldDoc, gnomeglade.Component):
+
+    __gtype_name__ = "VcView"
+
+    status_filters = GObject.property(
+        type=GObject.TYPE_STRV,
+        nick="File status filters",
+        blurb="Files with these statuses will be shown by the comparison.",
+    )
+
     # Map action names to VC commands and required arguments list
     action_vc_cmds_map = {
         "VcCommit": ("commit_command", ("",)),
@@ -208,13 +216,6 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
         addCol(_("Revision"), COL_REVISION, vc.DATA_REVISION)
         addCol(_("Options"), COL_OPTIONS, vc.DATA_OPTIONS)
 
-        self.state_filters = []
-        for s in self.state_actions:
-            if s in self.prefs.vc_status_filters:
-                action_name = self.state_actions[s][0]
-                self.state_filters.append(s)
-                self.actiongroup.get_action(action_name).set_active(True)
-
         self.consolestream = ConsoleStream(self.consoleview)
         self.location = None
         self.treeview_column_location.set_visible(self.actiongroup.get_action("VcFlatten").get_active())
@@ -229,6 +230,16 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
         self.combobox_vcs.add_attribute(cell, 'sensitive', 2)
         self.combobox_vcs.lock = False
 
+        settings.bind('vc-status-filters', self, 'status-filters',
+                      Gio.SettingsBindFlags.DEFAULT)
+
+        self.state_filters = []
+        for s in self.state_actions:
+            if s in self.props.status_filters:
+                action_name = self.state_actions[s][0]
+                self.state_filters.append(s)
+                self.actiongroup.get_action(action_name).set_active(True)
+
     def on_container_switch_in_event(self, ui):
         melddoc.MeldDoc.on_container_switch_in_event(self, ui)
         self.scheduler.add_task(self.on_treeview_cursor_changed)
@@ -514,7 +525,7 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
             return
 
         self.state_filters = active_filters
-        self.prefs.vc_status_filters = active_filters
+        self.props.status_filters = active_filters
         self.refresh()
 
     def on_treeview_selection_changed(self, selection=None):


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