[Xfce4-commits] <midori:master> Implement inline search in extensions treeview

Christian Dywan noreply at xfce.org
Tue Mar 12 18:16:01 CET 2013


Updating branch refs/heads/master
         to 4aca9bb410557e66d7f5906334bd4992da3c7d8a (commit)
       from b45f64c770d91c6787826bed7f261253ebb33347 (commit)

commit 4aca9bb410557e66d7f5906334bd4992da3c7d8a
Author: Christian Dywan <christian at twotoasts.de>
Date:   Tue Mar 12 18:12:06 2013 +0100

    Implement inline search in extensions treeview
    
    Fixes: https://bugs.launchpad.net/midori/+bug/1153393

 panels/midori-extensions.c |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/panels/midori-extensions.c b/panels/midori-extensions.c
index cd5d70c..c6e36a7 100644
--- a/panels/midori-extensions.c
+++ b/panels/midori-extensions.c
@@ -432,6 +432,29 @@ midori_extensions_treeview_button_pressed_cb (GtkWidget*      view,
     return ret;
 }
 
+static gboolean
+extensions_column_search_equal_func (GtkTreeModel* model,
+                                     gint          column,
+                                     const gchar*  key,
+                                     GtkTreeIter*  iter,
+                                     gpointer      search_data)
+{
+    MidoriExtension* extension;
+    gchar* name;
+    gchar* lower;
+    gboolean match;
+
+    gtk_tree_model_get (model, iter, 0, &extension, -1);
+    name = katze_object_get_string (extension, "name");
+    lower = g_utf8_strdown (name, -1);
+    match = !strstr (lower, key);
+
+    g_free (lower);
+    g_free (name);
+
+    return match;
+}
+
 static void
 midori_extensions_init (MidoriExtensions* extensions)
 {
@@ -494,6 +517,9 @@ midori_extensions_init (MidoriExtensions* extensions)
         "signal::row-activated",
         midori_extensions_treeview_row_activated_cb, extensions,
         NULL);
+    gtk_tree_view_set_search_column (GTK_TREE_VIEW (extensions->treeview), 0);
+    gtk_tree_view_set_search_equal_func (GTK_TREE_VIEW (extensions->treeview),
+                                         extensions_column_search_equal_func, NULL, NULL);
     gtk_widget_show (extensions->treeview);
     gtk_box_pack_start (GTK_BOX (extensions), extensions->treeview, TRUE, TRUE, 0);
 }


More information about the Xfce4-commits mailing list