[gnome-photos/wip/rishi/collection: 41/42] base-item: Add a refresh_icon virtual method



commit f4b2d52cc3ec2f37f347e131dfd90c2204954cfd
Author: Debarshi Ray <debarshir gnome org>
Date:   Thu Jan 25 15:20:03 2018 +0100

    base-item: Add a refresh_icon virtual method
    
    This will enable a future BaseItem sub-class for attached devices to
    hook into the thumbnailing process to gather additional information
    about the underlying device before it gets to creating the thumbnail.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=751212

 src/photos-base-item.c | 71 +++++++++++++++++++++++++-------------------------
 src/photos-base-item.h |  1 +
 2 files changed, 37 insertions(+), 35 deletions(-)
---
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index c7fbe21f..b9d4c14d 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -990,6 +990,40 @@ photos_base_item_default_open (PhotosBaseItem *self, GtkWindow *parent, guint32
 }
 
 
+static void
+photos_base_item_default_refresh_icon (PhotosBaseItem *self)
+{
+  PhotosBaseItemPrivate *priv;
+
+  priv = photos_base_item_get_instance_private (self);
+
+  if (priv->thumb_path != NULL)
+    {
+      photos_base_item_refresh_thumb_path (self);
+      return;
+    }
+
+  photos_base_item_set_thumbnailing_icon (self);
+
+  if (priv->failed_thumbnailing)
+    return;
+
+  if (priv->collection)
+    {
+      photos_base_item_refresh_collection_icon (self);
+      return;
+    }
+
+  photos_base_item_query_info_async (self,
+                                     G_FILE_ATTRIBUTE_THUMBNAIL_PATH,
+                                     G_FILE_QUERY_INFO_NONE,
+                                     G_PRIORITY_DEFAULT,
+                                     priv->cancellable,
+                                     photos_base_item_file_query_info,
+                                     NULL);
+}
+
+
 static void
 photos_base_item_default_update_type_description (PhotosBaseItem *self)
 {
@@ -2618,40 +2652,6 @@ photos_base_item_save_to_stream_load (GObject *source_object, GAsyncResult *res,
 }
 
 
-static void
-photos_base_item_refresh_icon (PhotosBaseItem *self)
-{
-  PhotosBaseItemPrivate *priv;
-
-  priv = photos_base_item_get_instance_private (self);
-
-  if (priv->thumb_path != NULL)
-    {
-      photos_base_item_refresh_thumb_path (self);
-      return;
-    }
-
-  photos_base_item_set_thumbnailing_icon (self);
-
-  if (priv->failed_thumbnailing)
-    return;
-
-  if (priv->collection)
-    {
-      photos_base_item_refresh_collection_icon (self);
-      return;
-    }
-
-  photos_base_item_query_info_async (self,
-                                     G_FILE_ATTRIBUTE_THUMBNAIL_PATH,
-                                     G_FILE_QUERY_INFO_NONE,
-                                     G_PRIORITY_DEFAULT,
-                                     priv->cancellable,
-                                     photos_base_item_file_query_info,
-                                     NULL);
-}
-
-
 static void
 photos_base_item_update_info_from_type (PhotosBaseItem *self)
 {
@@ -2807,7 +2807,7 @@ photos_base_item_populate_from_cursor (PhotosBaseItem *self, TrackerSparqlCursor
   name_fallback = PHOTOS_BASE_ITEM_GET_CLASS (self)->create_name_fallback (self);
   photos_utils_take_string (&priv->name_fallback, name_fallback);
 
-  photos_base_item_refresh_icon (self);
+  PHOTOS_BASE_ITEM_GET_CLASS (self)->refresh_icon (self);
 }
 
 
@@ -3039,6 +3039,7 @@ photos_base_item_class_init (PhotosBaseItemClass *class)
   class->create_thumbnail_path = photos_base_item_default_create_thumbnail_path;
   class->metadata_add_shared = photos_base_item_default_metadata_add_shared;
   class->open = photos_base_item_default_open;
+  class->refresh_icon = photos_base_item_default_refresh_icon;
   class->set_favorite = photos_base_item_default_set_favorite;
   class->update_type_description = photos_base_item_default_update_type_description;
 
diff --git a/src/photos-base-item.h b/src/photos-base-item.h
index 1679e216..6fe417ab 100644
--- a/src/photos-base-item.h
+++ b/src/photos-base-item.h
@@ -69,6 +69,7 @@ struct _PhotosBaseItemClass
                                              GCancellable    *cancellable,
                                              GError         **error);
   void        (*open)                       (PhotosBaseItem *self, GtkWindow *parent, guint32 timestamp);
+  void        (*refresh_icon)               (PhotosBaseItem *self);
   void        (*set_favorite)               (PhotosBaseItem *self, gboolean favorite);
   void        (*trash)                      (PhotosBaseItem *self);
   void        (*update_type_description)    (PhotosBaseItem *self);


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