diff options
author | Arx Cruz <arxcruz@gnome.org> | 2014-10-21 18:30:35 +0200 |
---|---|---|
committer | Arx Cruz <arxcruz@gnome.org> | 2014-10-21 18:30:35 +0200 |
commit | 15e2759668a1d17bb1570a890bf294aaa796cbf5 (patch) | |
tree | 76450a9da365aa5cdd497a093583cf619a87a5e7 /src/tree.c | |
parent | b44b2fb33dac0618e355f8cd5c46be0b3d13eadc (diff) | |
download | zenity-15e2759668a1d17bb1570a890bf294aaa796cbf5.tar.gz |
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'
Diffstat (limited to 'src/tree.c')
-rw-r--r-- | src/tree.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -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); } |