[gnome-photos] Let the back button cancel ongoing loads
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos] Let the back button cancel ongoing loads
- Date: Fri, 26 Sep 2014 16:06:29 +0000 (UTC)
commit 9679faa06af0c28d34ef6ee682effb3316a25691
Author: Debarshi Ray <debarshir gnome org>
Date: Fri Sep 26 15:03:20 2014 +0200
Let the back button cancel ongoing loads
Original patch from Pranav Kant for gnome-documents.
Fixes: https://bugzilla.gnome.org/734845
src/photos-embed.c | 5 ++++-
src/photos-item-manager.c | 9 +++++----
src/photos-item-manager.h | 2 +-
src/photos-main-toolbar.c | 22 ++++++++++++++++++++++
src/photos-main-toolbar.h | 3 +++
5 files changed, 35 insertions(+), 6 deletions(-)
---
diff --git a/src/photos-embed.c b/src/photos-embed.c
index 5bd9714..14f886c 100644
--- a/src/photos-embed.c
+++ b/src/photos-embed.c
@@ -216,6 +216,7 @@ photos_embed_load_finished (PhotosEmbed *self, PhotosBaseItem *item, GeglNode *n
{
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));
@@ -242,7 +243,7 @@ photos_embed_load_show_timeout (gpointer user_data)
static void
-photos_embed_load_started (PhotosEmbed *self)
+photos_embed_load_started (PhotosEmbed *self, PhotosBaseItem *item, GCancellable *cancellable)
{
PhotosEmbedPrivate *priv = self->priv;
PhotosWindowMode mode;
@@ -271,6 +272,8 @@ photos_embed_load_started (PhotosEmbed *self)
photos_mode_controller_set_window_mode (priv->mode_cntrlr, PHOTOS_WINDOW_MODE_PREVIEW);
photos_mode_controller_set_can_fullscreen (priv->mode_cntrlr, TRUE);
+ 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));
}
diff --git a/src/photos-item-manager.c b/src/photos-item-manager.c
index a8f330e..62e0443 100644
--- a/src/photos-item-manager.c
+++ b/src/photos-item-manager.c
@@ -326,7 +326,7 @@ photos_item_manager_set_active_object (PhotosBaseManager *manager, GObject *obje
photos_item_manager_item_load,
g_object_ref (self));
- g_signal_emit (self, signals[LOAD_STARTED], 0, PHOTOS_BASE_ITEM (object));
+ g_signal_emit (self, signals[LOAD_STARTED], 0, PHOTOS_BASE_ITEM (object), priv->loader_cancellable);
}
out:
@@ -421,10 +421,11 @@ photos_item_manager_class_init (PhotosItemManagerClass *class)
load_started),
NULL, /*accumulator */
NULL, /*accu_data */
- g_cclosure_marshal_VOID__OBJECT,
+ g_cclosure_marshal_generic,
G_TYPE_NONE,
- 1,
- PHOTOS_TYPE_BASE_ITEM);
+ 2,
+ PHOTOS_TYPE_BASE_ITEM,
+ G_TYPE_CANCELLABLE);
}
diff --git a/src/photos-item-manager.h b/src/photos-item-manager.h
index 43f6155..e246395 100644
--- a/src/photos-item-manager.h
+++ b/src/photos-item-manager.h
@@ -73,7 +73,7 @@ struct _PhotosItemManagerClass
/* signals */
void (*active_collection_changed) (PhotosItemManager *self, PhotosBaseItem *collection);
void (*load_finished) (PhotosItemManager *self, PhotosBaseItem *item, GeglNode *node);
- void (*load_started) (PhotosItemManager *self, PhotosBaseItem *item);
+ void (*load_started) (PhotosItemManager *self, PhotosBaseItem *item, GCancellable
*cancellable);
};
GType photos_item_manager_get_type (void) G_GNUC_CONST;
diff --git a/src/photos-main-toolbar.c b/src/photos-main-toolbar.c
index edbbd5e..4180388 100644
--- a/src/photos-main-toolbar.c
+++ b/src/photos-main-toolbar.c
@@ -46,6 +46,7 @@
struct _PhotosMainToolbarPrivate
{
GAction *search;
+ GCancellable *loader_cancellable;
GSimpleAction *gear_menu;
GtkWidget *coll_back_button;
GtkWidget *favorite_button;
@@ -322,6 +323,9 @@ photos_main_toolbar_back_button_clicked (PhotosMainToolbar *self)
{
PhotosMainToolbarPrivate *priv = self->priv;
+ if (priv->loader_cancellable != NULL)
+ g_cancellable_cancel (priv->loader_cancellable);
+
photos_base_manager_set_active_object (priv->item_mngr, NULL);
photos_mode_controller_go_back (priv->mode_cntrlr);
}
@@ -687,6 +691,7 @@ photos_main_toolbar_dispose (GObject *object)
photos_main_toolbar_clear_state_data (self);
+ g_clear_object (&priv->loader_cancellable);
g_clear_object (&priv->searchbar);
g_clear_object (&priv->item_mngr);
g_clear_object (&priv->mode_cntrlr);
@@ -885,6 +890,23 @@ photos_main_toolbar_reset_toolbar_mode (PhotosMainToolbar *self)
void
+photos_main_toolbar_set_cancellable (PhotosMainToolbar *self, GCancellable *cancellable)
+{
+ PhotosMainToolbarPrivate *priv = self->priv;
+
+ if (cancellable == priv->loader_cancellable)
+ return;
+
+ g_clear_object (&priv->loader_cancellable);
+
+ if (cancellable != NULL)
+ g_object_ref (cancellable);
+
+ priv->loader_cancellable = cancellable;
+}
+
+
+void
photos_main_toolbar_set_stack (PhotosMainToolbar *self, GtkStack *stack)
{
photos_header_bar_set_stack (PHOTOS_HEADER_BAR (self->priv->toolbar), stack);
diff --git a/src/photos-main-toolbar.h b/src/photos-main-toolbar.h
index 4e8f9b6..3ad4814 100644
--- a/src/photos-main-toolbar.h
+++ b/src/photos-main-toolbar.h
@@ -81,6 +81,9 @@ gboolean photos_main_toolbar_is_focus (PhotosMainToo
void photos_main_toolbar_reset_toolbar_mode (PhotosMainToolbar *self);
+void photos_main_toolbar_set_cancellable (PhotosMainToolbar *self,
+ GCancellable *cancellable);
+
void photos_main_toolbar_set_stack (PhotosMainToolbar *self, GtkStack *stack);
void photos_main_toolbar_set_view_model (PhotosMainToolbar *self, PhotosViewModel
*model);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]