[gnome-photos/wip/rishi/misc-fixes: 21/24] base-item: Add photos_base_item_save_to_dir_async
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/misc-fixes: 21/24] base-item: Add photos_base_item_save_to_dir_async
- Date: Wed, 23 Dec 2015 09:24:31 +0000 (UTC)
commit 133685cc9a17306426fff60470caec4298404006
Author: Debarshi Ray <debarshir gnome org>
Date: Tue Dec 22 20:17:50 2015 +0100
base-item: Add photos_base_item_save_to_dir_async
src/photos-base-item.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++
src/photos-base-item.h | 10 +++++++
2 files changed, 80 insertions(+), 0 deletions(-)
---
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index ca5c089..58f7376 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -1051,6 +1051,29 @@ photos_base_item_save_replace (GObject *source_object, GAsyncResult *res, gpoint
static void
+photos_base_item_save_to_dir_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_base_item_save_finish (self, res, &error))
+ {
+ g_task_return_error (task, error);
+ goto out;
+ }
+
+ g_task_return_boolean (task, TRUE);
+
+ out:
+ g_object_unref (task);
+}
+
+
+static void
photos_base_item_set_thumbnailing_icon (PhotosBaseItem *self)
{
if (thumbnailing_icon == NULL)
@@ -2062,6 +2085,53 @@ photos_base_item_save_finish (PhotosBaseItem *self, GAsyncResult *res, GError **
void
+photos_base_item_save_to_dir_async (PhotosBaseItem *self,
+ GFile *dir,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ PhotosBaseItemPrivate *priv;
+ GFile *file;
+ GTask *task;
+ gchar *uri;
+
+ g_return_if_fail (PHOTOS_IS_BASE_ITEM (self));
+ priv = self->priv;
+
+ 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);
+ g_return_if_fail (priv->processor != NULL);
+ g_return_if_fail (!gegl_processor_work (priv->processor, NULL));
+
+ task = g_task_new (self, cancellable, callback, user_data);
+ g_task_set_source_tag (task, photos_base_item_save_to_dir_async);
+
+ file = g_file_get_child (dir, priv->filename);
+ uri = g_file_get_uri (file);
+ photos_base_item_save_async (self, uri, NULL, photos_base_item_save_to_dir_save, g_object_ref (task));
+
+ g_free (uri);
+ g_object_unref (file);
+ g_object_unref (task);
+}
+
+
+gboolean
+photos_base_item_save_to_dir_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_save_to_dir_async, FALSE);
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+ return g_task_propagate_boolean (task, error);
+}
+
+
+void
photos_base_item_set_default_app (PhotosBaseItem *self, GAppInfo *default_app)
{
PhotosBaseItemPrivate *priv = self->priv;
diff --git a/src/photos-base-item.h b/src/photos-base-item.h
index ae5153b..9167478 100644
--- a/src/photos-base-item.h
+++ b/src/photos-base-item.h
@@ -227,6 +227,16 @@ gboolean photos_base_item_save_finish (PhotosBaseItem *se
GAsyncResult *res,
GError **error);
+void photos_base_item_save_to_dir_async (PhotosBaseItem *self,
+ GFile *dir,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+gboolean photos_base_item_save_to_dir_finish (PhotosBaseItem *self,
+ GAsyncResult *res,
+ GError **error);
+
void photos_base_item_set_default_app (PhotosBaseItem *self, GAppInfo *default_app);
void photos_base_item_set_default_app_name (PhotosBaseItem *self, const gchar
*default_app_name);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]