]> git.0d.be Git - empathy.git/blobdiff - src/empathy-call-window.c
call-window: ensure "Swap camera" is only visible when there are >1 cameras
[empathy.git] / src / empathy-call-window.c
index eb39855babb9632c1257b1a78a441b33f76c7ead..7fe365f304e3926be117bb1daac5a29684b22187 100644 (file)
 #include <telepathy-farstream/telepathy-farstream.h>
 #include <farstream/fs-element-added-notifier.h>
 #include <farstream/fs-utils.h>
+#include <tp-account-widgets/tpaw-builder.h>
+#include <tp-account-widgets/tpaw-camera-monitor.h>
+#include <tp-account-widgets/tpaw-images.h>
+#include <tp-account-widgets/tpaw-pixbuf-utils.h>
+#include <tp-account-widgets/tpaw-utils.h>
 
 #include "empathy-about-dialog.h"
 #include "empathy-audio-sink.h"
 #include "empathy-call-utils.h"
 #include "empathy-call-window-fullscreen.h"
 #include "empathy-camera-menu.h"
-#include "empathy-camera-monitor.h"
 #include "empathy-dialpad-widget.h"
 #include "empathy-geometry.h"
 #include "empathy-gsettings.h"
@@ -121,7 +125,7 @@ struct _EmpathyCallWindowPriv
 
   EmpathyContact *contact;
 
-  EmpathyCameraMonitor *camera_monitor;
+  TpawCameraMonitor *camera_monitor;
 
   CallState call_state;
   gboolean outgoing;
@@ -561,17 +565,17 @@ empathy_call_window_swap_camera_cb (GtkAction *action,
 
   DEBUG ("Swapping the camera");
 
-  cameras = empathy_camera_monitor_get_cameras (self->priv->camera_monitor);
+  cameras = tpaw_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;
+      TpawCamera *camera = l->data;
 
       if (!tp_strdiff (camera->device, current_cam))
         {
-          EmpathyCamera *next;
+          TpawCamera *next;
 
           if (l->next != NULL)
             next = l->next->data;
@@ -592,25 +596,29 @@ empathy_call_window_swap_camera_cb (GtkAction *action,
 }
 
 static void
-empathy_call_window_camera_added_cb (EmpathyCameraMonitor *monitor,
-    EmpathyCamera *camera,
-    EmpathyCallWindow *self)
+empathy_call_window_update_swap_camera (EmpathyCallWindow *self)
 {
-  const GList *cameras = empathy_camera_monitor_get_cameras (monitor);
+  const GList *cameras = tpaw_camera_monitor_get_cameras (
+      self->priv->camera_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,
+empathy_call_window_camera_added_cb (TpawCameraMonitor *monitor,
+    TpawCamera *camera,
     EmpathyCallWindow *self)
 {
-  const GList *cameras = empathy_camera_monitor_get_cameras (monitor);
+  empathy_call_window_update_swap_camera (self);
+}
 
-  gtk_action_set_visible (self->priv->menu_swap_camera,
-      g_list_length ((GList *) cameras) >= 2);
+static void
+empathy_call_window_camera_removed_cb (TpawCameraMonitor *monitor,
+    TpawCamera *camera,
+    EmpathyCallWindow *self)
+{
+  empathy_call_window_update_swap_camera (self);
 }
 
 static void
@@ -1622,7 +1630,7 @@ empathy_call_window_init (EmpathyCallWindow *self)
   priv->timer = g_timer_new ();
 
   filename = empathy_file_lookup ("empathy-call-window.ui", "src");
-  gui = empathy_builder_get_file (filename,
+  gui = tpaw_builder_get_file (filename,
     "call_window_vbox", &top_vbox,
     "errors_vbox", &priv->errors_vbox,
     "pane", &priv->pane,
@@ -1659,7 +1667,7 @@ empathy_call_window_init (EmpathyCallWindow *self)
     NULL);
   g_free (filename);
 
-  empathy_builder_connect (gui, self,
+  tpaw_builder_connect (gui, self,
     "hangup", "clicked", empathy_call_window_hangup_cb,
     "audiocall", "clicked", empathy_call_window_audio_call_cb,
     "videocall", "clicked", empathy_call_window_video_call_cb,
@@ -1680,7 +1688,8 @@ empathy_call_window_init (EmpathyCallWindow *self)
   empathy_set_css_provider (GTK_WIDGET (self));
   gtk_action_set_sensitive (priv->menu_fullscreen, FALSE);
 
-  priv->camera_monitor = empathy_camera_monitor_dup_singleton ();
+  priv->camera_monitor = tpaw_camera_monitor_dup_singleton ();
+  empathy_call_window_update_swap_camera (self);
 
   g_object_bind_property (priv->camera_monitor, "available",
       priv->camera_button, "sensitive",
@@ -1890,8 +1899,8 @@ init_contact_avatar_with_size (EmpathyContact *contact,
 
   if (pixbuf_avatar == NULL)
     {
-      pixbuf_avatar = empathy_pixbuf_from_icon_name_sized (
-          EMPATHY_IMAGE_AVATAR_DEFAULT, size);
+      pixbuf_avatar = tpaw_pixbuf_from_icon_name_sized (
+          TPAW_IMAGE_AVATAR_DEFAULT, size);
     }
 
   gtk_image_set_from_pixbuf (GTK_IMAGE (image_widget), pixbuf_avatar);
@@ -2454,12 +2463,15 @@ empathy_call_window_new (EmpathyCallHandler *handler)
 }
 
 void
-empathy_call_window_present (EmpathyCallWindow *self,
-    EmpathyCallHandler *handler)
+empathy_call_window_new_handler (EmpathyCallWindow *self,
+    EmpathyCallHandler *handler,
+    gboolean present,
+    guint32 x11_time)
 {
   g_return_if_fail (EMPATHY_IS_CALL_HANDLER (handler));
 
-  empathy_window_present (GTK_WINDOW (self));
+  if (present)
+    tpaw_window_present_with_time (GTK_WINDOW (self), x11_time);
 
   if (self->priv->call_state == DISCONNECTED)
     {
@@ -3268,7 +3280,7 @@ empathy_call_window_state_changed_cb (EmpathyCallHandler *handler,
 
   can_send_video = priv->video_input != NULL &&
     empathy_contact_can_voip_video (priv->contact) &&
-    empathy_camera_monitor_get_available (priv->camera_monitor);
+    tpaw_camera_monitor_get_available (priv->camera_monitor);
 
   g_object_get (priv->handler, "call-channel", &call, NULL);