Commit ee3a5edb authored by Debarshi Ray's avatar Debarshi Ray
Browse files

Merge PhotosModeController into PhotosItemManager

The legal ways to request a state change are now clearer and stricter
than before:
 - You cannot move to the preview directly. You must set a non-NULL
   active item to do that.
 - You cannot set a NULL active item to go back from the preview. You
   must use the go_back method for that.

We assert pre and post conditions for state transitions to enforce
these rules and catch programmer errors.

Earlier, the mode would be updated after "load-started" was emitted.
That is no longer the case. Signals are emitted only after the state
change is complete. So adjust accordingly.

Stop abusing "load-started" to do things that should be performed in
the "window-mode-changed" handler. ie. code that should not be run
while navigating within the preview.

Untangle and consolidate the search save and restore logic. Instead of
using hard to read and racy conditions in a
PhotosItemManager::active-changed handler, we have now split it into
the "window-mode-changed" and "active-collection-changed" handlers.
This is much easier to read and understand. The logic to relax the
search criteria when viewing a collection has now been moved to
PhotosEmbed from PhotosOverviewSearchbar. Otherwise, the
"active-collection-changed" handlers in these two classes would stomp
on each other.

Even though the state represented by these two classes are tightly
coupled (preview must have an active item, and you can't be in
overview with an active item, etc.), ItemManager sounds like a
misnomer for the purposes served by the ModeController. Due to my
inability to think of a better name, the ModeController type is now an
alias for ItemManager and we have retained the method names.

https://bugzilla.gnome.org/show_bug.cgi?id=737071
parent ebbace85
......@@ -133,8 +133,6 @@ gnome_photos_SOURCES = \
photos-main-window.h \
photos-media-server-item.c \
photos-media-server-item.h \
photos-mode-controller.c \
photos-mode-controller.h \
photos-notification-manager.c \
photos-notification-manager.h \
photos-offset-collections-controller.c \
......@@ -397,7 +395,7 @@ stamp-photos-enums.h: photos-enums.h.template
$(AM_V_GEN) ( \
( glib-mkenums \
--template $(srcdir)/photos-enums.h.template \
$(srcdir)/photos-mode-controller.h \
$(srcdir)/photos-item-manager.h \
$(srcdir)/photos-preview-nav-buttons.h \
) >> xgen-etbh \
&& ( cmp -s xgen-etbh photos-enums.h || cp xgen-etbh photos-enums.h ) \
......@@ -409,7 +407,7 @@ photos-enums.c: photos-enums.c.template
$(AM_V_GEN) ( \
( glib-mkenums \
--template $(srcdir)/photos-enums.c.template \
$(srcdir)/photos-mode-controller.h \
$(srcdir)/photos-item-manager.h \
$(srcdir)/photos-preview-nav-buttons.h \
) >> xgen-etbc \
&& ( cmp -s xgen-etbc photos-enums.c || cp xgen-etbc photos-enums.c ) \
......
......@@ -43,7 +43,6 @@
#include "photos-gom-miner.h"
#include "photos-item-manager.h"
#include "photos-main-window.h"
#include "photos-mode-controller.h"
#include "photos-properties-dialog.h"
#include "photos-query.h"
#include "photos-resources.h"
......@@ -82,7 +81,6 @@ struct _PhotosApplicationPrivate
GSimpleAction *remote_display_action;
GtkWidget *main_window;
PhotosCameraCache *camera_cache;
PhotosModeController *mode_cntrlr;
PhotosSearchContextState *state;
PhotosSearchProvider *search_provider;
TrackerExtractPriority *extract_priority;
......@@ -282,7 +280,7 @@ photos_application_can_fullscreen_changed (PhotosApplication *self)
PhotosApplicationPrivate *priv = self->priv;
gboolean can_fullscreen;
can_fullscreen = photos_mode_controller_get_can_fullscreen (priv->mode_cntrlr);
can_fullscreen = photos_mode_controller_get_can_fullscreen (priv->state->mode_cntrlr);
g_simple_action_set_enabled (priv->fs_action, can_fullscreen);
}
......@@ -292,7 +290,7 @@ photos_application_fullscreen (PhotosApplication *self, GVariant *parameter)
{
PhotosApplicationPrivate *priv = self->priv;
photos_mode_controller_toggle_fullscreen (priv->mode_cntrlr);
photos_mode_controller_toggle_fullscreen (priv->state->mode_cntrlr);
}
......@@ -312,7 +310,7 @@ photos_application_launch_search (PhotosApplication *self, const gchar* const *t
gchar *str;
photos_application_create_window (self);
photos_mode_controller_set_window_mode (priv->mode_cntrlr, PHOTOS_WINDOW_MODE_OVERVIEW);
photos_mode_controller_set_window_mode (priv->state->mode_cntrlr, PHOTOS_WINDOW_MODE_OVERVIEW);
str = g_strjoinv (" ", (gchar **) terms);
photos_search_controller_set_string (priv->state->srch_cntrlr, str);
......@@ -710,7 +708,7 @@ photos_application_activate (GApplication *application)
if (priv->main_window == NULL)
{
photos_application_create_window (self);
photos_mode_controller_set_window_mode (priv->mode_cntrlr, PHOTOS_WINDOW_MODE_OVERVIEW);
photos_mode_controller_set_window_mode (priv->state->mode_cntrlr, PHOTOS_WINDOW_MODE_OVERVIEW);
}
gtk_window_present_with_time (GTK_WINDOW (priv->main_window), priv->activation_timestamp);
......@@ -882,8 +880,6 @@ photos_application_startup (GApplication *application)
*/
priv->camera_cache = photos_camera_cache_dup_singleton ();
priv->mode_cntrlr = photos_mode_controller_dup_singleton ();
action = g_simple_action_new ("about", NULL);
g_signal_connect_swapped (action, "activate", G_CALLBACK (photos_application_about), self);
g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (action));
......@@ -893,7 +889,7 @@ photos_application_startup (GApplication *application)
g_signal_connect_swapped (priv->fs_action, "activate", G_CALLBACK (photos_application_fullscreen), self);
g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (priv->fs_action));
g_signal_connect_swapped (priv->mode_cntrlr,
g_signal_connect_swapped (priv->state->mode_cntrlr,
"can-fullscreen-changed",
G_CALLBACK (photos_application_can_fullscreen_changed),
self);
......@@ -972,7 +968,7 @@ photos_application_startup (GApplication *application)
g_signal_connect_swapped (priv->set_ss_action, "activate", G_CALLBACK (photos_application_set_bg_common), self);
g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (priv->set_ss_action));
g_signal_connect_swapped (priv->mode_cntrlr,
g_signal_connect_swapped (priv->state->mode_cntrlr,
"window-mode-changed",
G_CALLBACK (photos_application_window_mode_changed),
self);
......@@ -1050,7 +1046,6 @@ photos_application_dispose (GObject *object)
g_clear_object (&priv->set_bg_action);
g_clear_object (&priv->set_ss_action);
g_clear_object (&priv->camera_cache);
g_clear_object (&priv->mode_cntrlr);
g_clear_object (&priv->extract_priority);
if (priv->state != NULL)
......
/*
* Photos - access, organize and share your photos on GNOME
* Copyright © 2013 Intel Corporation. All rights reserved.
* Copyright © 2013, 2014 Red Hat, Inc.
* Copyright © 2013, 2014, 2015 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
......@@ -33,8 +33,8 @@
#include "photos-dlna-renderer.h"
#include "photos-dlna-renderers-manager.h"
#include "photos-icons.h"
#include "photos-item-manager.h"
#include "photos-local-item.h"
#include "photos-mode-controller.h"
#include "photos-remote-display-manager.h"
#include "photos-search-context.h"
......@@ -233,7 +233,7 @@ photos_dlna_renderers_dialog_init (PhotosDlnaRenderersDialog *self)
priv->item_mngr = g_object_ref (state->item_mngr);
priv->renderers_mngr = photos_dlna_renderers_manager_dup_singleton ();
priv->remote_mngr = photos_remote_display_manager_dup_singleton ();
priv->mode_cntrlr = photos_mode_controller_dup_singleton ();
priv->mode_cntrlr = g_object_ref (state->mode_cntrlr);
gtk_widget_init_template (GTK_WIDGET (self));
......
......@@ -35,7 +35,6 @@
#include "photos-embed.h"
#include "photos-filterable.h"
#include "photos-item-manager.h"
#include "photos-mode-controller.h"
#include "photos-notification-manager.h"
#include "photos-search-controller.h"
#include "photos-selection-toolbar.h"
......@@ -202,91 +201,11 @@ photos_embed_activate_result (PhotosEmbed *self)
}
static void
photos_embed_prepare_for_preview (PhotosEmbed *self)
{
PhotosEmbedPrivate *priv = self->priv;
/* TODO: SearchController,
* ErrorHandler
*/
photos_spinner_box_stop (PHOTOS_SPINNER_BOX (priv->spinner_box));
photos_preview_view_set_node (PHOTOS_PREVIEW_VIEW (priv->preview), NULL);
gtk_stack_set_visible_child_name (GTK_STACK (priv->stack), "preview");
}
static void
photos_embed_load_finished (PhotosEmbed *self, PhotosBaseItem *item, GeglNode *node)
{
PhotosEmbedPrivate *priv = self->priv;
photos_main_toolbar_set_cancellable (PHOTOS_MAIN_TOOLBAR (priv->toolbar), NULL);
photos_embed_clear_load_timer (self);
photos_spinner_box_stop (PHOTOS_SPINNER_BOX (priv->spinner_box));
if (node == NULL)
return;
photos_preview_view_set_node (PHOTOS_PREVIEW_VIEW (priv->preview), node);
/* TODO: set toolbar model */
}
static gboolean
photos_embed_load_show_timeout (gpointer user_data)
{
PhotosEmbed *self = PHOTOS_EMBED (user_data);
PhotosEmbedPrivate *priv = self->priv;
priv->load_show_id = 0;
photos_spinner_box_start (PHOTOS_SPINNER_BOX (priv->spinner_box));
g_object_unref (self);
return G_SOURCE_REMOVE;
}
static void
photos_embed_load_started (PhotosEmbed *self, PhotosBaseItem *item, GCancellable *cancellable)
{
PhotosEmbedPrivate *priv = self->priv;
PhotosWindowMode mode;
mode = photos_mode_controller_get_window_mode (priv->mode_cntrlr);
/* This is not needed when:
* - activated from the search provider
* - already in the preview and navigating using the buttons
*/
if (mode == PHOTOS_WINDOW_MODE_COLLECTIONS
|| mode == PHOTOS_WINDOW_MODE_FAVORITES
|| mode == PHOTOS_WINDOW_MODE_OVERVIEW
|| mode == PHOTOS_WINDOW_MODE_SEARCH)
{
GtkListStore *model;
GtkTreePath *current_path;
GtkWidget *view_container;
view_container = photos_embed_get_view_container_from_mode (self, mode);
current_path = photos_view_container_get_current_path (PHOTOS_VIEW_CONTAINER (view_container));
model = photos_view_container_get_model (PHOTOS_VIEW_CONTAINER (view_container));
photos_preview_view_set_model (PHOTOS_PREVIEW_VIEW (priv->preview), GTK_TREE_MODEL (model), current_path);
}
photos_mode_controller_set_window_mode (priv->mode_cntrlr, PHOTOS_WINDOW_MODE_PREVIEW);
photos_main_toolbar_set_cancellable (PHOTOS_MAIN_TOOLBAR (priv->toolbar), cancellable);
photos_embed_clear_load_timer (self);
self->priv->load_show_id = g_timeout_add (400, photos_embed_load_show_timeout, g_object_ref (self));
}
static void
photos_embed_restore_search (PhotosEmbed *self)
{
PhotosEmbedPrivate *priv = self->priv;
GVariant *state;
if (!priv->search_state.saved)
return;
......@@ -297,6 +216,9 @@ photos_embed_restore_search (PhotosEmbed *self)
priv->search_state.saved = FALSE;
photos_embed_clear_search (self);
state = g_variant_new ("b", TRUE);
g_action_change_state (priv->search_action, state);
}
......@@ -304,6 +226,7 @@ static void
photos_embed_save_search (PhotosEmbed *self)
{
PhotosEmbedPrivate *priv = self->priv;
GVariant *state;
if (priv->search_state.saved)
return;
......@@ -314,6 +237,9 @@ photos_embed_save_search (PhotosEmbed *self)
priv->search_state.search_type = g_object_ref (photos_base_manager_get_active_object (priv->srch_mngr));
priv->search_state.str = g_strdup (photos_search_controller_get_string (priv->srch_cntrlr));
priv->search_state.saved = TRUE;
state = g_variant_new ("b", FALSE);
g_action_change_state (priv->search_action, state);
}
......@@ -344,18 +270,14 @@ photos_embed_tracker_controllers_set_frozen (PhotosEmbed *self, gboolean frozen)
static void
photos_embed_active_changed (PhotosBaseManager *manager, GObject *object, gpointer user_data)
photos_embed_prepare_for_preview (PhotosEmbed *self, PhotosWindowMode old_mode)
{
PhotosEmbed *self = PHOTOS_EMBED (user_data);
PhotosEmbedPrivate *priv = self->priv;
PhotosBaseItem *active_collection;
PhotosWindowMode mode;
GObject *active_item;
GVariant *state;
gboolean show_search;
active_collection = photos_item_manager_get_active_collection (PHOTOS_ITEM_MANAGER (priv->item_mngr));
active_item = photos_base_manager_get_active_object (priv->item_mngr);
/* TODO: SearchController,
* ErrorHandler
*/
/* We want to freeze before saving the search state and to thaw
* after restoring it. We could thaw it earlier too, but that would
......@@ -363,28 +285,106 @@ photos_embed_active_changed (PhotosBaseManager *manager, GObject *object, gpoint
*
* Note that we don't want to freeze when showing a collection.
*/
if (active_item != (GObject *) active_collection) /* active_item != NULL */
photos_embed_tracker_controllers_set_frozen (self, TRUE);
photos_embed_tracker_controllers_set_frozen (self, TRUE);
/* Hide the search bar when we are moving from the search to the
* preview or collection viewin. Restore it when we are back.
*/
active_collection = photos_item_manager_get_active_collection (PHOTOS_ITEM_MANAGER (priv->item_mngr));
if (old_mode == PHOTOS_WINDOW_MODE_SEARCH && active_collection == NULL)
photos_embed_save_search (self);
/* This is not needed when activated from the search provider. */
if (old_mode != PHOTOS_WINDOW_MODE_NONE)
{
GtkListStore *model;
GtkTreePath *current_path;
GtkWidget *view_container;
view_container = photos_embed_get_view_container_from_mode (self, old_mode);
current_path = photos_view_container_get_current_path (PHOTOS_VIEW_CONTAINER (view_container));
model = photos_view_container_get_model (PHOTOS_VIEW_CONTAINER (view_container));
photos_preview_view_set_model (PHOTOS_PREVIEW_VIEW (priv->preview), GTK_TREE_MODEL (model), current_path);
}
photos_spinner_box_stop (PHOTOS_SPINNER_BOX (priv->spinner_box));
photos_preview_view_set_node (PHOTOS_PREVIEW_VIEW (priv->preview), NULL);
gtk_stack_set_visible_child_name (GTK_STACK (priv->stack), "preview");
}
static void
photos_embed_load_finished (PhotosEmbed *self, PhotosBaseItem *item, GeglNode *node)
{
PhotosEmbedPrivate *priv = self->priv;
photos_main_toolbar_set_cancellable (PHOTOS_MAIN_TOOLBAR (priv->toolbar), NULL);
photos_embed_clear_load_timer (self);
photos_spinner_box_stop (PHOTOS_SPINNER_BOX (priv->spinner_box));
if (node == NULL)
return;
photos_preview_view_set_node (PHOTOS_PREVIEW_VIEW (priv->preview), node);
/* TODO: set toolbar model */
}
static gboolean
photos_embed_load_show_timeout (gpointer user_data)
{
PhotosEmbed *self = PHOTOS_EMBED (user_data);
PhotosEmbedPrivate *priv = self->priv;
priv->load_show_id = 0;
photos_spinner_box_start (PHOTOS_SPINNER_BOX (priv->spinner_box));
g_object_unref (self);
return G_SOURCE_REMOVE;
}
static void
photos_embed_load_started (PhotosEmbed *self, PhotosBaseItem *item, GCancellable *cancellable)
{
PhotosEmbedPrivate *priv = self->priv;
photos_main_toolbar_set_cancellable (PHOTOS_MAIN_TOOLBAR (priv->toolbar), cancellable);
photos_embed_clear_load_timer (self);
self->priv->load_show_id = g_timeout_add (400, photos_embed_load_show_timeout, g_object_ref (self));
}
static void
photos_embed_active_collection_changed (PhotosBaseManager *manager, PhotosBaseItem *collection, gpointer user_data)
{
PhotosEmbed *self = PHOTOS_EMBED (user_data);
PhotosEmbedPrivate *priv = self->priv;
PhotosWindowMode mode;
mode = photos_mode_controller_get_window_mode (priv->mode_cntrlr);
show_search = (mode == PHOTOS_WINDOW_MODE_PREVIEW && active_item == NULL && active_collection == NULL)
|| (mode == PHOTOS_WINDOW_MODE_SEARCH && active_item == NULL);
if (mode != PHOTOS_WINDOW_MODE_SEARCH)
return;
if (show_search)
photos_embed_restore_search (self);
if (collection == NULL)
{
photos_embed_restore_search (self);
}
else
photos_embed_save_search (self);
{
PhotosSearchType *search_type;
const gchar *str;
const gchar *id;
state = g_variant_new ("b", show_search);
g_action_change_state (priv->search_action, state);
photos_embed_save_search (self);
/* See above. */
if (active_item == (GObject *) active_collection)
photos_embed_tracker_controllers_set_frozen (self, FALSE);
search_type = PHOTOS_SEARCH_TYPE (photos_base_manager_get_active_object (priv->srch_mngr));
str = photos_search_controller_get_string (priv->srch_cntrlr);
id = photos_filterable_get_id (PHOTOS_FILTERABLE (search_type));
if (g_strcmp0 (str, "") != 0 || g_strcmp0 (id, "all") != 0)
{
photos_base_manager_set_active_object_by_id (priv->srch_mngr, "all");
photos_search_controller_set_string (priv->srch_cntrlr, "");
}
}
}
......@@ -426,44 +426,60 @@ photos_embed_notify_visible_child (PhotosEmbed *self)
static void
photos_embed_prepare_for_collections (PhotosEmbed *self)
photos_embed_prepare_for_collections (PhotosEmbed *self, PhotosWindowMode old_mode)
{
PhotosEmbedPrivate *priv = self->priv;
photos_base_manager_set_active_object (priv->item_mngr, NULL);
if (old_mode == PHOTOS_WINDOW_MODE_PREVIEW)
photos_embed_tracker_controllers_set_frozen (self, FALSE);
photos_spinner_box_stop (PHOTOS_SPINNER_BOX (priv->spinner_box));
gtk_stack_set_visible_child_name (GTK_STACK (priv->stack), "collections");
}
static void
photos_embed_prepare_for_favorites (PhotosEmbed *self)
photos_embed_prepare_for_favorites (PhotosEmbed *self, PhotosWindowMode old_mode)
{
PhotosEmbedPrivate *priv = self->priv;
photos_base_manager_set_active_object (priv->item_mngr, NULL);
if (old_mode == PHOTOS_WINDOW_MODE_PREVIEW)
photos_embed_tracker_controllers_set_frozen (self, FALSE);
photos_spinner_box_stop (PHOTOS_SPINNER_BOX (priv->spinner_box));
gtk_stack_set_visible_child_name (GTK_STACK (priv->stack), "favorites");
}
static void
photos_embed_prepare_for_overview (PhotosEmbed *self)
photos_embed_prepare_for_overview (PhotosEmbed *self, PhotosWindowMode old_mode)
{
PhotosEmbedPrivate *priv = self->priv;
photos_base_manager_set_active_object (priv->item_mngr, NULL);
if (old_mode == PHOTOS_WINDOW_MODE_PREVIEW)
photos_embed_tracker_controllers_set_frozen (self, FALSE);
photos_spinner_box_stop (PHOTOS_SPINNER_BOX (priv->spinner_box));
gtk_stack_set_visible_child_name (GTK_STACK (priv->stack), "overview");
}
static void
photos_embed_prepare_for_search (PhotosEmbed *self)
photos_embed_prepare_for_search (PhotosEmbed *self, PhotosWindowMode old_mode)
{
PhotosEmbedPrivate *priv = self->priv;
photos_base_manager_set_active_object (priv->item_mngr, NULL);
if (old_mode == PHOTOS_WINDOW_MODE_PREVIEW)
{
PhotosBaseItem *active_collection;
active_collection = photos_item_manager_get_active_collection (PHOTOS_ITEM_MANAGER (priv->item_mngr));
if (active_collection == NULL)
photos_embed_restore_search (self);
photos_embed_tracker_controllers_set_frozen (self, FALSE);
}
photos_spinner_box_stop (PHOTOS_SPINNER_BOX (priv->spinner_box));
gtk_stack_set_visible_child_name (GTK_STACK (priv->stack), "search");
}
......@@ -564,23 +580,23 @@ photos_embed_window_mode_changed (PhotosModeController *mode_cntrlr,
switch (mode)
{
case PHOTOS_WINDOW_MODE_COLLECTIONS:
photos_embed_prepare_for_collections (self);
photos_embed_prepare_for_collections (self, old_mode);
goto set_toolbar_model;
case PHOTOS_WINDOW_MODE_FAVORITES:
photos_embed_prepare_for_favorites (self);
photos_embed_prepare_for_favorites (self, old_mode);
goto set_toolbar_model;
case PHOTOS_WINDOW_MODE_OVERVIEW:
photos_embed_prepare_for_overview (self);
photos_embed_prepare_for_overview (self, old_mode);
goto set_toolbar_model;
case PHOTOS_WINDOW_MODE_PREVIEW:
photos_embed_prepare_for_preview (self);
photos_embed_prepare_for_preview (self, old_mode);
break;
case PHOTOS_WINDOW_MODE_SEARCH:
photos_embed_prepare_for_search (self);
photos_embed_prepare_for_search (self, old_mode);
goto set_toolbar_model;
case PHOTOS_WINDOW_MODE_NONE:
......@@ -719,7 +735,7 @@ photos_embed_init (PhotosEmbed *self)
self,
G_CONNECT_SWAPPED);
priv->mode_cntrlr = photos_mode_controller_dup_singleton ();
priv->mode_cntrlr = g_object_ref (state->mode_cntrlr);
g_signal_connect_object (priv->mode_cntrlr,
"window-mode-changed",
G_CALLBACK (photos_embed_window_mode_changed),
......@@ -739,7 +755,11 @@ photos_embed_init (PhotosEmbed *self)
G_CONNECT_SWAPPED);
priv->item_mngr = g_object_ref (state->item_mngr);
g_signal_connect_object (priv->item_mngr, "active-changed", G_CALLBACK (photos_embed_active_changed), self, 0);
g_signal_connect_object (priv->item_mngr,
"active-collection-changed",
G_CALLBACK (photos_embed_active_collection_changed),
self,
0);
g_signal_connect_object (priv->item_mngr,
"load-finished",
G_CALLBACK (photos_embed_load_finished),
......
/*
* Photos - access, organize and share your photos on GNOME
* Copyright © 2012, 2013, 2014 Red Hat, Inc.
* Copyright © 2012, 2013, 2014, 2015 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
......@@ -27,7 +27,7 @@
#include <gtk/gtk.h>
#include "photos-mode-controller.h"
#include "photos-item-manager.h"
G_BEGIN_DECLS
......
......@@ -3,7 +3,7 @@
#include "config.h"
#include "photos-enums.h"
#include "photos-mode-controller.h"
#include "photos-item-manager.h"
#include "photos-preview-nav-buttons.h"
/*** END file-header ***/
......
......@@ -29,9 +29,11 @@
#include <glib.h>
#include <tracker-sparql.h>
#include "photos-enums.h"
#include "photos-filterable.h"
#include "photos-item-manager.h"
#include "photos-local-item.h"
#include "photos-marshalers.h"
#include "photos-query.h"
#include "photos-search-context.h"
#include "photos-single-item-job.h"
......@@ -47,8 +49,11 @@ struct _PhotosItemManager
GHashTable *collections;
GIOExtensionPoint *extension_point;
GQueue *collection_path;
GQueue *history;
PhotosBaseItem *active_collection;
PhotosTrackerChangeMonitor *monitor;
PhotosWindowMode mode;
gboolean fullscreen;
};
struct _PhotosItemManagerClass
......@@ -57,15 +62,21 @@ struct _PhotosItemManagerClass
/* signals */
void (*active_collection_changed) (PhotosItemManager *self, PhotosBaseItem *collection);
void (*can_fullscreen_changed) (PhotosItemManager *self);
void (*fullscreen_changed) (PhotosItemManager *self, gboolean fullscreen);
void (*load_finished) (PhotosItemManager *self, PhotosBaseItem *item, GeglNode *node);
void (*load_started) (PhotosItemManager *self, PhotosBaseItem *item, GCancellable *cancellable);
void (*window_mode_changed) (PhotosItemManager *self, PhotosWindowMode mode, PhotosWindowMode old_mode);
};
enum
{
ACTIVE_COLLECTION_CHANGED,
CAN_FULLSCREEN_CHANGED,
FULLSCREEN_CHANGED,
LOAD_FINISHED,
LOAD_STARTED,
WINDOW_MODE_CHANGED,
LAST_SIGNAL
};
......@@ -202,6 +213,14 @@ photos_item_manager_collection_path_free_foreach (gpointer data, gpointer user_d
}
static void
photos_item_manager_collection_path_free (PhotosItemManager *self)
{
g_queue_foreach (self->collection_path, photos_item_manager_collection_path_free_foreach, NULL);
g_queue_free (self->collection_path);
}
static gchar *
photos_item_manager_get_where (PhotosBaseManager *mngr, gint flags)
{
......@@ -260,47 +279,66 @@ photos_item_manager_remove_object_by_id (PhotosBaseManager *mngr, const gchar *i
}
static void
photos_item_manager_update_fullscreen (PhotosItemManager *self)
{
/* Should be called after priv->mode has been updated. */
if (!photos_mode_controller_get_can_fullscreen (self) && self->fullscreen)
photos_mode_controller_set_fullscreen (self, FALSE);
g_signal_emit (self, signals[CAN_FULLSCREEN_CHANGED], 0);
}