Small fixes.
[platform/upstream/glib.git] / docs / reference / gobject / tmpl / gparamspec.sgml
1 <!-- ##### SECTION Title ##### -->
2 GParamSpec
3
4 <!-- ##### SECTION Short_Description ##### -->
5 Metadata for parameter specifications
6
7 <!-- ##### SECTION Long_Description ##### -->
8 <para>
9 #GParamSpec is an object structure that encapsulates the metadata
10 required to specify parameters, such as e.g. #GObject properties.
11 </para>
12 <para>
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.
16 </para>
17
18 <!-- ##### SECTION See_Also ##### -->
19 <para>
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()
22 </para>
23
24 <!-- ##### SECTION Stability_Level ##### -->
25
26
27 <!-- ##### MACRO G_TYPE_IS_PARAM ##### -->
28 <para>
29 Returns whether @type "is a" %G_TYPE_PARAM.
30 </para>
31
32 @type: a #GType ID
33
34
35 <!-- ##### MACRO G_PARAM_SPEC ##### -->
36 <para>
37 Casts a derived #GParamSpec object (e.g. of type #GParamSpecInt) into
38 a #GParamSpec object.
39 </para>
40
41 @pspec: a valid #GParamSpec
42
43
44 <!-- ##### MACRO G_IS_PARAM_SPEC ##### -->
45 <para>
46 Checks whether @pspec "is a" valid #GParamSpec structure of type %G_TYPE_PARAM
47 or derived.
48 </para>
49
50 @pspec: a #GParamSpec
51
52
53 <!-- ##### MACRO G_PARAM_SPEC_CLASS ##### -->
54 <para>
55 Casts a derived #GParamSpecClass structure into a #GParamSpecClass structure.
56 </para>
57
58 @pclass: a valid #GParamSpecClass
59
60
61 <!-- ##### MACRO G_IS_PARAM_SPEC_CLASS ##### -->
62 <para>
63 Checks whether @pclass "is a" valid #GParamSpecClass structure of type 
64 %G_TYPE_PARAM or derived.
65 </para>
66
67 @pclass: a #GParamSpecClass
68
69
70 <!-- ##### MACRO G_PARAM_SPEC_GET_CLASS ##### -->
71 <para>
72 Retrieves the #GParamSpecClass of a #GParamSpec.
73 </para>
74
75 @pspec: a valid #GParamSpec
76
77
78 <!-- ##### MACRO G_PARAM_SPEC_TYPE ##### -->
79 <para>
80 Retrieves the #GType of this @pspec.
81 </para>
82
83 @pspec: a valid #GParamSpec
84
85
86 <!-- ##### MACRO G_PARAM_SPEC_TYPE_NAME ##### -->
87 <para>
88 Retrieves the #GType name of this @pspec.
89 </para>
90
91 @pspec: a valid #GParamSpec
92
93
94 <!-- ##### MACRO G_PARAM_SPEC_VALUE_TYPE ##### -->
95 <para>
96 Retrieves the #GType to initialize a #GValue for this parameter.
97 </para>
98
99 @pspec: a valid #GParamSpec
100
101
102 <!-- ##### STRUCT GParamSpec ##### -->
103 <para>
104 All fields of the <structname>GParamSpec</structname> struct are private and
105 should not be used directly, except for the following:
106 </para>
107
108 @g_type_instance: private #GTypeInstance portion
109 @name:            name of this parameter
110 @flags:           #GParamFlags flags for this parameter
111 @value_type:      the #GValue type for this parameter
112 @owner_type:      #GType type that uses (introduces) this paremeter
113
114 <!-- ##### STRUCT GParamSpecClass ##### -->
115 <para>
116 The class structure for the <structname>GParamSpec</structname> type.
117 Normally, <structname>GParamSpec</structname> classes are filled by
118 g_param_type_register_static().
119 </para>
120
121 @g_type_class: the parent class
122 @value_type: the #GValue type for this parameter
123 @finalize: The instance finalization function (optional), should chain 
124   up to the finalize method of the parent class.
125 @value_set_default: Resets a @value to the default value for this type
126   (recommended, the default is g_value_reset()), see 
127   g_param_value_set_default().
128 @value_validate: Ensures that the contents of @value comply with the 
129   specifications set out by this type (optional), see 
130   g_param_value_set_validate().
131 @values_cmp: Compares @value1 with @value2 according to this type
132   (recommended, the default is memcmp()), see g_param_values_cmp().
133
134 <!-- ##### ENUM GParamFlags ##### -->
135 <para>
136 Through the #GParamFlags flag values, certain aspects of parameters
137 can be configured.
138 </para>
139
140 @G_PARAM_READABLE:       the parameter is readable
141 @G_PARAM_WRITABLE:       the parameter is writable
142 @G_PARAM_CONSTRUCT:      the parameter will be set upon object construction
143 @G_PARAM_CONSTRUCT_ONLY: the parameter will only be set upon object construction
144 @G_PARAM_LAX_VALIDATION: upon parameter conversion (see g_param_value_convert())
145                          strict validation is not required
146 @G_PARAM_STATIC_NAME:    the string used as name when constructing the 
147                          parameter is guaranteed to remain valid and
148                          unmodified for the lifetime of the parameter. 
149                          Since 2.8
150 @G_PARAM_STATIC_BLURB:   the string used as blurb when constructing the 
151                          parameter is guaranteed to remain valid and 
152                          unmodified for the lifetime of the parameter. 
153                          Since 2.8
154
155 <!-- ##### MACRO G_PARAM_READWRITE ##### -->
156 <para>
157 #GParamFlags value alias for %G_PARAM_READABLE | %G_PARAM_WRITABLE.
158 </para>
159
160
161
162 <!-- ##### MACRO G_PARAM_MASK ##### -->
163 <para>
164 Mask containing the bits of #GParamSpec.flags which are reserved for GLib.
165 </para>
166
167
168
169 <!-- ##### MACRO G_PARAM_USER_SHIFT ##### -->
170 <para>
171 Minimum shift count to be used for user defined flags, to be stored in
172 #GParamSpec.flags.
173 </para>
174
175
176
177 <!-- ##### FUNCTION g_param_spec_ref ##### -->
178 <para>
179 Increments the reference count of @pspec.
180 </para>
181
182 @pspec:   a valid #GParamSpec
183 @Returns: the #GParamSpec that was passed into this function
184
185
186 <!-- ##### FUNCTION g_param_spec_unref ##### -->
187 <para>
188 Decrements the reference count of a @pspec.
189 </para>
190
191 @pspec: a valid #GParamSpec
192
193
194 <!-- ##### FUNCTION g_param_spec_sink ##### -->
195 <para>
196 The initial reference count of a newly created #GParamSpec is 1, even 
197 though no one has explicitly called g_param_spec_ref() on it yet. So the 
198 initial reference count is flagged as "floating", until someone calls 
199 <literal>g_param_spec_ref (pspec); g_param_spec_sink (pspec);</literal>
200 in sequence on it, taking over the initial reference count (thus
201 ending up with a @pspec that has a reference count of 1 still, but is
202 not flagged "floating" anymore).
203 </para>
204
205 @pspec: a valid #GParamSpec
206
207
208 <!-- ##### FUNCTION g_param_value_set_default ##### -->
209 <para>
210 Sets @value to its default value as specified in @pspec.
211 </para>
212
213 @pspec: a valid #GParamSpec
214 @value: a #GValue of correct type for @pspec
215
216
217 <!-- ##### FUNCTION g_param_value_defaults ##### -->
218 <para>
219 Checks whether @value contains the default value as specified in @pspec.
220 </para>
221
222 @pspec:   a valid #GParamSpec
223 @value:   a #GValue of correct type for @pspec
224 @Returns: whether @value contains the canonical defualt for this @pspec
225
226
227 <!-- ##### FUNCTION g_param_value_validate ##### -->
228 <para>
229 Ensures that the contents of @value comply with the specifications
230 set out by @pspec. For example, a #GParamSpecInt might require
231 that integers stored in @value may not be smaller than -42 and not be
232 greater than +42. If @value contains an integer outside of this range,
233 it is modified accordingly, so the resulting value will fit into the
234 range -42 .. +42.
235 </para>
236
237 @pspec:   a valid #GParamSpec
238 @value:   a #GValue of correct type for @pspec
239 @Returns: whether modifying @value was necessary to ensure validity
240
241
242 <!-- ##### FUNCTION g_param_value_convert ##### -->
243 <para>
244 Transforms @src_value into @dest_value if possible, and then validates 
245 @dest_value, in order for it to conform to @pspec.
246 If @strict_validation is %TRUE this function will only succeed if
247 the transformed @dest_value complied to @pspec without modifications.
248
249 See also g_value_type_transformable(), g_value_transform() and
250 g_param_value_validate().
251 </para>
252
253 @pspec:             a valid #GParamSpec
254 @src_value:         souce #GValue
255 @dest_value:        destination #GValue of correct type for @pspec
256 @strict_validation: %TRUE requires @dest_value to conform to @pspec without modifications
257 @Returns:           %TRUE if transformation and validation were successful,
258                     %FALSE otherwise and @dest_value is left untouched.
259
260
261 <!-- ##### FUNCTION g_param_values_cmp ##### -->
262 <para>
263 Compares @value1 with @value2 according to @pspec, and return -1, 0 or +1,
264 if @value1 is found to be less than, equal to or greater than @value2, 
265 respectively.
266 </para>
267
268 @pspec:   a valid #GParamSpec
269 @value1:  a #GValue of correct type for @pspec
270 @value2:  a #GValue of correct type for @pspec
271 @Returns: -1, 0 or +1, for a less than, equal to or greater than result
272
273
274 <!-- ##### FUNCTION g_param_spec_get_name ##### -->
275 <para>
276 Returns the name of a #GParamSpec.
277 </para>
278
279 @pspec: a valid #GParamSpec
280 @Returns: the name of @pspec.
281
282
283 <!-- ##### FUNCTION g_param_spec_get_nick ##### -->
284 <para>
285 Returns the nickname of a #GParamSpec.
286 </para>
287
288 @pspec: a valid #GParamSpec
289 @Returns: the nickname of @pspec.
290
291
292 <!-- ##### FUNCTION g_param_spec_get_blurb ##### -->
293 <para>
294 Returns the short description of a #GParamSpec.
295 </para>
296
297 @pspec: a valid #GParamSpec
298 @Returns: the short description of @pspec.
299
300
301 <!-- ##### FUNCTION g_param_spec_get_qdata ##### -->
302 <para>
303 Gets back user data pointers stored via g_param_spec_set_qdata().
304 </para>
305
306 @pspec: a valid #GParamSpec
307 @quark: a #GQuark, naming the user data pointer
308 @Returns: the user data pointer set, or %NULL
309
310
311 <!-- ##### FUNCTION g_param_spec_set_qdata ##### -->
312 <para>
313 Sets an opaque, named pointer on a #GParamSpec. The name is specified 
314 through a #GQuark (retrieved e.g. via g_quark_from_static_string()), and 
315 the pointer can be gotten back from the @pspec with g_param_spec_get_qdata().
316 Setting a previously set user data pointer, overrides (frees)
317 the old pointer set, using %NULL as pointer essentially
318 removes the data stored.
319 </para>
320
321 @pspec: the #GParamSpec to set store a user data pointer
322 @quark: a #GQuark, naming the user data pointer
323 @data: an opaque user data pointer
324
325
326 <!-- ##### FUNCTION g_param_spec_set_qdata_full ##### -->
327 <para>
328 This function works like g_param_spec_set_qdata(), but in addition, 
329 a <literal>void (*destroy) (gpointer)</literal> function may be 
330 specified which is called with @data as argument when the @pspec is 
331 finalized, or the data is being overwritten by a call to 
332 g_param_spec_set_qdata() with the same @quark.
333 </para>
334
335 @pspec:   the #GParamSpec to set store a user data pointer
336 @quark:   a #GQuark, naming the user data pointer
337 @data:    an opaque user data pointer
338 @destroy: function to invoke with @data as argument, when @data needs to
339           be freed
340
341
342 <!-- ##### FUNCTION g_param_spec_steal_qdata ##### -->
343 <para>
344 Gets back user data pointers stored via g_param_spec_set_qdata() and 
345 removes the @data from @pspec without invoking it's destroy() function 
346 (if any was set).
347 Usually, calling this function is only required to update
348 user data pointers with a destroy notifier.
349 </para>
350
351 @pspec: the #GParamSpec to get a stored user data pointer from
352 @quark: a #GQuark, naming the user data pointer
353 @Returns: the user data pointer set, or %NULL
354
355
356 <!-- ##### FUNCTION g_param_spec_get_redirect_target ##### -->
357 <para>
358 If the paramspec redirects operations to another paramspec,
359 returns that paramspec. Redirect is used typically for
360 providing a new implementation of a property in a derived
361 type while preserving all the properties from the parent
362 type. Redirection is established by creating a property
363 of type #GParamSpecOverride. See g_object_override_property()
364 for an example of the use of this capability.
365 </para>
366
367 @pspec: a #GParamSpec
368 @Returns: paramspec to which requests on this paramspec should
369   be redirected, or %NULL if none.
370 @Since: 2.4
371
372
373 <!-- ##### FUNCTION g_param_spec_internal ##### -->
374 <para>
375 Creates a new #GParamSpec instance.
376 </para>
377 <para>
378 A property name consists of segments consisting of ASCII letters and
379 digits, separated by either the '-' or '_' character. The first
380 character of a property name must be a letter. Names which violate these
381 rules lead to undefined behaviour. 
382 </para>
383 <para>
384 When creating and looking up a #GParamSpec, either separator can be used, 
385 but they cannot be mixed. Using '-' is considerably more efficient and in 
386 fact required when using property names as detail strings for signals.
387 </para>
388
389 @param_type: the #GType for the property; must be derived from #G_TYPE_PARAM
390 @name: the canonical name of the property
391 @nick: the nickname of the property
392 @blurb: a short description of the property
393 @flags: a combination of #GParamFlags
394 @Returns: a newly allocated #GParamSpec instance
395
396
397 <!-- ##### STRUCT GParamSpecTypeInfo ##### -->
398 <para>
399 This structure is used to provide the type system with the information
400 required to initialize and destruct (finalize) a parameter's class and
401 instances thereof.
402 The initialized structure is passed to the g_param_type_register_static() 
403 The type system will perform a deep copy of this structure, so it's memory 
404 does not need to be persistent across invocation of 
405 g_param_type_register_static().
406 </para>
407
408 @instance_size: Size of the instance (object) structure.
409 @n_preallocs: Number of pre-allocated (cached) instances to reserve memory for (0 indicates no caching).
410 @instance_init: Location of the instance initialization function (optional).
411 @value_type: The #GType of values conforming to this #GParamSpec
412 @finalize: The instance finalization function (optional).
413 @value_set_default: Resets a @value to the default value for @pspec 
414   (recommended, the default is g_value_reset()), see 
415   g_param_value_set_default().
416 @value_validate: Ensures that the contents of @value comply with the 
417   specifications set out by @pspec (optional), see 
418   g_param_value_set_validate().
419 @values_cmp: Compares @value1 with @value2 according to @pspec 
420   (recommended, the default is memcmp()), see g_param_values_cmp().
421
422
423 <!-- ##### FUNCTION g_param_type_register_static ##### -->
424 <para>
425 Registers @name as the name of a new static type derived from
426 #G_TYPE_PARAM. The type system uses the information contained in the
427 #GParamSpecTypeInfo structure pointed to by @info to manage the #GParamSpec 
428 type and its instances. 
429 </para>
430
431 @name: 0-terminated string used as the name of the new #GParamSpec type.
432 @pspec_info: The #GParamSpecTypeInfo for this #GParamSpec type.
433 @Returns: The new type identifier.
434
435
436 <!-- ##### STRUCT GParamSpecPool ##### -->
437 <para>
438 A #GParamSpecPool maintains a collection of #GParamSpec<!-- -->s which can be
439 quickly accessed by owner and name. The implementation of the #GObject property
440 system uses such a pool to store the #GParamSpecs of the properties all object
441 types. 
442 </para>
443
444
445 <!-- ##### FUNCTION g_param_spec_pool_new ##### -->
446 <para>
447 Creates a new #GParamSpecPool.
448 </para>
449 <para>
450 If @type_prefixing is %TRUE, lookups in the newly created pool will
451 allow to specify the owner as a colon-separated prefix of the property name, 
452 like "GtkContainer:border-width". This feature is deprecated, so you should 
453 always set @type_prefixing to %FALSE.
454 </para>
455
456 @type_prefixing: Whether the pool will support type-prefixed property names.
457 @Returns: a newly allocated #GParamSpecPool.
458
459
460 <!-- ##### FUNCTION g_param_spec_pool_insert ##### -->
461 <para>
462 Inserts a #GParamSpec in the pool.
463 </para>
464
465 @pool: a #GParamSpecPool.
466 @pspec: the #GParamSpec to insert
467 @owner_type: a #GType identifying the owner of @pspec
468
469
470 <!-- ##### FUNCTION g_param_spec_pool_remove ##### -->
471 <para>
472 Removes a #GParamSpec from the pool.
473 </para>
474
475 @pool: a #GParamSpecPool
476 @pspec: the #GParamSpec to remove
477
478
479 <!-- ##### FUNCTION g_param_spec_pool_lookup ##### -->
480 <para>
481 Looks up a #GParamSpec in the pool.
482 </para>
483
484 @pool: a #GParamSpecPool
485 @param_name: the name to look for
486 @owner_type: the owner to look for
487 @walk_ancestors: If %TRUE, also try to find a #GParamSpec with @param_name 
488   owned by an ancestor of @owner_type.
489 @Returns: The found #GParamSpec, or %NULL if no matching #GParamSpec was found.
490
491
492 <!-- ##### FUNCTION g_param_spec_pool_list ##### -->
493 <para>
494 Gets an array of all #GParamSpec<!-- -->s owned by @owner_type in the pool. 
495 </para>
496
497 @pool: a #GParamSpecPool
498 @owner_type: the owner to look for
499 @n_pspecs_p: return location for the length of the returned array
500 @Returns: a newly allocated array containing pointers to all 
501   #GParamSpec<!-- -->s owned by @owner_type in the pool
502
503
504 <!-- ##### FUNCTION g_param_spec_pool_list_owned ##### -->
505 <para>
506 Gets an #GList of all #GParamSpec<!-- -->s owned by @owner_type in the pool. 
507 </para>
508
509 @pool: a #GParamSpecPool
510 @owner_type: the owner to look for
511 @Returns: a #GList of all #GParamSpec<!-- -->s owned by @owner_type in 
512   the pool#GParamSpec<!-- -->s.
513
514