Commits

oliver_g committed 26b885c

enable type-ahead search in displayed values

  • Participants
  • Parent commits 499b4bf
  • Branches hachoir-gtk

Comments (0)

Files changed (2)

File hachoir-gtk/hachoir-gtk

 
         self.xml.get_widget("main_window").set_title("Hachoir - %s" % filename)
 
+        self.table.set_search_equal_func(resultSearchCb)
+
     def quit(self):
         gtk.main_quit()
 
             if field.is_field_set:
                 self.fill_tree(field, newparent, treeStore)
 
+def resultSearchCb (model, column, key, it):
+    """Callback function for searching in treeview"""
+    plainText = model.get_value(it, column)
+
+    # if search text contains only lower-case characters, do case-insensitive matching:
+    if key.islower():
+        plainText = plainText.lower()
+
+    # if the line contains the search text, it matches:
+    if plainText.find(key) >= 0:
+        return False
+
+    # line doesn't match:
+    return True
+
+
+#import cProfile
+# import profile
+
 def main():
     if(len(sys.argv)!=2 ):
         print "usage: %s file" %sys.argv[0]

File hachoir-gtk/hachoir.glade

               <property name="headers_visible">True</property>
               <property name="rules_hint">False</property>
               <property name="reorderable">False</property>
-              <property name="enable_search">False</property>
+              <property name="enable_search">True</property>
               <property name="fixed_height_mode">False</property>
               <property name="hover_selection">False</property>
               <property name="hover_expand">False</property>