[empathy] allow user to search for contacts using their full identifier
- From: Guillaume Desmottes <gdesmott src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [empathy] allow user to search for contacts using their full identifier
- Date: Wed, 1 Jun 2011 09:49:35 +0000 (UTC)
commit db6773ebf31853608353b1bb156156879b303569
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date: Wed Jun 1 11:06:28 2011 +0200
allow user to search for contacts using their full identifier
libempathy-gtk/empathy-individual-view.c | 3 ++-
libempathy-gtk/empathy-ui-utils.c | 13 ++++++++++++-
libempathy-gtk/empathy-ui-utils.h | 3 ++-
src/empathy-invite-participant-dialog.c | 15 +++++++++++----
4 files changed, 27 insertions(+), 7 deletions(-)
---
diff --git a/libempathy-gtk/empathy-individual-view.c b/libempathy-gtk/empathy-individual-view.c
index 72e64cf..c467e90 100644
--- a/libempathy-gtk/empathy-individual-view.c
+++ b/libempathy-gtk/empathy-individual-view.c
@@ -1728,7 +1728,8 @@ individual_view_is_visible_individual (EmpathyIndividualView *self,
return (priv->show_offline || is_online);
}
- return empathy_individual_match_words (individual,
+ return empathy_individual_match_string (individual,
+ empathy_live_search_get_text (live),
empathy_live_search_get_words (live));
}
diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c
index ee73c14..cf3228d 100644
--- a/libempathy-gtk/empathy-ui-utils.c
+++ b/libempathy-gtk/empathy-ui-utils.c
@@ -1949,8 +1949,13 @@ empathy_get_current_action_time (void)
return (tp_user_action_time_from_x11 (gtk_get_current_event_time ()));
}
+/* @words = empathy_live_search_strip_utf8_string (@text);
+ *
+ * User has to pass both so we don't have to compute @words ourself each time
+ * this function is called. */
gboolean
-empathy_individual_match_words (FolksIndividual *individual,
+empathy_individual_match_string (FolksIndividual *individual,
+ const char *text,
GPtrArray *words)
{
const gchar *str;
@@ -1975,6 +1980,12 @@ empathy_individual_match_words (FolksIndividual *individual,
continue;
str = folks_persona_get_display_id (l->data);
+
+ /* Accept the persona if @text is a full prefix of his ID; that allows
+ * user to find, say, a jabber contact by typing his JID. */
+ if (g_str_has_prefix (str, text))
+ return TRUE;
+
p = strstr (str, "@");
if (p != NULL)
str = dup_str = g_strndup (str, p - str);
diff --git a/libempathy-gtk/empathy-ui-utils.h b/libempathy-gtk/empathy-ui-utils.h
index aa46e8e..f61e9e3 100644
--- a/libempathy-gtk/empathy-ui-utils.h
+++ b/libempathy-gtk/empathy-ui-utils.h
@@ -149,8 +149,9 @@ GtkWidget * empathy_context_menu_new (GtkWidget *attach_to);
gint64 empathy_get_current_action_time (void);
-gboolean empathy_individual_match_words (
+gboolean empathy_individual_match_string (
FolksIndividual *individual,
+ const gchar *text,
GPtrArray *words);
G_END_DECLS
diff --git a/src/empathy-invite-participant-dialog.c b/src/empathy-invite-participant-dialog.c
index 7dfb338..a28c513 100644
--- a/src/empathy-invite-participant-dialog.c
+++ b/src/empathy-invite-participant-dialog.c
@@ -35,6 +35,7 @@ struct _EmpathyInviteParticipantDialogPrivate
GtkWidget *invite_button;
GPtrArray *search_words;
+ gchar *search_str;
};
static void
@@ -87,6 +88,7 @@ invite_participant_dialog_dispose (GObject *object)
tp_clear_object (&self->priv->tp_chat);
tp_clear_object (&self->priv->store);
tp_clear_pointer (&self->priv->search_words, g_ptr_array_unref);
+ tp_clear_pointer (&self->priv->search_str, g_free);
G_OBJECT_CLASS (empathy_invite_participant_dialog_parent_class)->dispose (
object);
@@ -189,8 +191,8 @@ filter_func (GtkTreeModel *model,
}
else
{
- if (!empathy_individual_match_words (individual,
- self->priv->search_words))
+ if (!empathy_individual_match_string (individual,
+ self->priv->search_str, self->priv->search_words))
goto out;
}
@@ -237,10 +239,15 @@ static void
search_text_changed (GtkEntry *entry,
EmpathyInviteParticipantDialog *self)
{
+ const gchar *id;
+
tp_clear_pointer (&self->priv->search_words, g_ptr_array_unref);
+ tp_clear_pointer (&self->priv->search_str, g_free);
+
+ id = gtk_entry_get_text (entry);
- self->priv->search_words = empathy_live_search_strip_utf8_string (
- gtk_entry_get_text (entry));
+ self->priv->search_words = empathy_live_search_strip_utf8_string (id);
+ self->priv->search_str = g_strdup (id);
empathy_individual_view_refilter (self->priv->view);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]