1 <!-- ##### SECTION Title ##### -->
4 <!-- ##### SECTION Short_Description ##### -->
5 Metadata for parameter specifications
7 <!-- ##### SECTION Long_Description ##### -->
9 #GParamSpec is an object structure that encapsulates the metadata
10 required to specify parameters, such as e.g. #GObject properties.
13 <!-- ##### SECTION See_Also ##### -->
15 g_object_class_install_property(), g_object_set(), g_object_get(),
16 g_object_set_property(), g_object_get_property(), g_value_register_transform_func()
19 <!-- ##### MACRO G_TYPE_IS_PARAM ##### -->
21 Returns whether @type "is a" %G_TYPE_PARAM.
27 <!-- ##### MACRO G_PARAM_SPEC ##### -->
29 Casts a derived #GParamSpec object (e.g. of type #GParamSpecInt) into
33 @pspec: a valid #GParamSpec
36 <!-- ##### MACRO G_IS_PARAM_SPEC ##### -->
38 Checks whether @pspec "is a" valid #GParamSpec structure of type %G_TYPE_PARAM
45 <!-- ##### MACRO G_PARAM_SPEC_CLASS ##### -->
47 Casts a derived #GParamSpecClass structure into a #GParamSpecClass structure.
50 @pclass: a valid #GParamSpecClass
53 <!-- ##### MACRO G_IS_PARAM_SPEC_CLASS ##### -->
55 Checks whether @pclass "is a" valid #GParamSpecClass structure of type
56 %G_TYPE_PARAM or derived.
59 @pclass: a #GParamSpecClass
62 <!-- ##### MACRO G_PARAM_SPEC_GET_CLASS ##### -->
64 Retrieves the #GParamSpecClass of a #GParamSpec.
67 @pspec: a valid #GParamSpec
70 <!-- ##### MACRO G_PARAM_SPEC_TYPE ##### -->
72 Retrieves the #GType of this @pspec.
75 @pspec: a valid #GParamSpec
78 <!-- ##### MACRO G_PARAM_SPEC_TYPE_NAME ##### -->
80 Retrieves the #GType name of this @pspec.
83 @pspec: a valid #GParamSpec
86 <!-- ##### MACRO G_PARAM_SPEC_VALUE_TYPE ##### -->
88 Retrieves the #GType to initialize a #GValue for this parameter.
91 @pspec: a valid #GParamSpec
94 <!-- ##### STRUCT GParamSpec ##### -->
96 All fields of the <structname>GParamSpec</structname> struct are private and
97 should not be used directly, except for the following:
100 @g_type_instance: private #GTypeInstance portion
101 @name: name of this parameter
102 @flags: #GParamFlags flags for this parameter
103 @value_type: the #GValue type for this parameter
104 @owner_type: #GType type that uses (introduces) this paremeter
106 <!-- ##### STRUCT GParamSpecClass ##### -->
108 The class structure for the <structname>GParamSpec</structname> type.
109 Normally, <structname>GParamSpec</structname> classes are filled by
110 g_param_type_register_static().
113 @g_type_class: the parent class
114 @value_type: the #GValue type for this parameter
115 @finalize: The instance finalization function (optional), should chain
116 up to the finalize method of the parent class.
117 @value_set_default: Resets a @value to the default value for this type
118 (recommended, the default is g_value_reset()), see
119 g_param_value_set_default().
120 @value_validate: Ensures that the contents of @value comply with the
121 specifications set out by this type (optional), see
122 g_param_value_set_validate().
123 @values_cmp: Compares @value1 with @value2 according to this type
124 (recommended, the default is memcmp()), see g_param_values_cmp().
126 <!-- ##### ENUM GParamFlags ##### -->
128 Through the #GParamFlags flag values, certain aspects of parameters
132 @G_PARAM_READABLE: the parameter is readable
133 @G_PARAM_WRITABLE: the parameter is writable
134 @G_PARAM_CONSTRUCT: the parameter will be set upon object construction
135 @G_PARAM_CONSTRUCT_ONLY: the parameter will only be set upon object construction
136 @G_PARAM_LAX_VALIDATION: upon parameter conversion (see g_param_value_convert())
137 strict validation is not required
140 <!-- ##### MACRO G_PARAM_READWRITE ##### -->
142 #GParamFlags value alias for %G_PARAM_READABLE | %G_PARAM_WRITABLE.
147 <!-- ##### MACRO G_PARAM_MASK ##### -->
149 Mask containing the bits of #GParamSpec.flags which are reserved for GLib.
154 <!-- ##### MACRO G_PARAM_USER_SHIFT ##### -->
156 Minimum shift count to be used for user defined flags, to be stored in
162 <!-- ##### FUNCTION g_param_spec_ref ##### -->
164 Increments the reference count of @pspec.
167 @pspec: a valid #GParamSpec
168 @Returns: the #GParamSpec that was passed into this function
171 <!-- ##### FUNCTION g_param_spec_unref ##### -->
173 Decrements the reference count of a @pspec.
176 @pspec: a valid #GParamSpec
179 <!-- ##### FUNCTION g_param_spec_sink ##### -->
181 The initial reference count of a newly created #GParamSpec is 1, even
182 though no one has explicitly called g_param_spec_ref() on it yet. So the
183 initial reference count is flagged as "floating", until someone calls
184 <literal>g_param_spec_ref (@pspec); g_param_spec_sink (@pspec);</literal>
185 in sequence on it, taking over the initial reference count (thus
186 ending up with a @pspec that has a reference count of 1 still, but is
187 not flagged "floating" anymore).
190 @pspec: a valid #GParamSpec
193 <!-- ##### FUNCTION g_param_value_set_default ##### -->
195 Sets @value to its default value as specified in @pspec.
198 @pspec: a valid #GParamSpec
199 @value: a #GValue of correct type for @pspec
202 <!-- ##### FUNCTION g_param_value_defaults ##### -->
204 Checks whether @value contains the default value as specified in @pspec.
207 @pspec: a valid #GParamSpec
208 @value: a #GValue of correct type for @pspec
209 @Returns: whether @value contains the canonical defualt for this @pspec
212 <!-- ##### FUNCTION g_param_value_validate ##### -->
214 Ensures that the contents of @value comply with the specifications
215 set out by @pspec. For example, a #GParamSpecInt might require
216 that integers stored in @value may not be smaller than -42 and not be
217 greater than +42. If @value contains an integer outside of this range,
218 it is modified accordingly, so the resulting value will fit into the
222 @pspec: a valid #GParamSpec
223 @value: a #GValue of correct type for @pspec
224 @Returns: whether modifying @value was necessary to ensure validity
227 <!-- ##### FUNCTION g_param_value_convert ##### -->
229 Transforms @src_value into @dest_value if possible, and then validates
230 @dest_value, in order for it to conform to @pspec.
231 If @strict_validation is %TRUE this function will only succeed if
232 the transformed @dest_value complied to @pspec without modifications.
234 See also g_value_type_transformable(), g_value_transform() and
235 g_param_value_validate().
238 @pspec: a valid #GParamSpec
239 @src_value: souce #GValue
240 @dest_value: destination #GValue of correct type for @pspec
241 @strict_validation: %TRUE requires @dest_value to conform to @pspec without modifications
242 @Returns: %TRUE if transformation and validation were successfull,
243 %FALSE otherwise and @dest_value is left untouched.
246 <!-- ##### FUNCTION g_param_values_cmp ##### -->
248 Compares @value1 with @value2 according to @pspec, and return -1, 0 or +1,
249 if @value1 is found to be less than, equal to or greater than @value2,
253 @pspec: a valid #GParamSpec
254 @value1: a #GValue of correct type for @pspec
255 @value2: a #GValue of correct type for @pspec
256 @Returns: -1, 0 or +1, for a less than, equal to or greater than result
259 <!-- ##### FUNCTION g_param_spec_get_name ##### -->
261 Returns the name of a #GParamSpec.
264 @pspec: a valid #GParamSpec
265 @Returns: the name of @pspec.
268 <!-- ##### FUNCTION g_param_spec_get_nick ##### -->
270 Returns the nickname of a #GParamSpec.
273 @pspec: a valid #GParamSpec
274 @Returns: the nickname of @pspec.
277 <!-- ##### FUNCTION g_param_spec_get_blurb ##### -->
279 Returns the short description of a #GParamSpec.
282 @pspec: a valid #GParamSpec
283 @Returns: the short description of @pspec.
286 <!-- ##### FUNCTION g_param_spec_get_qdata ##### -->
288 Gets back user data pointers stored via g_param_spec_set_qdata().
291 @pspec: a valid #GParamSpec
292 @quark: a #GQuark, naming the user data pointer
293 @Returns: the user data pointer set, or %NULL
296 <!-- ##### FUNCTION g_param_spec_set_qdata ##### -->
298 Sets an opaque, named pointer on a #GParamSpec. The name is specified
299 through a #GQuark (retrieved e.g. via g_quark_from_static_string()), and
300 the pointer can be gotten back from the @pspec with g_param_spec_get_qdata().
301 Setting a previously set user data pointer, overrides (frees)
302 the old pointer set, using #NULL as pointer essentially
303 removes the data stored.
306 @pspec: the #GParamSpec to set store a user data pointer
307 @quark: a #GQuark, naming the user data pointer
308 @data: an opaque user data pointer
311 <!-- ##### FUNCTION g_param_spec_set_qdata_full ##### -->
313 This function works like g_param_spec_set_qdata(), but in addition,
314 a <literal>void (*destroy) (gpointer)</literal> function may be
315 specified which is called with @data as argument when the @pspec is
316 finalized, or the data is being overwritten by a call to
317 g_param_spec_set_qdata() with the same @quark.
320 @pspec: the #GParamSpec to set store a user data pointer
321 @quark: a #GQuark, naming the user data pointer
322 @data: an opaque user data pointer
323 @destroy: function to invoke with @data as argument, when @data needs to
327 <!-- ##### FUNCTION g_param_spec_steal_qdata ##### -->
329 Gets back user data pointers stored via g_param_spec_set_qdata() and
330 removes the @data from @pspec without invoking it's destroy() function
332 Usually, calling this function is only required to update
333 user data pointers with a destroy notifier.
336 @pspec: the #GParamSpec to get a stored user data pointer from
337 @quark: a #GQuark, naming the user data pointer
338 @Returns: the user data pointer set, or %NULL
341 <!-- ##### FUNCTION g_param_spec_get_redirect_target ##### -->
343 If the paramspec redirects operations to another paramspec,
344 returns that paramspec. Redirect is used typically for
345 providing a new implementation of a property in a derived
346 type while perserving all the properties from the parent
347 type. Redirection is established by creating a property
348 of type #GParamSpecOverride. See g_object_override_property()
349 for an example of the use of this capability.
352 @pspec: a #GParamSpec
353 @Returns: paramspec to which requests on this paramspec should
354 be redirected, or %NULL if none.
358 <!-- ##### FUNCTION g_param_spec_internal ##### -->
360 Creates a new #GParamSpec instance.
363 A property name consists of segments consisting of ASCII letters and
364 digits, separated by either the '-' or '_' character. The first
365 character of a property name must be a letter. Names which violate these
366 rules lead to undefined behaviour.
369 When creating and looking up a #GParamSpec, either separator can be used,
370 but they cannot be mixed. Using '-' is considerably more efficient and in
371 fact required when using property names as detail strings for signals.
374 @param_type: the #GType for the property; must be derived from #G_TYPE_PARAM
375 @name: the canonical name of the property
376 @nick: the nickname of the property
377 @blurb: a short description of the property
378 @flags: a combination of #GParamFlags
379 @Returns: a newly allocated #GParamSpec instance
382 <!-- ##### STRUCT GParamSpecTypeInfo ##### -->
384 This structure is used to provide the type system with the information
385 required to initialize and destruct (finalize) a parameter's class and
387 The initialized structure is passed to the g_param_type_register_static()
388 The type system will perform a deep copy of this structure, so it's memory
389 does not need to be persistent across invocation of
390 g_param_type_register_static().
393 @instance_size: Size of the instance (object) structure.
394 @n_preallocs: Number of pre-allocated (cached) instances to reserve memory for (0 indicates no caching).
395 @instance_init: Location of the instance initialization function (optional).
396 @value_type: The #GType of values conforming to this #GParamSpec
397 @finalize: The instance finalization function (optional).
398 @value_set_default: Resets a @value to the default value for @pspec
399 (recommended, the default is g_value_reset()), see
400 g_param_value_set_default().
401 @value_validate: Ensures that the contents of @value comply with the
402 specifications set out by @pspec (optional), see
403 g_param_value_set_validate().
404 @values_cmp: Compares @value1 with @value2 according to @pspec
405 (recommended, the default is memcmp()), see g_param_values_cmp().
407 <!-- ##### FUNCTION g_param_type_register_static ##### -->
409 Registers @name as the name of a new static type derived from
410 #G_TYPE_PARAM. The type system uses the information contained in the
411 #GParamSpecTypeInfo structure pointed to by @info to manage the #GParamSpec
412 type and its instances.
415 @name: 0-terminated string used as the name of the new #GParamSpec type.
416 @pspec_info: The #GParamSpecTypeInfo for this #GParamSpec type.
417 @Returns: The new type identifier.
420 <!-- ##### STRUCT GParamSpecPool ##### -->
422 A #GParamSpecPool maintains a collection of #GParamSpec<!-- -->s which can be
423 quickly accessed by owner and name. The implementation of the #GObject property
424 system uses such a pool to store the #GParamSpecs of the properties all object
429 <!-- ##### FUNCTION g_param_spec_pool_new ##### -->
431 Creates a new #GParamSpecPool.
434 If @type_prefixing is %TRUE, lookups in the newly created pool will
435 allow to specify the owner as a colon-separated prefix of the property name,
436 like "GtkContainer:border-width". This feature is deprecated, so you should
437 always set @type_prefixing to %FALSE.
440 @type_prefixing: Whether the pool will support type-prefixed property names.
441 @Returns: a newly allocated #GParamSpecPool.
444 <!-- ##### FUNCTION g_param_spec_pool_insert ##### -->
446 Inserts a #GParamSpec in the pool.
449 @pool: a #GParamSpecPool.
450 @pspec: the #GParamSpec to insert
451 @owner_type: a #GType identifying the owner of @pspec
454 <!-- ##### FUNCTION g_param_spec_pool_remove ##### -->
456 Removes a #GParamSpec from the pool.
459 @pool: a #GParamSpecPool
460 @pspec: the #GParamSpec to remove
463 <!-- ##### FUNCTION g_param_spec_pool_lookup ##### -->
465 Looks up a #GParamSpec in the pool.
468 @pool: a #GParamSpecPool
469 @param_name: the name to look for
470 @owner_type: the owner to look for
471 @walk_ancestors: If %TRUE, also try to find a #GParamSpec with @param_name
472 owned by an ancestor of @owner_type.
473 @Returns: The found #GParamSpec, or %NULL if no matching #GParamSpec was found.
476 <!-- ##### FUNCTION g_param_spec_pool_list ##### -->
478 Gets an array of all #GParamSpec<!-- -->s owned by @owner_type in the pool.
481 @pool: a #GParamSpecPool
482 @owner_type: the owner to look for
483 @n_pspecs_p: return location for the length of the returned array
484 @Returns: a newly allocated array containing pointers to all
485 #GParamSpec<!-- -->s owned by @owner_type in the pool
488 <!-- ##### FUNCTION g_param_spec_pool_list_owned ##### -->
490 Gets an #GList of all #GParamSpec<!-- -->s owned by @owner_type in the pool.
493 @pool: a #GParamSpecPool
494 @owner_type: the owner to look for
495 @Returns: a #GList of all #GParamSpec<!-- -->s owned by @owner_type in
496 the pool#GParamSpec<!-- -->s.