summaryrefslogtreecommitdiff
path: root/src/tree.c
diff options
context:
space:
mode:
authorArx Cruz <arxcruz@gnome.org>2014-10-21 18:30:35 +0200
committerArx Cruz <arxcruz@gnome.org>2014-10-21 18:30:35 +0200
commit15e2759668a1d17bb1570a890bf294aaa796cbf5 (patch)
tree76450a9da365aa5cdd497a093583cf619a87a5e7 /src/tree.c
parentFixing g_timeout_add calls (diff)
downloadzenity-15e2759668a1d17bb1570a890bf294aaa796cbf5.tar.gz
zenity-15e2759668a1d17bb1570a890bf294aaa796cbf5.tar.bz2
zenity-15e2759668a1d17bb1570a890bf294aaa796cbf5.zip
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.c14
1 files changed, 14 insertions, 0 deletions
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);
}
bgstack15