aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>2011-03-07 19:30:38 +0800
committerEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>2011-03-07 19:30:38 +0800
commitc03cf1a26b17190e50f6ef305aa74452cc03a0b5 (patch)
tree0eabb3a64dee402b72339cc20a08d330a2da4132
parent0f5a0cf61fe7de389b5840308bfc782a1347ade5 (diff)
downloadgsoc2013-empathy-c03cf1a26b17190e50f6ef305aa74452cc03a0b5.tar
gsoc2013-empathy-c03cf1a26b17190e50f6ef305aa74452cc03a0b5.tar.gz
gsoc2013-empathy-c03cf1a26b17190e50f6ef305aa74452cc03a0b5.tar.bz2
gsoc2013-empathy-c03cf1a26b17190e50f6ef305aa74452cc03a0b5.tar.lz
gsoc2013-empathy-c03cf1a26b17190e50f6ef305aa74452cc03a0b5.tar.xz
gsoc2013-empathy-c03cf1a26b17190e50f6ef305aa74452cc03a0b5.tar.zst
gsoc2013-empathy-c03cf1a26b17190e50f6ef305aa74452cc03a0b5.zip
Show a profile info button in contact search results
-rw-r--r--libempathy-gtk/empathy-contact-search-dialog.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/libempathy-gtk/empathy-contact-search-dialog.c b/libempathy-gtk/empathy-contact-search-dialog.c
index b88e9306f..6ae9d94f9 100644
--- a/libempathy-gtk/empathy-contact-search-dialog.c
+++ b/libempathy-gtk/empathy-contact-search-dialog.c
@@ -32,6 +32,8 @@
#include <libempathy-gtk/empathy-account-chooser.h>
#include <libempathy-gtk/empathy-cell-renderer-text.h>
+#include <libempathy-gtk/empathy-cell-renderer-activatable.h>
+#include <libempathy-gtk/empathy-images.h>
#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
#include <libempathy/empathy-debug.h>
@@ -446,6 +448,52 @@ contact_search_dialog_row_activated_cb (GtkTreeView *tv,
}
static void
+on_profile_button_got_contact_cb (TpConnection *connection,
+ EmpathyContact *contact,
+ const GError *error,
+ gpointer user_data,
+ GObject *object)
+{
+ if (error != NULL)
+ {
+ g_warning ("Error while getting the contact: %s", error->message);
+ return;
+ }
+
+ empathy_contact_information_dialog_show (contact, NULL);
+}
+
+static void
+on_profile_button_clicked_cb (EmpathyCellRendererActivatable *cell,
+ const gchar *path_string,
+ EmpathyContactSearchDialog *self)
+{
+ EmpathyContactSearchDialogPrivate *priv = GET_PRIVATE (self);
+ GtkTreeSelection *selection;
+ TpConnection *conn;
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ gboolean valid;
+ gchar *id;
+
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->tree_view));
+
+ conn = empathy_account_chooser_get_connection (
+ EMPATHY_ACCOUNT_CHOOSER (priv->chooser));
+
+ valid = gtk_tree_model_get_iter_from_string (model, &iter, path_string);
+ g_return_if_fail (valid == TRUE);
+
+ gtk_tree_model_get (model, &iter, LOGIN_COLUMN, &id, -1);
+
+ DEBUG ("Requested to show profile for contact: %s", id);
+
+ empathy_tp_contact_factory_get_from_id (conn, id,
+ on_profile_button_got_contact_cb, NULL,
+ NULL, NULL);
+}
+
+static void
empathy_contact_search_dialog_init (EmpathyContactSearchDialog *self)
{
EmpathyContactSearchDialogPrivate *priv = GET_PRIVATE (self);
@@ -522,6 +570,7 @@ empathy_contact_search_dialog_init (EmpathyContactSearchDialog *self)
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (priv->tree_view), FALSE);
col = gtk_tree_view_column_new ();
+
cell = empathy_cell_renderer_text_new ();
gtk_tree_view_column_pack_start (col, cell, TRUE);
/* EmpathyCellRendererText displays "name" above and "status" below.
@@ -532,6 +581,12 @@ empathy_contact_search_dialog_init (EmpathyContactSearchDialog *self)
gtk_tree_view_column_add_attribute (col, cell,
"status", NAME_COLUMN);
+ cell = empathy_cell_renderer_activatable_new ();
+ gtk_tree_view_column_pack_end (col, cell, FALSE);
+ g_object_set (cell, "stock-id", EMPATHY_IMAGE_CONTACT_INFORMATION, NULL);
+ g_signal_connect (cell, "path-activated",
+ G_CALLBACK (on_profile_button_clicked_cb), self);
+
gtk_tree_view_append_column (GTK_TREE_VIEW (priv->tree_view), col);
gtk_dialog_add_button (GTK_DIALOG (self),