[gnome-photos] Make photos_base_item_save_finish return the exported file



commit a6710d28e989abfe55a3ac483653ae972a757cd6
Author: Debarshi Ray <debarshir gnome org>
Date:   Sun Feb 28 23:37:31 2016 +0100

    Make photos_base_item_save_finish return the exported file
    
    The caller needs to know the location of the exported file to show a
    notification. It won't be possible for it to re-create the location
    when we add code to avoid overwriting existing files during export.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=762371

 src/photos-application.c |    4 +++-
 src/photos-base-item.c   |   12 +++++++++---
 src/photos-base-item.h   |    4 ++--
 3 files changed, 14 insertions(+), 6 deletions(-)
---
diff --git a/src/photos-application.c b/src/photos-application.c
index ed261d5..aae059b 100644
--- a/src/photos-application.c
+++ b/src/photos-application.c
@@ -979,8 +979,9 @@ photos_application_save_save (GObject *source_object, GAsyncResult *res, gpointe
   PhotosApplication *self = PHOTOS_APPLICATION (user_data);
   PhotosBaseItem *item = PHOTOS_BASE_ITEM (source_object);
   GError *error = NULL;
+  GFile *file = NULL;
 
-  photos_base_item_save_finish (item, res, &error);
+  file = photos_base_item_save_finish (item, res, &error);
   if (error != NULL)
     {
       g_warning ("Unable to save: %s", error->message);
@@ -991,6 +992,7 @@ photos_application_save_save (GObject *source_object, GAsyncResult *res, gpointe
  out:
   photos_selection_controller_set_selection_mode (self->priv->sel_cntrlr, FALSE);
   g_application_release (G_APPLICATION (self));
+  g_clear_object (&file);
 }
 
 
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index 789e3ee..44a05f9 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -1145,7 +1145,11 @@ photos_base_item_save_save_metadata (GObject *source_object, GAsyncResult *res,
 {
   PhotosBaseItem *self = PHOTOS_BASE_ITEM (source_object);
   GError *error;
+  GFile *file = NULL;
   GTask *task = G_TASK (user_data);
+  PhotosBaseItemSaveData *data;
+
+  data = (PhotosBaseItemSaveData *) g_task_get_task_data (task);
 
   error = NULL;
   if (!photos_base_item_save_metadata_finish (self, res, &error))
@@ -1154,9 +1158,11 @@ photos_base_item_save_save_metadata (GObject *source_object, GAsyncResult *res,
       goto out;
     }
 
-  g_task_return_boolean (task, TRUE);
+  file = g_file_get_child (data->dir, self->priv->filename);
+  g_task_return_pointer (task, g_object_ref (file), g_object_unref);
 
  out:
+  g_clear_object (&file);
   g_object_unref (task);
 }
 
@@ -2345,7 +2351,7 @@ photos_base_item_save_async (PhotosBaseItem *self,
 }
 
 
-gboolean
+GFile *
 photos_base_item_save_finish (PhotosBaseItem *self, GAsyncResult *res, GError **error)
 {
   GTask *task = G_TASK (res);
@@ -2354,7 +2360,7 @@ photos_base_item_save_finish (PhotosBaseItem *self, GAsyncResult *res, GError **
   g_return_val_if_fail (g_task_get_source_tag (task) == photos_base_item_save_async, FALSE);
   g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
 
-  return g_task_propagate_boolean (task, error);
+  return g_task_propagate_pointer (task, error);
 }
 
 
diff --git a/src/photos-base-item.h b/src/photos-base-item.h
index 87cd93e..701125a 100644
--- a/src/photos-base-item.h
+++ b/src/photos-base-item.h
@@ -230,9 +230,9 @@ void                photos_base_item_save_async              (PhotosBaseItem *se
                                                               GAsyncReadyCallback callback,
                                                               gpointer user_data);
 
-gboolean            photos_base_item_save_finish             (PhotosBaseItem *self,
+GFile              *photos_base_item_save_finish             (PhotosBaseItem *self,
                                                               GAsyncResult *res,
-                                                              GError **error);
+                                                              GError **error) G_GNUC_WARN_UNUSED_RESULT;
 
 void                photos_base_item_save_guess_sizes_async  (PhotosBaseItem *self,
                                                               GCancellable *cancellable,


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