[gnome-photos/wip/uajain/side-car-file: 81/81] pipeline: Delete edit file on "Discard all Edits" in properties-dialog



commit c5c346b74fff73e1cce2f26eaecebf09c6350cb7
Author: Umang Jain <mailumangjain gmail com>
Date:   Tue Feb 20 14:00:02 2018 +0530

    pipeline: Delete edit file on "Discard all Edits" in properties-dialog
    
    In the previous commit, we now expose edit-file as a side-car file.
    On "Discard all Edits", the edit file's xml is just rewritten as:
    
    <gegl><gegl>
    
    Therefore, it is better to delete the edit-file as it does not
    have any additional value after being rewritten.
    
    https://gitlab.gnome.org/GNOME/gnome-photos/issues/87

 src/photos-application.c |  2 ++
 src/photos-base-item.c   | 12 ++++++++++++
 src/photos-base-item.h   |  2 ++
 src/photos-pipeline.c    | 12 ++++++++++++
 src/photos-pipeline.h    |  2 ++
 5 files changed, 30 insertions(+)
---
diff --git a/src/photos-application.c b/src/photos-application.c
index 7621158f..da59fff1 100644
--- a/src/photos-application.c
+++ b/src/photos-application.c
@@ -1747,6 +1747,8 @@ photos_application_properties_pipeline_save (GObject *source_object, GAsyncResul
       g_warning ("Unable to save pipeline: %s", error->message);
   }
 
+  photos_base_item_pipeline_file_delete (item);
+
   g_application_release (G_APPLICATION (self));
 }
 
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index 854e4cf7..5ef6c54f 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -4252,6 +4252,18 @@ photos_base_item_pipeline_snapshot (PhotosBaseItem *self)
 }
 
 
+void
+photos_base_item_pipeline_file_delete (PhotosBaseItem *self)
+{
+  PhotosPipeline *pipeline;
+
+  pipeline = PHOTOS_PIPELINE (egg_task_cache_peek (pipeline_cache, self));
+  g_return_if_fail (pipeline != NULL);
+
+  photos_pipeline_file_delete_async (pipeline);
+}
+
+
 void
 photos_base_item_print (PhotosBaseItem *self, GtkWidget *toplevel)
 {
diff --git a/src/photos-base-item.h b/src/photos-base-item.h
index daf97d35..b9e64419 100644
--- a/src/photos-base-item.h
+++ b/src/photos-base-item.h
@@ -269,6 +269,8 @@ gboolean            photos_base_item_pipeline_save_finish    (PhotosBaseItem *se
 
 void                photos_base_item_pipeline_snapshot       (PhotosBaseItem *self);
 
+void                photos_base_item_pipeline_file_delete    (PhotosBaseItem *self);
+
 void                photos_base_item_print                   (PhotosBaseItem *self, GtkWidget *toplevel);
 
 GFileInfo          *photos_base_item_query_info              (PhotosBaseItem *self,
diff --git a/src/photos-pipeline.c b/src/photos-pipeline.c
index 1ba6d391..4ee03c34 100644
--- a/src/photos-pipeline.c
+++ b/src/photos-pipeline.c
@@ -756,3 +756,15 @@ photos_pipeline_snapshot (PhotosPipeline *self)
   self->snapshot = gegl_node_to_xml_full (self->graph, self->graph, "/");
   photos_debug (PHOTOS_DEBUG_GEGL, "Snapshot: %s", self->snapshot);
 }
+
+
+void
+photos_pipeline_file_delete_async (PhotosPipeline *self)
+{
+  g_autoptr (GFile) file = NULL;
+
+  g_return_if_fail (PHOTOS_IS_PIPELINE (self));
+
+  file = g_file_new_for_uri (self->uri);
+  g_file_delete_async (file, G_PRIORITY_DEFAULT,  NULL, NULL, NULL);
+}
diff --git a/src/photos-pipeline.h b/src/photos-pipeline.h
index 61a6e589..71b088b4 100644
--- a/src/photos-pipeline.h
+++ b/src/photos-pipeline.h
@@ -53,6 +53,8 @@ gboolean               photos_pipeline_get_valist        (PhotosPipeline *self,
                                                           const gchar *first_property_name,
                                                           va_list ap) G_GNUC_WARN_UNUSED_RESULT;
 
+void                   photos_pipeline_file_delete_async (PhotosPipeline *self);
+
 GeglNode              *photos_pipeline_get_graph         (PhotosPipeline *self);
 
 GeglNode              *photos_pipeline_get_output        (PhotosPipeline *self);


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