From 490b4d0f533fbd1a353b3baa7e288de1f777692a Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Thu, 17 May 2012 15:03:34 +0100 Subject: pdm-dialog: Add type-ahead search to personal data The password treeview is unusable to find old passwords or cookies, as some are prefixed by "http://", and others will have different vhost names. The search function will look first for sub-string matches in the URIs, then in the usernames (or cookie names). https://bugzilla.gnome.org/show_bug.cgi?id=676240 --- src/pdm-dialog.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src') diff --git a/src/pdm-dialog.c b/src/pdm-dialog.c index 751322455..3cb8d6af5 100644 --- a/src/pdm-dialog.c +++ b/src/pdm-dialog.c @@ -1271,6 +1271,33 @@ passwords_show_toggled_cb (GtkWidget *button, gtk_tree_view_column_set_visible (column, active); } +static gboolean +password_search_equal (GtkTreeModel *model, + int column, + const gchar *key, + GtkTreeIter *iter, + gpointer search_data) +{ + char *host, *user; + gboolean retval; + + /* Note that this is function has to return FALSE for a *match* ! */ + + gtk_tree_model_get (model, iter, COL_PASSWORDS_HOST, &host, -1); + retval = strstr (host, key) == NULL; + g_free (host); + if (retval == FALSE) + return retval; + + gtk_tree_model_get (model, iter, COL_PASSWORDS_USER, &user, -1); + retval = strstr (user, key) == NULL; + g_free (user); + + return retval; +} + + + static void pdm_dialog_passwords_construct (PdmActionInfo *info) { @@ -1353,6 +1380,11 @@ pdm_dialog_passwords_construct (PdmActionInfo *info) gtk_tree_view_column_set_reorderable (column, TRUE); gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE); + /* Setup basic type ahead filtering */ + gtk_tree_view_set_search_equal_func (treeview, + (GtkTreeViewSearchEqualFunc) password_search_equal, + dialog, NULL); + info->treeview = treeview; setup_action (info); } -- cgit v1.2.3