aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/empathy-chat.c1
-rw-r--r--libempathy-gtk/empathy-individual-view.c42
-rw-r--r--libempathy-gtk/empathy-individual-view.h2
-rw-r--r--libempathy-gtk/empathy-live-search.c23
-rw-r--r--libempathy-gtk/empathy-live-search.h7
-rw-r--r--libempathy-gtk/empathy-ui-utils.c42
-rw-r--r--libempathy-gtk/empathy-ui-utils.h4
7 files changed, 81 insertions, 40 deletions
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c
index 83944a4ea..f026bbc8e 100644
--- a/libempathy-gtk/empathy-chat.c
+++ b/libempathy-gtk/empathy-chat.c
@@ -3398,6 +3398,7 @@ provide_password_cb (GObject *tp_chat,
/* Room joined */
gtk_widget_set_sensitive (priv->hpaned, TRUE);
+ gtk_widget_set_sensitive (self->input_text_view, TRUE);
gtk_widget_grab_focus (self->input_text_view);
}
diff --git a/libempathy-gtk/empathy-individual-view.c b/libempathy-gtk/empathy-individual-view.c
index b5c5022e9..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 *
@@ -2854,3 +2824,11 @@ empathy_individual_view_set_custom_filter (EmpathyIndividualView *self,
priv->custom_filter = filter;
priv->custom_filter_data = data;
}
+
+void
+empathy_individual_view_refilter (EmpathyIndividualView *self)
+{
+ EmpathyIndividualViewPriv *priv = GET_PRIV (self);
+
+ gtk_tree_model_filter_refilter (priv->filter);
+}
diff --git a/libempathy-gtk/empathy-individual-view.h b/libempathy-gtk/empathy-individual-view.h
index ae94ed3d6..5090bc7cc 100644
--- a/libempathy-gtk/empathy-individual-view.h
+++ b/libempathy-gtk/empathy-individual-view.h
@@ -133,5 +133,7 @@ void empathy_individual_view_set_custom_filter (EmpathyIndividualView *self,
GtkTreeModelFilterVisibleFunc filter,
gpointer data);
+void empathy_individual_view_refilter (EmpathyIndividualView *self);
+
G_END_DECLS
#endif /* __EMPATHY_INDIVIDUAL_VIEW_H__ */
diff --git a/libempathy-gtk/empathy-live-search.c b/libempathy-gtk/empathy-live-search.c
index bc7cfb10f..422bfcb73 100644
--- a/libempathy-gtk/empathy-live-search.c
+++ b/libempathy-gtk/empathy-live-search.c
@@ -139,8 +139,8 @@ append_word (GPtrArray **word_array,
}
}
-static GPtrArray *
-strip_utf8_string (const gchar *string)
+GPtrArray *
+empathy_live_search_strip_utf8_string (const gchar *string)
{
GPtrArray *word_array = NULL;
GString *word = NULL;
@@ -230,8 +230,8 @@ live_search_match_prefix (const gchar *string,
return FALSE;
}
-static gboolean
-live_search_match_words (const gchar *string,
+gboolean
+empathy_live_search_match_words (const gchar *string,
GPtrArray *words)
{
guint i;
@@ -309,7 +309,7 @@ live_search_text_changed (GtkEntry *entry,
if (priv->stripped_words != NULL)
g_ptr_array_unref (priv->stripped_words);
- priv->stripped_words = strip_utf8_string (text);
+ priv->stripped_words = empathy_live_search_strip_utf8_string (text);
g_object_notify (G_OBJECT (self), "text");
}
@@ -702,7 +702,7 @@ empathy_live_search_match (EmpathyLiveSearch *self,
priv = GET_PRIV (self);
- return live_search_match_words (string, priv->stripped_words);
+ return empathy_live_search_match_words (string, priv->stripped_words);
}
gboolean
@@ -712,11 +712,18 @@ empathy_live_search_match_string (const gchar *string,
GPtrArray *words;
gboolean match;
- words = strip_utf8_string (prefix);
- match = live_search_match_words (string, words);
+ words = empathy_live_search_strip_utf8_string (prefix);
+ match = empathy_live_search_match_words (string, words);
if (words != NULL)
g_ptr_array_unref (words);
return match;
}
+GPtrArray *
+empathy_live_search_get_words (EmpathyLiveSearch *self)
+{
+ EmpathyLiveSearchPriv *priv = GET_PRIV (self);
+
+ return priv->stripped_words;
+}
diff --git a/libempathy-gtk/empathy-live-search.h b/libempathy-gtk/empathy-live-search.h
index 78dc236c0..9f068396c 100644
--- a/libempathy-gtk/empathy-live-search.h
+++ b/libempathy-gtk/empathy-live-search.h
@@ -65,6 +65,13 @@ void empathy_live_search_set_text (EmpathyLiveSearch *self,
gboolean empathy_live_search_match (EmpathyLiveSearch *self,
const gchar *string);
+GPtrArray * empathy_live_search_strip_utf8_string (const gchar *string);
+
+gboolean empathy_live_search_match_words (const gchar *string,
+ GPtrArray *words);
+
+GPtrArray * empathy_live_search_get_words (EmpathyLiveSearch *self);
+
/* Made public for unit tests */
gboolean empathy_live_search_match_string (const gchar *string,
const gchar *prefix);
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__ */