gpropz

gpropz

Functions

Types and Values

#define GPROPZ_VERSION
  GpropzValueFilter
extern GpropzValueFilter gpropz_obj_ref_filter

Includes

#include <gpropz.h>

Description

Functions

gpropz_auto_get_property ()

void
gpropz_auto_get_property (GObject *object,
                          guint prop_id,
                          GValue *value,
                          GParamSpec *spec);

This function may be placed in GObjectClass.get_property in order to use gpropz's automated getter.


gpropz_auto_set_property ()

void
gpropz_auto_set_property (GObject *object,
                          guint prop_id,
                          const GValue *value,
                          GParamSpec *spec);

This function may be placed in GObjectClass.get_property in order to use gpropz's automated setter.


gpropz_class_init_property_functions ()

void
gpropz_class_init_property_functions (GObjectClass *object_class);

Set's the object_class 's get_property and set_property attributes to gpropz_auto_get_property() and gpropz_auto_set_property(), respectively.

Parameters

object_class

The GObjectClass to set properties on.

 

gpropz_bind_property_full ()

void
gpropz_bind_property_full (gsize struct_offset,
                           guint prop_id,
                           GParamSpec *pspec,
                           GpropzValueFilter *filter);

Binds the member located at struct_offset within the object to the GObject property passed in prop_id and pspec . This means that gpropz_auto_set_property() and gpropz_auto_get_property() will automatically write to / read from this location in the object structure. filter specifies a GpropzValueFilter that will be applied to the property, meaning that any writes or reads will go through GpropzValueFilter.set_filter and GpropzValueFilter.get_filter, respectively, instead of being directly written to the object.

In most cases, you want to use gpropz_bind_property() or gpropz_bind_property_private() instead, or the auto-install functions gpropz_install_property() and gpropz_install_property_private().

Parameters

struct_offset

The offset into the object structure that this property should be bound to.

 

prop_id

The ID associated with this property.

 

pspec

The property's parameter spec.

 

filter

An optional filter that will manage reads/writes.

[nullable]

gpropz_install_property_full ()

void
gpropz_install_property_full (GObjectClass *object_class,
                              gsize struct_offset,
                              guint prop_id,
                              GParamSpec *pspec,
                              GpropzValueFilter *filter);

Shorthand for calling g_object_class_install_property() and gpropz_install_property_full() in succession.


gpropz_bind_property()

#define             gpropz_bind_property(TypeName, member_name, prop_id, pspec, filter)

Shorthand for gpropz_bind_property_full() that passes offsetof (TypeName , member_name ) as the structure offset to use.


gpropz_bind_property_private()

#define             gpropz_bind_property_private(TypeName, member_name, prop_id, pspec, filter)

Shorthand for gpropz_bind_property_full() that passes G_PRIVATE_OFFSET (TypeName , member_name ) as the structure offset to use.


gpropz_install_property()

#define             gpropz_install_property(klass, TypeName, member_name, prop_id, pspec, filter)

Shorthand for gpropz_install_property_full() that passes offsetof (TypeName , member_name ) as the structure offset to use.


gpropz_install_property_private()

#define             gpropz_install_property_private(klass, TypeName, member_name, prop_id, pspec, filter)

Shorthand for gpropz_install_property_full() that passes G_PRIVATE_OFFSET (TypeName , member_name ) as the structure offset to use.


GPROPZ_DEFINE_RO()

#define             GPROPZ_DEFINE_RO(member_type, TypeName, type_name, method_name, pspec)

Automatically defines a C getter function to get the given property.

Parameters

member_type

The property's type.

 

TypeName

The PascalCase name of your class.

 

type_name

The snake_case name of your class.

 

method_name

The name of the getter, e.g. if this "my_prop", then the generated getter will be named type_name_get_my_prop. This name does not have to be the same as the property's name.

 

pspec

A global instance of the GParamSpec that represents the property to get.

 

GPROPZ_DEFINE_RW()

#define             GPROPZ_DEFINE_RW(member_type, TypeName, type_name, method_name, pspec)

Identical to GPROPZ_DEFINE_RO(), but defines a setter as well.

Types and Values

GPROPZ_VERSION

#define GPROPZ_VERSION "0.1.0"

GpropzValueFilter

typedef struct {
  void (*get_filter) (GObject      *object,
                      gconstpointer prop,
                      guint         prop_id,
                      gpointer      target,
                      GParamSpec   *pspec);

  void (*set_filter) (GObject      *object,
                      gpointer      prop,
                      guint         prop_id,
                      gconstpointer source,
                      GParamSpec   *pspec);
} GpropzValueFilter;

A "filter" is a pair of get/set functions that override gpropz's magic getters and setters with their own, custom versions. Unlike the normal GObject set_property / get_property functions, these take raw pointers instead of GValue instances, because they are also for the auto-generated, property-specific C getters and setters, and we want to avoid constructing GValue instances every time.

Filters also allow you to have a different property type than you tell GLib; simply convert between the types in the filter functions.

Members

get_filter ()

This function, if not NULL, must read the given property (located at prop ), apply whatever transformations are desired, and then write it to target .

 

set_filter ()

This function, if not NULL, must write to the property (located at prop ) the value located at source .

 

gpropz_obj_ref_filter

extern GpropzValueFilter gpropz_obj_ref_filter;

A default filter that calls g_object_ref() on the input for both get_filter and set_filter. If you only want one of the two behaviors, use gpropz_obj_ref_filter.get_filter or gpropz_obj_ref_filter.set_filter to build your own filter structure.