[meld] dirdiff: Move file status filters to GSettings



commit d3dfcd087e3e5ed828dd8be904af94277a4e8952
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sun Nov 24 06:27:48 2013 +1000

    dirdiff: Move file status filters to GSettings

 data/org.gnome.meld.gschema.xml |    5 +++++
 meld/dirdiff.py                 |   24 ++++++++++++++++--------
 meld/preferences.py             |    2 --
 3 files changed, 21 insertions(+), 10 deletions(-)
---
diff --git a/data/org.gnome.meld.gschema.xml b/data/org.gnome.meld.gschema.xml
index cb66f8e..d57907d 100644
--- a/data/org.gnome.meld.gschema.xml
+++ b/data/org.gnome.meld.gschema.xml
@@ -79,6 +79,11 @@
           <summary>File timestamp resolution</summary>
           <description>When comparing based on mtime, this is the minimum difference in nanoseconds between 
two files before they're considered to have different mtimes. This is useful when comparing files between 
filesystems with different timestamp resolution.</description>
       </key>
+      <key name="folder-status-filters" type="as">
+          <default>['normal', 'modified', 'new']</default>
+          <summary>File status filters</summary>
+          <description>List of statuses used to filter visible files in folder comparison.</description>
+      </key>
 
       <!-- Version control properties -->
       <key name="vc-show-commit-margin" type="b">
diff --git a/meld/dirdiff.py b/meld/dirdiff.py
index b5b05c8..79a2406 100644
--- a/meld/dirdiff.py
+++ b/meld/dirdiff.py
@@ -270,6 +270,11 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
         blurb="Whether to compare files based solely on size and mtime",
         default=False,
     )
+    status_filters = GObject.property(
+        type=GObject.TYPE_STRV,
+        nick="File status filters",
+        blurb="Files with these statuses will be shown by the comparison.",
+    )
     time_resolution = GObject.property(
         type=int,
         nick="Time resolution",
@@ -408,13 +413,6 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
                 "value-changed", self._sync_hscroll)
         self.linediffs = [[], []]
 
-        self.state_filters = []
-        for s in self.state_actions:
-            if self.state_actions[s][0] in self.prefs.dir_status_filters:
-                self.state_filters.append(s)
-                action_name = self.state_actions[s][1]
-                self.actiongroup.get_action(action_name).set_active(True)
-
         settings.bind('folder-columns', self, 'columns',
                       Gio.SettingsBindFlags.DEFAULT)
         settings.bind('folder-ignore-symlinks', self, 'ignore-symlinks',
@@ -423,11 +421,20 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
                       Gio.SettingsBindFlags.DEFAULT)
         settings.bind('folder-time-resolution', self, 'time-resolution',
                       Gio.SettingsBindFlags.DEFAULT)
+        settings.bind('folder-status-filters', self, 'status-filters',
+                      Gio.SettingsBindFlags.DEFAULT)
 
         self.update_comparator()
         self.connect("notify::shallow-comparison", self.update_comparator)
         self.connect("notify::time-resolution", self.update_comparator)
 
+        self.state_filters = []
+        for s in self.state_actions:
+            if self.state_actions[s][0] in self.props.status_filters:
+                self.state_filters.append(s)
+                action_name = self.state_actions[s][1]
+                self.actiongroup.get_action(action_name).set_active(True)
+
     def on_style_set(self, widget, prev_style):
         style = widget.get_style_context()
 
@@ -1175,7 +1182,8 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
 
         state_strs = [self.state_actions[s][0] for s in active_filters]
         self.state_filters = active_filters
-        self.prefs.dir_status_filters = state_strs
+        # TODO: Updating the property won't have any effect on its own
+        self.props.status_filters = state_strs
         self.refresh()
 
     def _update_name_filter(self, button, idx):
diff --git a/meld/preferences.py b/meld/preferences.py
index 58a9b3a..fc159ae 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),
-        "dir_status_filters": prefs.Value(prefs.LIST,
-                                          ['normal', 'modified', 'new']),
         "vc_status_filters": prefs.Value(prefs.LIST,
                                          ['flatten', 'modified']),
         # Currently, we're using a quite simple format to store the columns:


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