RSS/Atom feed Twitter
Site is read-only, email is disabled

Transforming types

This discussion is connected to the gegl-developer-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

3 of 3 messages available
Toggle history

Please log in to manage your subscriptions.

Transforming types Tom Lechner 30 Nov 23:06
  Transforming types Øyvind Kolås 01 Dec 15:15
   Transforming types Tom Lechner 01 Dec 23:23
Tom Lechner
2017-11-30 23:06:40 UTC (over 6 years ago)

Transforming types

Hi,

I'm trying to figure out how to translate various data types for use with gegl. For instance, I want to set a GeglColor on a property. The example sdl-draw.c uses GeglColor directly in gegl_node_new_child(), but if I try to do this with gegl_node_set_property(node, "color", GeglColor*), compiler complains about it not being a GValue.

What is the proper way to convert back and forth between GeglColor and GValue, or otherwise use gegl_node_set_property() starting with non-GValue data? (no, I don't really understand the GValue/GObject system at the moment, hints welcome).

I can set things by manually constructing GValues for simple things like int, strings, but I'm kind of a loss for how to deal with the multitude of other types that Gegl uses in properties.

-Tom -----
tomlechner.com
laidout.org

Øyvind Kolås
2017-12-01 15:15:51 UTC (over 6 years ago)

Transforming types

On Fri, Dec 1, 2017 at 12:06 AM, Tom Lechner wrote:

I'm trying to figure out how to translate various data types for use with gegl. For instance, I want to set a GeglColor on a property. The example sdl-draw.c uses GeglColor directly in gegl_node_new_child(), but if I try to do this with gegl_node_set_property(node, "color", GeglColor*), compiler complains about it not being a GValue.

What is the proper way to convert back and forth between GeglColor and GValue, or otherwise use gegl_node_set_property() starting with non-GValue data? (no, I don't really understand the GValue/GObject system at the moment, hints welcome).

First perhaps try calling gegl_node_set (node, "color", color_value, NULL) instead?

The gegl_node_set_property call is normally needed mostly for either language binding implementations for user interfaces implementing their own equivalent of gegl_node_set or UI toolkit integration.

For setting a property on a node from C you would most commonly use gegl_node_set rather than gegl_node_set_property, gegl_node_set takes a NULL terminated list
of key/value pairs as varargs, and determines the expected type of the argument based on data registered for the property. With this you can also set multiple properties in
one go:

GeglColor *col;
..
gegl_node_set (text, "size", 16.0,
"color", col, "string", "hello there", NULL);

I can set things by manually constructing GValues for simple things like int, strings, but I'm kind of a loss for how to deal with the multitude of other types that Gegl uses in properties.

If you really want to do this manually the code is more verbose:

GValue value_color = {0,}; ..
g_value_init (&value_color, G_TYPE_OBJECT); g_value_set_object (&value_color, col); gegl_node_set_property (text, "color", &value_color);

For further details I would refer to gobject documentation, as a starting point there,
gobject has the similar calls working the same way in the g_object_set / g_object_set_property calls.

pippin - http://pippin.gimp.org/

Tom Lechner
2017-12-01 23:23:39 UTC (over 6 years ago)

Transforming types

On 12/01/2017 07:15 AM, Øyvind Kolås wrote:

First perhaps try calling gegl_node_set (node, "color", color_value, NULL) instead?

Aha! Success! That helps a lot, thanks.

-Tom