[empathy] Display a context menu when clicking on audio/video icons (#590051)



commit 6ebf46cb5048e90de75dceead5df6052e776a3a3
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Wed Dec 23 12:09:45 2009 +0000

    Display a context menu when clicking on audio/video icons (#590051)

 libempathy-gtk/empathy-contact-list-view.c |   69 +++++++++++++---------------
 1 files changed, 32 insertions(+), 37 deletions(-)
---
diff --git a/libempathy-gtk/empathy-contact-list-view.c b/libempathy-gtk/empathy-contact-list-view.c
index e11a2e9..fe4be30 100644
--- a/libempathy-gtk/empathy-contact-list-view.c
+++ b/libempathy-gtk/empathy-contact-list-view.c
@@ -752,54 +752,49 @@ contact_list_view_row_activated (GtkTreeView       *view,
 }
 
 static void
-contact_list_start_voip_call (EmpathyCellRendererActivatable *cell,
+contact_list_view_call_activated_cb (
+    EmpathyCellRendererActivatable *cell,
     const gchar                    *path_string,
-    EmpathyContactListView         *view,
-    gboolean with_video)
+    EmpathyContactListView         *view)
 {
-	EmpathyContactListViewPriv *priv = GET_PRIV (view);
-	GtkTreeModel               *model;
-	GtkTreeIter                 iter;
-	EmpathyContact             *contact;
-
-	if (!(priv->contact_features & EMPATHY_CONTACT_FEATURE_CALL)) {
-		return;
-	}
+	GtkWidget *menu;
+	GtkTreeModel *model;
+	GtkTreeIter iter;
+	EmpathyContact *contact;
+	GdkEventButton *event;
+	GtkMenuShell *shell;
+	GtkWidget *item;
 
 	model = gtk_tree_view_get_model (GTK_TREE_VIEW (view));
-	if (!gtk_tree_model_get_iter_from_string (model, &iter, path_string)) {
+	if (!gtk_tree_model_get_iter_from_string (model, &iter, path_string))
 		return;
-	}
 
 	gtk_tree_model_get (model, &iter,
 			    EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, &contact,
 			    -1);
+	if (contact == NULL)
+		return;
 
-	if (contact) {
-		EmpathyCallFactory *factory;
-		factory = empathy_call_factory_get ();
-		empathy_call_factory_new_call_with_streams (factory, contact,
-			TRUE, with_video);
-		g_object_unref (contact);
-	}
-}
+	event = (GdkEventButton *) gtk_get_current_event ();
 
-static void
-contact_list_view_video_call_activated_cb (
-    EmpathyCellRendererActivatable *cell,
-    const gchar                    *path_string,
-    EmpathyContactListView         *view)
-{
-  contact_list_start_voip_call (cell, path_string, view, TRUE);
-}
+	menu = gtk_menu_new ();
+	shell = GTK_MENU_SHELL (menu);
 
+	/* audio */
+	item = empathy_contact_audio_call_menu_item_new (contact);
+	gtk_menu_shell_append (shell, item);
+	gtk_widget_show (item);
 
-static void
-contact_list_view_audio_call_activated_cb (EmpathyCellRendererActivatable *cell,
-				     const gchar                    *path_string,
-				     EmpathyContactListView         *view)
-{
-  contact_list_start_voip_call (cell, path_string, view, FALSE);
+	/* video */
+	item = empathy_contact_video_call_menu_item_new (contact);
+	gtk_menu_shell_append (shell, item);
+	gtk_widget_show (item);
+
+	gtk_widget_show (menu);
+	gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
+			event->button, event->time);
+
+	g_object_unref (contact);
 }
 
 static void
@@ -1155,7 +1150,7 @@ contact_list_view_setup (EmpathyContactListView *view)
 		      NULL);
 
 	g_signal_connect (cell, "path-activated",
-			  G_CALLBACK (contact_list_view_audio_call_activated_cb),
+			  G_CALLBACK (contact_list_view_call_activated_cb),
 			  view);
 
 	/* Video Call Icon */
@@ -1171,7 +1166,7 @@ contact_list_view_setup (EmpathyContactListView *view)
 		      NULL);
 
 	g_signal_connect (cell, "path-activated",
-			  G_CALLBACK (contact_list_view_video_call_activated_cb),
+			  G_CALLBACK (contact_list_view_call_activated_cb),
 			  view);
 
 	/* Avatar */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]