]> git.0d.be Git - empathy.git/commitdiff
factor out empathy_individual_match_words()
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Tue, 31 May 2011 13:24:28 +0000 (15:24 +0200)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Tue, 31 May 2011 13:36:45 +0000 (15:36 +0200)
libempathy-gtk/empathy-individual-view.c
libempathy-gtk/empathy-ui-utils.c
libempathy-gtk/empathy-ui-utils.h
libempathy/empathy-utils.c

index eb41996f5a49e211f07c0943e3df4a82fc7660bf..ec632989e5a292fcfc6a7816e79ca361e08beb5c 100644 (file)
@@ -1692,7 +1692,6 @@ individual_view_is_visible_individual (EmpathyIndividualView *self,
 {
   EmpathyIndividualViewPriv *priv = GET_PRIV (self);
   EmpathyLiveSearch *live = EMPATHY_LIVE_SEARCH (priv->search_widget);
-  const gchar *str;
   GList *personas, *l;
   gboolean is_favorite, contains_interesting_persona = FALSE;
 
@@ -1729,37 +1728,8 @@ individual_view_is_visible_individual (EmpathyIndividualView *self,
     return (priv->show_offline || is_online);
   }
 
-  /* check alias name */
-  str = folks_alias_details_get_alias (FOLKS_ALIAS_DETAILS (individual));
-
-  if (empathy_live_search_match (live, str))
-    return TRUE;
-
-  /* check contact id, remove the @server.com part */
-  for (l = personas; l; l = l->next)
-    {
-      const gchar *p;
-      gchar *dup_str = NULL;
-      gboolean visible;
-
-      if (!empathy_folks_persona_is_interesting (FOLKS_PERSONA (l->data)))
-        continue;
-
-      str = folks_persona_get_display_id (l->data);
-      p = strstr (str, "@");
-      if (p != NULL)
-        str = dup_str = g_strndup (str, p - str);
-
-      visible = empathy_live_search_match (live, str);
-      g_free (dup_str);
-      if (visible)
-        return TRUE;
-    }
-
-  /* FIXME: Add more rules here, we could check phone numbers in
-   * contact's vCard for example. */
-
-  return FALSE;
+  return empathy_individual_match_words (individual,
+      empathy_live_search_get_words (live));
 }
 
 static gchar *
index a1bd50f1a185832db555fde01e2e3d2f5c586ae8..ee73c14c81c717cb64f3a280ded8d6bf74b46925 100644 (file)
@@ -44,6 +44,7 @@
 
 #include "empathy-ui-utils.h"
 #include "empathy-images.h"
+#include "empathy-live-search.h"
 #include "empathy-smiley-manager.h"
 
 #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
@@ -1947,3 +1948,44 @@ empathy_get_current_action_time (void)
 {
   return (tp_user_action_time_from_x11 (gtk_get_current_event_time ()));
 }
+
+gboolean
+empathy_individual_match_words (FolksIndividual *individual,
+    GPtrArray *words)
+{
+  const gchar *str;
+  GList *personas, *l;
+
+  /* check alias name */
+  str = folks_alias_details_get_alias (FOLKS_ALIAS_DETAILS (individual));
+
+  if (empathy_live_search_match_words (str, words))
+    return TRUE;
+
+  personas = folks_individual_get_personas (individual);
+
+  /* check contact id, remove the @server.com part */
+  for (l = personas; l; l = l->next)
+    {
+      const gchar *p;
+      gchar *dup_str = NULL;
+      gboolean visible;
+
+      if (!empathy_folks_persona_is_interesting (FOLKS_PERSONA (l->data)))
+        continue;
+
+      str = folks_persona_get_display_id (l->data);
+      p = strstr (str, "@");
+      if (p != NULL)
+        str = dup_str = g_strndup (str, p - str);
+
+      visible = empathy_live_search_match_words (str, words);
+      g_free (dup_str);
+      if (visible)
+        return TRUE;
+    }
+
+  /* FIXME: Add more rules here, we could check phone numbers in
+   * contact's vCard for example. */
+  return FALSE;
+}
index af484012cef2c91bc18b53843a6aa95638cc99c7..aa46e8e436b89efafd457bf94ec8bd4d0e0ea7f1 100644 (file)
@@ -149,6 +149,10 @@ GtkWidget * empathy_context_menu_new                    (GtkWidget *attach_to);
 
 gint64      empathy_get_current_action_time             (void);
 
+gboolean empathy_individual_match_words (
+    FolksIndividual *individual,
+    GPtrArray *words);
+
 G_END_DECLS
 
 #endif /*  __EMPATHY_UI_UTILS_H__ */
index 8173f781dffcbeddeaea6db249691612f57fc4ce..d62066fb356df2bd6ae39851aab506949f173d69 100644 (file)
@@ -1031,4 +1031,3 @@ empathy_format_currency (gint         amount,
 
        return money;
 }
-