[gnome-photos] base-item, pipeline: Add API to remove an operation



commit 95a53a950baa7f554ce924ce3b03d1b934112c54
Author: Rafael Fonseca <r4f4rfs gmail com>
Date:   Wed Feb 17 17:40:30 2016 +0100

    base-item, pipeline: Add API to remove an operation
    
    This will be useful for PhotosToolCrop, which needs to remove the
    gegl:crop operation from the pipeline while it is active.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=761683

 src/photos-base-item.c |    7 +++++++
 src/photos-base-item.h |    2 ++
 src/photos-pipeline.c  |   36 ++++++++++++++++++++++++++++++++++++
 src/photos-pipeline.h  |    2 ++
 4 files changed, 47 insertions(+), 0 deletions(-)
---
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index 18b9745..844a58e 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -2176,6 +2176,13 @@ photos_base_item_operation_undo (PhotosBaseItem *self)
 }
 
 
+gboolean
+photos_base_item_operation_remove (PhotosBaseItem *self, const gchar *operation)
+{
+  return photos_pipeline_remove (self->priv->pipeline, operation);
+}
+
+
 void
 photos_base_item_operations_revert (PhotosBaseItem *self)
 {
diff --git a/src/photos-base-item.h b/src/photos-base-item.h
index 68d3bff..2b3760f 100644
--- a/src/photos-base-item.h
+++ b/src/photos-base-item.h
@@ -197,6 +197,8 @@ gboolean            photos_base_item_operation_get           (PhotosBaseItem *se
 
 gboolean            photos_base_item_operation_undo          (PhotosBaseItem *self);
 
+gboolean            photos_base_item_operation_remove        (PhotosBaseItem *self, const gchar *operation);
+
 void                photos_base_item_operations_revert       (PhotosBaseItem *self);
 
 void                photos_base_item_pipeline_save_async     (PhotosBaseItem *self,
diff --git a/src/photos-pipeline.c b/src/photos-pipeline.c
index e8c00e0..edbbbd3 100644
--- a/src/photos-pipeline.c
+++ b/src/photos-pipeline.c
@@ -578,6 +578,42 @@ photos_pipeline_undo (PhotosPipeline *self)
 }
 
 
+gboolean
+photos_pipeline_remove (PhotosPipeline *self, const gchar *operation)
+{
+  GeglNode *node;
+  GeglNode *source;
+  GeglNode **sinks = NULL;
+  gboolean ret_val = FALSE;
+  gchar *xml = NULL;
+  gint i;
+  gint nsinks;
+
+  node = GEGL_NODE (g_hash_table_lookup (self->hash, operation));
+  if (node == NULL)
+    goto out;
+
+  source = gegl_node_get_producer (node, "input", NULL);
+  nsinks = gegl_node_get_consumers (node, "output", &sinks, NULL);
+
+  g_hash_table_remove (self->hash, operation);
+  gegl_node_remove_child (self->graph, node);
+
+  for (i = 0; i < nsinks; i++)
+    gegl_node_link (source, sinks[i]);
+
+  xml = gegl_node_to_xml_full (self->graph, self->graph, "/");
+  photos_debug (PHOTOS_DEBUG_GEGL, "Pipeline: %s", xml);
+
+  ret_val = TRUE;
+
+ out:
+  g_free (sinks);
+  g_free (xml);
+  return ret_val;
+}
+
+
 void
 photos_pipeline_revert (PhotosPipeline *self)
 {
diff --git a/src/photos-pipeline.h b/src/photos-pipeline.h
index bb302e7..7d931b3 100644
--- a/src/photos-pipeline.h
+++ b/src/photos-pipeline.h
@@ -89,6 +89,8 @@ gboolean               photos_pipeline_save_finish       (PhotosPipeline *self,
 
 gboolean               photos_pipeline_undo              (PhotosPipeline *self);
 
+gboolean               photos_pipeline_remove            (PhotosPipeline *self, const gchar *operation);
+
 void                   photos_pipeline_revert            (PhotosPipeline *self);
 
 G_END_DECLS


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