]> git.0d.be Git - empathy.git/commitdiff
CallWindow: add a 'Swap camera' item to the preview menu
authorEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>
Tue, 2 Aug 2011 11:34:55 +0000 (12:34 +0100)
committerEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>
Mon, 15 Aug 2011 12:03:28 +0000 (13:03 +0100)
src/empathy-call-window.c
src/empathy-call-window.ui

index bf208d56223bff8b43a4ea7c51f7e99ef2772cb9..eb88d85bc7bfbcbd326e9c97e2c26f4af76a874d 100644 (file)
@@ -148,6 +148,7 @@ struct _EmpathyCallWindowPriv
   ClutterActor *floating_toolbar;
   GtkWidget *pane;
   GtkAction *menu_fullscreen;
+  GtkAction *menu_swap_camera;
 
   ClutterState *transitions;
 
@@ -498,6 +499,67 @@ empathy_call_window_maximise_camera_cb (GtkAction *action,
   clutter_actor_hide (self->priv->preview_hidden_button);
 }
 
+static void
+empathy_call_window_swap_camera_cb (GtkAction *action,
+    EmpathyCallWindow *self)
+{
+  const GList *cameras, *l;
+  gchar *current_cam;
+
+  DEBUG ("Swapping the camera");
+
+  cameras = empathy_camera_monitor_get_cameras (self->priv->camera_monitor);
+  current_cam = empathy_video_src_dup_device (
+      EMPATHY_GST_VIDEO_SRC (self->priv->video_input));
+
+  for (l = cameras; l != NULL; l = l->next)
+    {
+      EmpathyCamera *camera = l->data;
+
+      if (!tp_strdiff (camera->device, current_cam))
+        {
+          EmpathyCamera *next;
+
+          if (l->next != NULL)
+            next = l->next->data;
+          else
+            next = cameras->data;
+
+          /* EmpathyCameraMenu will update itself and do the actual change
+           * for us */
+          g_settings_set_string (self->priv->settings,
+              EMPATHY_PREFS_CALL_CAMERA_DEVICE,
+              next->device);
+
+          break;
+        }
+    }
+
+  g_free (current_cam);
+}
+
+static void
+empathy_call_window_camera_added_cb (EmpathyCameraMonitor *monitor,
+    EmpathyCamera *camera,
+    EmpathyCallWindow *self)
+{
+  const GList *cameras = empathy_camera_monitor_get_cameras (monitor);
+
+  gtk_action_set_visible (self->priv->menu_swap_camera,
+      g_list_length ((GList *) cameras) >= 2);
+}
+
+static void
+empathy_call_window_camera_removed_cb (EmpathyCameraMonitor *monitor,
+    EmpathyCamera *camera,
+    EmpathyCallWindow *self)
+{
+  const GList *cameras = empathy_camera_monitor_get_cameras (monitor);
+
+  gtk_action_set_visible (self->priv->menu_swap_camera,
+      g_list_length ((GList *) cameras) >= 2);
+}
+
 static void
 empathy_call_window_preview_button_clicked_cb (GtkButton *button,
     EmpathyCallWindow *self)
@@ -892,6 +954,7 @@ empathy_call_window_init (EmpathyCallWindow *self)
     "bottom_toolbar", &priv->bottom_toolbar,
     "ui_manager", &priv->ui_manager,
     "menufullscreen", &priv->menu_fullscreen,
+    "menupreviewswap", &priv->menu_swap_camera,
     "details_vbox",  &priv->details_vbox,
     "vcodec_encoding_label", &priv->vcodec_encoding_label,
     "acodec_encoding_label", &priv->acodec_encoding_label,
@@ -924,6 +987,7 @@ empathy_call_window_init (EmpathyCallWindow *self)
     "menupreviewdisable", "activate", empathy_call_window_disable_camera_cb,
     "menupreviewminimise", "activate", empathy_call_window_minimise_camera_cb,
     "menupreviewmaximise", "activate", empathy_call_window_maximise_camera_cb,
+    "menupreviewswap", "activate", empathy_call_window_swap_camera_cb,
     NULL);
 
   gtk_action_set_sensitive (priv->menu_fullscreen, FALSE);
@@ -934,6 +998,11 @@ empathy_call_window_init (EmpathyCallWindow *self)
       priv->camera_button, "sensitive",
       G_BINDING_SYNC_CREATE);
 
+  g_signal_connect (priv->camera_monitor, "added",
+      G_CALLBACK (empathy_call_window_camera_added_cb), self);
+  g_signal_connect (priv->camera_monitor, "removed",
+      G_CALLBACK (empathy_call_window_camera_removed_cb), self);
+
   priv->lock = g_mutex_new ();
 
   gtk_container_add (GTK_CONTAINER (self), top_vbox);
index 3c9ba7750ea9c697cd4e0dac9a07fba30bb92cd0..6e89cb3c3b7a24a68f664a5e1c5222287c290477 100644 (file)
             <property name="name">menuabout</property>
           </object>
         </child>
+        <child>
+          <object class="GtkAction" id="menupreviewswap">
+            <property name="name">menupreviewswap</property>
+            <property name="label" translatable="yes">Swap camera</property>
+          </object>
+        </child>
         <child>
           <object class="GtkAction" id="menupreviewminimise">
             <property name="name">menupreviewminimise</property>
           <menuitem name="menufullscreen" action="menufullscreen"/>
       </popup>
       <popup name="preview-menu">
+          <menuitem name="menupreviewswap" action="menupreviewswap"/>
           <menuitem name="menupreviewminimise" action="menupreviewminimise"/>
           <menuitem name="menupreviewdisable" action="menupreviewdisable"/>
       </popup>
       <popup name="preview-hidden-menu">
+          <menuitem name="menupreviewswap" action="menupreviewswap"/>
           <menuitem name="menupreviewmaximise" action="menupreviewmaximise"/>
           <menuitem name="menupreviewdisable" action="menupreviewdisable"/>
       </popup>