Commit a1e5533d authored by Kai Willadsen's avatar Kai Willadsen

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

parent 2eb4edc0
......@@ -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)
......
......@@ -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
......@@ -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(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment