aboutsummaryrefslogtreecommitdiffstats
path: root/src/empathy-call-window.c
diff options
context:
space:
mode:
authorEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>2011-08-02 19:34:55 +0800
committerEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>2011-08-15 20:03:28 +0800
commit0e00979f11c465a755b9dd29b2247a8f3ec1c51d (patch)
treea295c43880f5223511aaa4c1358ffc8c5af57750 /src/empathy-call-window.c
parent25504e2ad3be8e09f12fe9d712be67af11d0c605 (diff)
downloadgsoc2013-empathy-0e00979f11c465a755b9dd29b2247a8f3ec1c51d.tar
gsoc2013-empathy-0e00979f11c465a755b9dd29b2247a8f3ec1c51d.tar.gz
gsoc2013-empathy-0e00979f11c465a755b9dd29b2247a8f3ec1c51d.tar.bz2
gsoc2013-empathy-0e00979f11c465a755b9dd29b2247a8f3ec1c51d.tar.lz
gsoc2013-empathy-0e00979f11c465a755b9dd29b2247a8f3ec1c51d.tar.xz
gsoc2013-empathy-0e00979f11c465a755b9dd29b2247a8f3ec1c51d.tar.zst
gsoc2013-empathy-0e00979f11c465a755b9dd29b2247a8f3ec1c51d.zip
CallWindow: add a 'Swap camera' item to the preview menu
Diffstat (limited to 'src/empathy-call-window.c')
-rw-r--r--src/empathy-call-window.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/empathy-call-window.c b/src/empathy-call-window.c
index bf208d562..eb88d85bc 100644
--- a/src/empathy-call-window.c
+++ b/src/empathy-call-window.c
@@ -148,6 +148,7 @@ struct _EmpathyCallWindowPriv
ClutterActor *floating_toolbar;
GtkWidget *pane;
GtkAction *menu_fullscreen;
+ GtkAction *menu_swap_camera;
ClutterState *transitions;
@@ -499,6 +500,67 @@ empathy_call_window_maximise_camera_cb (GtkAction *action,
}
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);