[gnome-photos] embed, view-container: Let each mode have its own no-results page
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos] embed, view-container: Let each mode have its own no-results page
- Date: Thu, 6 Feb 2014 15:56:38 +0000 (UTC)
commit 5e10c5cd86ca80afbb255efbe889688810731e76
Author: Debarshi Ray <debarshir gnome org>
Date: Thu Feb 6 10:40:58 2014 +0100
embed, view-container: Let each mode have its own no-results page
... and do not hide it on PhotosTrackerChangeMonitor::changes-pending.
Only hide it when the count of the mode-specific
PhotosOffsetController goes above zero.
Fixes: https://bugzilla.gnome.org/720570
src/photos-embed.c | 62 -------------------------------------------
src/photos-view-container.c | 50 +++++++++++++++++++++++++++++++---
src/photos-view-container.h | 6 ++--
3 files changed, 48 insertions(+), 70 deletions(-)
---
diff --git a/src/photos-embed.c b/src/photos-embed.c
index c386bdd..982b2b9 100644
--- a/src/photos-embed.c
+++ b/src/photos-embed.c
@@ -31,13 +31,11 @@
#include "photos-application.h"
#include "photos-embed.h"
-#include "photos-empty-results-box.h"
#include "photos-error-box.h"
#include "photos-indexing-notification.h"
#include "photos-item-manager.h"
#include "photos-mode-controller.h"
#include "photos-notification-manager.h"
-#include "photos-offset-overview-controller.h"
#include "photos-preview-view.h"
#include "photos-search-controller.h"
#include "photos-selection-toolbar.h"
@@ -46,7 +44,6 @@
#include "photos-search-type-manager.h"
#include "photos-source.h"
#include "photos-source-manager.h"
-#include "photos-tracker-change-monitor.h"
#include "photos-tracker-overview-controller.h"
#include "photos-view-container.h"
@@ -73,9 +70,7 @@ struct _PhotosEmbedPrivate
PhotosBaseManager *src_mngr;
PhotosBaseManager *srch_mngr;
PhotosModeController *mode_cntrlr;
- PhotosOffsetController *offset_cntrlr;
PhotosSearchController *srch_cntrlr;
- PhotosTrackerChangeMonitor *monitor;
PhotosTrackerController *trk_ovrvw_cntrlr;
PhotosWindowMode old_mode;
guint load_show_id;
@@ -85,9 +80,6 @@ struct _PhotosEmbedPrivate
G_DEFINE_TYPE_WITH_PRIVATE (PhotosEmbed, photos_embed, GTK_TYPE_BOX);
-static void photos_embed_changes_pending (PhotosEmbed *self, GHashTable *changes);
-
-
static void
photos_embed_clear_load_timer (PhotosEmbed *self)
{
@@ -274,50 +266,6 @@ photos_embed_restore_last_page (PhotosEmbed *self)
static void
-photos_embed_hide_no_results_page (PhotosEmbed *self)
-{
- PhotosEmbedPrivate *priv = self->priv;
-
- if (G_LIKELY (priv->monitor != NULL))
- g_signal_handlers_disconnect_by_func (priv->monitor, photos_embed_changes_pending, self);
-
- photos_embed_restore_last_page (self);
-}
-
-
-static void
-photos_embed_changes_pending (PhotosEmbed *self, GHashTable *changes)
-{
- photos_embed_hide_no_results_page (self);
-}
-
-
-static void
-photos_embed_count_changed (PhotosEmbed *self, gint count)
-{
- PhotosEmbedPrivate *priv = self->priv;
- PhotosWindowMode mode;
-
- mode = photos_mode_controller_get_window_mode (priv->mode_cntrlr);
- if (mode != PHOTOS_WINDOW_MODE_OVERVIEW)
- return;
-
- if (count == 0)
- {
- if (G_LIKELY (priv->monitor != NULL))
- g_signal_connect_object (priv->monitor,
- "changes-pending",
- G_CALLBACK (photos_embed_changes_pending),
- self,
- G_CONNECT_SWAPPED);
- gtk_stack_set_visible_child_name (GTK_STACK (priv->stack), "no-results");
- }
- else
- photos_embed_hide_no_results_page (self);
-}
-
-
-static void
photos_embed_fullscreen_changed (PhotosModeController *mode_cntrlr, gboolean fullscreen, gpointer user_data)
{
}
@@ -542,8 +490,6 @@ photos_embed_dispose (GObject *object)
g_clear_object (&priv->src_mngr);
g_clear_object (&priv->srch_mngr);
g_clear_object (&priv->mode_cntrlr);
- g_clear_object (&priv->offset_cntrlr);
- g_clear_object (&priv->monitor);
g_clear_object (&priv->srch_cntrlr);
g_clear_object (&priv->trk_ovrvw_cntrlr);
@@ -629,9 +575,6 @@ photos_embed_init (PhotosEmbed *self)
priv->error_box = photos_error_box_new ();
gtk_stack_add_named (GTK_STACK (priv->stack), priv->error_box, "error");
- priv->no_results = photos_empty_results_box_new ();
- gtk_stack_add_named (GTK_STACK (priv->stack), priv->no_results, "no-results");
-
/* TODO: SearchBar.Dropdown, …
*/
@@ -657,9 +600,6 @@ photos_embed_init (PhotosEmbed *self)
G_CALLBACK (photos_embed_query_status_changed),
self);
- priv->offset_cntrlr = photos_offset_overview_controller_dup_singleton ();
- g_signal_connect_swapped (priv->offset_cntrlr, "count-changed", G_CALLBACK (photos_embed_count_changed),
self);
-
priv->item_mngr = photos_item_manager_dup_singleton ();
g_signal_connect (priv->item_mngr, "active-changed", G_CALLBACK (photos_embed_active_changed), self);
@@ -678,8 +618,6 @@ photos_embed_init (PhotosEmbed *self)
G_CALLBACK (photos_embed_search_changed),
self);
- priv->monitor = photos_tracker_change_monitor_dup_singleton (NULL, NULL);
-
gtk_widget_show (GTK_WIDGET (self));
}
diff --git a/src/photos-view-container.c b/src/photos-view-container.c
index cff092a..1614156 100644
--- a/src/photos-view-container.c
+++ b/src/photos-view-container.c
@@ -27,9 +27,14 @@
#include <libgd/gd.h>
#include "photos-application.h"
+#include "photos-empty-results-box.h"
#include "photos-enums.h"
#include "photos-item-manager.h"
#include "photos-load-more-button.h"
+#include "photos-offset-favorites-controller.h"
+#include "photos-offset-collections-controller.h"
+#include "photos-offset-overview-controller.h"
+#include "photos-offset-search-controller.h"
#include "photos-remote-display-manager.h"
#include "photos-selection-controller.h"
#include "photos-tracker-collections-controller.h"
@@ -47,8 +52,10 @@ struct _PhotosViewContainerPrivate
GtkListStore *model;
GtkTreePath *current_path;
GtkWidget *load_more;
+ GtkWidget *no_results;
PhotosBaseManager *item_mngr;
PhotosModeController *mode_cntrlr;
+ PhotosOffsetController *offset_cntrlr;
PhotosRemoteDisplayManager *remote_mngr;
PhotosSelectionController *sel_cntrlr;
PhotosTrackerController *trk_cntrlr;
@@ -63,7 +70,7 @@ enum
};
-G_DEFINE_TYPE_WITH_PRIVATE (PhotosViewContainer, photos_view_container, GTK_TYPE_GRID);
+G_DEFINE_TYPE_WITH_PRIVATE (PhotosViewContainer, photos_view_container, GTK_TYPE_STACK);
static void
@@ -131,6 +138,16 @@ photos_view_container_connect_view (PhotosViewContainer *self)
static void
+photos_view_container_count_changed (PhotosViewContainer *self, gint count)
+{
+ if (count == 0)
+ gtk_stack_set_visible_child_name (GTK_STACK (self), "no-results");
+ else
+ gtk_stack_set_visible_child_name (GTK_STACK (self), "view");
+}
+
+
+static void
photos_view_container_disconnect_view (PhotosViewContainer *self)
{
PhotosViewContainerPrivate *priv = self->priv;
@@ -248,22 +265,30 @@ photos_view_container_constructed (GObject *object)
PhotosViewContainerPrivate *priv = self->priv;
GAction *action;
GtkApplication *app;
+ GtkWidget *grid;
gboolean status;
G_OBJECT_CLASS (photos_view_container_parent_class)->constructed (object);
priv->model = photos_view_model_new (priv->mode);
- gtk_orientable_set_orientation (GTK_ORIENTABLE (self), GTK_ORIENTATION_VERTICAL);
+ grid = gtk_grid_new ();
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (grid), GTK_ORIENTATION_VERTICAL);
+ gtk_stack_add_named (GTK_STACK (self), grid, "view");
+
+ priv->no_results = photos_empty_results_box_new ();
+ gtk_stack_add_named (GTK_STACK (self), priv->no_results, "no-results");
priv->view = gd_main_view_new (GD_MAIN_VIEW_ICON);
- gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (priv->view));
+ gtk_container_add (GTK_CONTAINER (grid), GTK_WIDGET (priv->view));
priv->load_more = photos_load_more_button_new (priv->mode);
- gtk_container_add (GTK_CONTAINER (self), priv->load_more);
+ gtk_container_add (GTK_CONTAINER (grid), priv->load_more);
gtk_widget_show_all (GTK_WIDGET (self));
+ gtk_stack_set_visible_child_full (GTK_STACK (self), "view", GTK_STACK_TRANSITION_TYPE_NONE);
+
g_signal_connect (priv->view, "item-activated", G_CALLBACK (photos_view_container_item_activated), self);
g_signal_connect (priv->view,
"selection-mode-request",
@@ -297,18 +322,22 @@ photos_view_container_constructed (GObject *object)
{
case PHOTOS_WINDOW_MODE_COLLECTIONS:
priv->trk_cntrlr = photos_tracker_collections_controller_dup_singleton ();
+ priv->offset_cntrlr = photos_offset_collections_controller_dup_singleton ();
break;
case PHOTOS_WINDOW_MODE_FAVORITES:
priv->trk_cntrlr = photos_tracker_favorites_controller_dup_singleton ();
+ priv->offset_cntrlr = photos_offset_favorites_controller_dup_singleton ();
break;
case PHOTOS_WINDOW_MODE_OVERVIEW:
priv->trk_cntrlr = photos_tracker_overview_controller_dup_singleton ();
+ priv->offset_cntrlr = photos_offset_overview_controller_dup_singleton ();
break;
case PHOTOS_WINDOW_MODE_SEARCH:
priv->trk_cntrlr = photos_tracker_search_controller_dup_singleton ();
+ priv->offset_cntrlr = photos_offset_search_controller_dup_singleton ();
break;
default:
@@ -326,6 +355,12 @@ photos_view_container_constructed (GObject *object)
g_object_unref (app);
+ g_signal_connect_object (priv->offset_cntrlr,
+ "count-changed",
+ G_CALLBACK (photos_view_container_count_changed),
+ self,
+ G_CONNECT_SWAPPED);
+
g_signal_connect (priv->trk_cntrlr,
"query-status-changed",
G_CALLBACK (photos_view_container_query_status_changed),
@@ -352,6 +387,7 @@ photos_view_container_dispose (GObject *object)
g_clear_object (&priv->model);
g_clear_object (&priv->item_mngr);
g_clear_object (&priv->mode_cntrlr);
+ g_clear_object (&priv->offset_cntrlr);
g_clear_object (&priv->remote_mngr);
g_clear_object (&priv->sel_cntrlr);
g_clear_object (&priv->trk_cntrlr);
@@ -421,7 +457,11 @@ photos_view_container_class_init (PhotosViewContainerClass *class)
GtkWidget *
photos_view_container_new (PhotosWindowMode mode)
{
- return g_object_new (PHOTOS_TYPE_VIEW_CONTAINER, "mode", mode, NULL);
+ return g_object_new (PHOTOS_TYPE_VIEW_CONTAINER,
+ "homogeneous", TRUE,
+ "mode", mode,
+ "transition-type", GTK_STACK_TRANSITION_TYPE_CROSSFADE,
+ NULL);
}
diff --git a/src/photos-view-container.h b/src/photos-view-container.h
index c078b6c..b481e65 100644
--- a/src/photos-view-container.h
+++ b/src/photos-view-container.h
@@ -1,6 +1,6 @@
/*
* Photos - access, organize and share your photos on GNOME
- * Copyright © 2012 Red Hat, Inc.
+ * Copyright © 2012, 2014 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
@@ -59,13 +59,13 @@ typedef struct _PhotosViewContainerPrivate PhotosViewContainerPrivate;
struct _PhotosViewContainer
{
- GtkGrid parent_instance;
+ GtkStack parent_instance;
PhotosViewContainerPrivate *priv;
};
struct _PhotosViewContainerClass
{
- GtkGridClass parent_class;
+ GtkStackClass parent_class;
};
GType photos_view_container_get_type (void) G_GNUC_CONST;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]