[gnome-photos/wip/rishi/share-point-1] Add base_item_load_async to save_item_async



commit 96ef6cca6128d6f4cd8d211f20e6a9bae3b28a68
Author: Umang Jain <mailumangjain gmail com>
Date:   Mon Aug 15 14:52:37 2016 +0530

    Add base_item_load_async to save_item_async

 src/photos-base-item.c |   62 +++++++++++++++++++++++++++++++----------------
 1 files changed, 41 insertions(+), 21 deletions(-)
---
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index cca1c0e..3cb44c4 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -142,6 +142,7 @@ struct _PhotosBaseItemSaveData
   GFile *unique_file;
   GeglBuffer *buffer;
   gchar *type;
+  gdouble zoom;
 };
 
 struct _PhotosBaseItemSaveBufferData
@@ -168,7 +169,7 @@ static void photos_base_item_populate_from_cursor (PhotosBaseItem *self, Tracker
 
 
 static PhotosBaseItemSaveData *
-photos_base_item_save_data_new (GFile *dir, GeglBuffer *buffer, const gchar *type)
+photos_base_item_save_data_new (GFile *dir, GeglBuffer *buffer, const gchar *type, gdouble zoom)
 {
   PhotosBaseItemSaveData *data;
 
@@ -181,6 +182,7 @@ photos_base_item_save_data_new (GFile *dir, GeglBuffer *buffer, const gchar *typ
     data->buffer = g_object_ref (buffer);
 
   data->type = g_strdup (type);
+  data->zoom = zoom;
 
   return data;
 }
@@ -983,7 +985,7 @@ photos_base_item_guess_save_sizes_load (GObject *source_object, GAsyncResult *re
     }
 
   buffer = photos_utils_create_buffer_from_node (graph);
-  data = photos_base_item_save_data_new (NULL, buffer, self->priv->mime_type);
+  data = photos_base_item_save_data_new (NULL, buffer, self->priv->mime_type, 0.0);
   g_task_set_task_data (task, data, (GDestroyNotify) photos_base_item_save_data_free);
 
   g_task_run_in_thread (task, photos_base_item_guess_save_sizes_in_thread_func);
@@ -3207,25 +3209,24 @@ photos_base_item_refresh (PhotosBaseItem *self)
 }
 
 
-void
-photos_base_item_save_async (PhotosBaseItem *self,
-                             GFile *dir,
-                             gdouble zoom,
-                             GCancellable *cancellable,
-                             GAsyncReadyCallback callback,
-                             gpointer user_data)
+static void
+photos_base_item_loaded_save_async (GObject *source_object, GAsyncResult *res, gpointer user_data)
 {
+  PhotosBaseItem *self = PHOTOS_BASE_ITEM (source_object);
   PhotosBaseItemPrivate *priv;
-  GTask *task;
+  PhotosBaseItemSaveData *data;
+  GCancellable *cancellable;
   GeglBuffer *buffer;
   GeglNode *graph;
-  PhotosBaseItemSaveData *data;
+  GTask *task;
 
-  g_return_if_fail (PHOTOS_IS_BASE_ITEM (self));
   priv = self->priv;
+  task = G_TASK (user_data);
+  cancellable = g_task_get_cancellable (task);
+  data = (PhotosBaseItemSaveData *) g_task_get_task_data (task);
 
   g_return_if_fail (!priv->collection);
-  g_return_if_fail (G_IS_FILE (dir));
+  g_return_if_fail (G_IS_FILE (data->dir));
   g_return_if_fail (priv->edit_graph != NULL);
   g_return_if_fail (priv->filename != NULL && priv->filename[0] != '\0');
   g_return_if_fail (priv->load_graph != NULL);
@@ -3233,17 +3234,10 @@ photos_base_item_save_async (PhotosBaseItem *self,
   g_return_if_fail (priv->processor != NULL);
   g_return_if_fail (!gegl_processor_work (priv->processor, NULL));
 
-  data = photos_base_item_save_data_new (dir, NULL, NULL);
-
-  task = g_task_new (self, cancellable, callback, user_data);
-  g_task_set_source_tag (task, photos_base_item_save_async);
-  g_task_set_task_data (task, data, (GDestroyNotify) photos_base_item_save_data_free);
-
-  //photos_base_item_load_async (self, cancellable, photos_base_item_guess_save_sizes_load, g_object_ref 
(task));
   graph = photos_pipeline_get_graph (priv->pipeline);
   buffer = photos_utils_create_buffer_from_node (graph);
   photos_utils_buffer_zoom_async (buffer,
-                                  zoom,
+                                  data->zoom,
                                   cancellable,
                                   photos_base_item_save_buffer_zoom,
                                   g_object_ref (task));
@@ -3253,6 +3247,32 @@ photos_base_item_save_async (PhotosBaseItem *self,
 }
 
 
+void
+photos_base_item_save_async (PhotosBaseItem *self,
+                             GFile *dir,
+                             gdouble zoom,
+                             GCancellable *cancellable,
+                             GAsyncReadyCallback callback,
+                             gpointer user_data)
+{
+
+  GTask *task;
+  PhotosBaseItemSaveData *data;
+
+  g_return_if_fail (PHOTOS_IS_BASE_ITEM (self));
+
+  data = photos_base_item_save_data_new (dir, NULL, NULL, zoom);
+
+  task = g_task_new (self, cancellable, callback, user_data);
+  g_task_set_source_tag (task, photos_base_item_save_async);
+  g_task_set_task_data (task, data, (GDestroyNotify) photos_base_item_save_data_free);
+
+  photos_base_item_load_async (self, cancellable, photos_base_item_loaded_save_async, g_object_ref (task));
+
+  g_object_unref (task);
+}
+
+
 GFile *
 photos_base_item_save_finish (PhotosBaseItem *self, GAsyncResult *res, GError **error)
 {


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