aboutsummaryrefslogtreecommitdiffstats
path: root/src/empathy-call-window-fullscreen.c
diff options
context:
space:
mode:
authorjtellier <jtellier@Jospin.localdomain>2009-05-11 21:54:19 +0800
committerjtellier <jonathan.tellier@collabora.co.uk>2009-05-12 23:43:49 +0800
commitbb9f071a1edf595f89ce23b9d3cfb0955c89ab1d (patch)
tree5278cfb792c74d8a44d2c81392dec3448999b9fa /src/empathy-call-window-fullscreen.c
parent10686010ed50b5f39dc0abf000c66577dbff2ff9 (diff)
downloadgsoc2013-empathy-bb9f071a1edf595f89ce23b9d3cfb0955c89ab1d.tar
gsoc2013-empathy-bb9f071a1edf595f89ce23b9d3cfb0955c89ab1d.tar.gz
gsoc2013-empathy-bb9f071a1edf595f89ce23b9d3cfb0955c89ab1d.tar.bz2
gsoc2013-empathy-bb9f071a1edf595f89ce23b9d3cfb0955c89ab1d.tar.lz
gsoc2013-empathy-bb9f071a1edf595f89ce23b9d3cfb0955c89ab1d.tar.xz
gsoc2013-empathy-bb9f071a1edf595f89ce23b9d3cfb0955c89ab1d.tar.zst
gsoc2013-empathy-bb9f071a1edf595f89ce23b9d3cfb0955c89ab1d.zip
Fixed coding style by removing trailing spaces and not using a mix of
tabs and spaces. Removed some responsabilities from EmpathyCallWindowFullscreen. It now only manages the "Leave Fullscreen" popup and button.
Diffstat (limited to 'src/empathy-call-window-fullscreen.c')
-rw-r--r--src/empathy-call-window-fullscreen.c180
1 files changed, 63 insertions, 117 deletions
diff --git a/src/empathy-call-window-fullscreen.c b/src/empathy-call-window-fullscreen.c
index d01d65b06..888b1dfde 100644
--- a/src/empathy-call-window-fullscreen.c
+++ b/src/empathy-call-window-fullscreen.c
@@ -1,7 +1,12 @@
/*
- * empathy-call-window.c - Source for EmpathyCallWindow
+ * empathy-call-window-fullscreen.c - Source for EmpathyCallWindowFullscreen
* Copyright (C) 2009 Collabora Ltd.
*
+ * Some code is based on the Totem Movie Player, especially
+ * totem-fullscreen.c which has the following copyright:
+ * Copyright (C) 2001-2007 Bastien Nocera <hadess@hadess.net>
+ * Copyright (C) 2007 Sunil Mohan Adapa <sunilmohan@gnu.org.in>
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
@@ -24,10 +29,10 @@
#include <libempathy/empathy-utils.h>
#include <libempathy-gtk/empathy-ui-utils.h>
-/* The number of seconds fo 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, GTK_TYPE_WINDOW)
+G_DEFINE_TYPE (EmpathyCallWindowFullscreen, empathy_call_window_fullscreen, G_TYPE_OBJECT)
/* private structure */
typedef struct _EmpathyCallWindowFullscreenPriv EmpathyCallWindowFullscreenPriv;
@@ -35,11 +40,10 @@ typedef struct _EmpathyCallWindowFullscreenPriv EmpathyCallWindowFullscreenPriv;
struct _EmpathyCallWindowFullscreenPriv
{
EmpathyCallWindow *parent_window;
-
+
GtkWidget *leave_fullscreen_popup;
GtkWidget *video_widget;
- gulong motion_handler_id;
guint popup_timeout;
gboolean popup_creation_in_progress;
gboolean dispose_has_run;
@@ -52,8 +56,6 @@ 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_motion_notify (GtkWidget *widget,
- GdkEventMotion *event, EmpathyCallWindowFullscreen *fs);
static gboolean empathy_call_window_fullscreen_hide_popup (EmpathyCallWindowFullscreen *fs);
static void
@@ -75,8 +77,8 @@ empathy_call_window_fullscreen_add_popup_timeout (EmpathyCallWindowFullscreen *s
if (priv->popup_timeout == 0)
{
- priv->popup_timeout = g_timeout_add_seconds (FULLSCREEN_POPUP_TIMEOUT,
- (GSourceFunc) empathy_call_window_fullscreen_hide_popup, self);
+ priv->popup_timeout = g_timeout_add_seconds (FULLSCREEN_POPUP_TIMEOUT,
+ (GSourceFunc) empathy_call_window_fullscreen_hide_popup, self);
}
}
@@ -87,20 +89,20 @@ empathy_call_window_fullscreen_remove_popup_timeout (EmpathyCallWindowFullscreen
if (priv->popup_timeout != 0)
{
- g_source_remove (priv->popup_timeout);
- priv->popup_timeout = 0;
- }
+ g_source_remove (priv->popup_timeout);
+ priv->popup_timeout = 0;
+ }
}
-static void
+void
empathy_call_window_fullscreen_show_popup (EmpathyCallWindowFullscreen *self)
{
- g_assert (self->is_fullscreen);
-
gint leave_fullscreen_width, leave_fullscreen_height;
- GdkScreen *screen;
- GdkRectangle fullscreen_rect;
- EmpathyCallWindowFullscreenPriv *priv = GET_PRIV (self);
+ GdkScreen *screen;
+ GdkRectangle fullscreen_rect;
+ EmpathyCallWindowFullscreenPriv *priv = GET_PRIV (self);
+
+ g_assert (self->is_fullscreen);
g_return_if_fail (priv->parent_window != NULL);
@@ -108,30 +110,40 @@ empathy_call_window_fullscreen_show_popup (EmpathyCallWindowFullscreen *self)
return;
if (!gtk_window_is_active (GTK_WINDOW (priv->parent_window)))
- return;
+ return;
priv->popup_creation_in_progress = TRUE;
empathy_call_window_fullscreen_set_cursor_visible (self, TRUE);
- /* 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),
- &fullscreen_rect);
+ /* 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),
+ &fullscreen_rect);
- /* Getting the popup window sizes */
- gtk_window_get_size (GTK_WINDOW (priv->leave_fullscreen_popup),
- &leave_fullscreen_width, &leave_fullscreen_height);
+ /* Getting the popup window sizes */
+ gtk_window_get_size (GTK_WINDOW (priv->leave_fullscreen_popup),
+ &leave_fullscreen_width, &leave_fullscreen_height);
- /* Moving the popup to the top-left corner */
- gtk_window_move (GTK_WINDOW (priv->leave_fullscreen_popup),
- fullscreen_rect.width + fullscreen_rect.x - leave_fullscreen_width,
- fullscreen_rect.y);
+ /* 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)
+ {
+ gtk_window_move (GTK_WINDOW (priv->leave_fullscreen_popup),
+ fullscreen_rect.width + fullscreen_rect.x - leave_fullscreen_width,
+ fullscreen_rect.y);
+
+ }
+ else
+ {
+ gtk_window_move (GTK_WINDOW (priv->leave_fullscreen_popup), fullscreen_rect.x,
+ fullscreen_rect.y);
+ }
gtk_widget_show_all (priv->leave_fullscreen_popup);
empathy_call_window_fullscreen_add_popup_timeout (self);
-
+
priv->popup_creation_in_progress = FALSE;
}
@@ -162,7 +174,7 @@ empathy_call_window_fullscreen_init (EmpathyCallWindowFullscreen *self)
gui = empathy_builder_get_file (filename,
"leave_fullscreen_window", &priv->leave_fullscreen_popup,
"leave_fullscreen_button", &self->leave_fullscreen_button,
- NULL);
+ NULL);
gtk_widget_add_events (priv->leave_fullscreen_popup, GDK_POINTER_MOTION_MASK);
@@ -171,13 +183,11 @@ empathy_call_window_fullscreen_init (EmpathyCallWindowFullscreen *self)
}
static void
-empathy_call_window_fullscreen_class_init (
- EmpathyCallWindowFullscreenClass *empathy_call_window_fullscreen_class)
+empathy_call_window_fullscreen_class_init (EmpathyCallWindowFullscreenClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (empathy_call_window_fullscreen_class);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (empathy_call_window_fullscreen_class,
- sizeof (EmpathyCallWindowFullscreenPriv));
+ g_type_class_add_private (klass, sizeof (EmpathyCallWindowFullscreenPriv));
object_class->dispose = empathy_call_window_fullscreen_dispose;
object_class->finalize = empathy_call_window_fullscreen_finalize;
@@ -192,39 +202,23 @@ empathy_call_window_fullscreen_dispose (GObject *object)
if (priv->dispose_has_run)
return;
- if (priv->parent_window != NULL)
- g_object_unref (priv->parent_window);
- priv->parent_window = NULL;
-
+ priv->dispose_has_run = TRUE;
+
if (priv->leave_fullscreen_popup != NULL)
gtk_widget_destroy (priv->leave_fullscreen_popup);
priv->leave_fullscreen_popup = NULL;
- if (self->leave_fullscreen_button != NULL)
- gtk_widget_destroy (self->leave_fullscreen_button);
- self->leave_fullscreen_button = NULL;
-
if (G_OBJECT_CLASS (empathy_call_window_fullscreen_parent_class)->dispose)
G_OBJECT_CLASS (empathy_call_window_fullscreen_parent_class)->dispose (object);
-
- priv->dispose_has_run = TRUE;
}
void
empathy_call_window_fullscreen_finalize (GObject *object)
{
EmpathyCallWindowFullscreen *self = EMPATHY_CALL_WINDOW_FULLSCREEN (object);
- EmpathyCallWindowFullscreenPriv *priv = GET_PRIV (self);
empathy_call_window_fullscreen_remove_popup_timeout (self);
- if (priv->motion_handler_id != 0)
- {
- g_signal_handler_disconnect (G_OBJECT (priv->video_widget),
- priv->motion_handler_id);
- priv->motion_handler_id = 0;
- }
-
G_OBJECT_CLASS (empathy_call_window_fullscreen_parent_class)->finalize (object);
}
@@ -234,13 +228,13 @@ empathy_call_window_fullscreen_parent_window_notify (GtkWidget *parent_window,
{
EmpathyCallWindowFullscreenPriv *priv = GET_PRIV (fs);
- if (!fs->is_fullscreen)
- return;
+ if (!fs->is_fullscreen)
+ return;
- if (parent_window == GTK_WIDGET (priv->parent_window) &&
- gtk_window_is_active (GTK_WINDOW (parent_window)) == FALSE)
+ if (parent_window == GTK_WIDGET (priv->parent_window) &&
+ !gtk_window_is_active (GTK_WINDOW (parent_window)))
{
- empathy_call_window_fullscreen_hide_popup (fs);
+ empathy_call_window_fullscreen_hide_popup (fs);
empathy_call_window_fullscreen_set_cursor_visible (fs, TRUE);
}
}
@@ -254,56 +248,23 @@ empathy_call_window_fullscreen_new (EmpathyCallWindow *parent_window)
priv->parent_window = parent_window;
g_signal_connect (G_OBJECT (priv->parent_window), "notify::is-active",
- G_CALLBACK (empathy_call_window_fullscreen_parent_window_notify), self);
+ G_CALLBACK (empathy_call_window_fullscreen_parent_window_notify), self);
return self;
}
void
empathy_call_window_fullscreen_set_fullscreen (EmpathyCallWindowFullscreen *fs,
- gboolean sidebar_was_visible,
- gint original_width,
- gint original_height)
-{
- g_return_if_fail (!fs->is_fullscreen);
-
- EmpathyCallWindowFullscreenPriv *priv = GET_PRIV (fs);
-
- empathy_call_window_fullscreen_remove_popup_timeout (fs);
- empathy_call_window_fullscreen_set_cursor_visible (fs, FALSE);
-
- fs->sidebar_was_visible = sidebar_was_visible;
- fs->original_width = original_width;
- fs->original_height = original_height;
-
- if (priv->motion_handler_id == 0 && priv->video_widget != NULL)
- {
- priv->motion_handler_id = g_signal_connect (G_OBJECT (priv->video_widget),
- "motion-notify-event", G_CALLBACK (empathy_call_window_fullscreen_motion_notify),
- fs);
- }
-
- fs->is_fullscreen = TRUE;
-}
-
-void
-empathy_call_window_fullscreen_unset_fullscreen (EmpathyCallWindowFullscreen *fs)
+ gboolean set_fullscreen)
{
- g_return_if_fail (fs->is_fullscreen);
-
- EmpathyCallWindowFullscreenPriv *priv = GET_PRIV (fs);
-
- empathy_call_window_fullscreen_hide_popup (fs);
- empathy_call_window_fullscreen_set_cursor_visible (fs, TRUE);
- if (priv->motion_handler_id != 0)
- {
- g_signal_handler_disconnect (G_OBJECT (priv->video_widget),
- priv->motion_handler_id);
- priv->motion_handler_id = 0;
- }
+ if (set_fullscreen)
+ empathy_call_window_fullscreen_remove_popup_timeout (fs);
+ else
+ empathy_call_window_fullscreen_hide_popup (fs);
- fs->is_fullscreen = FALSE;
+ empathy_call_window_fullscreen_set_cursor_visible (fs, !set_fullscreen);
+ fs->is_fullscreen = set_fullscreen;
}
void
@@ -311,20 +272,5 @@ empathy_call_window_fullscreen_set_video_widget (EmpathyCallWindowFullscreen *fs
GtkWidget *video_widget)
{
EmpathyCallWindowFullscreenPriv *priv = GET_PRIV (fs);
-
priv->video_widget = video_widget;
-
- if (fs->is_fullscreen == TRUE && priv->motion_handler_id == 0) {
- priv->motion_handler_id = g_signal_connect (G_OBJECT (priv->video_widget),
- "motion-notify-event", G_CALLBACK (empathy_call_window_fullscreen_motion_notify),
- fs);
- }
}
-
-static gboolean
-empathy_call_window_fullscreen_motion_notify (GtkWidget *widget,
- GdkEventMotion *event, EmpathyCallWindowFullscreen *self)
-{
- empathy_call_window_fullscreen_show_popup (self);
- return FALSE;
-} \ No newline at end of file