mirror of https://github.com/GNOME/gimp.git
app: factor out gimp_gegl_config_proxy_sync() from GimpGeglTool
This commit is contained in:
parent
bfb3cd60d1
commit
726d3c980c
|
@ -19,8 +19,10 @@
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <cairo.h>
|
||||||
#include <gegl.h>
|
#include <gegl.h>
|
||||||
|
|
||||||
|
#include "libgimpcolor/gimpcolor.h"
|
||||||
#include "libgimpconfig/gimpconfig.h"
|
#include "libgimpconfig/gimpconfig.h"
|
||||||
|
|
||||||
#include "gimp-gegl-types.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);
|
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);
|
||||||
|
}
|
||||||
|
|
|
@ -19,7 +19,10 @@
|
||||||
#define __GIMP_GEGL_CONFIG_PROXY_H__
|
#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__ */
|
#endif /* __GIMP_GEGL_CONFIG_PROXY_H__ */
|
||||||
|
|
|
@ -172,57 +172,10 @@ gimp_gegl_tool_get_operation (GimpImageMapTool *im_tool,
|
||||||
static void
|
static void
|
||||||
gimp_gegl_tool_map (GimpImageMapTool *image_map_tool)
|
gimp_gegl_tool_map (GimpImageMapTool *image_map_tool)
|
||||||
{
|
{
|
||||||
GimpGeglTool *tool = GIMP_GEGL_TOOL (image_map_tool);
|
GimpGeglTool *tool = GIMP_GEGL_TOOL (image_map_tool);
|
||||||
GParamSpec **pspecs;
|
|
||||||
guint n_pspecs;
|
|
||||||
gint i;
|
|
||||||
|
|
||||||
if (! tool->config)
|
if (tool->config)
|
||||||
return;
|
gimp_gegl_config_proxy_sync (tool->config, image_map_tool->operation);
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (pspecs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
Loading…
Reference in New Issue