diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2011-06-01 17:06:28 +0800 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2011-06-01 17:48:49 +0800 |
commit | db6773ebf31853608353b1bb156156879b303569 (patch) | |
tree | f5f14546828f7ffdf42a11fc40a34f1e05ac437c | |
parent | cc6c2b5423c3a1906b5f484c157bc67dd9ee9d86 (diff) | |
download | gsoc2013-empathy-db6773ebf31853608353b1bb156156879b303569.tar gsoc2013-empathy-db6773ebf31853608353b1bb156156879b303569.tar.gz gsoc2013-empathy-db6773ebf31853608353b1bb156156879b303569.tar.bz2 gsoc2013-empathy-db6773ebf31853608353b1bb156156879b303569.tar.lz gsoc2013-empathy-db6773ebf31853608353b1bb156156879b303569.tar.xz gsoc2013-empathy-db6773ebf31853608353b1bb156156879b303569.tar.zst gsoc2013-empathy-db6773ebf31853608353b1bb156156879b303569.zip |
allow user to search for contacts using their full identifier
-rw-r--r-- | libempathy-gtk/empathy-individual-view.c | 3 | ||||
-rw-r--r-- | libempathy-gtk/empathy-ui-utils.c | 13 | ||||
-rw-r--r-- | libempathy-gtk/empathy-ui-utils.h | 3 | ||||
-rw-r--r-- | 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 72e64cf7d..c467e9091 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 ee73c14c8..cf3228da5 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 aa46e8e43..f61e9e348 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 7dfb338d0..a28c513ef 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); } |