[gnome-photos/wip/rishi/collection: 1/10] base-item: Support sporting a busy state through the "pulse" property



commit d109832654821ef585f5de03945acd64f67fe606
Author: Debarshi Ray <debarshir gnome org>
Date:   Thu Feb 8 04:12:14 2018 +0100

    base-item: Support sporting a busy state through the "pulse" property
    
    https://gitlab.gnome.org/GNOME/gnome-photos/issues/29

 src/photos-base-item.c | 39 +++++++++++++++++++++++++++++++++++++--
 src/photos-base-item.h |  4 ++++
 2 files changed, 41 insertions(+), 2 deletions(-)
---
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index ddcc6aa8..53e8c4c7 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -101,6 +101,7 @@ struct _PhotosBaseItemPrivate
   gint64 height;
   gint64 mtime;
   gint64 width;
+  guint busy_count;
 };
 
 enum
@@ -2969,8 +2970,12 @@ photos_base_item_get_property (GObject *object, guint prop_id, GValue *value, GP
       }
 
     case PROP_PULSE:
-      g_value_set_boolean (value, FALSE);
-      break;
+      {
+        gboolean pulse = priv->busy_count > 0;
+
+        g_value_set_boolean (value, pulse);
+        break;
+      }
 
     case PROP_SECONDARY_TEXT:
       g_value_set_string (value, priv->author);
@@ -3844,6 +3849,20 @@ photos_base_item_load_finish (PhotosBaseItem *self, GAsyncResult *res, GError **
 }
 
 
+void
+photos_base_item_mark_busy (PhotosBaseItem *self)
+{
+  PhotosBaseItemPrivate *priv;
+
+  g_return_if_fail (PHOTOS_IS_BASE_ITEM (self));
+  priv = photos_base_item_get_instance_private (self);
+
+  priv->busy_count++;
+  if (priv->busy_count == 1)
+    g_object_notify (G_OBJECT (self), "pulse");
+}
+
+
 void
 photos_base_item_metadata_add_shared_async (PhotosBaseItem *self,
                                             const gchar *provider_type,
@@ -4605,3 +4624,19 @@ photos_base_item_trash (PhotosBaseItem *self)
   job = photos_delete_item_job_new (priv->id);
   photos_delete_item_job_run (job, NULL, NULL, NULL);
 }
+
+
+void
+photos_base_item_unmark_busy (PhotosBaseItem *self)
+{
+  PhotosBaseItemPrivate *priv;
+
+  g_return_if_fail (PHOTOS_IS_BASE_ITEM (self));
+  priv = photos_base_item_get_instance_private (self);
+
+  g_return_if_fail (priv->busy_count > 0);
+
+  priv->busy_count--;
+  if (priv->busy_count == 0)
+    g_object_notify (G_OBJECT (self), "pulse");
+}
diff --git a/src/photos-base-item.h b/src/photos-base-item.h
index 6fe417ab..daf97d35 100644
--- a/src/photos-base-item.h
+++ b/src/photos-base-item.h
@@ -186,6 +186,8 @@ GeglNode           *photos_base_item_load_finish             (PhotosBaseItem *se
                                                               GAsyncResult *res,
                                                               GError **error);
 
+void                photos_base_item_mark_busy               (PhotosBaseItem *self);
+
 void                photos_base_item_metadata_add_shared_async  (PhotosBaseItem *self,
                                                                  const gchar *provider_type,
                                                                  const gchar *account_identity,
@@ -331,6 +333,8 @@ void                photos_base_item_set_favorite            (PhotosBaseItem *se
 
 void                photos_base_item_trash                   (PhotosBaseItem *self);
 
+void                photos_base_item_unmark_busy             (PhotosBaseItem *self);
+
 G_END_DECLS
 
 #endif /* PHOTOS_BASE_ITEM_H */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]