[gnome-photos] Improve the responsiveness of the favorite button
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos] Improve the responsiveness of the favorite button
- Date: Fri, 30 Oct 2015 10:12:20 +0000 (UTC)
commit f515adb3926d80c97e8c6aa6c6d2856f1333e066
Author: Alessandro Bono <shadow openaliasbox org>
Date: Fri Oct 23 18:24:26 2015 +0200
Improve the responsiveness of the favorite button
https://bugzilla.gnome.org/show_bug.cgi?id=757015
src/photos-base-item.c | 6 +++++-
src/photos-selection-toolbar.c | 16 +++++++++++++++-
2 files changed, 20 insertions(+), 2 deletions(-)
---
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index 1ae667c..104cf3c 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -404,7 +404,11 @@ photos_base_item_create_thumbnail_finish (PhotosBaseItem *self, GAsyncResult *re
static void
photos_base_item_default_set_favorite (PhotosBaseItem *self, gboolean favorite)
{
- photos_utils_set_favorite (self->priv->id, favorite);
+ PhotosBaseItemPrivate *priv = self->priv;
+
+ priv->favorite = favorite;
+ photos_base_item_check_effects_and_update_info (self);
+ photos_utils_set_favorite (priv->id, favorite);
}
diff --git a/src/photos-selection-toolbar.c b/src/photos-selection-toolbar.c
index e5d5e29..449fd1c 100644
--- a/src/photos-selection-toolbar.c
+++ b/src/photos-selection-toolbar.c
@@ -145,6 +145,7 @@ photos_selection_toolbar_favorite_clicked (GtkButton *button, gpointer user_data
{
PhotosSelectionToolbar *self = PHOTOS_SELECTION_TOOLBAR (user_data);
PhotosSelectionToolbarPrivate *priv = self->priv;
+ GList *items = NULL;
GList *selection;
GList *l;
@@ -156,14 +157,27 @@ photos_selection_toolbar_favorite_clicked (GtkButton *button, gpointer user_data
{
const gchar *urn = (gchar *) l->data;
PhotosBaseItem *item;
- gboolean favorite;
item = PHOTOS_BASE_ITEM (photos_base_manager_get_object_by_id (priv->item_mngr, urn));
+ items = g_list_prepend (items, g_object_ref (item));
+ }
+
+ /* photos_base_item_set_favorite will emit info-updated signal while
+ * looping: there is a chance that the selection will get modified
+ * while we are iterating over it. To avoid this we make a copy of
+ * the selection and work on it.
+ */
+ for (l = items; l != NULL; l = l->next)
+ {
+ PhotosBaseItem *item = PHOTOS_BASE_ITEM (l->data);
+ gboolean favorite;
+
favorite = photos_base_item_is_favorite (item);
photos_base_item_set_favorite (item, !favorite);
}
photos_selection_controller_set_selection_mode (priv->sel_cntrlr, FALSE);
+ g_list_free_full (items, g_object_unref);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]