]> git.0d.be Git - empathy.git/commitdiff
allow user to search for contacts using their full identifier
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Wed, 1 Jun 2011 09:06:28 +0000 (11:06 +0200)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Wed, 1 Jun 2011 09:48:49 +0000 (11:48 +0200)
libempathy-gtk/empathy-individual-view.c
libempathy-gtk/empathy-ui-utils.c
libempathy-gtk/empathy-ui-utils.h
src/empathy-invite-participant-dialog.c

index 72e64cf7d249c17e3f8b219f6f71df855feb8041..c467e9091da15f859591cfb3d5cb6a26c966e357 100644 (file)
@@ -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));
 }
 
index ee73c14c81c717cb64f3a280ded8d6bf74b46925..cf3228da51ddc0c677f923f5ae536844a422b884 100644 (file)
@@ -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);
index aa46e8e436b89efafd457bf94ec8bd4d0e0ea7f1..f61e9e348018a817b664aeafa3b219dc98bdf6f0 100644 (file)
@@ -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
index 7dfb338d03d05988e2dcbafacae52d72c0da86fa..a28c513efc1b063dbed4bfe8ab98557df2c8d903 100644 (file)
@@ -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);
 }