]> git.0d.be Git - empathy.git/blobdiff - src/empathy-call-window.c
CallWindow: correctly detect outgoing calls
[empathy.git] / src / empathy-call-window.c
index b3bc45432f2ed3b0bcaf81c7467b54019dbad663..05f63e2f6813197bd3fa569e4b3fb96cbf21c03d 100644 (file)
 #include <gst/farsight/fs-utils.h>
 
 #include <libempathy/empathy-camera-monitor.h>
+#include <libempathy/empathy-gsettings.h>
 #include <libempathy/empathy-tp-contact-factory.h>
 #include <libempathy/empathy-utils.h>
+
 #include <libempathy-gtk/empathy-avatar-image.h>
 #include <libempathy-gtk/empathy-ui-utils.h>
 #include <libempathy-gtk/empathy-sound-manager.h>
 #include "empathy-call-window-fullscreen.h"
 #include "empathy-call-factory.h"
 #include "empathy-video-widget.h"
+#include "empathy-about-dialog.h"
 #include "empathy-audio-src.h"
 #include "empathy-audio-sink.h"
 #include "empathy-video-src.h"
-#include "ev-sidebar.h"
-
-#define BUTTON_ID "empathy-call-dtmf-button-id"
+#include "empathy-mic-menu.h"
+#include "empathy-preferences.h"
+#include "empathy-rounded-actor.h"
+#include "empathy-rounded-rectangle.h"
+#include "empathy-rounded-texture.h"
+#include "empathy-camera-menu.h"
 
 #define CONTENT_HBOX_BORDER_WIDTH 6
 #define CONTENT_HBOX_SPACING 3
 #define CONTENT_HBOX_CHILDREN_PACKING_PADDING 3
 
 #define SELF_VIDEO_SECTION_WIDTH 120
-#define SELF_VIDEO_SECTION_HEIGTH 90
+#define SELF_VIDEO_SECTION_HEIGHT 90
+#define SELF_VIDEO_SECTION_MARGIN 10
+
+#define FLOATING_TOOLBAR_OPACITY 192
+#define FLOATING_TOOLBAR_WIDTH 280
+#define FLOATING_TOOLBAR_HEIGHT 36
+#define FLOATING_TOOLBAR_SPACING 20
 
 /* The avatar's default width and height are set to the same value because we
    want a square icon. */
@@ -76,6 +88,8 @@
 #define REMOTE_CONTACT_AVATAR_DEFAULT_HEIGHT \
   EMPATHY_VIDEO_WIDGET_DEFAULT_HEIGHT
 
+#define SMALL_TOOLBAR_SIZE 36
+
 /* If an video input error occurs, the error message will start with "v4l" */
 #define VIDEO_INPUT_ERROR_PREFIX "v4l"
 
@@ -101,6 +115,14 @@ typedef enum {
   CAMERA_STATE_ON,
 } CameraState;
 
+typedef enum {
+  PREVIEW_POS_NONE,
+  PREVIEW_POS_TOP_LEFT,
+  PREVIEW_POS_TOP_RIGHT,
+  PREVIEW_POS_BOTTOM_LEFT,
+  PREVIEW_POS_BOTTOM_RIGHT,
+} PreviewPosition;
+
 struct _EmpathyCallWindowPriv
 {
   gboolean dispose_has_run;
@@ -119,43 +141,53 @@ struct _EmpathyCallWindowPriv
    * alive only during call. */
   ClutterActor *video_output;
   ClutterActor *video_preview;
+  ClutterActor *drag_preview;
+  ClutterActor *preview_shown_button;
   ClutterActor *preview_hidden_button;
+  ClutterActor *preview_rectangle1;
+  ClutterActor *preview_rectangle2;
+  ClutterActor *preview_rectangle3;
+  ClutterActor *preview_rectangle4;
+  ClutterActor *preview_rectangle_box1;
+  ClutterActor *preview_rectangle_box2;
+  ClutterActor *preview_rectangle_box3;
+  ClutterActor *preview_rectangle_box4;
   GtkWidget *video_container;
   GtkWidget *remote_user_avatar_widget;
-  GtkWidget *sidebar;
-  GtkWidget *statusbar;
-  GtkWidget *volume_button;
-  GtkWidget *redial_button;
+  GtkWidget *remote_user_avatar_toolbar;
+  GtkWidget *remote_user_name_toolbar;
+  GtkWidget *status_label;
+  GtkWidget *hangup_button;
+  GtkWidget *audio_call_button;
+  GtkWidget *video_call_button;
   GtkWidget *mic_button;
   GtkWidget *camera_button;
   GtkWidget *dialpad_button;
   GtkWidget *toolbar;
+  GtkWidget *bottom_toolbar;
+  ClutterActor *floating_toolbar;
   GtkWidget *pane;
-  GtkAction *redial;
-  GtkAction *menu_sidebar;
   GtkAction *menu_fullscreen;
+  GtkAction *menu_swap_camera;
+
+  ClutterState *transitions;
 
   /* The box that contains self and remote avatar and video
      input/output. When we redial, we destroy and re-create the box */
   ClutterActor *video_box;
   ClutterLayoutManager *video_layout;
 
+  /* Coordinates of the preview drag event's start. */
+  PreviewPosition preview_pos;
+
   /* We keep a reference on the hbox which contains the main content so we can
      easilly repack everything when toggling fullscreen */
   GtkWidget *content_hbox;
 
-  /* This vbox is contained in the content_hbox and it contains the
-     sidebar button. When toggling fullscreen,
-     it needs to be repacked. We keep a reference on it for easier access. */
-  GtkWidget *vbox;
-
   gulong video_output_motion_handler_id;
   guint bus_message_source_id;
 
   gdouble volume;
-  GtkWidget *volume_scale;
-  GtkWidget *volume_progress_bar;
-  GtkAdjustment *audio_input_adj;
 
   GtkWidget *dtmf_panel;
 
@@ -187,15 +219,9 @@ struct _EmpathyCallWindowPriv
 
   GList *notifiers;
 
-  guint context_id;
-
   GTimer *timer;
   guint timer_id;
 
-  GtkWidget *video_contrast;
-  GtkWidget *video_brightness;
-  GtkWidget *video_gamma;
-
   GMutex *lock;
   gboolean call_started;
   gboolean sending_video;
@@ -204,13 +230,18 @@ struct _EmpathyCallWindowPriv
   EmpathyCallWindowFullscreen *fullscreen;
   gboolean is_fullscreen;
 
+  gboolean got_video;
+  guint got_video_src;
+
+  guint inactivity_src;
+
   /* Those fields represent the state of the window before it actually was in
      fullscreen mode. */
-  gboolean sidebar_was_visible_before_fs;
+  gboolean dialpad_was_visible_before_fs;
   gint original_width_before_fs;
   gint original_height_before_fs;
 
-  gint x, y, w, h, sidebar_width;
+  gint x, y, w, h, dialpad_width;
   gboolean maximized;
 
   /* TRUE if the call should be started when the pipeline is playing */
@@ -219,6 +250,10 @@ struct _EmpathyCallWindowPriv
   gboolean pipeline_playing;
 
   EmpathySoundManager *sound_mgr;
+
+  GSettings *settings;
+  EmpathyMicMenu *mic_menu;
+  EmpathyCameraMenu *camera_menu;
 };
 
 #define GET_PRIV(o) (EMPATHY_CALL_WINDOW (o)->priv)
@@ -238,19 +273,6 @@ static void empathy_call_window_set_send_video (EmpathyCallWindow *window,
 static void empathy_call_window_mic_toggled_cb (
   GtkToggleToolButton *toggle, EmpathyCallWindow *window);
 
-static void empathy_call_window_sidebar_cb (GtkToggleAction *menu,
-  EmpathyCallWindow *self);
-
-static void empathy_call_window_sidebar_hidden_cb (EvSidebar *sidebar,
-  EmpathyCallWindow *window);
-
-static void empathy_call_window_sidebar_shown_cb (EvSidebar *sidebar,
-  EmpathyCallWindow *window);
-
-static void empathy_call_window_sidebar_changed_cb (EvSidebar *sidebar,
-  const gchar *page,
-  EmpathyCallWindow *window);
-
 static void empathy_call_window_hangup_cb (gpointer object,
   EmpathyCallWindow *window);
 
@@ -271,9 +293,6 @@ static gboolean empathy_call_window_video_output_motion_notify (
 static void empathy_call_window_video_menu_popup (EmpathyCallWindow *window,
   guint button);
 
-static void empathy_call_window_redial_cb (gpointer object,
-  EmpathyCallWindow *window);
-
 static void empathy_call_window_dialpad_cb (GtkToggleToolButton *button,
   EmpathyCallWindow *window);
 
@@ -290,30 +309,29 @@ empathy_call_window_volume_changed_cb (GtkScaleButton *button,
   gdouble value, EmpathyCallWindow *window);
 
 static void
-empathy_call_window_setup_toolbar (EmpathyCallWindow *self)
+empathy_call_window_show_hangup_button (EmpathyCallWindow *self,
+    gboolean show)
 {
-  EmpathyCallWindowPriv *priv = GET_PRIV (self);
-  GtkToolItem *tool_item;
-
-  /* Add an empty expanded GtkToolItem so the volume button is at the end of
-   * the toolbar. */
-  tool_item = gtk_tool_item_new ();
-  gtk_tool_item_set_expand (tool_item, TRUE);
-  gtk_widget_show (GTK_WIDGET (tool_item));
-  gtk_toolbar_insert (GTK_TOOLBAR (priv->toolbar), tool_item, -1);
+  gtk_widget_set_visible (self->priv->hangup_button, show);
+  gtk_widget_set_visible (self->priv->audio_call_button, !show);
+  gtk_widget_set_visible (self->priv->video_call_button, !show);
+}
 
-  priv->volume_button = gtk_volume_button_new ();
-  /* FIXME listen to the audiosinks signals and update the button according to
-   * that, for now starting out at 1.0 and assuming only the app changes the
-   * volume will do */
-  gtk_scale_button_set_value (GTK_SCALE_BUTTON (priv->volume_button), 1.0);
-  g_signal_connect (G_OBJECT (priv->volume_button), "value-changed",
-    G_CALLBACK (empathy_call_window_volume_changed_cb), self);
+static void
+empathy_call_window_audio_call_cb (GtkToggleToolButton *button,
+    EmpathyCallWindow *self)
+{
+  g_object_set (self->priv->handler, "initial-video", FALSE, NULL);
+  empathy_call_window_restart_call (self);
+}
 
-  tool_item = gtk_tool_item_new ();
-  gtk_container_add (GTK_CONTAINER (tool_item), priv->volume_button);
-  gtk_widget_show_all (GTK_WIDGET (tool_item));
-  gtk_toolbar_insert (GTK_TOOLBAR (priv->toolbar), tool_item, -1);
+static void
+empathy_call_window_video_call_cb (GtkToggleToolButton *button,
+    EmpathyCallWindow *self)
+{
+  empathy_call_window_set_send_video (self, CAMERA_STATE_ON);
+  g_object_set (self->priv->handler, "initial-video", TRUE, NULL);
+  empathy_call_window_restart_call (self);
 }
 
 static void
@@ -326,7 +344,7 @@ dtmf_button_pressed_cb (GtkButton *button, EmpathyCallWindow *window)
 
   g_object_get (priv->handler, "call-channel", &call, NULL);
 
-  button_quark = g_quark_from_static_string (BUTTON_ID);
+  button_quark = g_quark_from_static_string (EMPATHY_DTMF_BUTTON_ID);
   event = GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (button),
     button_quark));
 
@@ -348,182 +366,14 @@ dtmf_button_released_cb (GtkButton *button, EmpathyCallWindow *window)
   g_object_unref (call);
 }
 
-static GtkWidget *
-empathy_call_window_create_dtmf (EmpathyCallWindow *self)
-{
-  GtkWidget *table;
-  int i;
-  GQuark button_quark;
-  struct {
-    const gchar *label;
-    TpDTMFEvent event;
-  } dtmfbuttons[] = { { "1", TP_DTMF_EVENT_DIGIT_1 },
-                      { "2", TP_DTMF_EVENT_DIGIT_2 },
-                      { "3", TP_DTMF_EVENT_DIGIT_3 },
-                      { "4", TP_DTMF_EVENT_DIGIT_4 },
-                      { "5", TP_DTMF_EVENT_DIGIT_5 },
-                      { "6", TP_DTMF_EVENT_DIGIT_6 },
-                      { "7", TP_DTMF_EVENT_DIGIT_7 },
-                      { "8", TP_DTMF_EVENT_DIGIT_8 },
-                      { "9", TP_DTMF_EVENT_DIGIT_9 },
-                      { "#", TP_DTMF_EVENT_HASH },
-                      { "0", TP_DTMF_EVENT_DIGIT_0 },
-                      { "*", TP_DTMF_EVENT_ASTERISK },
-                      { NULL, } };
-
-  button_quark = g_quark_from_static_string (BUTTON_ID);
-
-  table = gtk_table_new (4, 3, TRUE);
-
-  for (i = 0; dtmfbuttons[i].label != NULL; i++)
-    {
-      GtkWidget *button = gtk_button_new_with_label (dtmfbuttons[i].label);
-      gtk_table_attach (GTK_TABLE (table), button, i % 3, i % 3 + 1,
-        i/3, i/3 + 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 1, 1);
-
-      g_object_set_qdata (G_OBJECT (button), button_quark,
-        GUINT_TO_POINTER (dtmfbuttons[i].event));
-
-      g_signal_connect (G_OBJECT (button), "pressed",
-        G_CALLBACK (dtmf_button_pressed_cb), self);
-      g_signal_connect (G_OBJECT (button), "released",
-        G_CALLBACK (dtmf_button_released_cb), self);
-    }
-
-  return table;
-}
-
-static GtkWidget *
-empathy_call_window_create_video_input_add_slider (EmpathyCallWindow *self,
-  gchar *label_text, GtkWidget *bin)
-{
-   GtkWidget *vbox = gtk_vbox_new (FALSE, 2);
-   GtkWidget *scale = gtk_vscale_new_with_range (0, 100, 10);
-   GtkWidget *label = gtk_label_new (label_text);
-
-   gtk_widget_set_sensitive (scale, FALSE);
-
-   gtk_container_add (GTK_CONTAINER (bin), vbox);
-
-   gtk_range_set_inverted (GTK_RANGE (scale), TRUE);
-   gtk_box_pack_start (GTK_BOX (vbox), scale, TRUE, TRUE, 0);
-   gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
-
-   return scale;
-}
-
-static void
-empathy_call_window_video_contrast_changed_cb (GtkAdjustment *adj,
-  EmpathyCallWindow *self)
-
-{
-  EmpathyCallWindowPriv *priv = GET_PRIV (self);
-
-  empathy_video_src_set_channel (priv->video_input,
-    EMPATHY_GST_VIDEO_SRC_CHANNEL_CONTRAST, gtk_adjustment_get_value (adj));
-}
-
-static void
-empathy_call_window_video_brightness_changed_cb (GtkAdjustment *adj,
-  EmpathyCallWindow *self)
-
-{
-  EmpathyCallWindowPriv *priv = GET_PRIV (self);
-
-  empathy_video_src_set_channel (priv->video_input,
-    EMPATHY_GST_VIDEO_SRC_CHANNEL_BRIGHTNESS, gtk_adjustment_get_value (adj));
-}
-
-static void
-empathy_call_window_video_gamma_changed_cb (GtkAdjustment *adj,
-  EmpathyCallWindow *self)
-
-{
-  EmpathyCallWindowPriv *priv = GET_PRIV (self);
-
-  empathy_video_src_set_channel (priv->video_input,
-    EMPATHY_GST_VIDEO_SRC_CHANNEL_GAMMA, gtk_adjustment_get_value (adj));
-}
-
-
-static GtkWidget *
-empathy_call_window_create_video_input (EmpathyCallWindow *self)
-{
-  EmpathyCallWindowPriv *priv = GET_PRIV (self);
-  GtkWidget *hbox;
-
-  hbox = gtk_hbox_new (TRUE, 3);
-
-  priv->video_contrast = empathy_call_window_create_video_input_add_slider (
-    self,  _("Contrast"), hbox);
-
-  priv->video_brightness = empathy_call_window_create_video_input_add_slider (
-    self,  _("Brightness"), hbox);
-
-  priv->video_gamma = empathy_call_window_create_video_input_add_slider (
-    self,  _("Gamma"), hbox);
-
-  return hbox;
-}
-
-static void
-empathy_call_window_setup_video_input (EmpathyCallWindow *self)
-{
-  EmpathyCallWindowPriv *priv = GET_PRIV (self);
-  guint supported;
-  GtkAdjustment *adj;
-
-  supported = empathy_video_src_get_supported_channels (priv->video_input);
-
-  if (supported & EMPATHY_GST_VIDEO_SRC_SUPPORTS_CONTRAST)
-    {
-      adj = gtk_range_get_adjustment (GTK_RANGE (priv->video_contrast));
-
-      gtk_adjustment_set_value (adj,
-        empathy_video_src_get_channel (priv->video_input,
-          EMPATHY_GST_VIDEO_SRC_CHANNEL_CONTRAST));
-
-      g_signal_connect (G_OBJECT (adj), "value-changed",
-        G_CALLBACK (empathy_call_window_video_contrast_changed_cb), self);
-
-      gtk_widget_set_sensitive (priv->video_contrast, TRUE);
-    }
-
-  if (supported & EMPATHY_GST_VIDEO_SRC_SUPPORTS_BRIGHTNESS)
-    {
-      adj = gtk_range_get_adjustment (GTK_RANGE (priv->video_brightness));
-
-      gtk_adjustment_set_value (adj,
-        empathy_video_src_get_channel (priv->video_input,
-          EMPATHY_GST_VIDEO_SRC_CHANNEL_BRIGHTNESS));
-
-      g_signal_connect (G_OBJECT (adj), "value-changed",
-        G_CALLBACK (empathy_call_window_video_brightness_changed_cb), self);
-      gtk_widget_set_sensitive (priv->video_brightness, TRUE);
-    }
-
-  if (supported & EMPATHY_GST_VIDEO_SRC_SUPPORTS_GAMMA)
-    {
-      adj = gtk_range_get_adjustment (GTK_RANGE (priv->video_gamma));
-
-      gtk_adjustment_set_value (adj,
-        empathy_video_src_get_channel (priv->video_input,
-          EMPATHY_GST_VIDEO_SRC_CHANNEL_GAMMA));
-
-      g_signal_connect (G_OBJECT (adj), "value-changed",
-        G_CALLBACK (empathy_call_window_video_gamma_changed_cb), self);
-      gtk_widget_set_sensitive (priv->video_gamma, TRUE);
-    }
-}
-
 static void
-empathy_call_window_mic_volume_changed_cb (GtkAdjustment *adj,
-  EmpathyCallWindow *self)
+empathy_call_window_mic_volume_changed (EmpathyCallWindow *self)
 {
   EmpathyCallWindowPriv *priv = GET_PRIV (self);
   gdouble volume;
 
-  volume = gtk_adjustment_get_value (adj)/100.0;
+  volume = g_settings_get_double (priv->settings,
+      EMPATHY_PREFS_CALL_SOUND_VOLUME) / 100.0;
 
   /* Don't store the volume because of muting */
   if (volume > 0 || gtk_toggle_tool_button_get_active (
@@ -542,56 +392,34 @@ empathy_call_window_mic_volume_changed_cb (GtkAdjustment *adj,
 }
 
 static void
-empathy_call_window_audio_input_level_changed_cb (EmpathyGstAudioSrc *src,
-  gdouble level, EmpathyCallWindow *window)
+empathy_call_window_prefs_volume_changed_cb (GSettings *settings,
+    gchar *key,
+    EmpathyCallWindow *self)
 {
-  gdouble value;
-  EmpathyCallWindowPriv *priv = GET_PRIV (window);
-
-  value = CLAMP (pow (10, level / 20), 0.0, 1.0);
-  gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (priv->volume_progress_bar),
-      value);
+  empathy_call_window_mic_volume_changed (self);
 }
 
-static GtkWidget *
-empathy_call_window_create_audio_input (EmpathyCallWindow *self)
+static void
+empathy_call_window_raise_actors (EmpathyCallWindow *self)
 {
-  EmpathyCallWindowPriv *priv = GET_PRIV (self);
-  GtkWidget *hbox, *vbox, *label;
-
-  hbox = gtk_hbox_new (TRUE, 3);
-
-  vbox = gtk_vbox_new (FALSE, 3);
-  gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 3);
-
-  priv->volume_scale = gtk_vscale_new_with_range (0, 150, 100);
-  gtk_range_set_inverted (GTK_RANGE (priv->volume_scale), TRUE);
-  label = gtk_label_new (_("Volume"));
-
-  priv->audio_input_adj = gtk_range_get_adjustment (
-    GTK_RANGE (priv->volume_scale));
-  priv->volume =  empathy_audio_src_get_volume (EMPATHY_GST_AUDIO_SRC
-    (priv->audio_input));
-  gtk_adjustment_set_value (priv->audio_input_adj, priv->volume * 100);
-
-  g_signal_connect (G_OBJECT (priv->audio_input_adj), "value-changed",
-    G_CALLBACK (empathy_call_window_mic_volume_changed_cb), self);
+  clutter_actor_raise_top (self->priv->floating_toolbar);
 
-  gtk_box_pack_start (GTK_BOX (vbox), priv->volume_scale, TRUE, TRUE, 3);
-  gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 3);
-
-  priv->volume_progress_bar = gtk_progress_bar_new ();
-
-  gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->volume_progress_bar),
-      GTK_ORIENTATION_VERTICAL);
+  clutter_actor_raise_top (self->priv->preview_rectangle_box1);
+  clutter_actor_raise_top (self->priv->preview_rectangle_box2);
+  clutter_actor_raise_top (self->priv->preview_rectangle_box3);
+  clutter_actor_raise_top (self->priv->preview_rectangle_box4);
+}
 
-  gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (priv->volume_progress_bar),
-      0);
+static void
+empathy_call_window_show_video_output (EmpathyCallWindow *self,
+    gboolean show)
+{
+  if (self->priv->video_output != NULL)
+    g_object_set (self->priv->video_output, "visible", show, NULL);
 
-  gtk_box_pack_start (GTK_BOX (hbox), priv->volume_progress_bar, FALSE, FALSE,
-      3);
+  gtk_widget_set_visible (self->priv->remote_user_avatar_widget, !show);
 
-  return hbox;
+  empathy_call_window_raise_actors (self);
 }
 
 static void
@@ -639,10 +467,6 @@ create_audio_input (EmpathyCallWindow *self)
   priv->audio_input = empathy_audio_src_new ();
   gst_object_ref (priv->audio_input);
   gst_object_sink (priv->audio_input);
-
-  tp_g_signal_connect_object (priv->audio_input, "peak-level-changed",
-    G_CALLBACK (empathy_call_window_audio_input_level_changed_cb),
-    self, 0);
 }
 
 static void
@@ -709,6 +533,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)
@@ -728,51 +613,415 @@ empathy_call_window_preview_hidden_button_clicked_cb (GtkButton *button,
 {
   GtkWidget *menu;
 
-  menu = gtk_ui_manager_get_widget (self->priv->ui_manager,
-      "/preview-hidden-menu");
-  gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
-      0, gtk_get_current_event_time ());
-  gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
+  menu = gtk_ui_manager_get_widget (self->priv->ui_manager,
+      "/preview-hidden-menu");
+  gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
+      0, gtk_get_current_event_time ());
+  gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
+}
+
+static ClutterActor *
+empathy_call_window_create_preview_rectangle (EmpathyCallWindow *self,
+    ClutterActor **box,
+    ClutterBinAlignment x,
+    ClutterBinAlignment y)
+{
+  ClutterLayoutManager *layout1, *layout2;
+  ClutterActor *rectangle;
+  ClutterActor *box1, *box2;
+
+  layout1 = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
+      CLUTTER_BIN_ALIGNMENT_START);
+
+  box1 = clutter_box_new (layout1);
+
+  *box = box1;
+
+  rectangle = empathy_rounded_rectangle_new (
+      SELF_VIDEO_SECTION_WIDTH + 5,
+      SELF_VIDEO_SECTION_HEIGHT + 5);
+
+  clutter_actor_set_size (box1,
+      SELF_VIDEO_SECTION_WIDTH + 2 * SELF_VIDEO_SECTION_MARGIN,
+      SELF_VIDEO_SECTION_HEIGHT + 2 * SELF_VIDEO_SECTION_MARGIN +
+      FLOATING_TOOLBAR_HEIGHT + FLOATING_TOOLBAR_SPACING);
+
+  layout2 = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
+      CLUTTER_BIN_ALIGNMENT_CENTER);
+
+  /* We have a box with the margins and the video in the middle inside
+   * a bigger box with an extra bottom margin so we're not on top of
+   * the floating toolbar. */
+  box2 = clutter_box_new (layout2);
+
+  clutter_actor_set_size (box2,
+      SELF_VIDEO_SECTION_WIDTH + 2 * SELF_VIDEO_SECTION_MARGIN,
+      SELF_VIDEO_SECTION_HEIGHT + 2 * SELF_VIDEO_SECTION_MARGIN);
+
+  clutter_container_add_actor (CLUTTER_CONTAINER (box1), box2);
+  clutter_container_add_actor (CLUTTER_CONTAINER (box2), rectangle);
+
+  clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (self->priv->video_layout),
+      box1, x, y);
+
+  clutter_actor_hide (rectangle);
+
+  return rectangle;
+}
+
+static void
+empathy_call_window_create_preview_rectangles (EmpathyCallWindow *self)
+{
+  self->priv->preview_rectangle1 =
+      empathy_call_window_create_preview_rectangle (self,
+          &self->priv->preview_rectangle_box1,
+          CLUTTER_BIN_ALIGNMENT_START, CLUTTER_BIN_ALIGNMENT_START);
+  self->priv->preview_rectangle2 =
+      empathy_call_window_create_preview_rectangle (self,
+          &self->priv->preview_rectangle_box2,
+          CLUTTER_BIN_ALIGNMENT_START, CLUTTER_BIN_ALIGNMENT_END);
+  self->priv->preview_rectangle3 =
+      empathy_call_window_create_preview_rectangle (self,
+          &self->priv->preview_rectangle_box3,
+          CLUTTER_BIN_ALIGNMENT_END, CLUTTER_BIN_ALIGNMENT_START);
+  self->priv->preview_rectangle4 =
+      empathy_call_window_create_preview_rectangle (self,
+          &self->priv->preview_rectangle_box4,
+          CLUTTER_BIN_ALIGNMENT_END, CLUTTER_BIN_ALIGNMENT_END);
+}
+
+static void
+empathy_call_window_show_preview_rectangles (EmpathyCallWindow *self,
+    gboolean show)
+{
+  g_object_set (self->priv->preview_rectangle1, "visible", show, NULL);
+  g_object_set (self->priv->preview_rectangle2, "visible", show, NULL);
+  g_object_set (self->priv->preview_rectangle3, "visible", show, NULL);
+  g_object_set (self->priv->preview_rectangle4, "visible", show, NULL);
+}
+
+static PreviewPosition
+empathy_call_window_get_preview_position (EmpathyCallWindow *self,
+    gfloat event_x,
+    gfloat event_y)
+{
+  ClutterGeometry box;
+  PreviewPosition pos = PREVIEW_POS_NONE;
+
+  if (!clutter_actor_has_allocation (self->priv->video_box))
+    return pos;
+
+  clutter_actor_get_geometry (self->priv->video_box, &box);
+
+  if (0 + SELF_VIDEO_SECTION_MARGIN <= event_x &&
+      event_x <= (0 + SELF_VIDEO_SECTION_MARGIN + (gint) SELF_VIDEO_SECTION_WIDTH) &&
+      0 + SELF_VIDEO_SECTION_MARGIN <= event_y &&
+      event_y <= (0 + SELF_VIDEO_SECTION_MARGIN + (gint) SELF_VIDEO_SECTION_HEIGHT))
+    {
+      pos = PREVIEW_POS_TOP_LEFT;
+    }
+  else if (box.width - SELF_VIDEO_SECTION_MARGIN >= event_x &&
+      event_x >= (box.width - SELF_VIDEO_SECTION_MARGIN - (gint) SELF_VIDEO_SECTION_WIDTH) &&
+      0 + SELF_VIDEO_SECTION_MARGIN <= event_y &&
+      event_y <= (0 + SELF_VIDEO_SECTION_MARGIN + (gint) SELF_VIDEO_SECTION_HEIGHT))
+    {
+      pos = PREVIEW_POS_TOP_RIGHT;
+    }
+  else if (0 + SELF_VIDEO_SECTION_MARGIN <= event_x &&
+      event_x <= (0 + SELF_VIDEO_SECTION_MARGIN + (gint) SELF_VIDEO_SECTION_WIDTH) &&
+      box.height - SELF_VIDEO_SECTION_MARGIN - FLOATING_TOOLBAR_HEIGHT - FLOATING_TOOLBAR_SPACING >= event_y &&
+      event_y >= (box.height - SELF_VIDEO_SECTION_MARGIN - FLOATING_TOOLBAR_HEIGHT - FLOATING_TOOLBAR_SPACING - (gint) SELF_VIDEO_SECTION_HEIGHT))
+    {
+      pos = PREVIEW_POS_BOTTOM_LEFT;
+    }
+  else if (box.width - SELF_VIDEO_SECTION_MARGIN >= event_x &&
+      event_x >= (box.width - SELF_VIDEO_SECTION_MARGIN - (gint) SELF_VIDEO_SECTION_WIDTH) &&
+      box.height - SELF_VIDEO_SECTION_MARGIN - SELF_VIDEO_SECTION_MARGIN - FLOATING_TOOLBAR_HEIGHT - FLOATING_TOOLBAR_SPACING >= event_y &&
+      event_y >= (box.height - SELF_VIDEO_SECTION_MARGIN - FLOATING_TOOLBAR_HEIGHT - FLOATING_TOOLBAR_SPACING - (gint) SELF_VIDEO_SECTION_HEIGHT))
+    {
+      pos = PREVIEW_POS_BOTTOM_RIGHT;
+    }
+
+  return pos;
+}
+
+static ClutterActor *
+empathy_call_window_get_preview_rectangle (EmpathyCallWindow *self,
+    PreviewPosition pos)
+{
+  ClutterActor *rectangle;
+
+  switch (pos)
+    {
+      case PREVIEW_POS_TOP_LEFT:
+        rectangle = self->priv->preview_rectangle1;
+        break;
+      case PREVIEW_POS_TOP_RIGHT:
+        rectangle = self->priv->preview_rectangle3;
+        break;
+      case PREVIEW_POS_BOTTOM_LEFT:
+        rectangle = self->priv->preview_rectangle2;
+        break;
+      case PREVIEW_POS_BOTTOM_RIGHT:
+        rectangle = self->priv->preview_rectangle4;
+        break;
+      default:
+        rectangle = NULL;
+    }
+
+  return rectangle;
+}
+
+static void
+empathy_call_window_move_video_preview (EmpathyCallWindow *self,
+    PreviewPosition pos)
+{
+  ClutterBinLayout *layout = CLUTTER_BIN_LAYOUT (self->priv->video_layout);
+
+  DEBUG ("moving the video preview to %d", pos);
+
+  self->priv->preview_pos = pos;
+
+  switch (pos)
+    {
+      case PREVIEW_POS_TOP_LEFT:
+        clutter_bin_layout_set_alignment (layout,
+            self->priv->video_preview,
+            CLUTTER_BIN_ALIGNMENT_START,
+            CLUTTER_BIN_ALIGNMENT_START);
+        break;
+      case PREVIEW_POS_TOP_RIGHT:
+        clutter_bin_layout_set_alignment (layout,
+            self->priv->video_preview,
+            CLUTTER_BIN_ALIGNMENT_END,
+            CLUTTER_BIN_ALIGNMENT_START);
+        break;
+      case PREVIEW_POS_BOTTOM_LEFT:
+        clutter_bin_layout_set_alignment (layout,
+            self->priv->video_preview,
+            CLUTTER_BIN_ALIGNMENT_START,
+            CLUTTER_BIN_ALIGNMENT_END);
+        break;
+      case PREVIEW_POS_BOTTOM_RIGHT:
+        clutter_bin_layout_set_alignment (layout,
+            self->priv->video_preview,
+            CLUTTER_BIN_ALIGNMENT_END,
+            CLUTTER_BIN_ALIGNMENT_END);
+        break;
+      default:
+        g_warn_if_reached ();
+    }
+
+  g_settings_set_enum (self->priv->settings, "camera-position", pos);
+}
+
+static void
+empathy_call_window_highlight_preview_rectangle (EmpathyCallWindow *self,
+    PreviewPosition pos)
+{
+  ClutterActor *rectangle;
+
+  rectangle = empathy_call_window_get_preview_rectangle (self, pos);
+
+  empathy_rounded_rectangle_set_border_width (
+      EMPATHY_ROUNDED_RECTANGLE (rectangle), 5);
+  empathy_rounded_rectangle_set_border_color (
+      EMPATHY_ROUNDED_RECTANGLE (rectangle), CLUTTER_COLOR_Red);
+}
+
+static void
+empathy_call_window_darken_preview_rectangle (EmpathyCallWindow *self,
+    ClutterActor *rectangle)
+{
+  empathy_rounded_rectangle_set_border_width (
+      EMPATHY_ROUNDED_RECTANGLE (rectangle), 1);
+  empathy_rounded_rectangle_set_border_color (
+      EMPATHY_ROUNDED_RECTANGLE (rectangle), CLUTTER_COLOR_Black);
+}
+
+static void
+empathy_call_window_darken_preview_rectangles (EmpathyCallWindow *self)
+{
+  ClutterActor *rectangle;
+
+  rectangle = empathy_call_window_get_preview_rectangle (self,
+      self->priv->preview_pos);
+
+  /* We don't want to darken the rectangle where the preview
+   * currently is. */
+
+  if (self->priv->preview_rectangle1 != rectangle)
+    empathy_call_window_darken_preview_rectangle (self,
+        self->priv->preview_rectangle1);
+
+  if (self->priv->preview_rectangle2 != rectangle)
+    empathy_call_window_darken_preview_rectangle (self,
+        self->priv->preview_rectangle2);
+
+  if (self->priv->preview_rectangle3 != rectangle)
+    empathy_call_window_darken_preview_rectangle (self,
+        self->priv->preview_rectangle3);
+
+  if (self->priv->preview_rectangle4 != rectangle)
+    empathy_call_window_darken_preview_rectangle (self,
+        self->priv->preview_rectangle4);
+}
+
+static void
+empathy_call_window_preview_on_drag_begin_cb (ClutterDragAction *action,
+    ClutterActor *actor,
+    gfloat event_x,
+    gfloat event_y,
+    ClutterModifierType modifiers,
+    EmpathyCallWindow *self)
+{
+  ClutterActor *stage = clutter_actor_get_stage (actor);
+  gfloat rel_x, rel_y;
+
+  self->priv->drag_preview = clutter_clone_new (actor);
+
+  clutter_container_add_actor (CLUTTER_CONTAINER (stage),
+      self->priv->drag_preview);
+
+  clutter_actor_transform_stage_point (actor, event_x, event_y,
+      &rel_x, &rel_y);
+
+  clutter_actor_set_position (self->priv->drag_preview,
+      event_x - rel_x, event_y - rel_y);
+
+  clutter_drag_action_set_drag_handle (action,
+      self->priv->drag_preview);
+
+  clutter_actor_set_opacity (actor, 0);
+  clutter_actor_hide (self->priv->preview_shown_button);
+
+  empathy_call_window_show_preview_rectangles (self, TRUE);
+  empathy_call_window_darken_preview_rectangles (self);
+}
+
+static void
+empathy_call_window_preview_on_drag_end_cb (ClutterDragAction *action,
+    ClutterActor *actor,
+    gfloat event_x,
+    gfloat event_y,
+    ClutterModifierType modifiers,
+    EmpathyCallWindow *self)
+{
+  PreviewPosition pos;
+
+  /* Get the position before destroying the drag actor, otherwise the
+   * preview_box allocation won't be valid and we won't be able to
+   * calculate the position. */
+  pos = empathy_call_window_get_preview_position (self, event_x, event_y);
+
+  /* Destroy the video preview copy that we were dragging */
+  clutter_actor_destroy (self->priv->drag_preview);
+  self->priv->drag_preview = NULL;
+
+  clutter_actor_set_opacity (actor, 255);
+  clutter_actor_show (self->priv->preview_shown_button);
+
+  if (pos != PREVIEW_POS_NONE)
+    empathy_call_window_move_video_preview (self, pos);
+
+  empathy_call_window_show_preview_rectangles (self, FALSE);
+}
+
+static void
+empathy_call_window_preview_on_drag_motion_cb (ClutterDragAction *action,
+    ClutterActor *actor,
+    gfloat delta_x,
+    gfloat delta_y,
+    EmpathyCallWindow *self)
+{
+  PreviewPosition pos;
+  gfloat event_x, event_y;
+
+  clutter_drag_action_get_motion_coords (action, &event_x, &event_y);
+
+  pos = empathy_call_window_get_preview_position (self, event_x, event_y);
+
+  if (pos != PREVIEW_POS_NONE)
+    empathy_call_window_highlight_preview_rectangle (self, pos);
+  else
+    empathy_call_window_darken_preview_rectangles (self);
+}
+
+static gboolean
+empathy_call_window_preview_enter_event_cb (ClutterActor *actor,
+    ClutterCrossingEvent *event,
+    EmpathyCallWindow *self)
+{
+  ClutterActor *rectangle;
+
+  rectangle = empathy_call_window_get_preview_rectangle (self,
+      self->priv->preview_pos);
+
+  empathy_call_window_highlight_preview_rectangle (self,
+      self->priv->preview_pos);
+
+  clutter_actor_show (rectangle);
+
+  return FALSE;
+}
+
+static gboolean
+empathy_call_window_preview_leave_event_cb (ClutterActor *actor,
+    ClutterCrossingEvent *event,
+    EmpathyCallWindow *self)
+{
+  ClutterActor *rectangle;
+
+  rectangle = empathy_call_window_get_preview_rectangle (self,
+      self->priv->preview_pos);
+
+  empathy_call_window_darken_preview_rectangle (self, rectangle);
+
+  clutter_actor_hide (rectangle);
+
+  return FALSE;
 }
 
 static void
 create_video_preview (EmpathyCallWindow *self)
 {
   EmpathyCallWindowPriv *priv = GET_PRIV (self);
-  ClutterLayoutManager *layout, *layout_center;
+  ClutterLayoutManager *layout, *layout_center, *layout_end;
   ClutterActor *preview;
   ClutterActor *box;
   ClutterActor *b;
+  ClutterAction *action;
   GtkWidget *button;
+  PreviewPosition pos;
 
   g_assert (priv->video_preview == NULL);
 
-  preview = clutter_texture_new ();
+  pos = g_settings_get_enum (priv->settings, "camera-position");
+
+  preview = empathy_rounded_texture_new ();
   clutter_actor_set_size (preview,
-      SELF_VIDEO_SECTION_WIDTH, SELF_VIDEO_SECTION_HEIGTH);
+      SELF_VIDEO_SECTION_WIDTH, SELF_VIDEO_SECTION_HEIGHT);
   priv->video_preview_sink = clutter_gst_video_sink_new (
       CLUTTER_TEXTURE (preview));
 
-  /* Flip the video preview */
-  clutter_actor_set_rotation (preview,
-      CLUTTER_Y_AXIS,
-      180,
-      SELF_VIDEO_SECTION_WIDTH * 0.5,
-      0.0,
-      0.0);
-
   /* Add a little offset to the video preview */
-  layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_END,
+  layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
       CLUTTER_BIN_ALIGNMENT_START);
   priv->video_preview = clutter_box_new (layout);
   clutter_actor_set_size (priv->video_preview,
-      SELF_VIDEO_SECTION_WIDTH + 10, SELF_VIDEO_SECTION_HEIGTH + 10);
+      SELF_VIDEO_SECTION_WIDTH + 2 * SELF_VIDEO_SECTION_MARGIN,
+      SELF_VIDEO_SECTION_HEIGHT + 2 * SELF_VIDEO_SECTION_MARGIN +
+      FLOATING_TOOLBAR_HEIGHT + FLOATING_TOOLBAR_SPACING);
 
+  /* We have a box with the margins and the video in the middle inside
+   * a bigger box with an extra bottom margin so we're not on top of
+   * the floating toolbar. */
   layout_center = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
       CLUTTER_BIN_ALIGNMENT_CENTER);
   box = clutter_box_new (layout_center);
   clutter_actor_set_size (box,
-      SELF_VIDEO_SECTION_WIDTH, SELF_VIDEO_SECTION_HEIGTH);
+      SELF_VIDEO_SECTION_WIDTH + 2 * SELF_VIDEO_SECTION_MARGIN,
+      SELF_VIDEO_SECTION_HEIGHT + 2 * SELF_VIDEO_SECTION_MARGIN);
 
   clutter_container_add_actor (CLUTTER_CONTAINER (box), preview);
   clutter_container_add_actor (CLUTTER_CONTAINER (priv->video_preview), box);
@@ -785,12 +1034,21 @@ create_video_preview (EmpathyCallWindow *self)
   /* Translators: this is an "Info" label. It should be as short
    * as possible. */
   button = gtk_button_new_with_label (_("i"));
-  b = gtk_clutter_actor_new_with_contents (button);
+  priv->preview_shown_button = b = empathy_rounded_actor_new ();
+  gtk_container_add (
+      GTK_CONTAINER (gtk_clutter_actor_get_widget (GTK_CLUTTER_ACTOR (b))),
+      button);
+  clutter_actor_set_size (b, 24, 24);
 
-  clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (layout_center),
-      b,
-      CLUTTER_BIN_ALIGNMENT_END,
+  layout_end = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_END,
       CLUTTER_BIN_ALIGNMENT_END);
+  box = clutter_box_new (layout_end);
+  clutter_actor_set_size (box,
+      SELF_VIDEO_SECTION_WIDTH,
+      SELF_VIDEO_SECTION_HEIGHT + SELF_VIDEO_SECTION_MARGIN);
+
+  clutter_container_add_actor (CLUTTER_CONTAINER (box), b);
+  clutter_container_add_actor (CLUTTER_CONTAINER (priv->video_preview), box);
 
   g_signal_connect (button, "clicked",
       G_CALLBACK (empathy_call_window_preview_button_clicked_cb),
@@ -799,14 +1057,20 @@ create_video_preview (EmpathyCallWindow *self)
   /* Translators: this is an "Info" label. It should be as short
    * as possible. */
   button = gtk_button_new_with_label (_("i"));
-  priv->preview_hidden_button =
-      gtk_clutter_actor_new_with_contents (button);
+  b = empathy_rounded_actor_new ();
+  gtk_container_add (
+      GTK_CONTAINER (gtk_clutter_actor_get_widget (GTK_CLUTTER_ACTOR (b))),
+      button);
+  clutter_actor_set_size (b, 24, 24);
+  priv->preview_hidden_button = b;
 
   clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (priv->video_layout),
       priv->preview_hidden_button,
       CLUTTER_BIN_ALIGNMENT_START,
       CLUTTER_BIN_ALIGNMENT_END);
 
+  self->priv->preview_pos = PREVIEW_POS_BOTTOM_LEFT;
+
   clutter_actor_hide (priv->preview_hidden_button);
 
   g_signal_connect (button, "clicked",
@@ -817,10 +1081,29 @@ create_video_preview (EmpathyCallWindow *self)
       priv->video_preview,
       CLUTTER_BIN_ALIGNMENT_START,
       CLUTTER_BIN_ALIGNMENT_END);
+
+  empathy_call_window_move_video_preview (self, pos);
+
+  action = clutter_drag_action_new ();
+  g_signal_connect (action, "drag-begin",
+      G_CALLBACK (empathy_call_window_preview_on_drag_begin_cb), self);
+  g_signal_connect (action, "drag-end",
+      G_CALLBACK (empathy_call_window_preview_on_drag_end_cb), self);
+  g_signal_connect (action, "drag-motion",
+      G_CALLBACK (empathy_call_window_preview_on_drag_motion_cb), self);
+
+  g_signal_connect (preview, "enter-event",
+      G_CALLBACK (empathy_call_window_preview_enter_event_cb), self);
+  g_signal_connect (preview, "leave-event",
+      G_CALLBACK (empathy_call_window_preview_leave_event_cb), self);
+
+  clutter_actor_add_action (preview, action);
+  clutter_actor_set_reactive (preview, TRUE);
+  clutter_actor_set_reactive (priv->preview_shown_button, TRUE);
 }
 
-static void
-play_camera (EmpathyCallWindow *window,
+void
+empathy_call_window_play_camera (EmpathyCallWindow *window,
     gboolean play)
 {
   EmpathyCallWindowPriv *priv = GET_PRIV (window);
@@ -853,21 +1136,22 @@ display_video_preview (EmpathyCallWindow *self,
 
   if (display)
     {
-      /* Display the preview and hide the self avatar */
+      /* Display the video preview */
       DEBUG ("Show video preview");
 
-      play_camera (self, TRUE);
+      empathy_call_window_play_camera (self, TRUE);
       clutter_actor_show (priv->video_preview);
+      clutter_actor_raise_top (priv->floating_toolbar);
     }
   else
     {
-      /* Display the self avatar and hide the preview */
-      DEBUG ("Show self avatar");
+      /* Hide the video preview */
+      DEBUG ("Hide video preview");
 
       if (priv->video_preview != NULL)
         {
           clutter_actor_hide (priv->video_preview);
-          play_camera (self, FALSE);
+          empathy_call_window_play_camera (self, FALSE);
         }
     }
 }
@@ -880,6 +1164,9 @@ empathy_call_window_set_state_connecting (EmpathyCallWindow *window)
   empathy_call_window_status_message (window, _("Connecting…"));
   priv->call_state = CONNECTING;
 
+  /* Show the toolbar */
+  clutter_state_set_state (priv->transitions, "fade-in");
+
   if (priv->outgoing)
     empathy_sound_manager_start_playing (priv->sound_mgr, GTK_WIDGET (window),
         EMPATHY_SOUND_PHONE_OUTGOING, MS_BETWEEN_RING);
@@ -958,6 +1245,69 @@ create_pipeline (EmpathyCallWindow *self)
   g_object_unref (bus);
 }
 
+static void
+empathy_call_window_settings_cb (GtkAction *action,
+    EmpathyCallWindow *self)
+{
+  gchar *args = g_strdup_printf ("-p %s",
+      empathy_preferences_tab_to_string (EMPATHY_PREFERENCES_TAB_CALLS));
+
+  empathy_launch_program (BIN_DIR, "empathy", args);
+
+  g_free (args);
+}
+
+static void
+empathy_call_window_contents_cb (GtkAction *action,
+    EmpathyCallWindow *self)
+{
+  empathy_url_show (GTK_WIDGET (self), "ghelp:empathy?audio-video");
+}
+
+static void
+empathy_call_window_debug_cb (GtkAction *action,
+    EmpathyCallWindow *self)
+{
+  empathy_launch_program (BIN_DIR, "empathy-debugger", "-s Empathy.Call");
+}
+
+static void
+empathy_call_window_about_cb (GtkAction *action,
+    EmpathyCallWindow *self)
+{
+  empathy_about_dialog_new (GTK_WINDOW (self));
+}
+
+static gboolean
+empathy_call_window_toolbar_timeout (gpointer data)
+{
+  EmpathyCallWindow *self = data;
+
+  /* We don't want to hide the toolbar if we're not in a call, as
+   * to show the call status all the time. */
+  if (self->priv->call_state != CONNECTING &&
+      self->priv->call_state != DISCONNECTED)
+    clutter_state_set_state (self->priv->transitions, "fade-out");
+
+  return TRUE;
+}
+
+static gboolean
+empathy_call_window_motion_notify_cb (GtkWidget *widget,
+    GdkEvent *event,
+    EmpathyCallWindow *self)
+{
+  clutter_state_set_state (self->priv->transitions, "fade-in");
+
+  if (self->priv->inactivity_src > 0)
+    g_source_remove (self->priv->inactivity_src);
+
+  self->priv->inactivity_src = g_timeout_add_seconds (3,
+      empathy_call_window_toolbar_timeout, self);
+
+  return FALSE;
+}
+
 static gboolean
 empathy_call_window_configure_event_cb (GtkWidget *widget,
     GdkEvent  *event,
@@ -969,8 +1319,8 @@ empathy_call_window_configure_event_cb (GtkWidget *widget,
   gtk_window_get_position (GTK_WINDOW (self), &self->priv->x, &self->priv->y);
   gtk_window_get_size (GTK_WINDOW (self), &self->priv->w, &self->priv->h);
 
-  gtk_widget_get_preferred_width (self->priv->sidebar,
-      &self->priv->sidebar_width, NULL);
+  gtk_widget_get_preferred_width (self->priv->dtmf_panel,
+      &self->priv->dialpad_width, NULL);
 
   gdk_window = gtk_widget_get_window (widget);
   window_state = gdk_window_get_state (gdk_window);
@@ -983,27 +1333,38 @@ static void
 empathy_call_window_destroyed_cb (GtkWidget *object,
     EmpathyCallWindow *self)
 {
-  if (gtk_widget_get_visible (self->priv->sidebar))
+  if (gtk_widget_get_visible (self->priv->dtmf_panel))
     {
-      /* Save the geometry as if the sidebar was hidden. */
+      /* Save the geometry as if the dialpad was hidden. */
       empathy_geometry_save_values (GTK_WINDOW (self),
           self->priv->x, self->priv->y,
-          self->priv->w - self->priv->sidebar_width, self->priv->h,
+          self->priv->w - self->priv->dialpad_width, self->priv->h,
           self->priv->maximized);
     }
 }
 
+static void
+empathy_call_window_stage_allocation_changed_cb (ClutterActor *stage,
+    GParamSpec *pspec,
+    ClutterBindConstraint *constraint)
+{
+  ClutterActorBox allocation;
+
+  clutter_actor_get_allocation_box (stage, &allocation);
+
+  clutter_bind_constraint_set_offset (constraint,
+      allocation.y2 - allocation.y1 -
+      FLOATING_TOOLBAR_SPACING - FLOATING_TOOLBAR_HEIGHT);
+}
+
 static void
 empathy_call_window_init (EmpathyCallWindow *self)
 {
   EmpathyCallWindowPriv *priv;
   GtkBuilder *gui;
   GtkWidget *top_vbox;
-  GtkWidget *h;
-  GtkWidget *page;
   gchar *filename;
-  GtkWidget *scroll;
-  ClutterConstraint *size_constraint;
+  ClutterConstraint *constraint;
   ClutterActor *remote_avatar;
   GtkStyleContext *context;
   GdkRGBA rgba;
@@ -1017,16 +1378,20 @@ empathy_call_window_init (EmpathyCallWindow *self)
     "call_window_vbox", &top_vbox,
     "errors_vbox", &priv->errors_vbox,
     "pane", &priv->pane,
-    "statusbar", &priv->statusbar,
-    "redial", &priv->redial_button,
+    "remote_user_name_toolbar", &priv->remote_user_name_toolbar,
+    "remote_user_avatar_toolbar", &priv->remote_user_avatar_toolbar,
+    "status_label", &priv->status_label,
+    "audiocall", &priv->audio_call_button,
+    "videocall", &priv->video_call_button,
     "microphone", &priv->mic_button,
     "camera", &priv->camera_button,
+    "hangup", &priv->hangup_button,
     "dialpad", &priv->dialpad_button,
     "toolbar", &priv->toolbar,
-    "menuredial", &priv->redial,
-    "menusidebar", &priv->menu_sidebar,
+    "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,
@@ -1044,18 +1409,22 @@ empathy_call_window_init (EmpathyCallWindow *self)
   g_free (filename);
 
   empathy_builder_connect (gui, self,
-    "menuhangup", "activate", empathy_call_window_hangup_cb,
     "hangup", "clicked", empathy_call_window_hangup_cb,
-    "menuredial", "activate", empathy_call_window_redial_cb,
-    "redial", "clicked", empathy_call_window_redial_cb,
-    "menusidebar", "toggled", empathy_call_window_sidebar_cb,
+    "audiocall", "clicked", empathy_call_window_audio_call_cb,
+    "videocall", "clicked", empathy_call_window_video_call_cb,
+    "volume", "value-changed", empathy_call_window_volume_changed_cb,
     "microphone", "toggled", empathy_call_window_mic_toggled_cb,
     "camera", "toggled", empathy_call_window_camera_toggled_cb,
     "dialpad", "toggled", empathy_call_window_dialpad_cb,
     "menufullscreen", "activate", empathy_call_window_fullscreen_cb,
+    "menusettings", "activate", empathy_call_window_settings_cb,
+    "menucontents", "activate", empathy_call_window_contents_cb,
+    "menudebug", "activate", empathy_call_window_debug_cb,
+    "menuabout", "activate", empathy_call_window_about_cb,
     "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);
@@ -1066,6 +1435,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);
@@ -1073,7 +1447,8 @@ empathy_call_window_init (EmpathyCallWindow *self)
   priv->content_hbox = gtk_hbox_new (FALSE, CONTENT_HBOX_SPACING);
   gtk_container_set_border_width (GTK_CONTAINER (priv->content_hbox),
                                   CONTENT_HBOX_BORDER_WIDTH);
-  gtk_paned_pack1 (GTK_PANED (priv->pane), priv->content_hbox, TRUE, FALSE);
+  gtk_box_pack_start (GTK_BOX (priv->pane), priv->content_hbox,
+      TRUE, TRUE, 0);
 
   /* avatar/video box */
   priv->video_layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
@@ -1102,10 +1477,10 @@ empathy_call_window_init (EmpathyCallWindow *self)
       priv->video_box,
       NULL);
 
-  size_constraint = clutter_bind_constraint_new (
+  constraint = clutter_bind_constraint_new (
       gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (priv->video_container)),
       CLUTTER_BIND_SIZE, 0);
-  clutter_actor_add_constraint (priv->video_box, size_constraint);
+  clutter_actor_add_constraint (priv->video_box, constraint);
 
   priv->remote_user_avatar_widget = gtk_image_new ();
   remote_avatar = gtk_clutter_actor_new_with_contents (
@@ -1114,6 +1489,8 @@ empathy_call_window_init (EmpathyCallWindow *self)
   clutter_container_add_actor (CLUTTER_CONTAINER (priv->video_box),
       remote_avatar);
 
+  empathy_call_window_create_preview_rectangles (self);
+
   gtk_box_pack_start (GTK_BOX (priv->content_hbox),
       priv->video_container, TRUE, TRUE,
       CONTENT_HBOX_CHILDREN_PACKING_PADDING);
@@ -1123,59 +1500,85 @@ empathy_call_window_init (EmpathyCallWindow *self)
   create_audio_input (self);
   create_video_input (self);
 
-  /* The call will be started as soon the pipeline is playing */
-  priv->start_call_when_playing = TRUE;
+  priv->floating_toolbar = empathy_rounded_actor_new ();
 
-  priv->vbox = gtk_vbox_new (FALSE, 3);
-  gtk_box_pack_start (GTK_BOX (priv->content_hbox), priv->vbox,
-      FALSE, FALSE, CONTENT_HBOX_CHILDREN_PACKING_PADDING);
+  gtk_widget_reparent (priv->bottom_toolbar,
+      gtk_clutter_actor_get_widget (GTK_CLUTTER_ACTOR (priv->floating_toolbar)));
 
-  empathy_call_window_setup_toolbar (self);
+  constraint = clutter_bind_constraint_new (
+      gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (priv->video_container)),
+      CLUTTER_BIND_Y, 0);
+
+  clutter_actor_add_constraint (priv->floating_toolbar, constraint);
+
+  g_signal_connect (
+      gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (priv->video_container)),
+      "notify::allocation",
+      G_CALLBACK (empathy_call_window_stage_allocation_changed_cb),
+      constraint);
 
-  h = gtk_hbox_new (FALSE, 3);
-  gtk_box_pack_end (GTK_BOX (priv->vbox), h, FALSE, FALSE, 3);
+  clutter_actor_set_size (priv->floating_toolbar,
+      FLOATING_TOOLBAR_WIDTH, FLOATING_TOOLBAR_HEIGHT);
+  clutter_actor_set_opacity (priv->floating_toolbar, FLOATING_TOOLBAR_OPACITY);
 
-  priv->sidebar = ev_sidebar_new ();
-  g_signal_connect (G_OBJECT (priv->sidebar),
-    "hide", G_CALLBACK (empathy_call_window_sidebar_hidden_cb), self);
-  g_signal_connect (G_OBJECT (priv->sidebar),
-    "show", G_CALLBACK (empathy_call_window_sidebar_shown_cb), self);
-  g_signal_connect (G_OBJECT (priv->sidebar), "changed",
-    G_CALLBACK (empathy_call_window_sidebar_changed_cb), self);
-  gtk_paned_pack2 (GTK_PANED (priv->pane), priv->sidebar, FALSE, FALSE);
+  clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (priv->video_layout),
+      priv->floating_toolbar,
+      CLUTTER_BIN_ALIGNMENT_CENTER,
+      CLUTTER_BIN_ALIGNMENT_END);
 
-  page = empathy_call_window_create_audio_input (self);
-  ev_sidebar_add_page (EV_SIDEBAR (priv->sidebar), "audio-input",
-      _("Audio input"), page);
+  clutter_actor_raise_top (priv->floating_toolbar);
 
-  page = empathy_call_window_create_video_input (self);
-  ev_sidebar_add_page (EV_SIDEBAR (priv->sidebar), "video-input",
-      _("Video input"), page);
+  /* Transitions for the floating toolbar */
+  priv->transitions = clutter_state_new ();
 
-  priv->dtmf_panel = empathy_call_window_create_dtmf (self);
-  ev_sidebar_add_page (EV_SIDEBAR (priv->sidebar), "dialpad",
-      _("Dialpad"), priv->dtmf_panel);
+  /* all transitions last for 2s */
+  clutter_state_set_duration (priv->transitions, NULL, NULL, 2000);
 
-  gtk_widget_set_sensitive (priv->dtmf_panel, FALSE);
+  /* transition from any state to "fade-out" state */
+  clutter_state_set (priv->transitions, NULL, "fade-out",
+      priv->floating_toolbar,
+      "opacity", CLUTTER_EASE_OUT_QUAD, 0,
+      NULL);
 
-  /* Put the details vbox in a scroll window as it can require a lot of
-   * horizontal space. */
-  scroll = gtk_scrolled_window_new (NULL, NULL);
-  gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scroll),
-      priv->details_vbox);
+  /* transition from any state to "fade-in" state */
+  clutter_state_set (priv->transitions, NULL, "fade-in",
+      priv->floating_toolbar,
+      "opacity", CLUTTER_EASE_OUT_QUAD, FLOATING_TOOLBAR_OPACITY,
+      NULL);
+
+  /* put the actor into the "fade-in" state with no animation */
+  clutter_state_warp_to_state (priv->transitions, "fade-in");
+
+  /* The call will be started as soon the pipeline is playing */
+  priv->start_call_when_playing = TRUE;
+
+  priv->dtmf_panel = empathy_create_dtmf_dialpad (G_OBJECT (self),
+      G_CALLBACK (dtmf_button_pressed_cb),
+      G_CALLBACK (dtmf_button_released_cb));
+
+  gtk_box_pack_start (GTK_BOX (priv->pane), priv->dtmf_panel,
+      FALSE, FALSE, 6);
+
+  gtk_box_pack_start (GTK_BOX (priv->pane), priv->details_vbox,
+      FALSE, FALSE, 0);
 
-  ev_sidebar_add_page (EV_SIDEBAR (priv->sidebar), "details", _("Details"),
-    scroll);
+  gtk_widget_set_sensitive (priv->dtmf_panel, FALSE);
 
   gtk_widget_show_all (top_vbox);
 
-  gtk_widget_hide (priv->sidebar);
+  gtk_widget_hide (priv->dtmf_panel);
+  gtk_widget_hide (priv->details_vbox);
 
   priv->fullscreen = empathy_call_window_fullscreen_new (self);
 
   empathy_call_window_fullscreen_set_video_widget (priv->fullscreen,
       priv->video_container);
 
+  /* We hide the bottom toolbar after 3s of inactivity and show it
+   * again on mouse movement */
+  priv->inactivity_src = g_timeout_add_seconds (3,
+      empathy_call_window_toolbar_timeout, self);
+
   g_signal_connect (G_OBJECT (priv->fullscreen->leave_fullscreen_button),
       "clicked", G_CALLBACK (empathy_call_window_fullscreen_cb), self);
 
@@ -1191,23 +1594,42 @@ empathy_call_window_init (EmpathyCallWindow *self)
   g_signal_connect (G_OBJECT (self), "key-press-event",
       G_CALLBACK (empathy_call_window_key_press_cb), self);
 
+  g_signal_connect (self, "motion-notify-event",
+      G_CALLBACK (empathy_call_window_motion_notify_cb), self);
+
   priv->timer = g_timer_new ();
 
   g_object_ref (priv->ui_manager);
   g_object_unref (gui);
 
   priv->sound_mgr = empathy_sound_manager_dup_singleton ();
+  priv->mic_menu = empathy_mic_menu_new (self);
+  priv->camera_menu = empathy_camera_menu_new (self);
+
+  empathy_call_window_show_hangup_button (self, TRUE);
+
+  priv->settings = g_settings_new (EMPATHY_PREFS_CALL_SCHEMA);
+
+  /* Retrieve initial volume */
+  priv->volume = g_settings_get_double (priv->settings,
+      EMPATHY_PREFS_CALL_SOUND_VOLUME) / 100.0;
+
+  g_signal_connect (priv->settings, "changed::"EMPATHY_PREFS_CALL_SOUND_VOLUME,
+      G_CALLBACK (empathy_call_window_prefs_volume_changed_cb), self);
 
   empathy_geometry_bind (GTK_WINDOW (self), "call-window");
   /* These signals are used to track the window position and save it
    * when the window is destroyed. We need to do this as we don't want
-   * the window geometry to be saved with the sidebar taken into account. */
+   * the window geometry to be saved with the dialpad taken into account. */
   g_signal_connect (self, "destroy",
       G_CALLBACK (empathy_call_window_destroyed_cb), self);
   g_signal_connect (self, "configure-event",
       G_CALLBACK (empathy_call_window_configure_event_cb), self);
   g_signal_connect (self, "window-state-event",
       G_CALLBACK (empathy_call_window_configure_event_cb), self);
+
+  /* Don't display labels in both toolbars */
+  gtk_toolbar_set_style (GTK_TOOLBAR (priv->toolbar), GTK_TOOLBAR_ICONS);
 }
 
 /* Instead of specifying a width and a height, we specify only one size. That's
@@ -1254,23 +1676,51 @@ set_window_title (EmpathyCallWindow *self)
     }
   else
     {
-      gtk_window_set_title (GTK_WINDOW (self), _("Call with %d participants"));
+      g_warning ("Unknown remote contact!");
     }
 }
 
+static void
+set_remote_user_name (EmpathyCallWindow *self,
+  EmpathyContact *contact)
+{
+  const gchar *alias = empathy_contact_get_alias (contact);
+  const gchar *status = empathy_contact_get_status (contact);
+  gchar *label;
+
+  label = g_strdup_printf ("%s\n<small>%s</small>", alias, status);
+  gtk_label_set_markup (GTK_LABEL (self->priv->remote_user_name_toolbar),
+      label);
+  g_free (label);
+}
+
 static void
 contact_name_changed_cb (EmpathyContact *contact,
-    GParamSpec *pspec, EmpathyCallWindow *self)
+    GParamSpec *pspec,
+    EmpathyCallWindow *self)
 {
   set_window_title (self);
+  set_remote_user_name (self, contact);
+}
+
+static void
+contact_presence_changed_cb (EmpathyContact *contact,
+    GParamSpec *pspec,
+    EmpathyCallWindow *self)
+{
+  set_remote_user_name (self, contact);
 }
 
 static void
 contact_avatar_changed_cb (EmpathyContact *contact,
-    GParamSpec *pspec, GtkWidget *avatar_widget)
+    GParamSpec *pspec,
+    EmpathyCallWindow *self)
 {
   int size;
   GtkAllocation allocation;
+  GtkWidget *avatar_widget;
+
+  avatar_widget = self->priv->remote_user_avatar_widget;
 
   gtk_widget_get_allocation (avatar_widget, &allocation);
   size = allocation.height;
@@ -1283,6 +1733,19 @@ contact_avatar_changed_cb (EmpathyContact *contact,
     }
 
   init_contact_avatar_with_size (contact, avatar_widget, size);
+
+  avatar_widget = self->priv->remote_user_avatar_toolbar;
+
+  gtk_widget_get_allocation (avatar_widget, &allocation);
+  size = allocation.height;
+
+  if (size == 0)
+    {
+      /* the widget is not allocated yet, set a default size */
+      size = SMALL_TOOLBAR_SIZE;
+    }
+
+  init_contact_avatar_with_size (contact, avatar_widget, size);
 }
 
 static void
@@ -1291,19 +1754,25 @@ empathy_call_window_setup_avatars (EmpathyCallWindow *self,
 {
   EmpathyCallWindowPriv *priv = GET_PRIV (self);
 
-  g_signal_connect (priv->contact, "notify::name",
-      G_CALLBACK (contact_name_changed_cb), self);
-  g_signal_connect (priv->contact, "notify::avatar",
-    G_CALLBACK (contact_avatar_changed_cb),
-    priv->remote_user_avatar_widget);
+  tp_g_signal_connect_object (priv->contact, "notify::name",
+      G_CALLBACK (contact_name_changed_cb), self, 0);
+  tp_g_signal_connect_object (priv->contact, "notify::avatar",
+    G_CALLBACK (contact_avatar_changed_cb), self, 0);
+  tp_g_signal_connect_object (priv->contact, "notify::presence",
+      G_CALLBACK (contact_presence_changed_cb), self, 0);
 
   set_window_title (self);
+  set_remote_user_name (self, priv->contact);
 
   init_contact_avatar_with_size (priv->contact,
       priv->remote_user_avatar_widget,
       MIN (REMOTE_CONTACT_AVATAR_DEFAULT_WIDTH,
           REMOTE_CONTACT_AVATAR_DEFAULT_HEIGHT));
 
+  init_contact_avatar_with_size (priv->contact,
+      priv->remote_user_avatar_toolbar,
+      SMALL_TOOLBAR_SIZE);
+
   /* The remote avatar is shown by default and will be hidden when we receive
      video from the remote side. */
   clutter_actor_hide (priv->video_output);
@@ -1524,17 +1993,24 @@ empathy_call_window_constructed (GObject *object)
   EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (object);
   EmpathyCallWindowPriv *priv = GET_PRIV (self);
   TpyCallChannel *call;
+  TpyCallState state;
 
   g_assert (priv->handler != NULL);
 
   g_object_get (priv->handler, "call-channel", &call, NULL);
-  priv->outgoing = (call == NULL);
-  if (call != NULL)
-    g_object_unref (call);
+  state = tpy_call_channel_get_state (call, NULL, NULL);
+  priv->outgoing = (state == TPY_CALL_STATE_PENDING_INITIATOR);
+  tp_clear_object (&call);
 
   g_object_get (priv->handler, "target-contact", &priv->contact, NULL);
   g_assert (priv->contact != NULL);
 
+  if (!empathy_contact_can_voip_video (priv->contact))
+    {
+      gtk_widget_set_sensitive (priv->video_call_button, FALSE);
+      gtk_widget_set_sensitive (priv->camera_button, FALSE);
+    }
+
   empathy_call_window_setup_avatars (self, priv->handler);
   empathy_call_window_set_state_connecting (self);
 
@@ -1647,6 +2123,18 @@ empathy_call_window_dispose (GObject *object)
       priv->bus_message_source_id = 0;
     }
 
+  if (priv->got_video_src > 0)
+    {
+      g_source_remove (priv->got_video_src);
+      priv->got_video_src = 0;
+    }
+
+  if (priv->inactivity_src > 0)
+    {
+      g_source_remove (priv->inactivity_src);
+      priv->inactivity_src = 0;
+    }
+
   tp_clear_object (&priv->pipeline);
   tp_clear_object (&priv->video_input);
   tp_clear_object (&priv->audio_input);
@@ -1654,6 +2142,10 @@ empathy_call_window_dispose (GObject *object)
   tp_clear_object (&priv->ui_manager);
   tp_clear_object (&priv->fullscreen);
   tp_clear_object (&priv->camera_monitor);
+  tp_clear_object (&priv->settings);
+  tp_clear_object (&priv->sound_mgr);
+  tp_clear_object (&priv->mic_menu);
+  tp_clear_object (&priv->camera_menu);
 
   g_list_free_full (priv->notifiers, g_object_unref);
 
@@ -1668,9 +2160,6 @@ empathy_call_window_dispose (GObject *object)
       priv->contact = NULL;
     }
 
-
-  tp_clear_object (&priv->sound_mgr);
-
   G_OBJECT_CLASS (empathy_call_window_parent_class)->dispose (object);
 }
 
@@ -1772,9 +2261,6 @@ empathy_call_window_reset_pipeline (EmpathyCallWindow *self)
         g_object_unref (priv->pipeline);
       priv->pipeline = NULL;
 
-      g_signal_handlers_disconnect_by_func (priv->audio_input_adj,
-          empathy_call_window_mic_volume_changed_cb, self);
-
       if (priv->audio_output != NULL)
         g_object_unref (priv->audio_output);
       priv->audio_output = NULL;
@@ -1787,6 +2273,15 @@ empathy_call_window_reset_pipeline (EmpathyCallWindow *self)
         clutter_actor_destroy (priv->video_preview);
       priv->video_preview = NULL;
 
+      /* If we destroy the preview while it's being dragged, we won't
+       * get the ::drag-end signal, so manually destroy the clone */
+      if (priv->drag_preview != NULL)
+        {
+          clutter_actor_destroy (priv->drag_preview);
+          empathy_call_window_show_preview_rectangles (self, FALSE);
+          priv->drag_preview = NULL;
+        }
+
       priv->funnel = NULL;
 
       create_pipeline (self);
@@ -1838,6 +2333,9 @@ empathy_call_window_disconnected (EmpathyCallWindow *self,
   if (priv->call_state != REDIALING)
     priv->call_state = DISCONNECTED;
 
+  /* Show the toolbar */
+  clutter_state_set_state (priv->transitions, "fade-in");
+
   if (could_reset_pipeline)
     {
       g_mutex_lock (priv->lock);
@@ -1857,8 +2355,7 @@ empathy_call_window_disconnected (EmpathyCallWindow *self,
 
       empathy_call_window_status_message (self, _("Disconnected"));
 
-      gtk_action_set_sensitive (priv->redial, TRUE);
-      gtk_widget_set_sensitive (priv->redial_button, TRUE);
+      empathy_call_window_show_hangup_button (self, FALSE);
 
       /* Unsensitive the camera and mic button */
       gtk_widget_set_sensitive (priv->camera_button, FALSE);
@@ -1874,14 +2371,16 @@ empathy_call_window_disconnected (EmpathyCallWindow *self,
           display_video_preview (self, TRUE);
         }
 
-      gtk_progress_bar_set_fraction (
-          GTK_PROGRESS_BAR (priv->volume_progress_bar), 0);
-
       /* destroy the video output; it will be recreated when we'll redial */
       disconnect_video_output_motion_handler (self);
       if (priv->video_output != NULL)
         clutter_actor_destroy (priv->video_output);
       priv->video_output = NULL;
+      if (priv->got_video_src > 0)
+        {
+          g_source_remove (priv->got_video_src);
+          priv->got_video_src = 0;
+        }
 
       gtk_widget_show (priv->remote_user_avatar_widget);
 
@@ -2095,14 +2594,23 @@ empathy_call_window_update_timer (gpointer user_data)
 {
   EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
   EmpathyCallWindowPriv *priv = GET_PRIV (self);
+  const gchar *status;
   gchar *str;
   gdouble time_;
 
   time_ = g_timer_elapsed (priv->timer, NULL);
 
+  if (priv->call_state == HELD)
+    status = _("On hold");
+  else if (!gtk_toggle_tool_button_get_active (
+      GTK_TOGGLE_TOOL_BUTTON (priv->mic_button)))
+    status = _("Mute");
+  else
+    status = _("Duration");
+
   /* Translators: 'status - minutes:seconds' the caller has been connected */
   str = g_strdup_printf (_("%s — %d:%02dm"),
-      priv->call_state == HELD ? _("On hold") : _("Connected"),
+      status,
       (int) time_ / 60, (int) time_ % 60);
   empathy_call_window_status_message (self, str);
   g_free (str);
@@ -2338,8 +2846,7 @@ empathy_call_window_state_changed_cb (EmpathyCallHandler *handler,
 
   gtk_widget_set_sensitive (priv->camera_button, can_send_video);
 
-  gtk_action_set_sensitive (priv->redial, FALSE);
-  gtk_widget_set_sensitive (priv->redial_button, FALSE);
+  empathy_call_window_show_hangup_button (self, TRUE);
 
   gtk_widget_set_sensitive (priv->mic_button, TRUE);
 
@@ -2361,16 +2868,60 @@ empathy_call_window_state_changed_cb (EmpathyCallHandler *handler,
 }
 
 static gboolean
-emapthy_call_window_show_video_output_cb (gpointer user_data)
+empathy_call_window_show_video_output_cb (gpointer user_data)
 {
   EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
 
-  gtk_widget_hide (self->priv->remote_user_avatar_widget);
-  clutter_actor_show (self->priv->video_output);
+  if (self->priv->video_output != NULL)
+    {
+      gtk_widget_hide (self->priv->remote_user_avatar_widget);
+      clutter_actor_show (self->priv->video_output);
+      empathy_call_window_raise_actors (self);
+    }
 
   return FALSE;
 }
 
+static gboolean
+empathy_call_window_check_video_cb (gpointer data)
+{
+  EmpathyCallWindow *self = data;
+
+  if (self->priv->got_video)
+    {
+      self->priv->got_video = FALSE;
+      return TRUE;
+    }
+
+  /* No video in the last N seconds, display the remote avatar */
+  empathy_call_window_show_video_output (self, FALSE);
+
+  return TRUE;
+}
+
+/* Called from the streaming thread */
+static gboolean
+empathy_call_window_video_probe_cb (GstPad *pad,
+    GstMiniObject *mini_obj,
+    EmpathyCallWindow *self)
+{
+  /* Ignore events */
+  if (GST_IS_EVENT (mini_obj))
+    return TRUE;
+
+  if (G_UNLIKELY (!self->priv->got_video))
+    {
+      /* show the remote video */
+      g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
+          empathy_call_window_show_video_output_cb,
+          g_object_ref (self), g_object_unref);
+
+      self->priv->got_video = TRUE;
+    }
+
+  return TRUE;
+}
+
 /* Called from the streaming thread */
 static gboolean
 empathy_call_window_src_added_cb (EmpathyCallHandler *handler,
@@ -2390,8 +2941,15 @@ empathy_call_window_src_added_cb (EmpathyCallHandler *handler,
         pad = empathy_call_window_get_audio_sink_pad (self);
         break;
       case TP_MEDIA_STREAM_TYPE_VIDEO:
-        g_idle_add (emapthy_call_window_show_video_output_cb, self);
+        g_idle_add (empathy_call_window_show_video_output_cb, self);
         pad = empathy_call_window_get_video_sink_pad (self);
+
+        gst_pad_add_data_probe (src,
+            G_CALLBACK (empathy_call_window_video_probe_cb), self);
+        if (priv->got_video_src > 0)
+          g_source_remove (priv->got_video_src);
+        priv->got_video_src = g_timeout_add_seconds (5,
+            empathy_call_window_check_video_cb, self);
         break;
       default:
         g_assert_not_reached ();
@@ -2593,8 +3151,6 @@ empathy_call_window_bus_message (GstBus *bus, GstMessage *message,
         if (GST_MESSAGE_SRC (message) == GST_OBJECT (priv->video_input))
           {
             gst_message_parse_state_changed (message, NULL, &newstate, NULL);
-            if (newstate == GST_STATE_PAUSED)
-                empathy_call_window_setup_video_input (self);
           }
         if (GST_MESSAGE_SRC (message) == GST_OBJECT (priv->pipeline) &&
             !priv->call_started)
@@ -2721,6 +3277,11 @@ empathy_call_window_realized_cb (GtkWidget *widget, EmpathyCallWindow *window)
 {
   EmpathyCallWindowPriv *priv = GET_PRIV (window);
   TpyCallChannel *call;
+  gint width;
+
+  /* Make the hangup button twice as wide */
+  width = gtk_widget_get_allocated_width (priv->hangup_button);
+  gtk_widget_set_size_request (priv->hangup_button, width * 2, -1);
 
   g_signal_connect (priv->handler, "state-changed",
     G_CALLBACK (empathy_call_window_state_changed_cb), window);
@@ -2788,20 +3349,16 @@ show_controls (EmpathyCallWindow *window, gboolean set_fullscreen)
 
   if (set_fullscreen)
     {
-      gtk_widget_hide (priv->sidebar);
+      gtk_widget_hide (priv->dtmf_panel);
       gtk_widget_hide (menu);
-      gtk_widget_hide (priv->vbox);
-      gtk_widget_hide (priv->statusbar);
       gtk_widget_hide (priv->toolbar);
     }
   else
     {
-      if (priv->sidebar_was_visible_before_fs)
-        gtk_widget_show (priv->sidebar);
+      if (priv->dialpad_was_visible_before_fs)
+        gtk_widget_show (priv->dtmf_panel);
 
       gtk_widget_show (menu);
-      gtk_widget_show (priv->vbox);
-      gtk_widget_show (priv->statusbar);
       gtk_widget_show (priv->toolbar);
 
       gtk_window_resize (GTK_WINDOW (window), priv->original_width_before_fs,
@@ -2828,11 +3385,6 @@ show_borders (EmpathyCallWindow *window, gboolean set_fullscreen)
           GTK_PACK_START);
 #endif
     }
-
-  gtk_box_set_child_packing (GTK_BOX (priv->content_hbox),
-      priv->vbox, TRUE, TRUE,
-      set_fullscreen ? 0 : CONTENT_HBOX_CHILDREN_PACKING_PADDING,
-      GTK_PACK_START);
 }
 
 static gboolean
@@ -2847,7 +3399,7 @@ empathy_call_window_state_event_cb (GtkWidget *widget,
 
       if (set_fullscreen)
         {
-          gboolean sidebar_was_visible;
+          gboolean dialpad_was_visible;
           GtkAllocation allocation;
           gint original_width, original_height;
 
@@ -2855,9 +3407,11 @@ empathy_call_window_state_event_cb (GtkWidget *widget,
           original_width = allocation.width;
           original_height = allocation.height;
 
-          g_object_get (priv->sidebar, "visible", &sidebar_was_visible, NULL);
+          g_object_get (priv->dtmf_panel,
+              "visible", &dialpad_was_visible,
+              NULL);
 
-          priv->sidebar_was_visible_before_fs = sidebar_was_visible;
+          priv->dialpad_was_visible_before_fs = dialpad_was_visible;
           priv->original_width_before_fs = original_width;
           priv->original_height_before_fs = original_height;
 
@@ -2888,68 +3442,32 @@ empathy_call_window_state_event_cb (GtkWidget *widget,
 }
 
 static void
-empathy_call_window_update_sidebar_buttons (EmpathyCallWindow *window,
-    gboolean toggled)
-{
-  EmpathyCallWindowPriv *priv = GET_PRIV (window);
-
-  /* Update dialpad button */
-  g_signal_handlers_block_by_func (priv->dialpad_button,
-      empathy_call_window_dialpad_cb, window);
-  gtk_toggle_tool_button_set_active (
-      GTK_TOGGLE_TOOL_BUTTON (priv->dialpad_button),
-      toggled);
-  g_signal_handlers_unblock_by_func (priv->dialpad_button,
-      empathy_call_window_dialpad_cb, window);
-
-  /* Update sidebar menu */
-  g_signal_handlers_block_by_func (priv->menu_sidebar,
-      empathy_call_window_sidebar_cb, window);
-  gtk_toggle_action_set_active (
-      GTK_TOGGLE_ACTION (priv->menu_sidebar),
-      gtk_widget_get_visible (priv->sidebar));
-  g_signal_handlers_unblock_by_func (priv->menu_sidebar,
-      empathy_call_window_sidebar_cb, window);
-}
-
-static void
-empathy_call_window_show_sidebar (EmpathyCallWindow *window,
+empathy_call_window_show_dialpad (EmpathyCallWindow *window,
     gboolean active)
 {
   EmpathyCallWindowPriv *priv = GET_PRIV (window);
-  int w, h, sidebar_width, handle_size;
+  int w, h, dialpad_width;
   GtkAllocation allocation;
-  gchar *page;
-  gboolean dialpad_shown;
 
   gtk_widget_get_allocation (GTK_WIDGET (window), &allocation);
   w = allocation.width;
   h = allocation.height;
 
-  gtk_widget_style_get (priv->pane, "handle_size", &handle_size, NULL);
-
-  gtk_widget_get_preferred_width (priv->sidebar, &sidebar_width, NULL);
+  gtk_widget_get_preferred_width (priv->dtmf_panel, &dialpad_width, NULL);
 
   if (active)
     {
-      gtk_widget_show (priv->sidebar);
-      w += sidebar_width + handle_size;
+      gtk_widget_show (priv->dtmf_panel);
+      w += dialpad_width;
     }
   else
     {
-      w -= sidebar_width + handle_size;
-      gtk_widget_hide (priv->sidebar);
+      w -= dialpad_width;
+      gtk_widget_hide (priv->dtmf_panel);
     }
 
   if (w > 0 && h > 0)
     gtk_window_resize (GTK_WINDOW (window), w, h);
-
-  /* Update the 'Dialpad' menu */
-  page = ev_sidebar_get_current_page (EV_SIDEBAR (priv->sidebar));
-  dialpad_shown = active && !tp_strdiff (page, "dialpad");
-  g_free (page);
-
-  empathy_call_window_update_sidebar_buttons (window, dialpad_shown);
 }
 
 static void
@@ -2983,18 +3501,22 @@ empathy_call_window_set_send_video (EmpathyCallWindow *window,
 
 static void
 empathy_call_window_mic_toggled_cb (GtkToggleToolButton *toggle,
-  EmpathyCallWindow *window)
+  EmpathyCallWindow *self)
 {
-  EmpathyCallWindowPriv *priv = GET_PRIV (window);
+  EmpathyCallWindowPriv *priv = GET_PRIV (self);
   gboolean active;
 
   active = (gtk_toggle_tool_button_get_active (toggle));
 
+  /* We don't want the settings callback to react to this change to avoid
+   * a loop. */
+  g_signal_handlers_block_by_func (priv->settings,
+      empathy_call_window_prefs_volume_changed_cb, self);
+
   if (active)
     {
-      empathy_audio_src_set_volume (EMPATHY_GST_AUDIO_SRC (priv->audio_input),
-        priv->volume);
-      gtk_adjustment_set_value (priv->audio_input_adj, priv->volume * 100);
+      g_settings_set_double (priv->settings, EMPATHY_PREFS_CALL_SOUND_VOLUME,
+          priv->volume * 100);
     }
   else
     {
@@ -3003,45 +3525,21 @@ empathy_call_window_mic_toggled_cb (GtkToggleToolButton *toggle,
        * sides mute at the same time on certain CMs AFAIK. Need to revisit this
        * in the future. GNOME #574574
        */
-      empathy_audio_src_set_volume (EMPATHY_GST_AUDIO_SRC (priv->audio_input),
-        0);
-      gtk_adjustment_set_value (priv->audio_input_adj, 0);
+      g_settings_set_double (priv->settings, EMPATHY_PREFS_CALL_SOUND_VOLUME,
+          0);
     }
-}
-
-static void
-empathy_call_window_sidebar_hidden_cb (EvSidebar *sidebar,
-  EmpathyCallWindow *window)
-{
-  empathy_call_window_show_sidebar (window, FALSE);
-}
-
-static void
-empathy_call_window_sidebar_shown_cb (EvSidebar *sidebar,
-  EmpathyCallWindow *window)
-{
-  empathy_call_window_show_sidebar (window, TRUE);
-}
 
-static void
-empathy_call_window_sidebar_changed_cb (EvSidebar *sidebar,
-  const gchar *page,
-  EmpathyCallWindow *window)
-{
-  empathy_call_window_update_sidebar_buttons (window,
-      !tp_strdiff (page, "dialpad"));
+    g_signal_handlers_unblock_by_func (priv->settings,
+      empathy_call_window_prefs_volume_changed_cb, self);
 }
 
 static void
 empathy_call_window_hangup_cb (gpointer object,
-                               EmpathyCallWindow *window)
+    EmpathyCallWindow *self)
 {
-  EmpathyCallWindowPriv *priv = GET_PRIV (window);
+  empathy_call_handler_stop_call (self->priv->handler);
 
-  empathy_call_handler_stop_call (priv->handler);
-
-  if (empathy_call_window_disconnected (window, FALSE))
-    gtk_widget_destroy (GTK_WIDGET (window));
+  empathy_call_window_disconnected (self, TRUE);
 }
 
 static void
@@ -3055,13 +3553,10 @@ empathy_call_window_restart_call (EmpathyCallWindow *window)
 
   create_video_output_widget (window);
 
-  g_signal_connect (G_OBJECT (priv->audio_input_adj), "value-changed",
-      G_CALLBACK (empathy_call_window_mic_volume_changed_cb), window);
-
   /* While the call was disconnected, the input volume might have changed.
    * However, since the audio_input source was destroyed, its volume has not
    * been updated during that time. That's why we manually update it here */
-  empathy_call_window_mic_volume_changed_cb (priv->audio_input_adj, window);
+  empathy_call_window_mic_volume_changed (window);
 
   priv->outgoing = TRUE;
   empathy_call_window_set_state_connecting (window);
@@ -3072,49 +3567,20 @@ empathy_call_window_restart_call (EmpathyCallWindow *window)
     /* call will be started when the pipeline is ready */
     priv->start_call_when_playing = TRUE;
 
-
   empathy_call_window_setup_avatars (window, priv->handler);
 
-  gtk_action_set_sensitive (priv->redial, FALSE);
-  gtk_widget_set_sensitive (priv->redial_button, FALSE);
-}
-
-static void
-empathy_call_window_redial_cb (gpointer object,
-    EmpathyCallWindow *window)
-{
-  EmpathyCallWindowPriv *priv = GET_PRIV (window);
-
-  if (priv->call_state == CONNECTED)
-    priv->call_state = REDIALING;
-
-  empathy_call_handler_stop_call (priv->handler);
-
-  if (priv->call_state != CONNECTED)
-    empathy_call_window_restart_call (window);
+  empathy_call_window_show_hangup_button (window, TRUE);
 }
 
 static void
 empathy_call_window_dialpad_cb (GtkToggleToolButton *button,
     EmpathyCallWindow *window)
 {
-  EmpathyCallWindowPriv *priv = GET_PRIV (window);
   gboolean active;
 
   active = gtk_toggle_tool_button_get_active (button);
 
-  if (active)
-    ev_sidebar_set_current_page (EV_SIDEBAR (priv->sidebar), "dialpad");
-
-  empathy_call_window_show_sidebar (window, active);
-}
-
-static void
-empathy_call_window_sidebar_cb (GtkToggleAction *menu,
-    EmpathyCallWindow *self)
-{
-  empathy_call_window_show_sidebar (self,
-      gtk_toggle_action_get_active (menu));
+  empathy_call_window_show_dialpad (window, active);
 }
 
 static void
@@ -3174,6 +3640,9 @@ empathy_call_window_video_output_motion_notify (GtkWidget *widget,
   if (priv->is_fullscreen)
     {
       empathy_call_window_fullscreen_show_popup (priv->fullscreen);
+
+      /* Show the bottom toolbar */
+      empathy_call_window_motion_notify_cb (NULL, NULL, window);
       return TRUE;
     }
   return FALSE;
@@ -3194,23 +3663,10 @@ empathy_call_window_video_menu_popup (EmpathyCallWindow *window,
 }
 
 static void
-empathy_call_window_status_message (EmpathyCallWindow *window,
+empathy_call_window_status_message (EmpathyCallWindow *self,
   gchar *message)
 {
-  EmpathyCallWindowPriv *priv = GET_PRIV (window);
-
-  if (priv->context_id == 0)
-    {
-      priv->context_id = gtk_statusbar_get_context_id (
-        GTK_STATUSBAR (priv->statusbar), "voip call status messages");
-    }
-  else
-    {
-      gtk_statusbar_pop (GTK_STATUSBAR (priv->statusbar), priv->context_id);
-    }
-
-  gtk_statusbar_push (GTK_STATUSBAR (priv->statusbar), priv->context_id,
-    message);
+  gtk_label_set_label (GTK_LABEL (self->priv->status_label), message);
 }
 
 static void
@@ -3225,3 +3681,25 @@ empathy_call_window_volume_changed_cb (GtkScaleButton *button,
   empathy_audio_sink_set_volume (EMPATHY_GST_AUDIO_SINK (priv->audio_output),
     value);
 }
+
+GtkUIManager *
+empathy_call_window_get_ui_manager (EmpathyCallWindow *window)
+{
+  EmpathyCallWindowPriv *priv = GET_PRIV (window);
+
+  return priv->ui_manager;
+}
+
+EmpathyGstAudioSrc *
+empathy_call_window_get_audio_src (EmpathyCallWindow *window)
+{
+  EmpathyCallWindowPriv *priv = GET_PRIV (window);
+
+  return (EmpathyGstAudioSrc *) priv->audio_input;
+}
+
+EmpathyGstVideoSrc *
+empathy_call_window_get_video_src (EmpathyCallWindow *self)
+{
+  return EMPATHY_GST_VIDEO_SRC (self->priv->video_input);
+}