[gnome-photos] pipeline, utils: Refactor removal of children into a separate function
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos] pipeline, utils: Refactor removal of children into a separate function
- Date: Tue, 23 Feb 2016 19:49:36 +0000 (UTC)
commit 5dbf908fe01c58fe775658cb2d4a5e3db7968f2d
Author: Debarshi Ray <debarshir gnome org>
Date: Tue Feb 23 15:03:08 2016 +0100
pipeline, utils: Refactor removal of children into a separate function
We can't use gegl_node_remove_children because it would also remove the
proxies, which we want to avoid. We are going to use this when creating
the graph from XML because we only want to re-create the internals of
the graph and not the whole graph itself. Otherwise, external code
holding references to the graph and its proxies will get confused when
we revert the pipeline to an earlier snapshot.
https://bugzilla.gnome.org/show_bug.cgi?id=762046
src/photos-pipeline.c | 19 +------------------
src/photos-utils.c | 28 ++++++++++++++++++++++++++++
src/photos-utils.h | 2 ++
3 files changed, 31 insertions(+), 18 deletions(-)
---
diff --git a/src/photos-pipeline.c b/src/photos-pipeline.c
index 7f91ec6..cf4a5ee 100644
--- a/src/photos-pipeline.c
+++ b/src/photos-pipeline.c
@@ -587,27 +587,10 @@ photos_pipeline_remove (PhotosPipeline *self, const gchar *operation)
void
photos_pipeline_revert (PhotosPipeline *self)
{
- GeglNode *input;
- GeglNode *last;
- GeglNode *output;
gchar *xml;
- input = gegl_node_get_input_proxy (self->graph, "input");
- output = gegl_node_get_output_proxy (self->graph, "output");
- last = gegl_node_get_producer (output, "input", NULL);
-
g_hash_table_remove_all (self->hash);
-
- while (last != NULL && last != input)
- {
- GeglNode *last2;
-
- last2 = gegl_node_get_producer (last, "input", NULL);
- gegl_node_remove_child (self->graph, last);
- last = last2;
- }
-
- gegl_node_link (input, output);
+ photos_utils_remove_children_from_node (self->graph);
xml = gegl_node_to_xml_full (self->graph, self->graph, "/");
photos_debug (PHOTOS_DEBUG_GEGL, "Pipeline: %s", xml);
diff --git a/src/photos-utils.c b/src/photos-utils.c
index 2a26747..e85ebd9 100644
--- a/src/photos-utils.c
+++ b/src/photos-utils.c
@@ -1195,6 +1195,34 @@ photos_utils_update_executed (GObject *source_object, GAsyncResult *res, gpointe
void
+photos_utils_remove_children_from_node (GeglNode *node)
+{
+ GeglNode *input;
+ GeglNode *last;
+ GeglNode *output;
+ GeglOperation *operation;
+
+ operation = gegl_node_get_gegl_operation (node);
+ g_return_if_fail (operation == NULL);
+
+ input = gegl_node_get_input_proxy (node, "input");
+ output = gegl_node_get_output_proxy (node, "output");
+ last = gegl_node_get_producer (output, "input", NULL);
+
+ while (last != NULL && last != input)
+ {
+ GeglNode *last2;
+
+ last2 = gegl_node_get_producer (last, "input", NULL);
+ gegl_node_remove_child (node, last);
+ last = last2;
+ }
+
+ gegl_node_link (input, output);
+}
+
+
+void
photos_utils_set_edited_name (const gchar *urn, const gchar *title)
{
GError *error;
diff --git a/src/photos-utils.h b/src/photos-utils.h
index 3e0a000..86b8a90 100644
--- a/src/photos-utils.h
+++ b/src/photos-utils.h
@@ -157,6 +157,8 @@ GQuark photos_utils_orientation_right_quark (void);
GQuark photos_utils_orientation_top_quark (void);
+void photos_utils_remove_children_from_node (GeglNode *node);
+
void photos_utils_set_edited_name (const gchar *urn, const gchar *title);
void photos_utils_set_favorite (const gchar *urn, gboolean is_favorite);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]