[gnome-photos/wip/rishi/import-6: 2/5] base-item: Add a create_thumbnail_path virtual method



commit 26918da8e1e96fc7985e8d4803d75a4c3a466e0f
Author: Debarshi Ray <debarshir gnome org>
Date:   Wed Jan 24 18:57:19 2018 +0100

    base-item: Add a create_thumbnail_path virtual method
    
    This will enable a future BaseItem sub-class for attached devices to
    specify a different location for its thumbnails. The default
    implementation specifies the current location which is what most
    sub-classes will end up using.
    
    https://gitlab.gnome.org/GNOME/gnome-photos/issues/29

 src/photos-base-item.c | 26 ++++++++++++++++++++++++++
 src/photos-base-item.h |  3 +++
 2 files changed, 29 insertions(+)
---
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index a8d58794..e48a51ba 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -873,6 +873,19 @@ photos_base_item_file_query_info (GObject *source_object, GAsyncResult *res, gpo
 }
 
 
+static gchar *
+photos_base_item_default_create_thumbnail_path (PhotosBaseItem *self)
+{
+  PhotosBaseItemPrivate *priv;
+  gchar *path;
+
+  priv = photos_base_item_get_instance_private (self);
+
+  path = photos_utils_get_thumbnail_path_for_uri (priv->uri);
+  return path;
+}
+
+
 static void
 photos_base_item_default_set_favorite (PhotosBaseItem *self, gboolean favorite)
 {
@@ -2994,6 +3007,7 @@ photos_base_item_class_init (PhotosBaseItemClass *class)
   object_class->finalize = photos_base_item_finalize;
   object_class->get_property = photos_base_item_get_property;
   object_class->set_property = photos_base_item_set_property;
+  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->set_favorite = photos_base_item_default_set_favorite;
@@ -3178,6 +3192,18 @@ photos_base_item_create_preview (PhotosBaseItem *self,
 }
 
 
+gchar *
+photos_base_item_create_thumbnail_path (PhotosBaseItem *self)
+{
+  gchar *path;
+
+  g_return_val_if_fail (PHOTOS_IS_BASE_ITEM (self), NULL);
+
+  path = PHOTOS_BASE_ITEM_GET_CLASS (self)->create_thumbnail_path (self);
+  return path;
+}
+
+
 void
 photos_base_item_destroy (PhotosBaseItem *self)
 {
diff --git a/src/photos-base-item.h b/src/photos-base-item.h
index 9383a921..bc929f1d 100644
--- a/src/photos-base-item.h
+++ b/src/photos-base-item.h
@@ -59,6 +59,7 @@ struct _PhotosBaseItemClass
   gchar      *(*create_name_fallback)       (PhotosBaseItem *self);
   gchar      *(*create_pipeline_path)       (PhotosBaseItem *self);
   gboolean    (*create_thumbnail)           (PhotosBaseItem *self, GCancellable *cancellable, GError 
**error);
+  gchar      *(*create_thumbnail_path)      (PhotosBaseItem *self);
   gchar      *(*download)                   (PhotosBaseItem *self, GCancellable *cancellable, GError 
**error);
   GtkWidget  *(*get_source_widget)          (PhotosBaseItem *self);
   gboolean    (*metadata_add_shared)        (PhotosBaseItem  *self,
@@ -87,6 +88,8 @@ cairo_surface_t    *photos_base_item_create_preview          (PhotosBaseItem *se
                                                               const gchar *first_property_name,
                                                               ...) G_GNUC_NULL_TERMINATED 
G_GNUC_WARN_UNUSED_RESULT;
 
+gchar              *photos_base_item_create_thumbnail_path   (PhotosBaseItem *self) 
G_GNUC_WARN_UNUSED_RESULT;
+
 void                photos_base_item_destroy                 (PhotosBaseItem *self);
 
 gchar              *photos_base_item_download                (PhotosBaseItem *self,


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