Synopsis#include <glib-object.h> gpointer (*GBoxedCopyFunc) (gpointer boxed); void (*GBoxedFreeFunc) (gpointer boxed); gpointer g_boxed_copy (GType boxed_type, gconstpointer src_boxed); void g_boxed_free (GType boxed_type, gpointer boxed); GType g_boxed_type_register_static (const gchar *name, GBoxedCopyFunc boxed_copy, GBoxedFreeFunc boxed_free); GType g_pointer_type_register_static (const gchar *name); #define G_TYPE_HASH_TABLE #define G_TYPE_DATE #define G_TYPE_GSTRING #define G_TYPE_STRV #define G_TYPE_REGEX typedef GStrv; DescriptionGBoxed is a generic wrapper mechanism for arbitrary C structures. The only thing the type system needs to know about the structures is how to copy and free them, beyond that they are treated as opaque chunks of memory. Boxed types are useful for simple value-holder structures like rectangles or points. They can also be used for wrapping structures defined in non-GObject based libraries.
DetailsGBoxedCopyFunc ()gpointer (*GBoxedCopyFunc) (gpointer boxed); This function is provided by the user and should produce a copy of the passed in boxed structure.
GBoxedFreeFunc ()void (*GBoxedFreeFunc) (gpointer boxed); This function is provided by the user and should free the boxed structure passed.
g_boxed_copy ()gpointer g_boxed_copy (GType boxed_type, gconstpointer src_boxed);
Provide a copy of a boxed structure
g_boxed_free ()void g_boxed_free (GType boxed_type, gpointer boxed);
Free the boxed structure
g_boxed_type_register_static ()GType g_boxed_type_register_static (const gchar *name, GBoxedCopyFunc boxed_copy, GBoxedFreeFunc boxed_free);
This function creates a new
g_pointer_type_register_static ()GType g_pointer_type_register_static (const gchar *name);
Creates a new
G_TYPE_HASH_TABLE#define G_TYPE_HASH_TABLE (g_hash_table_get_type ()) The GType for a boxed type holding a GHashTable reference.
Since 2.10 G_TYPE_STRV#define G_TYPE_STRV (g_strv_get_type ())
The GType for a boxed type holding a
The code fragments in the following example show the use of a property of
type G_TYPE_STRV with
g_object_class_install_property (object_class, PROP_AUTHORS, g_param_spec_boxed ("authors", _("Authors"), _("List of authors"), G_TYPE_STRV, G_PARAM_READWRITE)); gchar *authors[] = { "Owen", "Tim", NULL }; g_object_set (obj, "authors", authors, NULL); gchar *writers[]; g_object_get (obj, "authors", &writers, NULL); // do something with writers g_strfreev (writers);
Since 2.4 G_TYPE_REGEX#define G_TYPE_REGEX (g_regex_get_type ()) The GType for a boxed type holding a GRegex reference.
Since 2.14 |