]> Pileus Git - ~andy/gtk/blob - docs/reference/gtk/tmpl/gtkobject.sgml
fixed minor error - using <em>.
[~andy/gtk] / docs / reference / gtk / tmpl / gtkobject.sgml
1 <!-- ##### SECTION Title ##### -->\r
2 GtkObject\r
3 \r
4 <!-- ##### SECTION Short_Description ##### -->\r
5 The base class of the Gtk type hierarchy.\r
6 \r
7 <!-- ##### SECTION Long_Description ##### -->\r
8 <refsect2>\r
9 <title>Description</title>\r
10 <para>\r
11 GtkObject is the root of the gtk+ type hierarchy.  It serves\r
12 a similar roles as java's Object class.  It is used \r
13 by the type-casting system to represent the base composite type.\r
14 </para>\r
15 <para>\r
16 Objects have <wordasword>arguments</wordasword> that are\r
17 name/typed-value pairs.  \r
18 They may be readable or writable (or both or neither).\r
19 The special handlers in every object are responsible for\r
20 setting and getting these parameters.\r
21 If the handler for a given argument <emphasis>must</emphasis>\r
22 be called before the object may be used, be sure the\r
23 #GTK_ARG_CONSTRUCT or #GTK_ARG_CONSTRUCT_ONLY flags\r
24 are set;  otherwise they are set only when the user does so.\r
25 </para>\r
26 <para>\r
27 Object also store a simpler association table, sometimes\r
28 called the object_data.  This is just an efficient mapping from\r
29 a fixed set of strings to a gpointer.  This can be used as\r
30 arbitrary extra members.  Notice that each new field name\r
31 allocates a new quark, so it is probably best only to use\r
32 this for fields with fixed names.\r
33 </para>\r
34 <para>\r
35 The primary difference between object_data and arguments is that\r
36 the object defines two functions which set and get each type of argument.\r
37 The object just has a table to store its object data in:  it does not\r
38 receive notice when data changes.\r
39 </para>\r
40 <para>\r
41 Objects are reference counted;  this means that we maintain\r
42 a count of how many references (usually in the form of a pointer)\r
43 are being held to this object.\r
44 To indicate that you reference an object, call gtk_object_ref().\r
45 The object will not be freed until everyone calls \r
46 gtk_object_unref().\r
47 </para>\r
48 <para>\r
49 In order to reduce the chances of a memory leak, gtk+ defines\r
50 "floating objects".  All objects created with gtk_object_new()\r
51 start out floating with a reference count of 1.\r
52 In order to reduce that initial reference count you should gtk_object_sink()\r
53 them, but usually the parent widget you add the child to will\r
54 sink the object.  \r
55 </para>\r
56 <para>So, because gtk_widget_set_parent() sinks the object from\r
57 gtk_container_add(), there are no memory leaks in this code:\r
58 <informalexample>\r
59 <programlisting>\r
60         button = gtk_button_new_with_label("Hi Mom!");\r
61         gtk_container_add(GTK_CONTAINER(window), button);\r
62         /* Button may not be used anymore since we don't retain a reference\r
63          * to it. */\r
64 </programlisting>\r
65 </informalexample>\r
66 Likewise, the following code attaches the same adjustment to two\r
67 ranges:\r
68 <informalexample>\r
69 <programlisting>\r
70         adjustment = (GtkAdjustment*) gtk_adjustment_new(0,10,0,0,0,0);\r
71         gtk_range_set_adjustment(range1, adjustment);\r
72         gtk_range_set_adjustment(range2, adjustment);\r
73 </programlisting>\r
74 </informalexample>\r
75 Note that we could put as many set_adjustments as we like:  cleanup is easy\r
76 because they all retain a reference but only one sinks the initial reference\r
77 count.  If it is possible for "range1" to stop retaining its reference\r
78 then we need to enclose the lines using "adjustment" with ref/unref\r
79 to guarantee the the object won't be deleted:\r
80 <informalexample>\r
81 <programlisting>\r
82         adjustment = (GtkAdjustment*) gtk_adjustment_new(0,10,0,0,0,0);\r
83         gtk_object_ref(GTK_OBJECT(adjustment));\r
84         gtk_range_set_adjustment(range1, adjustment);\r
85         gtk_range_set_adjustment(range1, another_adjustment);\r
86         /* With the initial reference, `adjustment' would have\r
87          * been deleted as `range1' lost its reference to it. */\r
88         gtk_range_set_adjustment(range2, adjustment);\r
89         gtk_object_unref(GTK_OBJECT(adjustment));\r
90 </programlisting>\r
91 </informalexample>\r
92 </para>\r
93 <para>\r
94 Be careful with reference counting:  if two objects reference eachother\r
95 then they will always have at least reference count 1, even if\r
96 there are no other pointers to them.  This means that they\r
97 will never be freed.  More precisely, you must be certain that\r
98 your references <emphasis>never</emphasis> can form cycles.\r
99 </para>\r
100 <para>\r
101 If you find yourself forming cyclic references, perhaps you\r
102 can convert some of them to <wordasword>weak-references</wordasword>.\r
103 A weak-reference is one that holds a pointer to an object,\r
104 but doesn't increase the reference count.  To insure\r
105 the object is valid when the referer tries to use it,\r
106 the referer registers a callback that will be invoked\r
107 after the object has been destroyed (but before its memory is actually\r
108 deallocated).  This callback must prevent the weak-reference from\r
109 being used again.\r
110 </para>\r
111 </refsect2>\r
112 <refsect2>\r
113 <title>Brief Glossary</title>\r
114 <variablelist>\r
115 \r
116 <varlistentry>\r
117 <term>argument</term>\r
118 <listitem><para>\r
119 A typed-variable identified by ObjectType::argument_name.  It may be\r
120 readable, writable, both or none.  For example,\r
121 "GtkButton::label" is a read/write string-valued argument.\r
122 </para></listitem>\r
123 </varlistentry>\r
124 \r
125 <varlistentry>\r
126 <term>constructed</term>\r
127 <listitem><para>\r
128 </para></listitem>\r
129 </varlistentry>\r
130 \r
131 <varlistentry>\r
132 <term>destroyed</term>\r
133 <listitem><para>\r
134 </para></listitem>\r
135 </varlistentry>\r
136 \r
137 <varlistentry>\r
138 <term>finalization</term>\r
139 <listitem><para>\r
140 </para></listitem>\r
141 </varlistentry>\r
142 \r
143 <varlistentry>\r
144 <term>floating</term>\r
145 <listitem><para>\r
146 </para></listitem>\r
147 </varlistentry>\r
148 \r
149 <varlistentry>\r
150 <term>object data</term>\r
151 <listitem><para>\r
152 </para></listitem>\r
153 </varlistentry>\r
154 \r
155 <varlistentry>\r
156 <term>reference count</term>\r
157 <listitem><para>\r
158 </para></listitem>\r
159 </varlistentry>\r
160 \r
161 <varlistentry>\r
162 <term>weak-reference</term>\r
163 <listitem><para>\r
164 </para></listitem>\r
165 </varlistentry>\r
166 \r
167 </variablelist>\r
168 </refsect2>\r
169 \r
170 <!-- ##### SECTION See_Also ##### -->\r
171 <para>\r
172 GtkType, GtkArg, gtk-signals.\r
173 </para>\r
174 \r
175 <!-- ##### STRUCT GtkObject ##### -->\r
176 <para>\r
177 The object itself.  You should never use these members directly-\r
178 instead you the accessing macros.\r
179 </para>\r
180 \r
181 @klass: a pointer to the GtkObjectClass (or deriver) which contains \r
182 the methods defined by this object.\r
183 @flags: the state of the object: whether it has been constructed\r
184 or destroyed, for example.\r
185 @ref_count: a reference count.  It is incremented when new\r
186 pointers to this object are made, and decremented when the\r
187 pointers are deleted.  When the reference count\r
188 returns to 0, the object is deleted.  By default, objects\r
189 have reference count 0 when created.\r
190 @object_data: \r
191 \r
192 <!-- ##### MACRO GTK_OBJECT_TYPE ##### -->\r
193 <para>\r
194 Get the type of an object.\r
195 </para>\r
196 \r
197 @obj: the object whose type we wish to get.\r
198 \r
199 \r
200 <!-- ##### MACRO GTK_OBJECT_SIGNALS ##### -->\r
201 <para>\r
202 Get the array of signals defined for this object.\r
203 </para>\r
204 \r
205 @obj: the object to fetch the signals from.\r
206 \r
207 \r
208 <!-- ##### MACRO GTK_OBJECT_NSIGNALS ##### -->\r
209 <para>\r
210 Get the number of signals defined by this object.\r
211 </para>\r
212 \r
213 @obj: the object to query.\r
214 \r
215 \r
216 <!-- ##### ENUM GtkObjectFlags ##### -->\r
217 <para>\r
218 Tells about the state of the object.\r
219 </para>\r
220 \r
221 @GTK_DESTROYED: the GtkObject has had gtk_object_destroyed() invoked on it\r
222 and is processing the shutdown callback.\r
223 @GTK_FLOATING: whether the object is orphaned.  Objects that take\r
224 strong hold of an object may gtk_object_sink() it, after obtaining\r
225 there own references, if they believe they are nearly primary\r
226 ownership of the object.\r
227 GTK_CONNECTED: refers to whether are signals are connected to this\r
228 object.\r
229 @GTK_CONSTRUCTED: refers to whether the arguments for this object are\r
230 ready.\r
231 \r
232 <!-- ##### MACRO GTK_OBJECT_FLAGS ##### -->\r
233 <para>\r
234 Get the #GtkObjectFlags for an object without directly\r
235 accessing its members.\r
236 </para>\r
237 \r
238 @obj: the object whose flags are returned.\r
239 \r
240 \r
241 <!-- ##### MACRO GTK_OBJECT_DESTROYED ##### -->\r
242 <para>\r
243 Test whether a GtkObject has had gtk_object_destroyed() invoked on it.\r
244 </para>\r
245 \r
246 @obj: the object to examine.\r
247 \r
248 \r
249 <!-- ##### MACRO GTK_OBJECT_FLOATING ##### -->\r
250 <para>\r
251 When an object is created, it has an initial reference count\r
252 of 1 and is floating.  <wordasword>Sinking</wordasword> the object \r
253 refers to decrementing that original reference count.\r
254 </para>\r
255 \r
256 @obj: the object to examine.\r
257 \r
258 \r
259 <!-- ##### MACRO GTK_OBJECT_CONNECTED ##### -->\r
260 <para>\r
261 Test whether a GtkObject has had a signal connected to it.\r
262 </para>\r
263 \r
264 @obj: the object to examine.\r
265 \r
266 \r
267 <!-- ##### MACRO GTK_OBJECT_CONSTRUCTED ##### -->\r
268 <para>\r
269 Test whether a GtkObject's arguments have been prepared.\r
270 </para>\r
271 \r
272 @obj: the object to examine.\r
273 \r
274 \r
275 <!-- ##### MACRO GTK_OBJECT_SET_FLAGS ##### -->\r
276 <para>\r
277 Turn on certain object flags.  (Private)\r
278 </para>\r
279 \r
280 @obj: the object to affect.\r
281 @flag: the flags to set.\r
282 \r
283 \r
284 <!-- ##### MACRO GTK_OBJECT_UNSET_FLAGS ##### -->\r
285 <para>\r
286 Turn off certain object flags.  (Private)\r
287 </para>\r
288 \r
289 @obj: the object to affect.\r
290 @flag: the flags to unset.\r
291 \r
292 \r
293 <!-- ##### ENUM GtkArgFlags ##### -->\r
294 <para>\r
295 Possible flags indicating how an argument should be treated.\r
296 </para>\r
297 \r
298 @GTK_ARG_READABLE: the argument is readable. (i.e. can be queried)\r
299 @GTK_ARG_WRITABLE: the argument is writable. (i.e. settable)\r
300 @GTK_ARG_CONSTRUCT: the argument needs construction.\r
301 @GTK_ARG_CONSTRUCT_ONLY: the argument needs construction (and will\r
302 be set once during object creation), but is otherwise cannot be\r
303 set.  Hence this flag is not allowed with #GTK_ARG_WRITABLE,\r
304 and is redundant with #GTK_ARG_CONSTRUCT.\r
305 @GTK_ARG_CHILD_ARG: an argument type that applies to (and may be different for)\r
306 each child.  Used by #GtkContainer.\r
307 @GTK_ARG_MASK: the bitwise-OR of all the flags.\r
308 @GTK_ARG_READWRITE: the argument is readable and writable.\r
309 \r
310 <!-- ##### FUNCTION gtk_object_class_user_signal_new ##### -->\r
311 <para>\r
312 Define a signal-handler for a new signal on an already defined\r
313 object.\r
314 </para>\r
315 <para>\r
316 See the signal documentation for more general information.\r
317 </para>\r
318 \r
319 @klass: the object class to define the signal for.\r
320 @name: the name of the signal.\r
321 @signal_flags: the default emission behavior for the signal.\r
322 See gtk_signal_new().\r
323 @marshaller: a function that will take an array of GtkArgs\r
324 and invoke the appropriate handler with the normal calling\r
325 conventions.\r
326 @return_val: specify the return-value type for the signal\r
327 (or GTK_TYPE_NONE for no return-value).\r
328 @nparams: specify the number of parameters the signal\r
329 receives from the caller of gtk_signal_emit().\r
330 @Varargs: list of nparams #GtkTypes to pass to the signal handlers.\r
331 @Returns: the signal id.  (See #GtkSignals)\r
332 \r
333 \r
334 <!-- ##### FUNCTION gtk_object_class_user_signal_newv ##### -->\r
335 <para>\r
336 Define a signal-handler for a new signal on an already defined\r
337 object.\r
338 </para>\r
339 \r
340 @klass: the object class to define the signal for.\r
341 @name: the name of the signal.\r
342 @signal_flags: the default emission behavior for the signal.\r
343 See gtk_signal_new().\r
344 @marshaller: takes a GtkObject, a #GtkSignalFunc, and an array\r
345 of arguments, and invokes the function using the appropriate\r
346 calling conventions.  Usually just select a function\r
347 out of gtkmarshal.h.\r
348 @return_val: specify the return-value type for the signal (possibly\r
349 #GTK_TYPE_NONE).\r
350 @nparams: specify the number of parameters the signal\r
351 receives from the caller of gtk_signal_emit().\r
352 @params: array of #GtkTypes the signal handlers for this signal\r
353 should have in their prototype (of length nparams).\r
354 @Returns: the signal id.  (See #GtkSignals)\r
355 \r
356 \r
357 <!-- ##### FUNCTION gtk_object_new ##### -->\r
358 <para>\r
359 Construct an object given its arguments, enumerated in the call to the\r
360 function.\r
361 </para>\r
362 \r
363 @type: the type identifying this object.  Returned by gtk_type_unique()\r
364 although (for a properly-written object it should be accessible through\r
365 #GTK_TYPE_FOO.)\r
366 @first_arg_name: name of the first argument to set when constructing\r
367 the object.\r
368 @Varargs: the first argument's value, followed by any number of\r
369 name/argument-value pairs, terminated with NULL.\r
370 @Returns: the new GtkObject.\r
371 \r
372 \r
373 <!-- ##### FUNCTION gtk_object_newv ##### -->\r
374 <para>\r
375 Construct an object with an array of arguments.\r
376 </para>\r
377 \r
378 @object_type: the type of the object to create.\r
379 @n_args: the number of arguments to set.\r
380 @args: an array of n_args arguments (which are name and value pairs).\r
381 @Returns: the new GtkObject.\r
382 \r
383 \r
384 <!-- ##### FUNCTION gtk_object_constructed ##### -->\r
385 <para>\r
386 Mark an allocated object as constructed.\r
387 This is used for situations\r
388 that require precise control of the construction process.\r
389 </para>\r
390 <para>\r
391 This is done when gtk_object_default_construct() is inadequate.\r
392 In #GtkCList the need arises because #GtkCList does construction work that\r
393 must happen <emphasis>after</emphasis> its derivers.  This work\r
394 cannot be done in an initializer function, so an alternate\r
395 constructor is mandatory.  It calls gtk_object_constructed() to\r
396 indicate it has done its job, so that no other constructor will\r
397 be invoked.\r
398 </para>\r
399 <para>\r
400 Normally this function is just automatically run from\r
401 gtk_object_default_construct().\r
402 </para>\r
403 \r
404 @object: object which has been constructed.  This is usually\r
405 done automatically by gtk_object_new() and gtk_object_newv().\r
406 \r
407 \r
408 <!-- ##### FUNCTION gtk_object_default_construct ##### -->\r
409 <para>\r
410 This function is called to construct arguments that haven't been initialized\r
411 but have the #GTK_ARG_CONSTRUCT flag set.\r
412 </para>\r
413 <para>\r
414 All number arguments are set to 0.  All pointers and strings\r
415 are set to NULL.\r
416 </para>\r
417 <para>\r
418 Normally invoked by gtk_object_new() automatically; gtk_type_new() can\r
419 be used to bypass it.\r
420 </para>\r
421 \r
422 @object: the object to initialize.\r
423 \r
424 \r
425 <!-- ##### FUNCTION gtk_object_sink ##### -->\r
426 <para>\r
427 Decrement the initial count given to the object.\r
428 Additional invocations have no effect.\r
429 </para>\r
430 <para>\r
431 This is designed to free the user from worrying about\r
432 dereferencing an object that they have just created.\r
433 So long as the object is sunk at some point, the reference count\r
434 will be set properly.\r
435 </para>\r
436 <para>\r
437 furthermore it may be sunk multiple times.\r
438 Only the first time will actually dereference.\r
439 </para>\r
440 <para>\r
441 The basic outline is: when you create an object it is floating.\r
442 Setting its parent causes it to be sunk, however its parent\r
443 has obtained a reference, so its reference count is one.\r
444 </para>\r
445 \r
446 @object: the object to sink.\r
447 \r
448 \r
449 <!-- ##### FUNCTION gtk_object_ref ##### -->\r
450 <para>\r
451 Increase the reference count of the object.\r
452 </para>\r
453 \r
454 @object: the object to reference.\r
455 \r
456 \r
457 <!-- ##### FUNCTION gtk_object_unref ##### -->\r
458 <para>\r
459 Decrease the reference count of an object.  When its reference\r
460 count drops to 0, the object is deleted.\r
461 </para>\r
462 <para>\r
463 If it was not already destroyed, it will be, with gtk_object_destroy(),\r
464 then weak links are notified, then the object-data is freed\r
465 and the memory for the object itself is freed using gtk_type_free().\r
466 </para>\r
467 \r
468 @object: the object to dereference.\r
469 \r
470 \r
471 <!-- ##### FUNCTION gtk_object_weakref ##### -->\r
472 <para>\r
473 Adds a weak reference callback to an object.\r
474 </para>\r
475 <para>\r
476 Weak references are a mechanism to safely keep a pointer to\r
477 an object without using the reference counting\r
478 mechansim.  They use a callback function to receive\r
479 notice that the object is about to be freed (aka finalized).\r
480 This happens <emphasis>after</emphasis> the destroy\r
481 callback has been run.\r
482 </para>\r
483 \r
484 @object: object to weakly reference.\r
485 @notify: callback to invoke before the object is freed.\r
486 @data: extra data to pass to #notify.\r
487 \r
488 \r
489 <!-- ##### FUNCTION gtk_object_weakunref ##### -->\r
490 <para>\r
491 Removes a weak reference callback to an object.\r
492 </para>\r
493 \r
494 @object: object stop weakly referencing.\r
495 @notify: callback to search for.\r
496 @data: data to search for.\r
497 \r
498 \r
499 <!-- ##### FUNCTION gtk_object_destroy ##### -->\r
500 <para>\r
501 Calls the object's shutdown handler.\r
502 </para>\r
503 <para>\r
504 The memory for the object itself won't be deleted until\r
505 its reference count drops to 0, though.\r
506 See gtk_object_unref().\r
507 </para>\r
508 \r
509 @object: the object to destroy.\r
510 \r
511 \r
512 <!-- ##### FUNCTION gtk_object_getv ##### -->\r
513 <para>\r
514 Gets an array of argument values from an object.\r
515 </para>\r
516 \r
517 @object: the object to get arguments from.\r
518 @n_args: the number of arguments to query.\r
519 @args: the arguments to fill in.\r
520 \r
521 \r
522 <!-- ##### FUNCTION gtk_object_set ##### -->\r
523 <para>\r
524 This function sets multiple arguments of an object.\r
525 </para>\r
526 <para>\r
527 It takes an object, then a list of name/value pairs\r
528 in a list, followed by NULL.\r
529 </para>\r
530 <para>\r
531 <informalexample>\r
532 <programlisting>\r
533 void set_box_properties(GtkBox* box)\r
534 {\r
535   gtk_object_set(GTK_OBJECT(box), "homogeneous", TRUE,\r
536                                   "spacing", 8,\r
537                                   NULL);\r
538 }\r
539 </programlisting>\r
540 </informalexample>\r
541 </para>\r
542 \r
543 \r
544 @object: the object whose arguments should be set.\r
545 @first_arg_name: the name of the first argument to set.\r
546 @Varargs: the value of the first argument, followed optionally\r
547 by more name/value pairs, followed by NULL.\r
548 \r
549 <!-- ##### FUNCTION gtk_object_setv ##### -->\r
550 <para>\r
551 Set an array of arguments.\r
552 </para>\r
553 \r
554 @object: the object whose arguments should be set.\r
555 @n_args: the number of arguments to set.\r
556 @args: the desired values, as an array of #GtkArgs (which contain \r
557 the names, types, and values of the arguments).\r
558 \r
559 \r
560 <!-- ##### FUNCTION gtk_object_query_args ##### -->\r
561 <para>\r
562 Get all the arguments that may be used for a given type.\r
563 </para>\r
564 <para>\r
565 In Java, this type of mechanism is called \r
566 <wordasword>introspection</wordasword>.  It is used by applications\r
567 like Glade, that have to determine what can be done to an object\r
568 at run-time.\r
569 </para>\r
570 \r
571 @class_type: the GtkType of the ObjectClass\r
572 (returned from GTK_OBJECT_CLASS(class)-&gt;type for example).\r
573 @arg_flags: if non-NULL, obtains the #GtkArgFlags that apply to\r
574 each argument.  You must g_free() this if you request it.\r
575 @n_args: the number of arguments is returned in this field.\r
576 @Returns: an array of arguments, that you must deallocate with g_free().\r
577 \r
578 \r
579 <!-- ##### FUNCTION gtk_object_set_data ##### -->\r
580 <para>\r
581 Each object carries around a table of associations from\r
582 strings to pointers.  This function lets you set an association.\r
583 </para>\r
584 <para>\r
585 If the object already had an association with that name,\r
586 the old association will be destroyed.\r
587 </para>\r
588 \r
589 @object: object containing the associations.\r
590 @key: name of the key.\r
591 @data: data to associate with that key.\r
592 \r
593 \r
594 <!-- ##### FUNCTION gtk_object_set_data_full ##### -->\r
595 <para>\r
596 Like gtk_object_set_data() except it adds notification\r
597 for when the association is destroyed, either by\r
598 gtk_object_remove_data() or when the object is destroyed.\r
599 </para>\r
600 \r
601 @object: object containing the associations.\r
602 @key: name of the key.\r
603 @data: data to associate with that key.\r
604 @destroy: function to call when the association is destroyed.\r
605 \r
606 \r
607 <!-- ##### FUNCTION gtk_object_remove_data ##### -->\r
608 <para>\r
609 Remove a specified datum from the object's data associations (the object_data).\r
610 Subsequent calls to gtk_object_get_data() will return NULL.\r
611 </para>\r
612 <para>\r
613 If you specified a destroy handler with gtk_object_set_data_full(),\r
614 it will be invoked.\r
615 </para>\r
616 \r
617 \r
618 @object: the object maintaining the association.\r
619 @key: name of the key for that association.\r
620 \r
621 \r
622 <!-- ##### FUNCTION gtk_object_get_data ##### -->\r
623 <para>\r
624 Get a named field from the object's table of associations (the object_data).\r
625 </para>\r
626 \r
627 @object: the object maintaining the associations.\r
628 @key: name of the key for that association.\r
629 @Returns: the data if found, or NULL if no such data exists.\r
630 \r
631 \r
632 <!-- ##### FUNCTION gtk_object_remove_no_notify ##### -->\r
633 <para>\r
634 Remove a specified datum from the object's data associations (the object_data),\r
635 without invoking the association's destroy handler.\r
636 </para>\r
637 <para>\r
638 Just like gtk_object_remove_data() except that any destroy handler\r
639 will be ignored.\r
640 Therefore this only affects data set using gtk_object_set_data_full().\r
641 </para>\r
642 \r
643 @object: the object maintaining the association.\r
644 @key: name of the key for that association.\r
645 \r
646 \r
647 <!-- ##### FUNCTION gtk_object_set_user_data ##### -->\r
648 <para>\r
649 For convenience, every object offers a generic user data\r
650 pointer.  The function set it.\r
651 </para>\r
652 <para>\r
653 This function is equivalent to:\r
654 <informalexample>\r
655 <programlisting>\r
656         gtk_object_set_data(object, "user_data", data);\r
657 </programlisting>\r
658 </informalexample>\r
659 </para>\r
660 \r
661 @object: the object whose user data should be set.\r
662 @data: the new value for the user data.\r
663 \r
664 \r
665 <!-- ##### FUNCTION gtk_object_get_user_data ##### -->\r
666 <para>\r
667 Get the object's user data pointer.\r
668 </para>\r
669 <para>\r
670 This is intended to be a pointer for your convenience in\r
671 writing applications.\r
672 </para>\r
673 \r
674 @object: the object.\r
675 @Returns: the user data field for object.\r
676 \r
677 \r
678 <!-- ##### FUNCTION gtk_object_class_add_signals ##### -->\r
679 <para>\r
680 Add an array of signals to a #GtkObjectClass.\r
681 Usually this is called when registering a new type of object.\r
682 </para>\r
683 \r
684 @klass: the object class to append signals to.\r
685 @signals: the signals to append.\r
686 @nsignals: the number of signals being appended.\r
687 \r
688 \r
689 <!-- ##### FUNCTION gtk_object_add_arg_type ##### -->\r
690 <para>\r
691 Add a new type of argument to an object class.\r
692 Usually this is called when registering a new type of object.\r
693 </para>\r
694 \r
695 @arg_name: fully qualify object name, for example GtkObject::user_data.\r
696 @arg_type: type of the argument.\r
697 @arg_flags: bitwise-OR of the #GtkArgFlags enum.  (Whether the argument is\r
698 settable or gettable, whether it is set when the object is constructed.)\r
699 @arg_id: an internal number, passed in from here to the "set_arg" and\r
700 "get_arg" handlers of the object.\r
701 \r
702 \r
703 <!-- ##### FUNCTION gtk_object_set_data_by_id ##### -->\r
704 <para>\r
705 Just like gtk_object_set_data() except that it takes\r
706 a #GQuark instead of a string, so it is slightly faster.\r
707 </para>\r
708 <para>\r
709 Use gtk_object_data_try_key() and gtk_object_data_force_id()\r
710 to get an id from a string.\r
711 </para>\r
712 \r
713 @object: object containing the associations.\r
714 @data_id: quark of the key.\r
715 @data: data to associate with that key.\r
716 \r
717 \r
718 <!-- ##### FUNCTION gtk_object_set_data_by_id_full ##### -->\r
719 <para>\r
720 Just like gtk_object_set_data_full() except that it takes\r
721 a #GQuark instead of a string, so it is slightly faster.\r
722 </para>\r
723 <para>\r
724 Use gtk_object_data_try_key() and gtk_object_data_force_id()\r
725 to get an id from a string.\r
726 </para>\r
727 \r
728 @object: object containing the associations.\r
729 @data_id: quark of the key.\r
730 @data: data to associate with that key.\r
731 @destroy: function to call when the association is destroyed.\r
732 \r
733 \r
734 <!-- ##### FUNCTION gtk_object_get_data_by_id ##### -->\r
735 <para>\r
736 Just like gtk_object_get_data() except that it takes\r
737 a #GQuark instead of a string, so it is slightly faster.\r
738 </para>\r
739 <para>\r
740 Use gtk_object_data_try_key() and gtk_object_data_force_id()\r
741 to get an id from a string.\r
742 </para>\r
743 \r
744 @object: object containing the associations.\r
745 @data_id: quark of the key.\r
746 @Returns: the data if found, or NULL if no such data exists.\r
747 \r
748 \r
749 <!-- ##### FUNCTION gtk_object_remove_data_by_id ##### -->\r
750 <para>\r
751 Just like gtk_object_remove_data() except that it takes\r
752 a #GQuark instead of a string, so it is slightly faster.\r
753 </para>\r
754 <para>\r
755 Remove a specified datum from the object's data associations.\r
756 Subsequent calls to gtk_object_get_data() will return NULL.\r
757 </para>\r
758 <para>\r
759 Use gtk_object_data_try_key() and gtk_object_data_force_id()\r
760 to get an id from a string.\r
761 </para>\r
762 \r
763 @object: object containing the associations.\r
764 @data_id: quark of the key.\r
765 \r
766 \r
767 <!-- ##### FUNCTION gtk_object_remove_no_notify_by_id ##### -->\r
768 <para>\r
769 Just like gtk_object_remove_no_notify() except that it takes\r
770 a #GQuark instead of a string, so it is slightly faster.\r
771 </para>\r
772 <para>\r
773 Use gtk_object_data_try_key() and gtk_object_data_force_id()\r
774 to get an id from a string.\r
775 </para>\r
776 \r
777 @object: object containing the associations.\r
778 @data_id: quark of the key.\r
779 \r
780 \r
781 <!-- ##### MACRO gtk_object_data_try_key ##### -->\r
782 <para>\r
783 Sees whether a certain quark exists.\r
784 Returns that quark if so.\r
785 </para>\r
786 <para>\r
787 Although this is currently the same as g_quark_try_string(),\r
788 it might someday be different, for example, if GQuarks\r
789 and object data are converted to separate mechanisms,\r
790 so it is good to use this macro.\r
791 </para>\r
792 \r
793 \r
794 \r
795 <!-- ##### MACRO gtk_object_data_force_id ##### -->\r
796 <para>\r
797 Makes a quark from a string, possibly allocating a new quark.\r
798 </para>\r
799 <para>\r
800 Although this is currently the same as g_quark_from_string(),\r
801 it might someday be different, for example, if GQuarks\r
802 and object data are converted to separate mechanisms,\r
803 so it is good to use this macro.\r
804 </para>\r
805 \r
806 \r
807 \r
808 <!-- ##### FUNCTION gtk_object_arg_set ##### -->\r
809 <para>\r
810 Private function to set an argument and argument info to an object.\r
811 </para>\r
812 \r
813 @object: the object whose argument should be set.\r
814 @arg: the argument.\r
815 @info: infomation about this type of argument in general.\r
816 \r
817 \r
818 <!-- ##### FUNCTION gtk_object_arg_get ##### -->\r
819 <para>\r
820 Private function to get an argument and argument info from an object.\r
821 </para>\r
822 \r
823 @object: the object whose argument should be retrieved.\r
824 @arg: the argument, for the name on input, the rest is filled on output.\r
825 @info: a #GtkArgInfo structure to optionally fill in.\r
826 \r
827 \r
828 <!-- ##### FUNCTION gtk_object_args_collect ##### -->\r
829 <para>\r
830 Private: Gets an array of #GtkArgs from a va_list C structure.\r
831 </para>\r
832 <para>\r
833 \r
834 @object_type: the type of object to collect arguments for.\r
835 @arg_list_p: pointer to be filled in with a list of parsed arguments.\r
836 @info_list_p: optional pointer for a returned list #GtkArgInfos.\r
837 @first_arg_name: name of first argument.\r
838 @var_args: value of first argument, followed by more key/value pairs,\r
839 terminated by NULL.\r
840 @Returns: an error message, or NULL on success.\r
841 It is the caller's responsibility to call g_free() in the event of error.\r
842 \r
843 \r
844 <!-- ##### FUNCTION gtk_object_arg_get_info ##### -->\r
845 <para>\r
846 Query information about an argument type.\r
847 </para>\r
848 \r
849 @object_type: type of object to query about.\r
850 @arg_name: name of the argument.\r
851 @info_p: pointer to be filled in with a pointer to the GtkArgInfo.\r
852 @Returns: an error message, or NULL on success.\r
853 It is the caller's responsibility to call g_free() in the event of error.\r
854 \r
855 \r
856 <!-- ##### FUNCTION gtk_trace_referencing ##### -->\r
857 <para>\r
858 Private: print debugging information while doing a gtk_object_ref() or \r
859 a gtk_object_unref().\r
860 </para>\r
861 \r
862 @object: object to reference or unreference.\r
863 @func: name of caller's function to print (used within macros).\r
864 @dummy: unused.\r
865 @line: line number (used within macros).\r
866 @do_ref: whether to reference or unreference.\r
867 \r
868 \r
869 <!-- ##### SIGNAL GtkObject::destroy ##### -->\r
870 <para>\r
871 Indicates that an object is being destroyed.\r
872 </para>\r
873 \r
874 @object: the object which received the signal.\r
875 \r
876 <!-- ##### ARG GtkObject:user_data ##### -->\r
877 <para>\r
878 A pointer for convenience when programming applications.\r
879 </para>\r
880 \r
881 <!-- ##### ARG GtkObject:signal ##### -->\r
882 <para>\r
883 Setting this with a GtkType of GTK_TYPE_SIGNAL connects\r
884 the signal to the object.\r
885 </para>\r
886 \r
887 <!-- ##### ARG GtkObject:signal_after ##### -->\r
888 <para>\r
889 Setting this with a GtkType of GTK_TYPE_SIGNAL connects\r
890 the signal to the object, so that the signal is always run\r
891 after other user handlers and the default handler.\r
892 </para>\r
893 \r
894 <!-- ##### ARG GtkObject:object_signal ##### -->\r
895 <para>\r
896 Setting this with a GtkType of GTK_TYPE_SIGNAL connects\r
897 the signal to the object, so that the user data and objects\r
898 and swapped when the signal handler is invoked.\r
899 </para>\r
900 <para>\r
901 This is useful for handlers that are primarily notifying\r
902 other objects and could just invoke an already existing function\r
903 if the parameters were swapped.\r
904 See gtk_signal_connect_object() for more details.\r
905 </para>\r
906 \r
907 <!-- ##### ARG GtkObject:object_signal_after ##### -->\r
908 <para>\r
909 Setting this with a GtkType of GTK_TYPE_SIGNAL connects\r
910 the signal to the object, so that the user data and objects\r
911 and swapped when the signal handler is invoked,\r
912 and so that the handler is invoked after all others.\r
913 </para>\r
914 <para>\r
915 See gtk_signal_connect_object_after() for more details.\r
916 </para>\r
917 \r