[gnome-photos/gnome-3-16] mode-controller: Clean up the fullscreen code
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/gnome-3-16] mode-controller: Clean up the fullscreen code
- Date: Wed, 7 Oct 2015 13:32:21 +0000 (UTC)
commit e5ac396edd567d85f04b6c63c1624d24a0df44c9
Author: Debarshi Ray <debarshir gnome org>
Date: Tue Oct 6 17:53:35 2015 +0200
mode-controller: Clean up the fullscreen code
Ensure that the fullscreen logic runs after priv->mode has been updated
so that there are no state changes between can-fullscreen-changed and
window-mode-changed.
This changes the current requirement that set_fullscreen has to be used
before the mode is updated, which I found to be confusing, and we don't
need a separate priv->can_fullscreen variable any more.
https://bugzilla.gnome.org/show_bug.cgi?id=756131
src/photos-mode-controller.c | 38 +++++++++++---------------------------
src/photos-mode-controller.h | 3 ---
2 files changed, 11 insertions(+), 30 deletions(-)
---
diff --git a/src/photos-mode-controller.c b/src/photos-mode-controller.c
index b2a0e9c..a98e7d1 100644
--- a/src/photos-mode-controller.c
+++ b/src/photos-mode-controller.c
@@ -37,7 +37,6 @@ struct _PhotosModeControllerPrivate
GQueue *history;
PhotosWindowMode mode;
gboolean fullscreen;
- gboolean can_fullscreen;
};
enum
@@ -54,10 +53,15 @@ static guint signals[LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE_WITH_PRIVATE (PhotosModeController, photos_mode_controller, G_TYPE_OBJECT);
-static gboolean
-photos_mode_controller_can_fullscreen_policy (PhotosModeController *self, PhotosWindowMode mode)
+static void
+photos_mode_controller_update_fullscreen (PhotosModeController *self)
{
- return mode == PHOTOS_WINDOW_MODE_PREVIEW;
+ PhotosModeControllerPrivate *priv = self->priv;
+
+ if (!photos_mode_controller_get_can_fullscreen (self) && priv->fullscreen)
+ photos_mode_controller_set_fullscreen (self, FALSE);
+
+ g_signal_emit (self, signals[CAN_FULLSCREEN_CHANGED], 0);
}
@@ -101,7 +105,6 @@ photos_mode_controller_init (PhotosModeController *self)
priv->history = g_queue_new ();
priv->mode = PHOTOS_WINDOW_MODE_NONE;
priv->fullscreen = FALSE;
- priv->can_fullscreen = FALSE;
}
@@ -161,7 +164,7 @@ photos_mode_controller_dup_singleton (void)
gboolean
photos_mode_controller_get_can_fullscreen (PhotosModeController *self)
{
- return self->priv->can_fullscreen;
+ return self->priv->mode == PHOTOS_WINDOW_MODE_PREVIEW;
}
@@ -185,7 +188,6 @@ photos_mode_controller_go_back (PhotosModeController *self)
PhotosModeControllerPrivate *priv = self->priv;
PhotosWindowMode old_mode;
PhotosWindowMode tmp;
- gboolean policy;
if (g_queue_is_empty (priv->history))
return;
@@ -202,14 +204,12 @@ photos_mode_controller_go_back (PhotosModeController *self)
if (old_mode == PHOTOS_WINDOW_MODE_NONE)
return;
- policy = photos_mode_controller_can_fullscreen_policy (self, old_mode);
- photos_mode_controller_set_can_fullscreen (self, policy);
-
/* Swap the old and current modes */
tmp = old_mode;
old_mode = priv->mode;
priv->mode = tmp;
+ photos_mode_controller_update_fullscreen (self);
g_signal_emit (self, signals[WINDOW_MODE_CHANGED], 0, priv->mode, old_mode);
}
@@ -222,19 +222,6 @@ photos_mode_controller_toggle_fullscreen (PhotosModeController *self)
void
-photos_mode_controller_set_can_fullscreen (PhotosModeController *self, gboolean can_fullscreen)
-{
- PhotosModeControllerPrivate *priv = self->priv;
-
- priv->can_fullscreen = can_fullscreen;
- if (!priv->can_fullscreen && priv->fullscreen)
- photos_mode_controller_set_fullscreen (self, FALSE);
-
- g_signal_emit (self, signals[CAN_FULLSCREEN_CHANGED], 0);
-}
-
-
-void
photos_mode_controller_set_fullscreen (PhotosModeController *self, gboolean fullscreen)
{
PhotosModeControllerPrivate *priv = self->priv;
@@ -252,18 +239,15 @@ photos_mode_controller_set_window_mode (PhotosModeController *self, PhotosWindow
{
PhotosModeControllerPrivate *priv = self->priv;
PhotosWindowMode old_mode;
- gboolean policy;
old_mode = priv->mode;
if (old_mode == mode)
return;
- policy = photos_mode_controller_can_fullscreen_policy (self, mode);
- photos_mode_controller_set_can_fullscreen (self, policy);
-
g_queue_push_head (priv->history, GINT_TO_POINTER (old_mode));
priv->mode = mode;
+ photos_mode_controller_update_fullscreen (self);
g_signal_emit (self, signals[WINDOW_MODE_CHANGED], 0, priv->mode, old_mode);
}
diff --git a/src/photos-mode-controller.h b/src/photos-mode-controller.h
index 6eb13af..91cc9da 100644
--- a/src/photos-mode-controller.h
+++ b/src/photos-mode-controller.h
@@ -94,9 +94,6 @@ void photos_mode_controller_go_back (PhotosMode
void photos_mode_controller_toggle_fullscreen (PhotosModeController *self);
-void photos_mode_controller_set_can_fullscreen (PhotosModeController *self,
- gboolean can_fullscreen);
-
void photos_mode_controller_set_fullscreen (PhotosModeController *self,
gboolean fullscreen);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]