[anjuta] symbol-db: add support for the builtin gtktreeview search
- From: Johannes Schmid <jhs src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] symbol-db: add support for the builtin gtktreeview search
- Date: Wed, 6 Apr 2011 21:10:47 +0000 (UTC)
commit 5cb4ea296036597dd7cf3013ef26d1ed02fbe27c
Author: Carl-Anton Ingmarsson <ca ingmarsson gmail com>
Date: Mon Mar 28 00:59:29 2011 +0200
symbol-db: add support for the builtin gtktreeview search
plugins/symbol-db/symbol-db-views.c | 27 +++++++++++++++++++++++++++
1 files changed, 27 insertions(+), 0 deletions(-)
---
diff --git a/plugins/symbol-db/symbol-db-views.c b/plugins/symbol-db/symbol-db-views.c
index d470f5e..288a346 100644
--- a/plugins/symbol-db/symbol-db-views.c
+++ b/plugins/symbol-db/symbol-db-views.c
@@ -122,6 +122,26 @@ on_treeview_has_child_toggled (GtkTreeModel *model,
g_free (symbol_name);
}
+static gboolean
+symbol_db_view_search_equal_func (GtkTreeModel *model, gint column,
+ const gchar *key, GtkTreeIter *iter,
+ gpointer search_data)
+{
+ gchar *pattern, *str;
+ gboolean res;
+
+ gtk_tree_model_get (model, iter, column, &str, -1);
+
+ pattern = g_strdup_printf (".*%s.*", key);
+ res = g_regex_match_simple (pattern, str, G_REGEX_CASELESS, 0);
+
+ g_free (pattern);
+ g_free (str);
+
+ return !res;
+}
+
+
static void
on_search_entry_changed (GtkEntry *entry, SymbolDBModelSearch *model)
{
@@ -207,6 +227,13 @@ symbol_db_view_new (SymbolViewType view_type,
gtk_container_add (GTK_CONTAINER (sw), dbv);
gtk_widget_show (sw);
+ /* Search */
+ gtk_tree_view_set_search_equal_func (GTK_TREE_VIEW (dbv),
+ symbol_db_view_search_equal_func,
+ NULL, NULL);
+ gtk_tree_view_set_search_column (GTK_TREE_VIEW (dbv),
+ SYMBOL_DB_MODEL_PROJECT_COL_LABEL);
+
if (view_type == SYMBOL_DB_VIEW_SEARCH)
{
entry = gtk_entry_new ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]