diff options
author | Elia Argentieri <elia.argentieri@openmailbox.org> | 2017-07-06 21:37:28 +0200 |
---|---|---|
committer | Elia Argentieri <elia.argentieri@openmailbox.org> | 2017-07-06 21:37:28 +0200 |
commit | f0f522b20744bf32252bb18b92a11249ede935ce (patch) | |
tree | 6ad7db7ccac55a2d0a3ba8cbd83aa1709e5e927c | |
parent | 810d589610ef851096d5a4c1e711725afe817f92 (diff) |
Add a mid-string case insensitive search function to files tree view.
Closes #46.
-rw-r--r-- | src/trg-files-tree-view.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/trg-files-tree-view.c b/src/trg-files-tree-view.c index 70147f7..2b739c9 100644 --- a/src/trg-files-tree-view.c +++ b/src/trg-files-tree-view.c @@ -180,6 +180,18 @@ view_onButtonPressed(GtkWidget * treeview, return handled; } +static gboolean +search_func (GtkTreeModel *model, gint column, + const gchar *key, GtkTreeIter *iter, + gpointer search_data) +{ + gchar *iter_string = NULL; + gtk_tree_model_get(model, iter, column, &iter_string, -1); + gboolean result = g_strrstr(g_utf8_strdown(iter_string, -1), key) == NULL; + g_free(iter_string); + return result; +} + static void trg_files_tree_view_init(TrgFilesTreeView * self) { TrgTreeView *ttv = TRG_TREE_VIEW(self); @@ -200,6 +212,11 @@ static void trg_files_tree_view_init(TrgFilesTreeView * self) gtk_tree_view_set_search_column(GTK_TREE_VIEW(self), FILESCOL_NAME); + gtk_tree_view_set_search_equal_func(GTK_TREE_VIEW(self), + (GtkTreeViewSearchEqualFunc) search_func, + gtk_tree_view_get_model(GTK_TREE_VIEW(self)), + NULL); + g_signal_connect(self, "button-press-event", G_CALLBACK(view_onButtonPressed), NULL); g_signal_connect(self, "popup-menu", |