doc common functions like ref/ sink/unref/invalidate.
[platform/upstream/glib.git] / docs / reference / gobject / tmpl / objects.sgml
1 <!-- ##### SECTION Title ##### -->
2 GObject
3
4 <!-- ##### SECTION Short_Description ##### -->
5 The base object type.
6
7 <!-- ##### SECTION Long_Description ##### -->
8 <para>
9
10 </para>
11
12 <!-- ##### SECTION See_Also ##### -->
13 <para>
14
15 </para>
16
17 <!-- ##### STRUCT GObject ##### -->
18 <para>
19 All the fields in the GObject structure are private to the #GObject implementation
20 and should never be accessed directly.
21 </para>
22
23 @g_type_instance: 
24
25 <!-- ##### STRUCT GObjectClass ##### -->
26 <para>
27
28 </para>
29
30
31 <!-- ##### USER_FUNCTION GObjectGetPropertyFunc ##### -->
32 <para>
33
34 </para>
35
36 @object: 
37 @property_id: 
38 @value: 
39 @pspec: 
40 <!-- # Unused Parameters # -->
41 @trailer: 
42
43
44 <!-- ##### USER_FUNCTION GObjectSetPropertyFunc ##### -->
45 <para>
46
47 </para>
48
49 @object: 
50 @property_id: 
51 @value: 
52 @pspec: 
53 <!-- # Unused Parameters # -->
54 @trailer: 
55
56
57 <!-- ##### USER_FUNCTION GObjectFinalizeFunc ##### -->
58 <para>
59
60 </para>
61
62 @object: 
63
64
65 <!-- ##### MACRO G_TYPE_IS_OBJECT ##### -->
66 <para>
67 Return a boolean value of %FALSE or %TRUE indicating whether
68 the passed in type id is a %G_TYPE_OBJECT or derived from it.
69 </para>
70
71 @type: Type id to check for is a %G_TYPE_OBJECT relationship.
72 @Returns: %FALSE or %TRUE, indicating whether @type is a %G_TYPE_OBJECT.
73
74
75 <!-- ##### MACRO G_OBJECT ##### -->
76 <para>
77 Cast a #GObject or derived pointer into a (GObject*) pointer.
78 Depending on the current debugging level, this function may invoke
79 certain runtime checks to identify invalid casts.
80 </para>
81
82 @object: Object which is subject to casting.
83
84
85 <!-- ##### MACRO G_IS_OBJECT ##### -->
86 <para>
87 Check whether a valid #GTypeInstance pointer is of type %G_TYPE_OBJECT.
88 </para>
89
90 @object: Instance to check for being a %G_TYPE_OBJECT.
91
92
93 <!-- ##### MACRO G_OBJECT_CLASS ##### -->
94 <para>
95
96 </para>
97
98 @class: 
99
100
101 <!-- ##### MACRO G_IS_OBJECT_CLASS ##### -->
102 <para>
103
104 </para>
105
106 @class: 
107
108
109 <!-- ##### MACRO G_OBJECT_GET_CLASS ##### -->
110 <para>
111
112 </para>
113
114 @object: 
115
116
117 <!-- ##### MACRO G_OBJECT_TYPE ##### -->
118 <para>
119 Return the type id of an object.
120 </para>
121
122 @object: Object to return the type id for.
123 @Returns: Type id of @object.
124
125
126 <!-- ##### MACRO G_OBJECT_TYPE_NAME ##### -->
127 <para>
128
129 </para>
130
131 @object: 
132
133
134 <!-- ##### MACRO G_OBJECT_CLASS_TYPE ##### -->
135 <para>
136
137 </para>
138
139 @class: 
140
141
142 <!-- ##### MACRO G_OBJECT_CLASS_NAME ##### -->
143 <para>
144
145 </para>
146
147 @class: 
148
149
150 <!-- ##### FUNCTION g_object_class_install_property ##### -->
151 <para>
152
153 </para>
154
155 @oclass: 
156 @property_id: 
157 @pspec: 
158
159
160 <!-- ##### FUNCTION g_object_class_find_property ##### -->
161 <para>
162
163 </para>
164
165 @oclass: 
166 @property_name: 
167 @Returns: 
168
169
170 <!-- ##### FUNCTION g_object_class_list_properties ##### -->
171 <para>
172
173 </para>
174
175 @oclass: 
176 @n_properties: 
177 @Returns: 
178
179
180 <!-- ##### FUNCTION g_object_new ##### -->
181 <para>
182
183 </para>
184
185 @object_type: 
186 @first_property_name: 
187 @Varargs: 
188 @Returns: 
189 <!-- # Unused Parameters # -->
190 @first_param_name: 
191
192
193 <!-- ##### FUNCTION g_object_newv ##### -->
194 <para>
195
196 </para>
197
198 @object_type: 
199 @n_parameters: 
200 @parameters: 
201 @Returns: 
202
203
204 <!-- ##### STRUCT GParameter ##### -->
205 <para>
206
207 </para>
208
209 @name: 
210 @value: 
211
212 <!-- ##### FUNCTION g_object_ref ##### -->
213 <para>
214
215 </para>
216
217 @object: 
218 @Returns: 
219
220
221 <!-- ##### FUNCTION g_object_unref ##### -->
222 <para>
223
224 </para>
225
226 @object: 
227
228
229 <!-- ##### USER_FUNCTION GWeakNotify ##### -->
230 <para>
231
232 </para>
233
234 @data: 
235 @where_the_object_was: 
236
237
238 <!-- ##### FUNCTION g_object_weak_ref ##### -->
239 <para>
240
241 </para>
242
243 @object: 
244 @notify: 
245 @data: 
246
247
248 <!-- ##### FUNCTION g_object_weak_unref ##### -->
249 <para>
250
251 </para>
252
253 @object: 
254 @notify: 
255 @data: 
256
257
258 <!-- ##### FUNCTION g_object_add_weak_pointer ##### -->
259 <para>
260 Adds a weak reference from weak_pointer to @object to indicate that
261 the pointer located at @weak_pointer_location is only valid during the 
262 lifetime of @object. When the @object is finalized, @weak_pointer will 
263 be set to %NULL.
264 </para>
265
266 @object: The object that should be weak referenced.
267 @weak_pointer_location: The memory address of a pointer.
268
269
270 <!-- ##### FUNCTION g_object_remove_weak_pointer ##### -->
271 <para>
272 Removes a weak reference from @object that was previously added
273 using g_object_add_weak_pointer(). The @weak_pointer_location has
274 to match the one used with g_object_add_weak_pointer().
275 </para>
276
277 @object: The object that is weak referenced.
278 @weak_pointer_location: The memory address of a pointer.
279
280
281 <!-- ##### FUNCTION g_object_connect ##### -->
282 <para>
283
284 </para>
285
286 @object: 
287 @signal_spec: 
288 @Varargs: 
289 @Returns: 
290
291
292 <!-- ##### FUNCTION g_object_disconnect ##### -->
293 <para>
294
295 </para>
296
297 @object: 
298 @signal_spec: 
299 @Varargs: 
300 <!-- # Unused Parameters # -->
301 @Returns: 
302
303
304 <!-- ##### FUNCTION g_object_set ##### -->
305 <para>
306
307 </para>
308
309 @object: 
310 @first_property_name: 
311 @Varargs: 
312 <!-- # Unused Parameters # -->
313 @Returns: 
314
315
316 <!-- ##### FUNCTION g_object_get ##### -->
317 <para>
318
319 </para>
320
321 @object: 
322 @first_property_name: 
323 @Varargs: 
324
325
326 <!-- ##### FUNCTION g_object_notify ##### -->
327 <para>
328
329 </para>
330
331 @object: 
332 @property_name: 
333
334
335 <!-- ##### FUNCTION g_object_freeze_notify ##### -->
336 <para>
337
338 </para>
339
340 @object: 
341
342
343 <!-- ##### FUNCTION g_object_thaw_notify ##### -->
344 <para>
345
346 </para>
347
348 @object: 
349
350
351 <!-- ##### FUNCTION g_object_get_data ##### -->
352 <para>
353
354 </para>
355
356 @object: 
357 @key: 
358 @Returns: 
359
360
361 <!-- ##### FUNCTION g_object_set_data ##### -->
362 <para>
363
364 </para>
365
366 @object: 
367 @key: 
368 @data: 
369
370
371 <!-- ##### FUNCTION g_object_set_data_full ##### -->
372 <para>
373
374 </para>
375
376 @object: 
377 @key: 
378 @data: 
379 @destroy: 
380
381
382 <!-- ##### FUNCTION g_object_steal_data ##### -->
383 <para>
384
385 </para>
386
387 @object: 
388 @key: 
389 @Returns: 
390
391
392 <!-- ##### FUNCTION g_object_get_qdata ##### -->
393 <para>
394 This function gets back user data pointers stored via
395 g_object_set_qdata().
396 </para>
397
398 @object:  The GObject to get a stored user data pointer from
399 @quark:   A #GQuark, naming the user data pointer
400 @Returns: The user data pointer set, or %NULL
401
402
403 <!-- ##### FUNCTION g_object_set_qdata ##### -->
404 <para>
405 This sets an opaque, named pointer on an object.
406 The name is specified through a #GQuark (retrived e.g. via
407 g_quark_from_static_string()), and the pointer
408 can be gotten back from the @object with g_object_get_qdata()
409 until the @object is finalized.
410 Setting a previously set user data pointer, overrides (frees)
411 the old pointer set, using #NULL as pointer essentially
412 removes the data stored.
413 </para>
414
415 @object: The GObject to set store a user data pointer
416 @quark:  A #GQuark, naming the user data pointer
417 @data:   An opaque user data pointer
418
419
420 <!-- ##### FUNCTION g_object_set_qdata_full ##### -->
421 <para>
422 This function works like g_object_set_qdata(), but in addition,
423 a void (*destroy) (gpointer) function may be specified which is
424 called with @data as argument when the @object is finalized, or
425 the data is being overwritten by a call to g_object_set_qdata()
426 with the same @quark.
427 </para>
428
429 @object:  The GObject to set store a user data pointer
430 @quark:   A #GQuark, naming the user data pointer
431 @data:    An opaque user data pointer
432 @destroy: Function to invoke with @data as argument, when @data needs to be freed
433
434
435 <!-- ##### FUNCTION g_object_steal_qdata ##### -->
436 <para>
437 This function gets back user data pointers stored via
438 g_object_set_qdata() and removes the @data from object
439 without invoking it's destroy() function (if any was
440 set).
441 Usually, calling this function is only required to update
442 user data pointers with a destroy notifier, for example:
443 <msgtext><programlisting>
444 void
445 object_add_to_user_list (GObject     *object,
446                          const gchar *new_string)
447 {
448   /* the quark, naming the object data */
449   GQuark quark_string_list = g_quark_from_static_string ("my-string-list");
450   /* retrive the old string list */
451   GList *list = g_object_steal_qdata (object, quark_string_list);
452   
453   /* prepend new string */
454   list = g_list_prepend (list, g_strdup (new_string));
455   /* this changed 'list', so we need to set it again */
456   g_object_set_qdata_full (object, quark_string_list, list, free_string_list);
457 }
458 static void
459 free_string_list (gpointer data)
460 {
461   GList *node, *list = data;
462   
463   for (node = list; node; node = node->next)
464     g_free (node->data);
465   g_list_free (list);
466 }
467 </programlisting></msgtext>
468 Using g_object_get_qdata() in the above example, instead of g_object_steal_qdata()
469 would have left the destroy function set, and thus the partial string list would
470 have been freed upon g_object_set_qdata_full().
471 </para>
472
473 @object:  The GObject to get a stored user data pointer from
474 @quark:   A #GQuark, naming the user data pointer
475 @Returns: The user data pointer set, or %NULL
476
477
478 <!-- ##### FUNCTION g_object_set_property ##### -->
479 <para>
480
481 </para>
482
483 @object: 
484 @property_name: 
485 @value: 
486
487
488 <!-- ##### FUNCTION g_object_get_property ##### -->
489 <para>
490
491 </para>
492
493 @object: 
494 @property_name: 
495 @value: 
496
497
498 <!-- ##### FUNCTION g_object_new_valist ##### -->
499 <para>
500
501 </para>
502
503 @object_type: 
504 @first_property_name: 
505 @var_args: 
506 @Returns: 
507
508
509 <!-- ##### FUNCTION g_object_set_valist ##### -->
510 <para>
511
512 </para>
513
514 @object: 
515 @first_property_name: 
516 @var_args: 
517
518
519 <!-- ##### FUNCTION g_object_get_valist ##### -->
520 <para>
521
522 </para>
523
524 @object: 
525 @first_property_name: 
526 @var_args: 
527
528
529 <!-- ##### FUNCTION g_object_watch_closure ##### -->
530 <para>
531 This function essentially limits the life time of the @closure
532 to the life time of the object. That is, when the object is finalized,
533 the @closure is invalidated by calling g_closure_invalidate() on it,
534 in order to prevent invocations of the closure with a finalized (non
535 existing) object. Also, g_object_ref() and g_object_unref() are added
536 as marshal guards to the @closure, to ensure that an extra reference
537 count is held on @object during invocation of the @closure.
538 Usually, this function will be called on closures that use this @object
539 as closure data.
540 </para>
541
542 @object:  GObject restricting lifetime of @closure
543 @closure: GClosure to watch
544
545
546 <!-- ##### FUNCTION g_object_run_dispose ##### -->
547 <para>
548
549 </para>
550
551 @object: 
552
553
554 <!-- ##### MACRO G_OBJECT_WARN_INVALID_PSPEC ##### -->
555 <para>
556
557 </para>
558
559 @object: 
560 @pname: 
561 @property_id: 
562 @pspec: 
563
564
565 <!-- ##### MACRO G_OBJECT_WARN_INVALID_PROPERTY_ID ##### -->
566 <para>
567
568 </para>
569
570 @object: 
571 @property_id: 
572 @pspec: 
573
574