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 ##### -->
99 @g_type_instance: private #GTypeInstance portion
100 @name: name of this parameter
101 @flags: #GParamFlags flags for this parameter
102 @value_type: the #GValue type for this parameter
103 @owner_type: #GType type that uses (introduces) this paremeter
105 <!-- ##### STRUCT GParamSpecClass ##### -->
118 <!-- ##### ENUM GParamFlags ##### -->
120 Through the #GParamFlags flag values, certain aspects of parameters
124 @G_PARAM_READABLE: the parameter is readable
125 @G_PARAM_WRITABLE: the parameter is writable
126 @G_PARAM_CONSTRUCT: the parameter will be set upon object construction
127 @G_PARAM_CONSTRUCT_ONLY: the parameter will only be set upon object construction
128 @G_PARAM_LAX_VALIDATION: upon parameter conversion (see g_param_value_convert())
129 strict validation is not required
132 <!-- ##### MACRO G_PARAM_READWRITE ##### -->
134 #GParamFlags value alias for %G_PARAM_READABLE | %G_PARAM_WRITABLE.
139 <!-- ##### MACRO G_PARAM_MASK ##### -->
141 Mask containing the bits of #GParamSpec.flags which are reserved for GLib.
146 <!-- ##### MACRO G_PARAM_USER_SHIFT ##### -->
148 Minimum shift count to be used for user defined flags, to be stored in
154 <!-- ##### FUNCTION g_param_spec_ref ##### -->
156 Increments the reference count of @pspec.
159 @pspec: a valid #GParamSpec
160 @Returns: the #GParamSpec that was passed into this function
163 <!-- ##### FUNCTION g_param_spec_unref ##### -->
165 Decrements the reference count of a @pspec.
168 @pspec: a valid #GParamSpec
171 <!-- ##### FUNCTION g_param_spec_sink ##### -->
173 The initial reference count of a newly created #GParamSpec is 1, even
174 though no one has explicitly called g_param_spec_ref() on it yet. So the
175 initial reference count is flagged as "floating", until someone calls
176 <literal>g_param_spec_ref (@pspec); g_param_spec_sink (@pspec);</literal>
177 in sequence on it, taking over the initial reference count (thus
178 ending up with a @pspec that has a reference count of 1 still, but is
179 not flagged "floating" anymore).
182 @pspec: a valid #GParamSpec
185 <!-- ##### FUNCTION g_param_value_set_default ##### -->
187 Sets @value to its default value as specified in @pspec.
190 @pspec: a valid #GParamSpec
191 @value: a #GValue of correct type for @pspec
194 <!-- ##### FUNCTION g_param_value_defaults ##### -->
196 Checks whether @value contains the default value as specified in @pspec.
199 @pspec: a valid #GParamSpec
200 @value: a #GValue of correct type for @pspec
201 @Returns: whether @value contains the canonical defualt for this @pspec
204 <!-- ##### FUNCTION g_param_value_validate ##### -->
206 Ensures that the contents of @value comply with the specifications
207 set out by @pspec. For example, a #GParamSpecInt might require
208 that integers stored in @value may not be smaller than -42 and not be
209 greater than +42. If @value contains an integer outside of this range,
210 it is modified accordingly, so the resulting value will fit into the
214 @pspec: a valid #GParamSpec
215 @value: a #GValue of correct type for @pspec
216 @Returns: whether modifying @value was necessary to ensure validity
219 <!-- ##### FUNCTION g_param_value_convert ##### -->
221 Transforms @src_value into @dest_value if possible, and then validates
222 @dest_value, in order for it to conform to @pspec.
223 If @strict_validation is %TRUE this function will only succeed if
224 the transformed @dest_value complied to @pspec without modifications.
226 See also g_value_type_transformable(), g_value_transform() and
227 g_param_value_validate().
230 @pspec: a valid #GParamSpec
231 @src_value: souce #GValue
232 @dest_value: destination #GValue of correct type for @pspec
233 @strict_validation: %TRUE requires @dest_value to conform to @pspec without modifications
234 @Returns: %TRUE if transformation and validation were successfull,
235 %FALSE otherwise and @dest_value is left untouched.
238 <!-- ##### FUNCTION g_param_values_cmp ##### -->
240 Compares @value1 with @value2 according to @pspec, and return -1, 0 or +1,
241 if @value1 is found to be less than, equal to or greater than @value2,
245 @pspec: a valid #GParamSpec
246 @value1: a #GValue of correct type for @pspec
247 @value2: a #GValue of correct type for @pspec
248 @Returns: -1, 0 or +1, for a less than, equal to or greater than result
251 <!-- ##### FUNCTION g_param_spec_get_name ##### -->
253 Returns the name of a #GParamSpec.
256 @pspec: a valid #GParamSpec
257 @Returns: the name of @pspec.
260 <!-- ##### FUNCTION g_param_spec_get_nick ##### -->
262 Returns the nickname of a #GParamSpec.
265 @pspec: a valid #GParamSpec
266 @Returns: the nickname of @pspec.
269 <!-- ##### FUNCTION g_param_spec_get_blurb ##### -->
271 Returns the short description of a #GParamSpec.
274 @pspec: a valid #GParamSpec
275 @Returns: the short description of @pspec.
278 <!-- ##### FUNCTION g_param_spec_get_qdata ##### -->
280 Gets back user data pointers stored via g_param_spec_set_qdata().
283 @pspec: a valid #GParamSpec
284 @quark: a #GQuark, naming the user data pointer
285 @Returns: the user data pointer set, or %NULL
288 <!-- ##### FUNCTION g_param_spec_set_qdata ##### -->
290 Sets an opaque, named pointer on a #GParamSpec. The name is specified
291 through a #GQuark (retrieved e.g. via g_quark_from_static_string()), and
292 the pointer can be gotten back from the @pspec with g_param_spec_get_qdata().
293 Setting a previously set user data pointer, overrides (frees)
294 the old pointer set, using #NULL as pointer essentially
295 removes the data stored.
298 @pspec: the #GParamSpec to set store a user data pointer
299 @quark: a #GQuark, naming the user data pointer
300 @data: an opaque user data pointer
303 <!-- ##### FUNCTION g_param_spec_set_qdata_full ##### -->
305 This function works like g_param_spec_set_qdata(), but in addition,
306 a <literal>void (*destroy) (gpointer)</literal> function may be
307 specified which is called with @data as argument when the @pspec is
308 finalized, or the data is being overwritten by a call to
309 g_param_spec_set_qdata() with the same @quark.
312 @pspec: the #GParamSpec to set store a user data pointer
313 @quark: a #GQuark, naming the user data pointer
314 @data: an opaque user data pointer
315 @destroy: function to invoke with @data as argument, when @data needs to
319 <!-- ##### FUNCTION g_param_spec_steal_qdata ##### -->
321 Gets back user data pointers stored via g_param_spec_set_qdata() and
322 removes the @data from @pspec without invoking it's destroy() function
324 Usually, calling this function is only required to update
325 user data pointers with a destroy notifier.
328 @pspec: the #GParamSpec to get a stored user data pointer from
329 @quark: a #GQuark, naming the user data pointer
330 @Returns: the user data pointer set, or %NULL
333 <!-- ##### FUNCTION g_param_spec_get_redirect_target ##### -->
335 If the paramspec redirects operations to another paramspec,
336 returns that paramspec. Redirect is used typically for
337 providing a new implementation of a property in a derived
338 type while perserving all the properties from the parent
339 type. Redirection is established by creating a property
340 of type #GParamSpecOverride. See g_object_override_property()
341 for an example of the use of this capability.
344 @pspec: a #GParamSpec
345 @Returns: paramspec to which requests on this paramspec should
346 be redirected, or %NULL if none.
349 <!-- ##### FUNCTION g_param_spec_internal ##### -->
351 Creates a new #GParamSpec instance.
354 A property name consists of segments consisting of ASCII letters and
355 digits, separated by either the '-' or '_' character. The first
356 character of a property name must be a letter. Names which violate these
357 rules lead to undefined behaviour.
360 When creating and looking up a #GParamSpec, either separator can be used,
361 but they cannot be mixed. Using '-' is considerably more efficient and in
362 fact required when using property names as detail strings for signals.
365 @param_type: the #GType for the property; must be derived from #G_TYPE_PARAM
366 @name: the canonical name of the property
367 @nick: the nickname of the property
368 @blurb: a short description of the property
369 @flags: a combination of #GParamFlags
370 @Returns: a newly allocated #GParamSpec instance
373 <!-- ##### STRUCT GParamSpecTypeInfo ##### -->
375 This structure is used to provide the type system with the information
376 required to initialize and destruct (finalize) a parameter's class and
378 The initialized structure is passed to the g_param_type_register_static()
379 The type system will perform a deep copy of this structure, so it's memory
380 does not need to be persistent across invocation of
381 g_param_type_register_static().
384 @instance_size: Size of the instance (object) structure.
385 @n_preallocs: Number of pre-allocated (cached) instances to reserve memory for (0 indicates no caching).
386 @instance_init: Location of the instance initialization function (optional).
387 @value_type: The #GType of values conforming to this #GParamSpec
388 @finalize: The instance finalization function (optional).
389 @value_set_default: Resets a @value to the default value for @pspec
390 (recommended, the default is g_value_reset()), see
391 g_param_value_set_default().
392 @value_validate: Ensures that the contents of @value comply with the
393 specifications set out by @pspec (optional), see
394 g_param_value_set_validate().
395 @values_cmp: Compares @value1 with @value2 according to @pspec
396 (recommended, the default is memcmp()), see g_param_values_cmp().
398 <!-- ##### FUNCTION g_param_type_register_static ##### -->
400 Registers @name as the name of a new static type derived from
401 #G_TYPE_PARAM. The type system uses the information contained in the
402 #GParamSpecTypeInfo structure pointed to by @info to manage the #GParamSpec
403 type and its instances.
406 @name: 0-terminated string used as the name of the new #GParamSpec type.
407 @pspec_info: The #GParamSpecTypeInfo for this #GParamSpec type.
408 @Returns: The new type identifier.
411 <!-- ##### STRUCT GParamSpecPool ##### -->
413 A #GParamSpecPool maintains a collection of #GParamSpec<!-- -->s which can be
414 quickly accessed by owner and name. The implementation of the #GObject property
415 system uses such a pool to store the #GParamSpecs of the properties all object
420 <!-- ##### FUNCTION g_param_spec_pool_new ##### -->
422 Creates a new #GParamSpecPool.
425 If @type_prefixing is %TRUE, lookups in the newly created pool will
426 allow to specify the owner as a colon-separated prefix of the property name,
427 like "GtkContainer:border-width". This feature is deprecated, so you should
428 always set @type_prefixing to %FALSE.
431 @type_prefixing: Whether the pool will support type-prefixed property names.
432 @Returns: a newly allocated #GParamSpecPool.
435 <!-- ##### FUNCTION g_param_spec_pool_insert ##### -->
437 Inserts a #GParamSpec in the pool.
440 @pool: a #GParamSpecPool.
441 @pspec: the #GParamSpec to insert
442 @owner_type: a #GType identifying the owner of @pspec
445 <!-- ##### FUNCTION g_param_spec_pool_remove ##### -->
447 Removes a #GParamSpec from the pool.
450 @pool: a #GParamSpecPool
451 @pspec: the #GParamSpec to remove
454 <!-- ##### FUNCTION g_param_spec_pool_lookup ##### -->
456 Looks up a #GParamSpec in the pool.
459 @pool: a #GParamSpecPool
460 @param_name: the name to look for
461 @owner_type: the owner to look for
462 @walk_ancestors: If %TRUE, also try to find a #GParamSpec with @param_name
463 owned by an ancestor of @owner_type.
464 @Returns: The found #GParamSpec, or %NULL if no matching #GParamSpec was found.
467 <!-- ##### FUNCTION g_param_spec_pool_list ##### -->
469 Gets an array of all #GParamSpec<!-- -->s owned by @owner_type in the pool.
472 @pool: a #GParamSpecPool
473 @owner_type: the owner to look for
474 @n_pspecs_p: return location for the length of the returned array
475 @Returns: a newly allocated array containing pointers to all
476 #GParamSpec<!-- -->s owned by @owner_type in the pool
480 <!-- ##### FUNCTION g_param_spec_pool_list_owned ##### -->
482 Gets an #GList of all #GParamSpec<!-- -->s owned by @owner_type in the pool.
485 @pool: a #GParamSpecPool
486 @owner_type: the owner to look for
487 @Returns: a #GList of all #GParamSpec<!-- -->s owned by @owner_type in
488 the pool#GParamSpec<!-- -->s.