aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-05-31 21:24:28 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-05-31 21:36:45 +0800
commit5dc3feb4979804c710d4e872a1f05bc425fd9410 (patch)
tree56a8c25b388d10f9400aefa72a379d824806fa6b
parentd4e5a5295ff83f664c80fe3af61db0692829ea1b (diff)
downloadgsoc2013-empathy-5dc3feb4979804c710d4e872a1f05bc425fd9410.tar
gsoc2013-empathy-5dc3feb4979804c710d4e872a1f05bc425fd9410.tar.gz
gsoc2013-empathy-5dc3feb4979804c710d4e872a1f05bc425fd9410.tar.bz2
gsoc2013-empathy-5dc3feb4979804c710d4e872a1f05bc425fd9410.tar.lz
gsoc2013-empathy-5dc3feb4979804c710d4e872a1f05bc425fd9410.tar.xz
gsoc2013-empathy-5dc3feb4979804c710d4e872a1f05bc425fd9410.tar.zst
gsoc2013-empathy-5dc3feb4979804c710d4e872a1f05bc425fd9410.zip
factor out empathy_individual_match_words()
-rw-r--r--libempathy-gtk/empathy-individual-view.c34
-rw-r--r--libempathy-gtk/empathy-ui-utils.c42
-rw-r--r--libempathy-gtk/empathy-ui-utils.h4
-rw-r--r--libempathy/empathy-utils.c1
4 files changed, 48 insertions, 33 deletions
diff --git a/libempathy-gtk/empathy-individual-view.c b/libempathy-gtk/empathy-individual-view.c
index eb41996f5..ec632989e 100644
--- a/libempathy-gtk/empathy-individual-view.c
+++ b/libempathy-gtk/empathy-individual-view.c
@@ -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 *
diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c
index a1bd50f1a..ee73c14c8 100644
--- a/libempathy-gtk/empathy-ui-utils.c
+++ b/libempathy-gtk/empathy-ui-utils.c
@@ -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;
+}
diff --git a/libempathy-gtk/empathy-ui-utils.h b/libempathy-gtk/empathy-ui-utils.h
index af484012c..aa46e8e43 100644
--- a/libempathy-gtk/empathy-ui-utils.h
+++ b/libempathy-gtk/empathy-ui-utils.h
@@ -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__ */
diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c
index 8173f781d..d62066fb3 100644
--- a/libempathy/empathy-utils.c
+++ b/libempathy/empathy-utils.c
@@ -1031,4 +1031,3 @@ empathy_format_currency (gint amount,
return money;
}
-