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 Parameter names need to start with a letter (a-z or A-Z). Subsequent
14 characters can be letters, numbers or a '-'.
15 All other characters are replaced by a '-' during construction.
18 <!-- ##### SECTION See_Also ##### -->
20 g_object_class_install_property(), g_object_set(), g_object_get(),
21 g_object_set_property(), g_object_get_property(), g_value_register_transform_func()
24 <!-- ##### MACRO G_TYPE_IS_PARAM ##### -->
26 Returns whether @type "is a" %G_TYPE_PARAM.
32 <!-- ##### MACRO G_PARAM_SPEC ##### -->
34 Casts a derived #GParamSpec object (e.g. of type #GParamSpecInt) into
38 @pspec: a valid #GParamSpec
41 <!-- ##### MACRO G_IS_PARAM_SPEC ##### -->
43 Checks whether @pspec "is a" valid #GParamSpec structure of type %G_TYPE_PARAM
50 <!-- ##### MACRO G_PARAM_SPEC_CLASS ##### -->
52 Casts a derived #GParamSpecClass structure into a #GParamSpecClass structure.
55 @pclass: a valid #GParamSpecClass
58 <!-- ##### MACRO G_IS_PARAM_SPEC_CLASS ##### -->
60 Checks whether @pclass "is a" valid #GParamSpecClass structure of type
61 %G_TYPE_PARAM or derived.
64 @pclass: a #GParamSpecClass
67 <!-- ##### MACRO G_PARAM_SPEC_GET_CLASS ##### -->
69 Retrieves the #GParamSpecClass of a #GParamSpec.
72 @pspec: a valid #GParamSpec
75 <!-- ##### MACRO G_PARAM_SPEC_TYPE ##### -->
77 Retrieves the #GType of this @pspec.
80 @pspec: a valid #GParamSpec
83 <!-- ##### MACRO G_PARAM_SPEC_TYPE_NAME ##### -->
85 Retrieves the #GType name of this @pspec.
88 @pspec: a valid #GParamSpec
91 <!-- ##### MACRO G_PARAM_SPEC_VALUE_TYPE ##### -->
93 Retrieves the #GType to initialize a #GValue for this parameter.
96 @pspec: a valid #GParamSpec
99 <!-- ##### STRUCT GParamSpec ##### -->
101 All fields of the <structname>GParamSpec</structname> struct are private and
102 should not be used directly, except for the following:
105 @g_type_instance: private #GTypeInstance portion
106 @name: name of this parameter
107 @flags: #GParamFlags flags for this parameter
108 @value_type: the #GValue type for this parameter
109 @owner_type: #GType type that uses (introduces) this paremeter
111 <!-- ##### STRUCT GParamSpecClass ##### -->
113 The class structure for the <structname>GParamSpec</structname> type.
114 Normally, <structname>GParamSpec</structname> classes are filled by
115 g_param_type_register_static().
118 @g_type_class: the parent class
119 @value_type: the #GValue type for this parameter
120 @finalize: The instance finalization function (optional), should chain
121 up to the finalize method of the parent class.
122 @value_set_default: Resets a @value to the default value for this type
123 (recommended, the default is g_value_reset()), see
124 g_param_value_set_default().
125 @value_validate: Ensures that the contents of @value comply with the
126 specifications set out by this type (optional), see
127 g_param_value_set_validate().
128 @values_cmp: Compares @value1 with @value2 according to this type
129 (recommended, the default is memcmp()), see g_param_values_cmp().
131 <!-- ##### ENUM GParamFlags ##### -->
133 Through the #GParamFlags flag values, certain aspects of parameters
137 @G_PARAM_READABLE: the parameter is readable
138 @G_PARAM_WRITABLE: the parameter is writable
139 @G_PARAM_CONSTRUCT: the parameter will be set upon object construction
140 @G_PARAM_CONSTRUCT_ONLY: the parameter will only be set upon object construction
141 @G_PARAM_LAX_VALIDATION: upon parameter conversion (see g_param_value_convert())
142 strict validation is not required
145 <!-- ##### MACRO G_PARAM_READWRITE ##### -->
147 #GParamFlags value alias for %G_PARAM_READABLE | %G_PARAM_WRITABLE.
152 <!-- ##### MACRO G_PARAM_MASK ##### -->
154 Mask containing the bits of #GParamSpec.flags which are reserved for GLib.
159 <!-- ##### MACRO G_PARAM_USER_SHIFT ##### -->
161 Minimum shift count to be used for user defined flags, to be stored in
167 <!-- ##### FUNCTION g_param_spec_ref ##### -->
169 Increments the reference count of @pspec.
172 @pspec: a valid #GParamSpec
173 @Returns: the #GParamSpec that was passed into this function
176 <!-- ##### FUNCTION g_param_spec_unref ##### -->
178 Decrements the reference count of a @pspec.
181 @pspec: a valid #GParamSpec
184 <!-- ##### FUNCTION g_param_spec_sink ##### -->
186 The initial reference count of a newly created #GParamSpec is 1, even
187 though no one has explicitly called g_param_spec_ref() on it yet. So the
188 initial reference count is flagged as "floating", until someone calls
189 <literal>g_param_spec_ref (@pspec); g_param_spec_sink (@pspec);</literal>
190 in sequence on it, taking over the initial reference count (thus
191 ending up with a @pspec that has a reference count of 1 still, but is
192 not flagged "floating" anymore).
195 @pspec: a valid #GParamSpec
198 <!-- ##### FUNCTION g_param_value_set_default ##### -->
200 Sets @value to its default value as specified in @pspec.
203 @pspec: a valid #GParamSpec
204 @value: a #GValue of correct type for @pspec
207 <!-- ##### FUNCTION g_param_value_defaults ##### -->
209 Checks whether @value contains the default value as specified in @pspec.
212 @pspec: a valid #GParamSpec
213 @value: a #GValue of correct type for @pspec
214 @Returns: whether @value contains the canonical defualt for this @pspec
217 <!-- ##### FUNCTION g_param_value_validate ##### -->
219 Ensures that the contents of @value comply with the specifications
220 set out by @pspec. For example, a #GParamSpecInt might require
221 that integers stored in @value may not be smaller than -42 and not be
222 greater than +42. If @value contains an integer outside of this range,
223 it is modified accordingly, so the resulting value will fit into the
227 @pspec: a valid #GParamSpec
228 @value: a #GValue of correct type for @pspec
229 @Returns: whether modifying @value was necessary to ensure validity
232 <!-- ##### FUNCTION g_param_value_convert ##### -->
234 Transforms @src_value into @dest_value if possible, and then validates
235 @dest_value, in order for it to conform to @pspec.
236 If @strict_validation is %TRUE this function will only succeed if
237 the transformed @dest_value complied to @pspec without modifications.
239 See also g_value_type_transformable(), g_value_transform() and
240 g_param_value_validate().
243 @pspec: a valid #GParamSpec
244 @src_value: souce #GValue
245 @dest_value: destination #GValue of correct type for @pspec
246 @strict_validation: %TRUE requires @dest_value to conform to @pspec without modifications
247 @Returns: %TRUE if transformation and validation were successfull,
248 %FALSE otherwise and @dest_value is left untouched.
251 <!-- ##### FUNCTION g_param_values_cmp ##### -->
253 Compares @value1 with @value2 according to @pspec, and return -1, 0 or +1,
254 if @value1 is found to be less than, equal to or greater than @value2,
258 @pspec: a valid #GParamSpec
259 @value1: a #GValue of correct type for @pspec
260 @value2: a #GValue of correct type for @pspec
261 @Returns: -1, 0 or +1, for a less than, equal to or greater than result
264 <!-- ##### FUNCTION g_param_spec_get_name ##### -->
266 Returns the name of a #GParamSpec.
269 @pspec: a valid #GParamSpec
270 @Returns: the name of @pspec.
273 <!-- ##### FUNCTION g_param_spec_get_nick ##### -->
275 Returns the nickname of a #GParamSpec.
278 @pspec: a valid #GParamSpec
279 @Returns: the nickname of @pspec.
282 <!-- ##### FUNCTION g_param_spec_get_blurb ##### -->
284 Returns the short description of a #GParamSpec.
287 @pspec: a valid #GParamSpec
288 @Returns: the short description of @pspec.
291 <!-- ##### FUNCTION g_param_spec_get_qdata ##### -->
293 Gets back user data pointers stored via g_param_spec_set_qdata().
296 @pspec: a valid #GParamSpec
297 @quark: a #GQuark, naming the user data pointer
298 @Returns: the user data pointer set, or %NULL
301 <!-- ##### FUNCTION g_param_spec_set_qdata ##### -->
303 Sets an opaque, named pointer on a #GParamSpec. The name is specified
304 through a #GQuark (retrieved e.g. via g_quark_from_static_string()), and
305 the pointer can be gotten back from the @pspec with g_param_spec_get_qdata().
306 Setting a previously set user data pointer, overrides (frees)
307 the old pointer set, using #NULL as pointer essentially
308 removes the data stored.
311 @pspec: the #GParamSpec to set store a user data pointer
312 @quark: a #GQuark, naming the user data pointer
313 @data: an opaque user data pointer
316 <!-- ##### FUNCTION g_param_spec_set_qdata_full ##### -->
318 This function works like g_param_spec_set_qdata(), but in addition,
319 a <literal>void (*destroy) (gpointer)</literal> function may be
320 specified which is called with @data as argument when the @pspec is
321 finalized, or the data is being overwritten by a call to
322 g_param_spec_set_qdata() with the same @quark.
325 @pspec: the #GParamSpec to set store a user data pointer
326 @quark: a #GQuark, naming the user data pointer
327 @data: an opaque user data pointer
328 @destroy: function to invoke with @data as argument, when @data needs to
332 <!-- ##### FUNCTION g_param_spec_steal_qdata ##### -->
334 Gets back user data pointers stored via g_param_spec_set_qdata() and
335 removes the @data from @pspec without invoking it's destroy() function
337 Usually, calling this function is only required to update
338 user data pointers with a destroy notifier.
341 @pspec: the #GParamSpec to get a stored user data pointer from
342 @quark: a #GQuark, naming the user data pointer
343 @Returns: the user data pointer set, or %NULL
346 <!-- ##### FUNCTION g_param_spec_get_redirect_target ##### -->
348 If the paramspec redirects operations to another paramspec,
349 returns that paramspec. Redirect is used typically for
350 providing a new implementation of a property in a derived
351 type while perserving all the properties from the parent
352 type. Redirection is established by creating a property
353 of type #GParamSpecOverride. See g_object_override_property()
354 for an example of the use of this capability.
357 @pspec: a #GParamSpec
358 @Returns: paramspec to which requests on this paramspec should
359 be redirected, or %NULL if none.
363 <!-- ##### FUNCTION g_param_spec_internal ##### -->
365 Creates a new #GParamSpec instance.
368 A property name consists of segments consisting of ASCII letters and
369 digits, separated by either the '-' or '_' character. The first
370 character of a property name must be a letter. Names which violate these
371 rules lead to undefined behaviour.
374 When creating and looking up a #GParamSpec, either separator can be used,
375 but they cannot be mixed. Using '-' is considerably more efficient and in
376 fact required when using property names as detail strings for signals.
379 @param_type: the #GType for the property; must be derived from #G_TYPE_PARAM
380 @name: the canonical name of the property
381 @nick: the nickname of the property
382 @blurb: a short description of the property
383 @flags: a combination of #GParamFlags
384 @Returns: a newly allocated #GParamSpec instance
387 <!-- ##### STRUCT GParamSpecTypeInfo ##### -->
389 This structure is used to provide the type system with the information
390 required to initialize and destruct (finalize) a parameter's class and
392 The initialized structure is passed to the g_param_type_register_static()
393 The type system will perform a deep copy of this structure, so it's memory
394 does not need to be persistent across invocation of
395 g_param_type_register_static().
398 @instance_size: Size of the instance (object) structure.
399 @n_preallocs: Number of pre-allocated (cached) instances to reserve memory for (0 indicates no caching).
400 @instance_init: Location of the instance initialization function (optional).
401 @value_type: The #GType of values conforming to this #GParamSpec
402 @finalize: The instance finalization function (optional).
403 @value_set_default: Resets a @value to the default value for @pspec
404 (recommended, the default is g_value_reset()), see
405 g_param_value_set_default().
406 @value_validate: Ensures that the contents of @value comply with the
407 specifications set out by @pspec (optional), see
408 g_param_value_set_validate().
409 @values_cmp: Compares @value1 with @value2 according to @pspec
410 (recommended, the default is memcmp()), see g_param_values_cmp().
412 <!-- ##### FUNCTION g_param_type_register_static ##### -->
414 Registers @name as the name of a new static type derived from
415 #G_TYPE_PARAM. The type system uses the information contained in the
416 #GParamSpecTypeInfo structure pointed to by @info to manage the #GParamSpec
417 type and its instances.
420 @name: 0-terminated string used as the name of the new #GParamSpec type.
421 @pspec_info: The #GParamSpecTypeInfo for this #GParamSpec type.
422 @Returns: The new type identifier.
425 <!-- ##### STRUCT GParamSpecPool ##### -->
427 A #GParamSpecPool maintains a collection of #GParamSpec<!-- -->s which can be
428 quickly accessed by owner and name. The implementation of the #GObject property
429 system uses such a pool to store the #GParamSpecs of the properties all object
434 <!-- ##### FUNCTION g_param_spec_pool_new ##### -->
436 Creates a new #GParamSpecPool.
439 If @type_prefixing is %TRUE, lookups in the newly created pool will
440 allow to specify the owner as a colon-separated prefix of the property name,
441 like "GtkContainer:border-width". This feature is deprecated, so you should
442 always set @type_prefixing to %FALSE.
445 @type_prefixing: Whether the pool will support type-prefixed property names.
446 @Returns: a newly allocated #GParamSpecPool.
449 <!-- ##### FUNCTION g_param_spec_pool_insert ##### -->
451 Inserts a #GParamSpec in the pool.
454 @pool: a #GParamSpecPool.
455 @pspec: the #GParamSpec to insert
456 @owner_type: a #GType identifying the owner of @pspec
459 <!-- ##### FUNCTION g_param_spec_pool_remove ##### -->
461 Removes a #GParamSpec from the pool.
464 @pool: a #GParamSpecPool
465 @pspec: the #GParamSpec to remove
468 <!-- ##### FUNCTION g_param_spec_pool_lookup ##### -->
470 Looks up a #GParamSpec in the pool.
473 @pool: a #GParamSpecPool
474 @param_name: the name to look for
475 @owner_type: the owner to look for
476 @walk_ancestors: If %TRUE, also try to find a #GParamSpec with @param_name
477 owned by an ancestor of @owner_type.
478 @Returns: The found #GParamSpec, or %NULL if no matching #GParamSpec was found.
481 <!-- ##### FUNCTION g_param_spec_pool_list ##### -->
483 Gets an array of all #GParamSpec<!-- -->s owned by @owner_type in the pool.
486 @pool: a #GParamSpecPool
487 @owner_type: the owner to look for
488 @n_pspecs_p: return location for the length of the returned array
489 @Returns: a newly allocated array containing pointers to all
490 #GParamSpec<!-- -->s owned by @owner_type in the pool
493 <!-- ##### FUNCTION g_param_spec_pool_list_owned ##### -->
495 Gets an #GList of all #GParamSpec<!-- -->s owned by @owner_type in the pool.
498 @pool: a #GParamSpecPool
499 @owner_type: the owner to look for
500 @Returns: a #GList of all #GParamSpec<!-- -->s owned by @owner_type in
501 the pool#GParamSpec<!-- -->s.