[gnome-photos/wip/foo: 4/8] Add a new collections mode
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/foo: 4/8] Add a new collections mode
- Date: Mon, 8 Apr 2013 23:10:12 +0000 (UTC)
commit 3113f12e5aedbb370630b16226682e62bb173888
Author: Debarshi Ray <debarshir gnome org>
Date: Mon Apr 8 22:14:03 2013 +0200
Add a new collections mode
This is presented to the user as "Albums".
src/photos-application.c | 4 +++-
src/photos-embed.c | 32 +++++++++++++++++++++++++++++++-
src/photos-load-more-button.c | 7 ++++++-
src/photos-main-toolbar.c | 20 +++++++++++++++++++-
src/photos-mode-controller.c | 6 ++++--
src/photos-mode-controller.h | 3 ++-
src/photos-query-builder.c | 5 ++++-
src/photos-view-container.c | 9 ++++++++-
src/photos-view-model.c | 18 +++++++++++++++---
9 files changed, 92 insertions(+), 12 deletions(-)
---
diff --git a/src/photos-application.c b/src/photos-application.c
index ec0a752..2698c3f 100644
--- a/src/photos-application.c
+++ b/src/photos-application.c
@@ -159,7 +159,9 @@ photos_application_window_mode_changed (PhotosApplication *self, PhotosWindowMod
PhotosApplicationPrivate *priv = self->priv;
gboolean enable;
- enable = (mode == PHOTOS_WINDOW_MODE_OVERVIEW || mode == PHOTOS_WINDOW_MODE_FAVORITES);
+ enable = (mode == PHOTOS_WINDOW_MODE_OVERVIEW
+ || mode == PHOTOS_WINDOW_MODE_COLLECTIONS
+ || mode == PHOTOS_WINDOW_MODE_FAVORITES);
g_simple_action_set_enabled (priv->sel_all_action, enable);
g_simple_action_set_enabled (priv->sel_none_action, enable);
diff --git a/src/photos-embed.c b/src/photos-embed.c
index 7c841bc..701f2c9 100644
--- a/src/photos-embed.c
+++ b/src/photos-embed.c
@@ -49,6 +49,7 @@
struct _PhotosEmbedPrivate
{
GCancellable *loader_cancellable;
+ GtkWidget *collections;
GtkWidget *error_box;
GtkWidget *favorites;
GtkWidget *indexing_ntfctn;
@@ -164,6 +165,10 @@ photos_embed_restore_last_page (PhotosEmbed *self)
mode = photos_mode_controller_get_window_mode (priv->mode_cntrlr);
switch (mode)
{
+ case PHOTOS_WINDOW_MODE_COLLECTIONS:
+ page = "collections";
+ break;
+
case PHOTOS_WINDOW_MODE_FAVORITES:
page = "favorites";
break;
@@ -246,12 +251,32 @@ photos_embed_notify_visible_child (PhotosEmbed *self)
visible_child = gd_stack_get_visible_child (GD_STACK (priv->stack));
if (visible_child == priv->overview)
photos_mode_controller_set_window_mode (priv->mode_cntrlr, PHOTOS_WINDOW_MODE_OVERVIEW);
+ else if (visible_child == priv->collections)
+ photos_mode_controller_set_window_mode (priv->mode_cntrlr, PHOTOS_WINDOW_MODE_COLLECTIONS);
else if (visible_child == priv->favorites)
photos_mode_controller_set_window_mode (priv->mode_cntrlr, PHOTOS_WINDOW_MODE_FAVORITES);
}
static void
+photos_embed_prepare_for_collections (PhotosEmbed *self)
+{
+ PhotosEmbedPrivate *priv = self->priv;
+
+ photos_base_manager_set_active_object (priv->item_mngr, NULL);
+
+ if (priv->loader_cancellable != NULL)
+ {
+ g_cancellable_cancel (priv->loader_cancellable);
+ g_clear_object (&priv->loader_cancellable);
+ }
+
+ photos_spinner_box_stop (PHOTOS_SPINNER_BOX (priv->spinner_box));
+ gd_stack_set_visible_child_name (GD_STACK (priv->stack), "collections");
+}
+
+
+static void
photos_embed_prepare_for_favorites (PhotosEmbed *self)
{
PhotosEmbedPrivate *priv = self->priv;
@@ -345,7 +370,9 @@ photos_embed_window_mode_changed (PhotosModeController *mode_cntrlr,
PhotosEmbed *self = PHOTOS_EMBED (user_data);
PhotosEmbedPrivate *priv = self->priv;
- if (mode == PHOTOS_WINDOW_MODE_FAVORITES)
+ if (mode == PHOTOS_WINDOW_MODE_COLLECTIONS)
+ photos_embed_prepare_for_collections (self);
+ else if (mode == PHOTOS_WINDOW_MODE_FAVORITES)
photos_embed_prepare_for_favorites (self);
else if (mode == PHOTOS_WINDOW_MODE_OVERVIEW)
photos_embed_prepare_for_overview (self);
@@ -416,6 +443,9 @@ photos_embed_init (PhotosEmbed *self)
priv->indexing_ntfctn = g_object_ref_sink (photos_indexing_notification_new ());
+ priv->collections = photos_view_container_new (PHOTOS_WINDOW_MODE_COLLECTIONS);
+ gd_stack_add_titled (GD_STACK (priv->stack), priv->collections, "collections", _("Albums"));
+
priv->overview = photos_view_container_new (PHOTOS_WINDOW_MODE_OVERVIEW);
gd_stack_add_titled (GD_STACK (priv->stack), priv->overview, "overview", _("Photos"));
diff --git a/src/photos-load-more-button.c b/src/photos-load-more-button.c
index 0ee2e1b..383b194 100644
--- a/src/photos-load-more-button.c
+++ b/src/photos-load-more-button.c
@@ -1,6 +1,6 @@
/*
* Photos - access, organize and share your photos on GNOME
- * Copyright © 2012 Red Hat, Inc.
+ * Copyright © 2012, 2013 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
@@ -31,6 +31,7 @@
#include "photos-enums.h"
#include "photos-load-more-button.h"
+#include "photos-offset-collections-controller.h"
#include "photos-offset-favorites-controller.h"
#include "photos-offset-overview-controller.h"
@@ -101,6 +102,10 @@ photos_load_more_button_constructed (GObject *object)
switch (priv->mode)
{
+ case PHOTOS_WINDOW_MODE_COLLECTIONS:
+ priv->offset_cntrlr = photos_offset_collections_controller_new ();
+ break;
+
case PHOTOS_WINDOW_MODE_FAVORITES:
priv->offset_cntrlr = photos_offset_favorites_controller_new ();
break;
diff --git a/src/photos-main-toolbar.c b/src/photos-main-toolbar.c
index d9335df..5a76a20 100644
--- a/src/photos-main-toolbar.c
+++ b/src/photos-main-toolbar.c
@@ -76,7 +76,9 @@ photos_main_toolbar_set_toolbar_title (PhotosMainToolbar *self)
selection_mode = photos_selection_controller_get_selection_mode (priv->sel_cntrlr);
window_mode = photos_mode_controller_get_window_mode (priv->mode_cntrlr);
- if (window_mode == PHOTOS_WINDOW_MODE_OVERVIEW || window_mode == PHOTOS_WINDOW_MODE_FAVORITES)
+ if (window_mode == PHOTOS_WINDOW_MODE_OVERVIEW
+ || window_mode == PHOTOS_WINDOW_MODE_COLLECTIONS
+ || window_mode == PHOTOS_WINDOW_MODE_FAVORITES)
{
if (!selection_mode)
{
@@ -316,6 +318,20 @@ photos_main_toolbar_done_button_clicked (GtkButton *button, gpointer user_data)
static void
+photos_main_toolbar_populate_for_collections (PhotosMainToolbar *self)
+{
+ PhotosMainToolbarPrivate *priv = self->priv;
+ GObject *object;
+
+ photos_header_bar_set_mode (PHOTOS_HEADER_BAR (priv->toolbar), PHOTOS_HEADER_BAR_MODE_NORMAL);
+ photos_main_toolbar_add_selection_button (self);
+
+ object = photos_base_manager_get_active_object (priv->col_mngr);
+ photos_main_toolbar_active_changed (priv->col_mngr, object, self);
+}
+
+
+static void
photos_main_toolbar_populate_for_favorites (PhotosMainToolbar *self)
{
PhotosMainToolbarPrivate *priv = self->priv;
@@ -403,6 +419,8 @@ photos_main_toolbar_reset_toolbar_mode (PhotosMainToolbar *self)
if (selection_mode)
photos_main_toolbar_populate_for_selection_mode (self);
+ else if (window_mode == PHOTOS_WINDOW_MODE_COLLECTIONS)
+ photos_main_toolbar_populate_for_collections (self);
else if (window_mode == PHOTOS_WINDOW_MODE_FAVORITES)
photos_main_toolbar_populate_for_favorites (self);
else if (window_mode == PHOTOS_WINDOW_MODE_OVERVIEW)
diff --git a/src/photos-mode-controller.c b/src/photos-mode-controller.c
index b779840..8b4ad83 100644
--- a/src/photos-mode-controller.c
+++ b/src/photos-mode-controller.c
@@ -1,6 +1,6 @@
/*
* Photos - access, organize and share your photos on GNOME
- * Copyright © 2012 Red Hat, Inc.
+ * Copyright © 2012, 2013 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
@@ -211,7 +211,9 @@ photos_mode_controller_set_window_mode (PhotosModeController *self, PhotosWindow
if (old_mode == mode)
return;
- if (mode == PHOTOS_WINDOW_MODE_OVERVIEW || mode == PHOTOS_WINDOW_MODE_FAVORITES)
+ if (mode == PHOTOS_WINDOW_MODE_OVERVIEW
+ || mode == PHOTOS_WINDOW_MODE_COLLECTIONS
+ || mode == PHOTOS_WINDOW_MODE_FAVORITES)
photos_mode_controller_set_can_fullscreen (self, FALSE);
priv->mode = mode;
diff --git a/src/photos-mode-controller.h b/src/photos-mode-controller.h
index b3e1647..94e0532 100644
--- a/src/photos-mode-controller.h
+++ b/src/photos-mode-controller.h
@@ -1,6 +1,6 @@
/*
* Photos - access, organize and share your photos on GNOME
- * Copyright © 2012 Red Hat, Inc.
+ * Copyright © 2012, 2013 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
@@ -54,6 +54,7 @@ G_BEGIN_DECLS
typedef enum
{
PHOTOS_WINDOW_MODE_NONE,
+ PHOTOS_WINDOW_MODE_COLLECTIONS,
PHOTOS_WINDOW_MODE_FAVORITES,
PHOTOS_WINDOW_MODE_OVERVIEW,
PHOTOS_WINDOW_MODE_PREVIEW
diff --git a/src/photos-query-builder.c b/src/photos-query-builder.c
index 2e08941..af71273 100644
--- a/src/photos-query-builder.c
+++ b/src/photos-query-builder.c
@@ -28,6 +28,7 @@
#include <gio/gio.h>
#include "photos-collection-manager.h"
+#include "photos-offset-collections-controller.h"
#include "photos-offset-favorites-controller.h"
#include "photos-offset-overview-controller.h"
#include "photos-query-builder.h"
@@ -147,7 +148,9 @@ photos_query_builder_query (gboolean global, gint flags)
gint offset;
gint step;
- if (flags & PHOTOS_QUERY_FLAGS_FAVORITES)
+ if (flags & PHOTOS_QUERY_FLAGS_COLLECTIONS)
+ offset_cntrlr = photos_offset_collections_controller_new ();
+ else if (flags & PHOTOS_QUERY_FLAGS_FAVORITES)
offset_cntrlr = photos_offset_favorites_controller_new ();
else
offset_cntrlr = photos_offset_overview_controller_new ();
diff --git a/src/photos-view-container.c b/src/photos-view-container.c
index 9d2d89c..863e2d5 100644
--- a/src/photos-view-container.c
+++ b/src/photos-view-container.c
@@ -31,6 +31,7 @@
#include "photos-item-manager.h"
#include "photos-load-more-button.h"
#include "photos-selection-controller.h"
+#include "photos-tracker-collections-controller.h"
#include "photos-tracker-favorites-controller.h"
#include "photos-tracker-overview-controller.h"
#include "photos-utils.h"
@@ -233,7 +234,9 @@ photos_view_container_window_mode_changed (PhotosModeController *mode_cntrlr,
photos_view_container_disconnect_view (self);
- if (mode == PHOTOS_WINDOW_MODE_FAVORITES || mode == PHOTOS_WINDOW_MODE_OVERVIEW)
+ if (mode == PHOTOS_WINDOW_MODE_COLLECTIONS
+ || mode == PHOTOS_WINDOW_MODE_FAVORITES
+ || mode == PHOTOS_WINDOW_MODE_OVERVIEW)
photos_view_container_connect_view (self);
}
@@ -290,6 +293,10 @@ photos_view_container_constructed (GObject *object)
switch (priv->mode)
{
+ case PHOTOS_WINDOW_MODE_COLLECTIONS:
+ priv->trk_cntrlr = photos_tracker_collections_controller_new ();
+ break;
+
case PHOTOS_WINDOW_MODE_FAVORITES:
priv->trk_cntrlr = photos_tracker_favorites_controller_new ();
break;
diff --git a/src/photos-view-model.c b/src/photos-view-model.c
index 16f6dde..8af1491 100644
--- a/src/photos-view-model.c
+++ b/src/photos-view-model.c
@@ -1,6 +1,6 @@
/*
* Photos - access, organize and share your photos on GNOME
- * Copyright © 2012 Red Hat, Inc.
+ * Copyright © 2012, 2013 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
@@ -129,7 +129,17 @@ photos_view_model_info_updated (PhotosBaseItem *item, gpointer user_data)
row_ref = (GtkTreeRowReference *) g_object_get_data (G_OBJECT (item), priv->row_ref_key);
- if (priv->mode == PHOTOS_WINDOW_MODE_FAVORITES)
+ if (priv->mode == PHOTOS_WINDOW_MODE_COLLECTIONS)
+ {
+ gboolean collection;
+
+ collection = photos_base_item_is_collection (item);
+ if (!collection && row_ref != NULL)
+ photos_view_model_object_removed (self, G_OBJECT (item));
+ else if (collection && row_ref == NULL)
+ photos_view_model_add_item (self, item);
+ }
+ else if (priv->mode == PHOTOS_WINDOW_MODE_FAVORITES)
{
gboolean favorite;
@@ -156,8 +166,10 @@ static void
photos_view_model_object_added (PhotosViewModel *self, GObject *object)
{
PhotosBaseItem *item = PHOTOS_BASE_ITEM (object);
+ PhotosViewModelPrivate *priv = self->priv;
- if (self->priv->mode == PHOTOS_WINDOW_MODE_FAVORITES && !photos_base_item_is_favorite (item))
+ if ((priv->mode == PHOTOS_WINDOW_MODE_COLLECTIONS && !photos_base_item_is_collection (item))
+ || (priv->mode == PHOTOS_WINDOW_MODE_FAVORITES && !photos_base_item_is_favorite (item)))
goto out;
photos_view_model_add_item (self, item);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]