Commit 2c511392 authored by Daniel Sabo's avatar Daniel Sabo

Improve gegl_node_get_property, fix introspection

Allow gegl_node_get_property to see all properties of the node,
and add an introspectable version that takes care of initializing
the GValue to the correct type.
parent 6e88342b
......@@ -39,67 +39,66 @@ LIBS = \
GEGL_publicdir = $(includedir)/gegl-$(GEGL_API_VERSION)
GEGL_introspectable_headers = \
gegl.h \
gegl-types.h \
gegl-enums.h \
gegl-utils.h \
gegl-matrix.h \
gegl-lookup.h \
gegl-version.h \
buffer/gegl-buffer.h \
buffer/gegl-buffer-iterator.h \
buffer/gegl-buffer-backend.h \
buffer/gegl-tile-backend.h \
buffer/gegl-tile-handler.h \
buffer/gegl-tile-source.h \
process/gegl-graph-debug.h \
property-types/gegl-paramspecs.h \
property-types/gegl-color.h \
property-types/gegl-path.h \
property-types/gegl-curve.h
gegl.h \
gegl-types.h \
gegl-enums.h \
gegl-utils.h \
gegl-matrix.h \
gegl-lookup.h \
gegl-version.h \
buffer/gegl-buffer.h \
buffer/gegl-buffer-iterator.h \
buffer/gegl-buffer-backend.h \
buffer/gegl-tile-backend.h \
buffer/gegl-tile-handler.h \
buffer/gegl-tile-source.h \
process/gegl-graph-debug.h \
property-types/gegl-paramspecs.h \
property-types/gegl-color.h \
property-types/gegl-path.h \
property-types/gegl-curve.h
GEGL_public_HEADERS = \
$(GEGL_introspectable_headers) \
gegl-chant.h \
gegl-cpuaccel.h \
gegl-plugin.h \
buffer/gegl-tile.h
gegl-chant.h \
gegl-cpuaccel.h \
gegl-plugin.h \
buffer/gegl-tile.h
GEGL_introspectable_sources = \
GEGL_sources = \
gegl-c.c \
gegl-apply.c \
gegl-apply.c \
gegl-config.c \
gegl-cpuaccel.c \
gegl-dot.c \
gegl-dot-visitor.c \
gegl-enums.c \
gegl-enums.c \
gegl-init.c \
gegl-instrument.c \
gegl-introspection-support.c \
gegl-utils.c \
gegl-lookup.c \
gegl-xml.c \
gegl-random.c \
gegl-matrix.c \
gegl-random.c \
gegl-matrix.c \
\
gegl-lookup.h \
gegl-apply.h \
gegl-chant.h \
gegl-config.h \
gegl-cpuaccel.h \
gegl-cpuaccel-priv.h \
gegl-debug.h \
gegl-dot.h \
gegl-dot-visitor.h \
gegl-init.h \
gegl-instrument.h \
gegl-introspection-support.h \
gegl-lookup.h \
gegl-matrix.h \
gegl-module.h \
gegl-plugin.h \
gegl-types-internal.h \
gegl-xml.h \
gegl-matrix.h
GEGL_sources = \
$(GEGL_introspectable_sources) \
gegl-module.h \
gegl-apply.h \
gegl-chant.h \
gegl-cpuaccel-priv.h
gegl-xml.h
lib_LTLIBRARIES = libgegl-@GEGL_API_VERSION@.la
......@@ -117,8 +116,8 @@ libgegl_@GEGL_API_VERSION@_la_LIBADD = \
if HAVE_INTROSPECTION
introspection_sources = \
$(GEGL_instrospectable_sources) \
$(GEGL_introspectable_headers)
$(GEGL_introspectable_headers) \
gegl-introspection-support.h
Gegl-@GEGL_API_VERSION@.gir: libgegl-@GEGL_API_VERSION@.la Makefile
Gegl_@GEGL_MAJOR_VERSION@_@GEGL_MINOR_VERSION@_gir_INCLUDES = GObject-2.0 GLib-2.0
......
/* This file is part of GEGL
*
* GEGL is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* GEGL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2013 Daniel Sabo
*/
/*
* This file contains alternate versions of functions to make them
* more introspection friendly. They are not a public part of the
* C API and should not be used outside of this file.
*/
#include "config.h"
#include <string.h>
#include <glib-object.h>
#include "gegl-types-internal.h"
#include "gegl.h"
#include "graph/gegl-node.h"
#include "gegl-introspection-support.h"
GValue *
gegl_node_introspectable_get_property (GeglNode *node,
const gchar *property_name)
{
GValue *result = g_new0 (GValue, 1);
gegl_node_get_property (node, property_name, result);
return result;
}
/* This file is part of GEGL
*
* GEGL is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* GEGL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2013 Daniel Sabo
*/
/*
* This file contains alternate versions of functions to make them
* more introspection friendly. They are not a public part of the
* C API and should not be used outside of this file.
*/
#include <glib-object.h>
#include <gegl-types.h>
/**
* gegl_node_introspectable_get_property:
* @node: the node to get a property from
* @property_name: the name of the property to get
*
* Rename to: gegl_node_get_property
*
* Return value: (transfer full): pointer to a GValue containing the value of the property
*/
GValue * gegl_node_introspectable_get_property (GeglNode *node,
const gchar *property_name);
......@@ -693,7 +693,7 @@ GeglNode * gegl_node_create_child (GeglNode *parent,
/**
* gegl_node_get_property:
* gegl_node_get_property: (skip)
* @node: the node to get a property from
* @property_name: the name of the property to get
* @value: (out): pointer to a GValue where the value of the property should be stored
......
......@@ -1433,34 +1433,38 @@ gegl_node_get_property (GeglNode *self,
const gchar *property_name,
GValue *value)
{
GParamSpec *pspec;
g_return_if_fail (GEGL_IS_NODE (self));
g_return_if_fail (property_name != NULL);
g_return_if_fail (value != NULL);
if (!strcmp (property_name, "operation") ||
!strcmp (property_name, "name"))
/* Unlinke GObject's get_property this function also
* accepts a zero'd GValue and will fill it with the
* correct type automaticaly.
*/
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (self), property_name);
if (pspec)
{
g_object_get_property (G_OBJECT (self),
property_name, value);
if (!G_IS_VALUE (value))
g_value_init (value, pspec->value_type);
g_object_get_property (G_OBJECT (self), property_name, value);
return;
}
else
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (self->operation), property_name);
if (pspec)
{
if (self->is_graph &&
!strcmp (property_name, "output"))
{
g_warning ("Eeek!");
g_object_get_property (G_OBJECT (gegl_node_get_output_proxy (self, "output")->operation),
property_name, value);
}
else
{
if (self->operation)
{
g_object_get_property (G_OBJECT (self->operation),
property_name, value);
}
}
if (!G_IS_VALUE (value))
g_value_init (value, pspec->value_type);
g_object_get_property (G_OBJECT (self->operation), property_name, value);
return;
}
g_warning ("%s is not a valid property of %s",
property_name,
gegl_node_get_debug_name (self));
}
GParamSpec *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment