[Xfce4-commits] <xfce4-taskmanager:master> Use a personal SearchFunc for the tree view

Mike Massonnet noreply at xfce.org
Wed May 26 12:10:01 CEST 2010


Updating branch refs/heads/master
         to 322b9978df40b02a61722122ca7a4e02a4e25dc4 (commit)
       from 00082540559e1aceb6fae0a17e1b60a6304a3667 (commit)

commit 322b9978df40b02a61722122ca7a4e02a4e25dc4
Author: Mike Massonnet <mmassonnet at xfce.org>
Date:   Wed May 26 12:08:07 2010 +0200

    Use a personal SearchFunc for the tree view
    
    Use the function strstr to find matches inside the command line, and not
    only starting with. Browsing through matches can be done by typing the
    arrows down and up.

 src/process-tree-view.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/src/process-tree-view.c b/src/process-tree-view.c
index d063798..ab895b8 100644
--- a/src/process-tree-view.c
+++ b/src/process-tree-view.c
@@ -57,6 +57,7 @@ G_DEFINE_TYPE (XtmProcessTreeView, xtm_process_tree_view, GTK_TYPE_TREE_VIEW)
 static gboolean		treeview_clicked				(XtmProcessTreeView *treeview, GdkEventButton *event);
 static void		column_clicked					(GtkTreeViewColumn *column, XtmProcessTreeView *treeview);
 static gboolean		visible_func					(GtkTreeModel *model, GtkTreeIter *iter, XtmProcessTreeView *treeview);
+static gboolean		search_func					(GtkTreeModel *model, gint column, const gchar *key, GtkTreeIter *iter, gpointer user_data);
 static void		settings_changed				(GObject *object, GParamSpec *pspec, XtmProcessTreeView *treeview);
 
 
@@ -191,6 +192,7 @@ xtm_process_tree_view_init (XtmProcessTreeView *treeview)
 		gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (treeview->model), sort_column_id, sort_type);
 	}
 
+	gtk_tree_view_set_search_equal_func (GTK_TREE_VIEW (treeview), (GtkTreeViewSearchEqualFunc)search_func, NULL, NULL);
 	g_signal_connect (treeview, "button-press-event", G_CALLBACK (treeview_clicked), NULL);
 }
 
@@ -403,6 +405,17 @@ visible_func (GtkTreeModel *model, GtkTreeIter *iter, XtmProcessTreeView *treevi
 	return (treeview->owner_uid == uid) ? TRUE : FALSE;
 }
 
+static gboolean
+search_func (GtkTreeModel *model, gint column, const gchar *key, GtkTreeIter *iter, gpointer user_data)
+{
+	gchar *cmdline;
+	gchar *p;
+	gtk_tree_model_get (GTK_TREE_MODEL (model), iter, XTM_PTV_COLUMN_COMMAND, &cmdline, -1);
+	p = g_strrstr_len (cmdline, -1, key);
+	g_free (cmdline);
+	return (p == NULL) ? TRUE : FALSE;
+}
+
 static void
 settings_changed (GObject *object, GParamSpec *pspec, XtmProcessTreeView *treeview)
 {



More information about the Xfce4-commits mailing list