|
Packit Service |
2781ba |
/* This file is part of GEGL
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* GEGL is free software; you can redistribute it and/or
|
|
Packit Service |
2781ba |
* modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
2781ba |
* License as published by the Free Software Foundation; either
|
|
Packit Service |
2781ba |
* version 3 of the License, or (at your option) any later version.
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* GEGL is distributed in the hope that it will be useful,
|
|
Packit Service |
2781ba |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
2781ba |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
2781ba |
* Lesser General Public License for more details.
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
2781ba |
* License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* Copyright 2009 Øyvind Kolås
|
|
Packit Service |
2781ba |
*/
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#include "config.h"
|
|
Packit Service |
2781ba |
#include <gegl.h>
|
|
Packit Service |
2781ba |
#include <gegl-plugin.h>
|
|
Packit Service |
2781ba |
#undef gegl_sampler_get
|
|
Packit Service |
2781ba |
#include <glib/gprintf.h>
|
|
Packit Service |
2781ba |
#include <gobject/gvaluecollector.h>
|
|
Packit Service |
2781ba |
#include <stdarg.h>
|
|
Packit Service |
2781ba |
#include <unistd.h>
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#include "graph/gegl-node.h"
|
|
Packit Service |
2781ba |
#include "graph/gegl-pad.h"
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static void
|
|
Packit Service |
2781ba |
gegl_graph_adopt (GeglNode *graph, GeglNode *node)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
GeglNode *input, *aux;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
gegl_node_add_child (graph, node);
|
|
Packit Service |
2781ba |
g_object_unref (node);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
if ((input = gegl_node_get_producer (node, "input", NULL)))
|
|
Packit Service |
2781ba |
gegl_graph_adopt (graph, input);
|
|
Packit Service |
2781ba |
if ((aux = gegl_node_get_producer (node, "aux", NULL)))
|
|
Packit Service |
2781ba |
gegl_graph_adopt (graph, aux);
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
GeglNode *
|
|
Packit Service |
2781ba |
gegl_graph (GeglNode *node)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
GeglNode *graph;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
graph = g_object_new (GEGL_TYPE_NODE, NULL);
|
|
Packit Service |
2781ba |
if (gegl_node_get_pad (node, "output"))
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
GeglNode *outproxynop = gegl_node_get_output_proxy (graph, "output");
|
|
Packit Service |
2781ba |
gegl_node_connect_to (node, "output", outproxynop, "input");
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
gegl_graph_adopt (graph, node);
|
|
Packit Service |
2781ba |
return graph;
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
GeglNode *
|
|
Packit Service |
2781ba |
gegl_node (const gchar *type,
|
|
Packit Service |
2781ba |
const gchar *firstname,
|
|
Packit Service |
2781ba |
...)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
GeglNode *node;
|
|
Packit Service |
2781ba |
GeglOperation *operation;
|
|
Packit Service |
2781ba |
va_list var_args;
|
|
Packit Service |
2781ba |
const gchar *property_name;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
node = g_object_new (GEGL_TYPE_NODE, "operation", type, NULL);
|
|
Packit Service |
2781ba |
g_object_get (G_OBJECT (node), "gegl-operation", &operation, NULL);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
g_object_freeze_notify (G_OBJECT (node));
|
|
Packit Service |
2781ba |
va_start (var_args, firstname);
|
|
Packit Service |
2781ba |
property_name = firstname;
|
|
Packit Service |
2781ba |
while (property_name)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
GValue value = { 0, };
|
|
Packit Service |
2781ba |
GParamSpec *pspec = NULL;
|
|
Packit Service |
2781ba |
gchar *error = NULL;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
if (!strcmp (property_name, "name"))
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
pspec = g_object_class_find_property (
|
|
Packit Service |
2781ba |
G_OBJECT_GET_CLASS (G_OBJECT (node)), property_name);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
|
|
Packit Service |
2781ba |
G_VALUE_COLLECT (&value, var_args, 0, &error);
|
|
Packit Service |
2781ba |
if (error)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
g_warning ("%s: %s", G_STRFUNC, error);
|
|
Packit Service |
2781ba |
g_free (error);
|
|
Packit Service |
2781ba |
g_value_unset (&value);
|
|
Packit Service |
2781ba |
break;
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
g_object_set_property (G_OBJECT (node), property_name, &value);
|
|
Packit Service |
2781ba |
g_value_unset (&value);
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
else
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
if (operation)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
pspec = g_object_class_find_property (
|
|
Packit Service |
2781ba |
G_OBJECT_GET_CLASS (G_OBJECT (operation)), property_name);
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
if (!pspec)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
g_warning ("%s:%s has no property named: '%s'",
|
|
Packit Service |
2781ba |
G_STRFUNC,
|
|
Packit Service |
2781ba |
G_OBJECT_TYPE_NAME (operation), property_name);
|
|
Packit Service |
2781ba |
break;
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
if (!(pspec->flags & G_PARAM_WRITABLE))
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
g_warning ("%s: property (%s of operation class '%s' is not writable",
|
|
Packit Service |
2781ba |
G_STRFUNC,
|
|
Packit Service |
2781ba |
pspec->name,
|
|
Packit Service |
2781ba |
G_OBJECT_TYPE_NAME (operation));
|
|
Packit Service |
2781ba |
break;
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
|
|
Packit Service |
2781ba |
G_VALUE_COLLECT (&value, var_args, 0, &error);
|
|
Packit Service |
2781ba |
if (error)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
g_warning ("%s: %s", G_STRFUNC, error);
|
|
Packit Service |
2781ba |
g_free (error);
|
|
Packit Service |
2781ba |
g_value_unset (&value);
|
|
Packit Service |
2781ba |
break;
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
g_object_set_property (G_OBJECT (operation), property_name, &value);
|
|
Packit Service |
2781ba |
g_value_unset (&value);
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
property_name = va_arg (var_args, gchar *);
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
g_object_thaw_notify (G_OBJECT (node));
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
/* The input pads checked for are hard-coded, if no output is connected
|
|
Packit Service |
2781ba |
* pass NULL to indicate no connected node.
|
|
Packit Service |
2781ba |
*/
|
|
Packit Service |
2781ba |
if (gegl_node_get_pad (node, "input"))
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
GeglNode *input = va_arg (var_args, GeglNode*);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
if (input)
|
|
Packit Service |
2781ba |
gegl_node_connect_from (node, "input", input, "output");
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
if (gegl_node_get_pad (node, "aux"))
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
GeglNode *aux = va_arg (var_args, GeglNode*);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
if (aux)
|
|
Packit Service |
2781ba |
gegl_node_connect_from (node, "aux", aux, "output");
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
va_end (var_args);
|
|
Packit Service |
2781ba |
return node;
|
|
Packit Service |
2781ba |
}
|