]> git.0d.be Git - empathy.git/commitdiff
Display a context menu when clicking on audio/video icons (#590051)
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Wed, 23 Dec 2009 12:09:45 +0000 (12:09 +0000)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Wed, 6 Jan 2010 17:54:05 +0000 (17:54 +0000)
libempathy-gtk/empathy-contact-list-view.c

index e11a2e93f34eba4743710f9c62cf36000917635a..fe4be30df1bbdaeb64cc761f307973da04006ef4 100644 (file)
@@ -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 */