From 15e2759668a1d17bb1570a890bf294aaa796cbf5 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Tue, 21 Oct 2014 18:30:35 +0200 Subject: Bug #685051 Adding --mid-search option to --list This will enable users to find a row with a text matching the middle of the row. Consider the following list: Little piggy one Little piggy two Little piggy three As a user I would expect that entering 'th' would focus the last row, because it's the first one that contains 'th' --- src/tree.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/tree.c') diff --git a/src/tree.c b/src/tree.c index a8b324f7..819f9a8e 100644 --- a/src/tree.c +++ b/src/tree.c @@ -298,6 +298,17 @@ zenity_tree_fill_entries (GtkTreeView *tree_view, } } +static gboolean +zenity_mid_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); + return ! g_strrstr (g_utf8_strdown(iter_string, -1), + g_utf8_strdown(key, -1)) != NULL; +} + static void zenity_cell_edited_callback (GtkCellRendererText *cell, const gchar *path_string, @@ -564,6 +575,9 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) zenity_util_show_dialog (dialog, data->attach); + if (tree_data->mid_search) + gtk_tree_view_set_search_equal_func(GTK_TREE_VIEW(tree_view), (GtkTreeViewSearchEqualFunc) zenity_mid_search_func, model, NULL); + if(data->timeout_delay > 0) { g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); } -- cgit