[gimp/goat-invasion: 266/418] app: factor out gimp_gegl_config_proxy_sync() from GimpGeglTool



commit 0db50e3ee5295ac0e051fbfc4b0aecb4ee953c8c
Author: Michael Natterer <mitch gimp org>
Date:   Mon Mar 26 19:32:14 2012 +0200

    app: factor out gimp_gegl_config_proxy_sync() from GimpGeglTool

 app/gegl/gimp-gegl-config-proxy.c |   66 +++++++++++++++++++++++++++++++++++++
 app/gegl/gimp-gegl-config-proxy.h |    5 ++-
 app/tools/gimpgegltool.c          |   53 ++----------------------------
 3 files changed, 73 insertions(+), 51 deletions(-)
---
diff --git a/app/gegl/gimp-gegl-config-proxy.c b/app/gegl/gimp-gegl-config-proxy.c
index 4075597..6da44cf 100644
--- a/app/gegl/gimp-gegl-config-proxy.c
+++ b/app/gegl/gimp-gegl-config-proxy.c
@@ -19,8 +19,10 @@
 
 #include <string.h>
 
+#include <cairo.h>
 #include <gegl.h>
 
+#include "libgimpcolor/gimpcolor.h"
 #include "libgimpconfig/gimpconfig.h"
 
 #include "gimp-gegl-types.h"
@@ -197,3 +199,67 @@ gimp_gegl_get_config_proxy (const gchar *operation)
 
   return g_object_new (config_type, NULL);
 }
+
+void
+gimp_gegl_config_proxy_sync (GimpObject  *proxy,
+                             GeglNode    *node)
+{
+  GParamSpec **pspecs;
+  gchar       *operation;
+  guint        n_pspecs;
+  gint         i;
+
+  g_return_if_fail (GIMP_IS_OBJECT (proxy));
+  g_return_if_fail (GEGL_IS_NODE (node));
+
+  gegl_node_get (node,
+                 "operation", &operation,
+                 NULL);
+
+  g_return_if_fail (operation != NULL);
+
+  pspecs = gegl_list_properties (operation, &n_pspecs);
+  g_free (operation);
+
+  for (i = 0; i < n_pspecs; i++)
+    {
+      GParamSpec *gegl_pspec = pspecs[i];
+      GParamSpec *gimp_pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (proxy),
+                                                             gegl_pspec->name);
+
+      if (gimp_pspec)
+        {
+          GValue value = { 0, };
+
+          g_value_init (&value, gimp_pspec->value_type);
+
+          g_object_get_property (G_OBJECT (proxy), gimp_pspec->name,
+                                 &value);
+
+          if (GIMP_IS_PARAM_SPEC_RGB (gimp_pspec))
+            {
+              GeglColor *gegl_color = gegl_color_new (NULL);
+              GimpRGB    gimp_color;
+
+              gimp_value_get_rgb (&value, &gimp_color);
+              g_value_unset (&value);
+
+              gegl_color_set_rgba (gegl_color,
+                                   gimp_color.r,
+                                   gimp_color.g,
+                                   gimp_color.b,
+                                   gimp_color.a);
+
+              g_value_init (&value, gegl_pspec->value_type);
+              g_value_take_object (&value, gegl_color);
+            }
+
+          gegl_node_set_property (node, gegl_pspec->name,
+                                  &value);
+
+          g_value_unset (&value);
+        }
+    }
+
+  g_free (pspecs);
+}
diff --git a/app/gegl/gimp-gegl-config-proxy.h b/app/gegl/gimp-gegl-config-proxy.h
index 55298aa..741f7fe 100644
--- a/app/gegl/gimp-gegl-config-proxy.h
+++ b/app/gegl/gimp-gegl-config-proxy.h
@@ -19,7 +19,10 @@
 #define __GIMP_GEGL_CONFIG_PROXY_H__
 
 
-GimpObject * gimp_gegl_get_config_proxy (const gchar *operation);
+GimpObject * gimp_gegl_get_config_proxy  (const gchar *operation);
+
+void         gimp_gegl_config_proxy_sync (GimpObject  *proxy,
+                                          GeglNode    *node);
 
 
 #endif /* __GIMP_GEGL_CONFIG_PROXY_H__ */
diff --git a/app/tools/gimpgegltool.c b/app/tools/gimpgegltool.c
index f29b85b..a10cdff 100644
--- a/app/tools/gimpgegltool.c
+++ b/app/tools/gimpgegltool.c
@@ -172,57 +172,10 @@ gimp_gegl_tool_get_operation (GimpImageMapTool  *im_tool,
 static void
 gimp_gegl_tool_map (GimpImageMapTool *image_map_tool)
 {
-  GimpGeglTool  *tool = GIMP_GEGL_TOOL (image_map_tool);
-  GParamSpec   **pspecs;
-  guint          n_pspecs;
-  gint           i;
-
-  if (! tool->config)
-    return;
-
-  pspecs = gegl_operation_list_properties (tool->operation, &n_pspecs);
-
-  for (i = 0; i < n_pspecs; i++)
-    {
-      GParamSpec *gegl_pspec = pspecs[i];
-      GParamSpec *gimp_pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (tool->config),
-                                                             gegl_pspec->name);
-
-      if (gimp_pspec)
-        {
-          GValue value = { 0, };
-
-          g_value_init (&value, gimp_pspec->value_type);
-
-          g_object_get_property (G_OBJECT (tool->config), gimp_pspec->name,
-                                 &value);
-
-          if (GIMP_IS_PARAM_SPEC_RGB (gimp_pspec))
-            {
-              GeglColor *gegl_color = gegl_color_new (NULL);
-              GimpRGB    gimp_color;
-
-              gimp_value_get_rgb (&value, &gimp_color);
-              g_value_unset (&value);
-
-              gegl_color_set_rgba (gegl_color,
-                                   gimp_color.r,
-                                   gimp_color.g,
-                                   gimp_color.b,
-                                   gimp_color.a);
-
-              g_value_init (&value, gegl_pspec->value_type);
-              g_value_take_object (&value, gegl_color);
-            }
-
-          gegl_node_set_property (image_map_tool->operation, gegl_pspec->name,
-                                  &value);
-
-          g_value_unset (&value);
-        }
-    }
+  GimpGeglTool *tool = GIMP_GEGL_TOOL (image_map_tool);
 
-  g_free (pspecs);
+  if (tool->config)
+    gimp_gegl_config_proxy_sync (tool->config, image_map_tool->operation);
 }
 
 static gboolean



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