[gnome-photos/wip/rishi/misc-fixes: 8/21] base-item: Add photos_base_item_pipeline_save_async
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/misc-fixes: 8/21] base-item: Add photos_base_item_pipeline_save_async
- Date: Thu, 24 Dec 2015 02:30:53 +0000 (UTC)
commit 31db03547d099b4f4702d4e9a9eebec3cca05365
Author: Debarshi Ray <debarshir gnome org>
Date: Fri Dec 18 13:41:51 2015 +0100
base-item: Add photos_base_item_pipeline_save_async
https://bugzilla.gnome.org/show_bug.cgi?id=759363
src/photos-base-item.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++
src/photos-base-item.h | 9 ++++++
2 files changed, 85 insertions(+), 0 deletions(-)
---
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index 8e8f528..682b878 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -899,6 +899,29 @@ photos_base_item_load_load_buffer (GObject *source_object, GAsyncResult *res, gp
}
+static void
+photos_base_item_pipeline_save_save (GObject *source_object, GAsyncResult *res, gpointer user_data)
+{
+ GTask *task = G_TASK (user_data);
+ PhotosBaseItem *self;
+ GError *error;
+
+ self = PHOTOS_BASE_ITEM (g_task_get_source_object (task));
+
+ error = NULL;
+ if (!photos_pipeline_save_finish (self->priv->pipeline, res, &error))
+ {
+ g_task_return_error (task, error);
+ goto out;
+ }
+
+ g_task_return_boolean (task, TRUE);
+
+ out:
+ g_object_unref (task);
+}
+
+
static gboolean
photos_base_item_process_idle (gpointer user_data)
{
@@ -1842,6 +1865,59 @@ photos_base_item_operation_undo (PhotosBaseItem *self)
void
+photos_base_item_pipeline_save_async (PhotosBaseItem *self,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ PhotosBaseItemPrivate *priv;
+ GTask *task;
+ gchar *path;
+ gchar *uri;
+ PhotosBaseItemClass *class;
+
+ g_return_if_fail (PHOTOS_IS_BASE_ITEM (self));
+ priv = self->priv;
+
+ class = PHOTOS_BASE_ITEM_GET_CLASS (self);
+ g_return_if_fail (class->create_pipeline_path != NULL);
+
+ g_return_if_fail (priv->edit_graph != NULL);
+ g_return_if_fail (priv->load_graph != NULL);
+ g_return_if_fail (priv->pipeline != NULL);
+
+ task = g_task_new (self, cancellable, callback, user_data);
+ g_task_set_source_tag (task, photos_base_item_pipeline_save_async);
+
+ path = class->create_pipeline_path (self);
+ uri = photos_utils_convert_path_to_uri (path);
+
+ photos_pipeline_save_async (priv->pipeline,
+ uri,
+ cancellable,
+ photos_base_item_pipeline_save_save,
+ g_object_ref (task));
+
+ g_free (path);
+ g_free (uri);
+ g_object_unref (task);
+}
+
+
+gboolean
+photos_base_item_pipeline_save_finish (PhotosBaseItem *self, GAsyncResult *res, GError **error)
+{
+ GTask *task = G_TASK (res);
+
+ g_return_val_if_fail (g_task_is_valid (res, self), FALSE);
+ g_return_val_if_fail (g_task_get_source_tag (task) == photos_base_item_pipeline_save_async, FALSE);
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+ return g_task_propagate_boolean (task, error);
+}
+
+
+void
photos_base_item_print (PhotosBaseItem *self, GtkWidget *toplevel)
{
photos_base_item_load_async (self, NULL, photos_base_item_print_load, g_object_ref (toplevel));
diff --git a/src/photos-base-item.h b/src/photos-base-item.h
index b99fd42..ae5153b 100644
--- a/src/photos-base-item.h
+++ b/src/photos-base-item.h
@@ -195,6 +195,15 @@ gboolean photos_base_item_operation_get (PhotosBaseItem *se
gboolean photos_base_item_operation_undo (PhotosBaseItem *self);
+void photos_base_item_pipeline_save_async (PhotosBaseItem *self,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+gboolean photos_base_item_pipeline_save_finish (PhotosBaseItem *self,
+ GAsyncResult *res,
+ GError **error);
+
void photos_base_item_print (PhotosBaseItem *self, GtkWidget *toplevel);
void photos_base_item_process_async (PhotosBaseItem *self,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]