[Telepathy] [PATCH 3/9] Chooser: implement match-select

Niv Sardi xaiki at debian.org
Mon Jun 8 13:31:38 PDT 2009


to call presence_chooser_entry_activate_cb(), this should be solved by a g_signal_connect_after() but it doesn't seem to work... as we have to extract evything from the model, we might as well tell the default handeler not to run..

Signed-off-by: Niv Sardi <xaiki at debian.org>
---
 libempathy-gtk/empathy-presence-chooser.c |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/libempathy-gtk/empathy-presence-chooser.c b/libempathy-gtk/empathy-presence-chooser.c
index 7a2a52e..cdc665e 100644
--- a/libempathy-gtk/empathy-presence-chooser.c
+++ b/libempathy-gtk/empathy-presence-chooser.c
@@ -138,6 +138,8 @@ static void            presence_chooser_set_state              (McPresence
 								const gchar                *status);
 static void            presence_chooser_custom_activate_cb     (GtkWidget                  *item,
 								gpointer                    user_data);
+static void	       presence_chooser_entry_activate_cb (EmpathyPresenceChooser *self,
+							   GtkEntry               *entry);
 
 G_DEFINE_TYPE (EmpathyPresenceChooser, empathy_presence_chooser, GTK_TYPE_COMBO_BOX_ENTRY);
 
@@ -172,6 +174,30 @@ empathy_chooser_setup_cell_layout (GtkCellLayout *layout)
 					NULL);
 }
 
+static gboolean
+presence_chooser_completion_match_selected_cb (GtkEntryCompletion *widget,
+					       GtkTreeModel       *model,
+					       GtkTreeIter        *iter,
+					       EmpathyPresenceChooser *self)
+{
+	gchar *status;
+	guint state;
+	EmpathyPresenceChooserPriv *priv = GET_PRIV (self);
+	GtkWidget *entry = gtk_bin_get_child (GTK_BIN (self));
+
+	gtk_tree_model_get (model, iter,
+			    COL_STATE, &state,
+			    COL_STATUS_TEXT, &status,
+			    -1);
+
+	gtk_entry_set_text (GTK_ENTRY (entry), status);
+	g_free (status);
+
+	priv->state = state;
+	presence_chooser_entry_activate_cb (self, GTK_ENTRY (entry));
+	return TRUE;
+}
+
 static void
 presence_chooser_create_model (EmpathyPresenceChooser *self)
 {
@@ -259,6 +285,9 @@ presence_chooser_create_model (EmpathyPresenceChooser *self)
 	gtk_entry_completion_set_text_column (completion, COL_STATUS_TEXT);
 	gtk_entry_completion_set_inline_completion(completion, TRUE);
 
+	g_signal_connect (completion, "match-selected",
+		G_CALLBACK (presence_chooser_completion_match_selected_cb), self);
+
 	empathy_chooser_setup_cell_layout (GTK_CELL_LAYOUT (completion));
         gtk_entry_set_completion (GTK_ENTRY (entry), completion);
 
-- 
1.6.3.1



More information about the telepathy mailing list