[gnome-photos] embed: Untangle the notify::visible-child & window-mode-changed logic
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos] embed: Untangle the notify::visible-child & window-mode-changed logic
- Date: Wed, 30 Aug 2017 18:05:23 +0000 (UTC)
commit cacf92ffe1ce035f2a974e47ebabcffdb41c8f63
Author: Debarshi Ray <debarshir gnome org>
Date: Fri Aug 25 15:17:04 2017 +0200
embed: Untangle the notify::visible-child & window-mode-changed logic
The purpose of the GtkStack::notify::visible-child handler is to change
the WindowMode when the GtkStackSwitcher is used. That's only possible
with a left-click or tapping the touchscreen.
The ModeController::window-mode-changed handler is meant to do all
that's necessary when the mode changes - setting up the widgets,
saving application state, etc..
So far, both the handlers would be invoked for every mode change
regardless of whether the GtkStackSwitcher was used or not; but the
order in which they ran was determined by the involvement of the
GtkStackSwitcher. That's confusing.
From now on, the photos_embed_notify_visible_child will ignore changes
to the visible child unless it happened due to a left-click or touch
event. The logic to determine whether to hide the searchbar or not has
been moved to photos_embed_window_mode_changed because it is just like
the rest of the window-mode-changed handling code, and has nothing to
do with the GtkStackSwitcher.
https://bugzilla.gnome.org/show_bug.cgi?id=786936
src/photos-embed.c | 49 +++++++++++++++++++++++++++++++++++++++----------
1 files changed, 39 insertions(+), 10 deletions(-)
---
diff --git a/src/photos-embed.c b/src/photos-embed.c
index 5359109..5e76e82 100644
--- a/src/photos-embed.c
+++ b/src/photos-embed.c
@@ -364,10 +364,17 @@ photos_embed_fullscreen_changed (PhotosModeController *mode_cntrlr, gboolean ful
static void
photos_embed_notify_visible_child (PhotosEmbed *self)
{
+ GdkEvent *event = NULL;
GtkWidget *visible_child;
- GVariant *state;
PhotosWindowMode mode = PHOTOS_WINDOW_MODE_NONE;
+ event = gtk_get_current_event ();
+ if (event == NULL)
+ goto out;
+
+ if (event->type != GDK_BUTTON_RELEASE && event->type != GDK_TOUCH_END)
+ goto out;
+
visible_child = gtk_stack_get_visible_child (GTK_STACK (self->stack));
if (visible_child == self->overview)
mode = PHOTOS_WINDOW_MODE_OVERVIEW;
@@ -377,17 +384,12 @@ photos_embed_notify_visible_child (PhotosEmbed *self)
mode = PHOTOS_WINDOW_MODE_FAVORITES;
if (mode == PHOTOS_WINDOW_MODE_NONE)
- return;
-
- if (!photos_main_toolbar_is_focus (PHOTOS_MAIN_TOOLBAR (self->toolbar)))
- {
- photos_embed_block_search_changed (self);
- state = g_variant_new ("b", FALSE);
- g_action_change_state (self->search_action, state);
- photos_embed_unblock_search_changed (self);
- }
+ goto out;
photos_mode_controller_set_window_mode (self->mode_cntrlr, mode);
+
+ out:
+ g_clear_pointer (&event, (GDestroyNotify) gdk_event_free);
}
@@ -557,6 +559,33 @@ photos_embed_window_mode_changed (PhotosModeController *mode_cntrlr,
{
PhotosEmbed *self = PHOTOS_EMBED (user_data);
+ switch (mode)
+ {
+ case PHOTOS_WINDOW_MODE_COLLECTIONS:
+ case PHOTOS_WINDOW_MODE_FAVORITES:
+ case PHOTOS_WINDOW_MODE_OVERVIEW:
+ if (!photos_main_toolbar_is_focus (PHOTOS_MAIN_TOOLBAR (self->toolbar)))
+ {
+ GVariant *state;
+
+ photos_embed_block_search_changed (self);
+ state = g_variant_new ("b", FALSE);
+ g_action_change_state (self->search_action, state);
+ photos_embed_unblock_search_changed (self);
+ }
+ break;
+
+ case PHOTOS_WINDOW_MODE_EDIT:
+ case PHOTOS_WINDOW_MODE_PREVIEW:
+ case PHOTOS_WINDOW_MODE_SEARCH:
+ break;
+
+ case PHOTOS_WINDOW_MODE_NONE:
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+
photos_main_toolbar_reset_toolbar_mode (PHOTOS_MAIN_TOOLBAR (self->toolbar));
switch (mode)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]