summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/option.c15
-rw-r--r--src/tree.c14
-rw-r--r--src/zenity.h1
3 files changed, 30 insertions, 0 deletions
diff --git a/src/option.c b/src/option.c
index c1e3a77f..e11c1ba9 100644
--- a/src/option.c
+++ b/src/option.c
@@ -83,6 +83,7 @@ static gchar *zenity_list_print_column;
static gchar *zenity_list_hide_column;
static gboolean zenity_list_hide_header;
static gboolean zenity_list_imagelist;
+static gboolean zenity_list_mid_search;
#ifdef HAVE_LIBNOTIFY
/* Notification Dialog Options */
@@ -651,6 +652,15 @@ static GOptionEntry list_options[] = {
N_("Hides the column headers"),
NULL
},
+ {
+ "mid-search",
+ '\0',
+ G_OPTION_FLAG_NOALIAS,
+ G_OPTION_ARG_NONE,
+ &zenity_list_mid_search,
+ N_("Change list default search function searching for text in the middle, not on the beginning"),
+ NULL
+ },
{
NULL
}
@@ -1531,6 +1541,7 @@ zenity_list_pre_callback (GOptionContext *context,
zenity_list_hide_header = FALSE;
zenity_list_print_column = NULL;
zenity_list_hide_column = NULL;
+ zenity_list_mid_search = FALSE;
return TRUE;
}
@@ -1876,6 +1887,7 @@ zenity_list_post_callback (GOptionContext *context,
results->tree_data->hide_column = zenity_list_hide_column;
results->tree_data->hide_header = zenity_list_hide_header;
results->tree_data->separator = zenity_general_separator;
+ results->tree_data->mid_search = zenity_list_mid_search;
} else {
if (zenity_list_columns)
zenity_option_error (zenity_option_get_name (list_options, &zenity_list_columns),
@@ -1904,6 +1916,9 @@ zenity_list_post_callback (GOptionContext *context,
if (zenity_list_hide_header)
zenity_option_error (zenity_option_get_name (list_options, &zenity_list_hide_header),
ERROR_SUPPORT);
+ if (zenity_list_mid_search)
+ zenity_option_error (zenity_option_get_name (list_options, &zenity_list_mid_search),
+ ERROR_SUPPORT);
}
return TRUE;
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);
}
diff --git a/src/zenity.h b/src/zenity.h
index 4cf7a044..4b3214dd 100644
--- a/src/zenity.h
+++ b/src/zenity.h
@@ -132,6 +132,7 @@ typedef struct {
gchar *separator;
gboolean multi;
gboolean editable;
+ gboolean mid_search;
gchar *print_column;
gchar *hide_column;
const gchar **data;
bgstack15