From 292be9d5d57f26ef58224cdd8eaba9f0397ac3b6 Mon Sep 17 00:00:00 2001
From: Tristan Matthews <tristan.matthews@savoirfairelinux.com>
Date: Thu, 17 May 2012 15:30:07 -0400
Subject: [PATCH] * #11207: fixed history search bar

---
 gnome/src/contacts/calltree.c | 11 +----------
 gnome/src/contacts/calltree.h | 12 ++++++++++++
 gnome/src/contacts/history.c  | 31 ++++++++++---------------------
 3 files changed, 23 insertions(+), 31 deletions(-)

diff --git a/gnome/src/contacts/calltree.c b/gnome/src/contacts/calltree.c
index 2163706c34..3fc9df6ae9 100644
--- a/gnome/src/contacts/calltree.c
+++ b/gnome/src/contacts/calltree.c
@@ -79,15 +79,6 @@ static GtkTargetEntry target_list[] = {
 
 static const guint n_targets = G_N_ELEMENTS(target_list);
 
-enum {
-    COLUMN_ACCOUNT_PIXBUF = 0,
-    COLUMN_ACCOUNT_DESC,
-    COLUMN_ACCOUNT_SECURITY_PIXBUF,
-    COLUMN_ID,
-    COLUMN_IS_CONFERENCE,
-    COLUMNS_IN_TREE_STORE
-};
-
 /**
  * Show popup menu
  */
@@ -100,7 +91,7 @@ popup_menu(GtkWidget *widget,
 }
 
 /* Returns TRUE if row contains a conference object pointer */
-static gboolean
+gboolean
 is_conference(GtkTreeModel *model, GtkTreeIter *iter)
 {
     gboolean result = FALSE;
diff --git a/gnome/src/contacts/calltree.h b/gnome/src/contacts/calltree.h
index 073e847959..b9e9e49768 100644
--- a/gnome/src/contacts/calltree.h
+++ b/gnome/src/contacts/calltree.h
@@ -106,4 +106,16 @@ calltree_display (calltab_t *);
 gboolean
 calltree_update_clock(gpointer);
 
+gboolean
+is_conference(GtkTreeModel *model, GtkTreeIter *iter);
+
+enum {
+    COLUMN_ACCOUNT_PIXBUF = 0,
+    COLUMN_ACCOUNT_DESC,
+    COLUMN_ACCOUNT_SECURITY_PIXBUF,
+    COLUMN_ID,
+    COLUMN_IS_CONFERENCE,
+    COLUMNS_IN_TREE_STORE
+};
+
 #endif
diff --git a/gnome/src/contacts/history.c b/gnome/src/contacts/history.c
index 33b01177d9..681ae12e5b 100644
--- a/gnome/src/contacts/history.c
+++ b/gnome/src/contacts/history.c
@@ -54,45 +54,34 @@ search_type_matches_state(SearchType type, const gchar *state)
 
 static gboolean history_is_visible(GtkTreeModel* model, GtkTreeIter* iter, gpointer data UNUSED)
 {
-    gboolean ret = TRUE;
-    callable_obj_t *history_entry = NULL;
-    const gchar *text = NULL;
+    /* Skip conferences */
+    if (is_conference(model, iter))
+        return TRUE;
 
     // Fetch the call description
-    GValue val;
-    memset(&val, 0, sizeof val);
-    gtk_tree_model_get_value(GTK_TREE_MODEL(model), iter, 1, &val);
-
-    if (G_VALUE_HOLDS_STRING(&val))
-        text = (gchar *) g_value_get_string(&val);
-
-    // Fetch the call type
-    GValue obj;
-    memset(&obj, 0, sizeof obj);
-    gtk_tree_model_get_value(GTK_TREE_MODEL(model), iter, 3, &obj);
-
-    if (G_VALUE_HOLDS_POINTER(&obj))
-        history_entry = (gpointer) g_value_get_pointer(&obj);
+    const gchar *text = NULL;
+    const gchar *id = NULL;
+    gtk_tree_model_get(model, iter, COLUMN_ACCOUNT_DESC, &text, COLUMN_ID, &id, -1);
+    callable_obj_t *history_entry = calllist_get_call(history_tab, id);
 
+    gboolean ret = TRUE;
     if (text && history_entry) {
         // Filter according to the type of call
         // MISSED, INCOMING, OUTGOING, ALL
         const gchar* search = gtk_entry_get_text(history_searchbar_widget);
 
         if (!search || !*search)
-            goto end;
+            return TRUE;
 
         SearchType search_type = get_current_history_search_type();
         ret = g_regex_match_simple(search, text, G_REGEX_CASELESS, 0);
 
         if (search_type == SEARCH_ALL)
-            goto end;
+            return ret;
         else // We need a match on the history_state and the current search type
             ret = ret && search_type_matches_state(search_type, history_entry->_history_state);
     }
 
-end:
-    g_value_unset(&val);
     return ret;
 }
 
-- 
GitLab