[meld] Implement type-ahead search for VC view
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] Implement type-ahead search for VC view
- Date: Thu, 21 Apr 2011 21:43:56 +0000 (UTC)
commit 3c6bb46f56945c79aac8453ad26b57b562516d24
Author: Oliver Gerlich <oliver gerlich gmx de>
Date: Mon Apr 18 21:20:59 2011 +0200
Implement type-ahead search for VC view
The search is started by typing any letter into the treeview.
meld/vcview.py | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/meld/vcview.py b/meld/vcview.py
index 51f281b..6b9d045 100644
--- a/meld/vcview.py
+++ b/meld/vcview.py
@@ -153,6 +153,7 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
self.treeview.set_model(self.model)
self.treeview.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
self.treeview.set_headers_visible(1)
+ self.treeview.set_search_equal_func(self.treeview_search_cb)
column = gtk.TreeViewColumn( _("Name") )
renicon = ui.emblemcellrenderer.EmblemCellRenderer()
rentext = gtk.CellRendererText()
@@ -674,3 +675,23 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
def on_reload_activate(self, *extra):
self.on_fileentry_activate(self.fileentry)
+
+ def treeview_search_cb(self, model, column, key, it):
+ """Callback function for searching in VcView treeview"""
+ path = model.get_value(it, tree.COL_PATH)
+
+ # if query text contains slash, search in full path
+ if key.find('/') >= 0:
+ lineText = path
+ else:
+ lineText = os.path.basename(path)
+
+ # Perform case-insensitive matching if query text is all lower-case
+ if key.islower():
+ lineText = lineText.lower()
+
+ if lineText.find(key) >= 0:
+ # line matches
+ return False
+ else:
+ return True
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]