I want to define properties on a custom GObject-based class with the type of the property being GstStructure *
. This is a registered GType, but not a subclass of GObject. Properties are set and retrieved as GValue
, but GValue doesn't seem to support GType
values. It is possible to create a g_param_spec_gtype
, but the GType parameter to that factory function is called is_a_type
, which is confusing, because it implies boolean, so I'm not sure what this type of param spec is for. Should I just register it as a pointer and sacrifice some type-safety for simplicity, or are you supposed to use GBoxed?
The GParamSpec
for GType
is for storing an actual GType
value, not for storing instances of a type registered in the type system.
There are no GParamSpec
provided by GLib for fundamental instantiatable types—i.e. types that inherits from GTypeInstance
but do not derive from GObject
—because GLib can't know anything about them: they are a separate hierarchy.
If a library is providing you with a fundamental instantiatable type, then the same library should also provide you with:
GValue
wrappers, for boxing and unboxing instances in properties and signalsGParamSpec
type and an API to define GObject propertiesThe GstStructure
type, though, is a reference counted plain old data type, and it inherits from GBoxed
; this means you can use g_param_spec_boxed()
to define a property that holds a GstStructure
instance.