[epiphany] pdm-dialog: Add type-ahead search to personal data



commit 490b4d0f533fbd1a353b3baa7e288de1f777692a
Author: Bastien Nocera <hadess hadess net>
Date:   Thu May 17 15:03:34 2012 +0100

    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 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/src/pdm-dialog.c b/src/pdm-dialog.c
index 7513224..3cb8d6a 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);
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]