Re: Transforming types

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

 



On Fri, Dec 1, 2017 at 12:06 AM, Tom Lechner <tomscoding@xxxxxxxxx> 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/
_______________________________________________
gegl-developer-list mailing list
List address:    gegl-developer-list@xxxxxxxxx
List membership: https://mail.gnome.org/mailman/listinfo/gegl-developer-list




[Index of Archives]     [Yosemite News]     [Yosemite Photos]     [gtk]     [GIMP Users]     [KDE]     [Gimp's Home]     [Gimp on Windows]     [Steve's Art]

  Powered by Linux