]> git.0d.be Git - empathy.git/blobdiff - src/empathy-call-window-fullscreen.c
Updated Spanish translation
[empathy.git] / src / empathy-call-window-fullscreen.c
index 888b1dfde1a6ba64779d19a97f51a8c851120e79..5ecc123ad72d1fe2163b73dd70965de3c215fa59 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * empathy-call-window-fullscreen.c - Source for EmpathyCallWindowFullscreen
- * Copyright (C) 2009 Collabora Ltd.
+ * Copyright (C) 2009-2011 Collabora Ltd.
  *
  * Some code is based on the Totem Movie Player, especially
  * totem-fullscreen.c which has the following copyright:
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#include "config.h"
 #include "empathy-call-window-fullscreen.h"
 
-#include <gtk/gtk.h>
+#include <tp-account-widgets/tpaw-builder.h>
 
-#include <libempathy/empathy-utils.h>
-#include <libempathy-gtk/empathy-ui-utils.h>
+#include "empathy-ui-utils.h"
+#include "empathy-utils.h"
 
-/* The number of seconds for which the "leave fullscreen" popup should be shown */
+/* The number of seconds for which the "leave fullscreen" popup should
+   be shown */
 #define FULLSCREEN_POPUP_TIMEOUT 5
 
-G_DEFINE_TYPE (EmpathyCallWindowFullscreen, empathy_call_window_fullscreen, G_TYPE_OBJECT)
+G_DEFINE_TYPE (EmpathyCallWindowFullscreen, empathy_call_window_fullscreen,
+    G_TYPE_OBJECT)
 
 /* private structure */
-typedef struct _EmpathyCallWindowFullscreenPriv EmpathyCallWindowFullscreenPriv;
+typedef struct _EmpathyCallWindowFullscreenPriv
+    EmpathyCallWindowFullscreenPriv;
 
 struct _EmpathyCallWindowFullscreenPriv
 {
@@ -56,22 +60,31 @@ struct _EmpathyCallWindowFullscreenPriv
 static void empathy_call_window_fullscreen_dispose (GObject *object);
 static void empathy_call_window_fullscreen_finalize (GObject *object);
 
-static gboolean empathy_call_window_fullscreen_hide_popup (EmpathyCallWindowFullscreen *fs);
+static gboolean empathy_call_window_fullscreen_hide_popup (
+    EmpathyCallWindowFullscreen *fs);
 
 static void
-empathy_call_window_fullscreen_set_cursor_visible (EmpathyCallWindowFullscreen *fs,
+empathy_call_window_fullscreen_set_cursor_visible (
+    EmpathyCallWindowFullscreen *fs,
     gboolean show_cursor)
 {
   EmpathyCallWindowFullscreenPriv *priv = GET_PRIV (fs);
+  GdkWindow *window;
 
-  if (priv->video_widget != NULL && !show_cursor)
-    gdk_window_set_cursor (priv->video_widget->window, gdk_cursor_new (GDK_BLANK_CURSOR));
+  if (priv->video_widget == NULL)
+    return;
+
+  window = gtk_widget_get_window (priv->video_widget);
+
+  if (!show_cursor)
+    gdk_window_set_cursor (window, gdk_cursor_new (GDK_BLANK_CURSOR));
   else
-    gdk_window_set_cursor (priv->video_widget->window, NULL);
+    gdk_window_set_cursor (window, NULL);
 }
 
 static void
-empathy_call_window_fullscreen_add_popup_timeout (EmpathyCallWindowFullscreen *self)
+empathy_call_window_fullscreen_add_popup_timeout (
+    EmpathyCallWindowFullscreen *self)
 {
   EmpathyCallWindowFullscreenPriv *priv = GET_PRIV (self);
 
@@ -83,7 +96,8 @@ empathy_call_window_fullscreen_add_popup_timeout (EmpathyCallWindowFullscreen *s
 }
 
 static void
-empathy_call_window_fullscreen_remove_popup_timeout (EmpathyCallWindowFullscreen *self)
+empathy_call_window_fullscreen_remove_popup_timeout (
+    EmpathyCallWindowFullscreen *self)
 {
   EmpathyCallWindowFullscreenPriv *priv = GET_PRIV (self);
 
@@ -119,7 +133,8 @@ empathy_call_window_fullscreen_show_popup (EmpathyCallWindowFullscreen *self)
   /* Obtaining the screen rectangle */
   screen = gtk_window_get_screen (GTK_WINDOW (priv->parent_window));
   gdk_screen_get_monitor_geometry (screen,
-      gdk_screen_get_monitor_at_window (screen, GTK_WIDGET (priv->parent_window)->window),
+      gdk_screen_get_monitor_at_window (screen,
+          gtk_widget_get_window (GTK_WIDGET (priv->parent_window))),
       &fullscreen_rect);
 
   /* Getting the popup window sizes */
@@ -128,7 +143,8 @@ empathy_call_window_fullscreen_show_popup (EmpathyCallWindowFullscreen *self)
 
   /* Moving the popup to the top-right corner (if the direction is LTR) or the
      top-left corner (if the direction is RTL).*/
-  if (gtk_widget_get_direction (priv->leave_fullscreen_popup) == GTK_TEXT_DIR_LTR)
+  if (gtk_widget_get_direction (priv->leave_fullscreen_popup)
+        == GTK_TEXT_DIR_LTR)
     {
       gtk_window_move (GTK_WINDOW (priv->leave_fullscreen_popup),
           fullscreen_rect.width + fullscreen_rect.x - leave_fullscreen_width,
@@ -137,8 +153,8 @@ empathy_call_window_fullscreen_show_popup (EmpathyCallWindowFullscreen *self)
     }
   else
     {
-      gtk_window_move (GTK_WINDOW (priv->leave_fullscreen_popup), fullscreen_rect.x,
-          fullscreen_rect.y);
+      gtk_window_move (GTK_WINDOW (priv->leave_fullscreen_popup),
+          fullscreen_rect.x, fullscreen_rect.y);
     }
 
   gtk_widget_show_all (priv->leave_fullscreen_popup);
@@ -171,7 +187,7 @@ empathy_call_window_fullscreen_init (EmpathyCallWindowFullscreen *self)
   gchar *filename;
 
   filename = empathy_file_lookup ("empathy-call-window-fullscreen.ui", "src");
-  gui = empathy_builder_get_file (filename,
+  gui = tpaw_builder_get_file (filename,
     "leave_fullscreen_window", &priv->leave_fullscreen_popup,
     "leave_fullscreen_button", &self->leave_fullscreen_button,
     NULL);
@@ -183,7 +199,8 @@ empathy_call_window_fullscreen_init (EmpathyCallWindowFullscreen *self)
 }
 
 static void
-empathy_call_window_fullscreen_class_init (EmpathyCallWindowFullscreenClass *klass)
+empathy_call_window_fullscreen_class_init (
+    EmpathyCallWindowFullscreenClass *klass)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
@@ -209,7 +226,10 @@ empathy_call_window_fullscreen_dispose (GObject *object)
   priv->leave_fullscreen_popup = NULL;
 
   if (G_OBJECT_CLASS (empathy_call_window_fullscreen_parent_class)->dispose)
-    G_OBJECT_CLASS (empathy_call_window_fullscreen_parent_class)->dispose (object);
+    {
+      G_OBJECT_CLASS (
+          empathy_call_window_fullscreen_parent_class)->dispose (object);
+    }
 }
 
 void
@@ -219,7 +239,8 @@ empathy_call_window_fullscreen_finalize (GObject *object)
 
   empathy_call_window_fullscreen_remove_popup_timeout (self);
 
-  G_OBJECT_CLASS (empathy_call_window_fullscreen_parent_class)->finalize (object);
+  G_OBJECT_CLASS (
+      empathy_call_window_fullscreen_parent_class)->finalize (object);
 }
 
 static void
@@ -267,10 +288,23 @@ empathy_call_window_fullscreen_set_fullscreen (EmpathyCallWindowFullscreen *fs,
   fs->is_fullscreen = set_fullscreen;
 }
 
+static void
+video_widget_destroy_cb (GtkWidget *widget,
+    EmpathyCallWindowFullscreen *self)
+{
+  EmpathyCallWindowFullscreenPriv *priv = GET_PRIV (self);
+
+  priv->video_widget = NULL;
+}
+
 void
-empathy_call_window_fullscreen_set_video_widget (EmpathyCallWindowFullscreen *fs,
+empathy_call_window_fullscreen_set_video_widget (
+    EmpathyCallWindowFullscreen *fs,
     GtkWidget *video_widget)
 {
   EmpathyCallWindowFullscreenPriv *priv = GET_PRIV (fs);
   priv->video_widget = video_widget;
+
+  tp_g_signal_connect_object (video_widget, "destroy",
+      G_CALLBACK (video_widget_destroy_cb), fs, 0);
 }