[meld] tree: Pull search callback out of model; it's a view helper function



commit a1e5533da6fab09981f5fd13965dce62fb64796f
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sun Oct 23 07:21:44 2016 +1000

    tree: Pull search callback out of model; it's a view helper function

 meld/dirdiff.py |  2 +-
 meld/tree.py    | 33 +++++++++++++++++----------------
 meld/vcview.py  |  3 +--
 3 files changed, 19 insertions(+), 19 deletions(-)
---
diff --git a/meld/dirdiff.py b/meld/dirdiff.py
index eb2c26d6..656aaed8 100644
--- a/meld/dirdiff.py
+++ b/meld/dirdiff.py
@@ -358,7 +358,7 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
             self.focus_in_events.append(handler_id)
             handler_id = treeview.connect("focus-out-event", self.on_treeview_focus_out_event)
             self.focus_out_events.append(handler_id)
-            treeview.set_search_equal_func(self.model.treeview_search_cb, None)
+            treeview.set_search_equal_func(tree.treeview_search_cb, None)
         self.force_cursor_recalculate = False
         self.current_path, self.prev_path, self.next_path = None, None, None
         self.on_treeview_focus_out_event(None, None)
diff --git a/meld/tree.py b/meld/tree.py
index 61bac4d5..4c68f706 100644
--- a/meld/tree.py
+++ b/meld/tree.py
@@ -226,22 +226,6 @@ class DiffTreeStore(Gtk.TreeStore):
 
         return prev_path, next_path
 
-    def treeview_search_cb(self, model, column, key, it, data):
-        # If the key contains a path separator, search the whole path,
-        # otherwise just use the filename. If the key is all lower-case, do a
-        # case-insensitive match.
-        abs_search = '/' in key
-        lower_key = key.islower()
-
-        for path in model.value_paths(it):
-            if not path:
-                continue
-            text = path if abs_search else os.path.basename(path)
-            text = text.lower() if lower_key else text
-            if key in text:
-                return False
-        return True
-
     def state_rows(self, states):
         """Generator of rows in one of the given states
 
@@ -252,3 +236,20 @@ class DiffTreeStore(Gtk.TreeStore):
             state = self.get_state(it, 0)
             if state in states:
                 yield it
+
+
+def treeview_search_cb(model, column, key, it, data):
+    # If the key contains a path separator, search the whole path,
+    # otherwise just use the filename. If the key is all lower-case, do a
+    # case-insensitive match.
+    abs_search = '/' in key
+    lower_key = key.islower()
+
+    for path in model.value_paths(it):
+        if not path:
+            continue
+        text = path if abs_search else os.path.basename(path)
+        text = text.lower() if lower_key else text
+        if key in text:
+            return False
+    return True
diff --git a/meld/vcview.py b/meld/vcview.py
index fef033d7..d33d36ce 100644
--- a/meld/vcview.py
+++ b/meld/vcview.py
@@ -167,8 +167,7 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
         self.treeview.set_model(self.model)
         self.treeview.get_selection().connect(
             "changed", self.on_treeview_selection_changed)
-        self.treeview.set_search_equal_func(
-            self.model.treeview_search_cb, None)
+        self.treeview.set_search_equal_func(tree.treeview_search_cb, None)
         self.current_path, self.prev_path, self.next_path = None, None, None
 
         self.name_column.set_attributes(


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