aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2012-05-17 22:03:34 +0800
committerBastien Nocera <hadess@hadess.net>2012-09-27 18:22:38 +0800
commit857b10c70d38103ba9643e681307a02fd176b35e (patch)
tree7dd81531e02682eed038c9f6108f338d2f6a1940
parented5d02e80aab0297b04b31939a83bc13e75baf45 (diff)
downloadgsoc2013-epiphany-857b10c70d38103ba9643e681307a02fd176b35e.tar.gz
gsoc2013-epiphany-857b10c70d38103ba9643e681307a02fd176b35e.tar.zst
gsoc2013-epiphany-857b10c70d38103ba9643e681307a02fd176b35e.zip
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
-rw-r--r--src/pdm-dialog.c32
1 files changed, 32 insertions, 0 deletions
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);
}