source: trunk/third/gtk/docs/gtk.info-1 @ 14810

Revision 14810, 48.7 KB checked in by ghudson, 25 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r14809, which included commits to RCS files with non-trunk default branches.
Line 
1This is gtk.info, produced by makeinfo version 4.0 from gtk.texi.
2
3   This file documents GTK, the GIMP Toolkit
4
5   Copyright (C) 1996 Peter Mattis Copyright (C) 1997 Peter Mattis
6
7   Permission is granted to make and distribute verbatim copies of this
8manual provided the copyright notice and this permission notice are
9preserved on all copies
10
11   Permission is granted to copy and distribute modified versions of
12this manual under the conditions for verbatim copying, provided that the
13entire resulting derived work is distributed under the terms of a
14permission notice identical to this one.
15
16   Permission is granted to copy and distribute translations of this
17manual into another language, under the above conditions for modified
18versions, except that this permission notice may be stated in a
19translation approved by Peter Mattis.
20
21INFO-DIR-SECTION User Interface Toolkit
22START-INFO-DIR-ENTRY
23* GTK: (gtk).           The GIMP Toolkit
24END-INFO-DIR-ENTRY
25
26
27File: gtk.info,  Node: Top,  Next: Copying,  Prev: (dir),  Up: (dir)
28
29The GIMP Toolkit
30****************
31
32   This is edition 1.0 of the GTK documentation, 23 August 1998.
33
34* Menu:
35
36* Copying::                     Your rights.
37* Overview::                    What is GTK?
38* Types::
39* Objects::
40* Signals::                     Signals overview.
41* Widgets::                     Widget overview.
42* Other Objects::               Utility objects.
43* Miscellaneous::               Initialization, exit and other features.
44* Examples::                    Using GTK.
45* Object Implementation::       Object internals.
46* Signal Implementation::       Signal internals.
47* Widget Implementation::       Widget internals.
48* Function Index::              Index of functions.
49* Concept Index::               Index of concepts.
50
51
52File: gtk.info,  Node: Copying,  Next: Overview,  Prev: Top,  Up: Top
53
54Copying
55*******
56
57   GTK is "free"; this means that everyone is free to use it and free
58to redistribute it on a free basis. GTK is not in the public domain; it
59is copyrighted and there are restrictions on its distribution, but
60these restrictions are designed to permit everything that a good
61cooperating citizen would want to do. What is not allowed is to try to
62prevent others from further sharing any version of GTK that they might
63get from you.
64
65   Specifically, we want to make sure that you have the right to give
66away copies of GTK, that you receive source code or else can get it if
67you want it, that you can change GTK or use pieces of it in new free
68programs, and that you know you can do these things.
69
70   To make sure that everyone has such rights, we have to forbid you to
71deprive anyone else of these rights. For example, if you distribute
72copies of GTK, you must give the recipients all the rights that you
73have. You must make sure that they, too, receive or can get the source
74code. And you must tell them their rights.
75
76   Also, for our own protection, we must make certain that everyone
77finds out that there is no warranty for GTK. If GTK is modified by
78someone else and passed on, we want their recipients to know that what
79they have is not what we distributed, so that any problems introduced
80by others will no reflect on our reputation.
81
82   The precise conditions of the licenses for GTK are found in the
83General Public Licenses that accompany it.
84
85
86File: gtk.info,  Node: Overview,  Next: Types,  Prev: Copying,  Up: Top
87
88What is GTK?
89************
90
91   GTK is a library for creating graphical user interfaces similar to
92the Motif "look and feel". It is designed to be small and efficient, but
93still flexible enough to allow the programmer freedom in the interfaces
94created. GTK allows the programmer to use a variety of standard user
95interface widgets (*note Widgets::) such as push, radio and check
96buttons, menus, lists and frames. It also provides several "container"
97widgets which can be used to control the layout of the user interface
98elements.
99
100   GTK provides some unique features. (At least, I know of no other
101widget library which provides them). For example, a button does not
102contain a label, it contains a child widget, which in most instances
103will be a label. However, the child widget can also be a pixmap, image
104or any combination possible the programmer desires. This flexibility is
105adhered to throughout the library.
106
107   To make life easier for you, GTK presents this flexibility in a
108uniform framework.  Specifically, it implements its own support for
109object oriented programming that is well adapted to the purposes of a
110user interface toolkit and it aims at providing a reasonable sane and
111disciplined programming interface.  This uniformity and discipline is
112intended to make it easy and reliable to access GTK from languages other
113than C.  Especially more dynamic languages like Perl, Python or Scheme
114will find amble support, and in fact, bindings to these languages
115already exist.
116
117
118File: gtk.info,  Node: Types,  Next: Objects,  Prev: Overview,  Up: Top
119
120Types
121*****
122
123                                 Other kid's games are all such a bore!
124                    They've gotta have rules and they gotta keep score!
125
126                                          - Calvin about CalvinBall(tm)
127
128   GTK implements a semi-simple type system with an associated class
129mechanism for widgets and several other useful objects.  This type
130system is intended to be general enough to allow both a smooth binding
131of dynamically typed languages to Gtk, as well as to serve for a
132rigorous and formalistic definition of the larger part of the Gtk API.
133
134   The classes for the individual widgets are by far the most important
135part of this type system, but before we get to them, we describe the
136basics of the type system itself.  This is mostly of interest for widget
137writers and language binders, so you might want to skip ahead to the
138next chapter, which talks about the object oriented stuff.
139
140* Menu:
141
142* Type introduction::
143* Basics::
144* Simple types::
145* Enumerations and flags::
146* Strings::
147* Boxed types::
148* Callbacks::
149* Composite types::
150
151
152File: gtk.info,  Node: Type introduction,  Next: Basics,  Prev: Types,  Up: Types
153
154Introduction to the Type System
155===============================
156
157   Gtk defines its own system of types, much like a computer language
158defines what types it supports.  Of course, the Gtk type system is build
159on top of the types that C provides, so it includes members like `int',
160`long' and `float'.  But, compared to C, it allows only few carefully
161selected types and specifies a lot of restrictions on the way you can
162use values of these types.  For example, there is no general facility
163for specifying _pointer to X_.  Instead, we take a more higher level
164approach and define such things as `string', which is just like a
165`char*' but with additional rules about how to manage the memory that
166it points to.
167
168   The type system has two purposes: to define a formal system with
169which to describe the various exported features of Gtk; and to
170implement this system at run-time so that we get sound and flexible
171"dynamic" types for the dynamic languages that want to interface with
172Gtk.
173
174   Let me restate this with different words, because I think it is
175important to understand this idea.  We will see in a moment that the
176type system is indeed well defined and all this detail is implemented
177with functions and data structures in Gtk.  For example, every type (and
178there can be any number of them) can be represented with a unique
179integer and Gtk has support for the necessary bookkeeping for this.
180Every type also has a name and there are functions for converting
181between the name of a type and its unique number.  Maybe more useful,
182there is a big discriminated union that can be used to pass around a
183value of any representable type, together with its precise type.
184
185   This is the run-time or dynamic side of the type system.  Mostly,
186you do not need to use it when you don't want to.  The compile-time or
187static side of the type system can is used to statically define the
188programming interface of Gtk.  For example, suppose there is function
189`gtk_foo' in the Gtk API that has a prototype
190
191     char *gtk_foo (char *);
192
193   This looks like it does something with strings.  But what does it do
194with the memory of the string that has been passed in, and what are we
195supposed or allowed to do with the memory that the returned pointer
196points to?  The more restricted type `string' from the Gtk type system
197can be used to be more precise.  In fact, the definition of `string'
198below includes the rule that when a `string' is passed to a function,
199that function is not allowed to retain a pointer into the string beyond
200the life time of that function call.  So we are safe to deallocate it
201or override it when the function has returned.  Likewise, the
202definition specifies that the memory of a `string' that is returned
203from a function becomes the sole property of the calling function.  The
204calling function is responsible for deallocating it eventually and it
205can be sure that nobody else scribbles in it.  When `gtk_foo' really
206obeys these rules, we can say that it takes one argument, which is a
207`string', and it returns a `string'.
208
209   Now we can understand why it makes sense to have a more restrictive
210type system than that of C.  With it, it is possible to be more precise
211and we actually have a framework where we can be sure that as long as we
212stay inside this framework we are not gratuitously causing trouble for
213languages that are more disciplined than C.  Of course, you are not
214restricted to making all your interfaces expressible within the
215framework.  There are valid reasons for breaking it, for performance or
216simply for convenience.  But please try to provide all the functionality
217of your module in such a way that it can be described with this type
218system and treat the non-conforming functions as additional goodies that
219are nice to have but not essential.  The reward is an instant
220accessibility of your code from a huge number of scripting and extension
221languages such as Perl, Python, and Guile.
222
223   These formal specifications of the Gtk interface are contained in
224special declarations in the header files of Gtk.  They are ignored by
225the C compiler, but can be used by other language processors.  For extra
226convenience, these declarations are also available in a more condensed
227form that is easier to parse.  Tools for generating bindings of Gtk to
228other languages can read these declarations and--because all the
229important details are defined--automatically generate the bulk of the
230needed glue code.  It is also possible to feed these declarations into a
231running application (an interface builder, say) and thus make it aware
232of new widgets and functions without recompiling anything.
233
234   The run-time side of the type system is also somewhat introspective.
235This means that you can query Gtk about all the members of an
236enumeration for example.  Gtk provides tools that help you provide this
237introspection for your definitions also.
238
239   Types are not enough to completely specify an interface, so GTK also
240has "modes".  A mode specifies what happens to a value when it crosses a
241module boundary; it can be `in', `out', or `inout'.  Most fundamental
242types (and their derived types) support only mode `in'.  The modes
243`out' and `inout' can only be used with the composite types: lists and
244vectors.  When argument of these types are marked as `out' or `inout'
245it means that the called module is allowed to change the contents of
246the composite value and that these changes need to be propagated back
247to the originator of the value.  Mode `out' means that the argument has
248no meaningful value at the beginning and should not be read.  Mode `in'
249specifies that the called module is not allowed to change the value in
250any way.
251
252   The type system allows for an unbounded number of types.  Every
253widget is a type for example and you can add new widget types at any
254time without confusing the run-time implementation of the type system.
255Nevertheless, all types are derived from a certain "fundamental" type,
256and there are only a small and finite number of fundamental types.  We
257only specify rules for the fundamental types and all other types
258inherit these rules from their fundamental type.  For example, `int' is
259a fundamental type, as is `GtkObject'.  All widgets derive from
260`GtkObject' and so the rules for `GtkObject' apply to all widgets as
261well.
262
263   This derivation defines a type hierarchy, but this hierarchy is not
264completely general.  You can't derive from `int' for example, and you
265can only have one level of derivation from `enum'.  The fundamental
266type `GtkObject', however, is the basis for the large and deep
267hierarchy of widget types.
268
269   The individual fundamental types are defined and explained in the
270following sections.  Here is a complete list of them:
271
272`none'
273     The not-a-value type, similar to `void'.
274
275`char'
276     A character.  Internationalization issues are still undecided.
277
278`bool'
279     True or false.
280
281`byte, ubyte, int, uint, long, ulong, float, double'
282     The usual assortment of scalar types.
283
284`string'
285     A string.  Internationalization issues are still undecided.
286
287`enum, flags'
288     Enumerations with a fixed set of literals.  Either used to express
289     a single choice from this set or to individually turn on and off
290     several flags.
291
292`boxed'
293     A pointer to an opaque structure that can be copied and destroyed.
294
295`callback'
296     A pointer to a function with enough extra information so that it
297     can also be used for functions written in languages completely
298     different from C.
299
300`GtkObject'
301     A pointer to a GtkObject or derived type.  The fun starts here.
302
303`args, slist, dlist, cvec, tvec'
304     An assortment of composite types like linked lists and counted or
305     zero-terminated arrays.
306
307`pointer, signal, c_callback'
308     Obsolete types.
309
310
311File: gtk.info,  Node: Basics,  Next: Simple types,  Prev: Type introduction,  Up: Types
312
313Basic Concepts
314==============
315
316   The basis for the type system are the fundamental types.  At
317run-time, they are represented by members of the `GtkFundamentalType'
318enumeration.  For the static declarations, they are identified with a
319unique name.
320
321 - Enumeration: GtkFundamentalType
322     This enumeration contains a member for each defined fundamental
323     type.  Most members are listed along with the description of their
324     semantics, but one is listed here:
325
326    `GTK_TYPE_INVALID'
327          No valid type is derived from this.  Use `GTK_TYPE_INVALID' to
328          express exceptional situations.  This member does not really
329          correspond to a fundamental type and thus there is no name
330          for it.
331
332 - Data type: GtkType
333     The type `GtkType' holds the run-time representation of a type.  It
334     is an integer of a certain size.  The follwing macros are defined
335     to access the basic properties of a `GtkType':
336
337      - Macro: unsigned int GTK_TYPE_SEQNO (GtkType type)
338          Returns the sequence number of TYPE.  The sequence numbers are
339          guaranteed to be dense, i.e., you can use them to index a
340          table and the table need not be much larger than the number
341          of different GtkTypes that you might encounter.
342
343      - Macro: GtkFundamentalType GTK_FUNDAMENTAL_TYPE (GtkType type)
344          Returns the fundamental type of TYPE.
345
346     Both macros simply access different bit-fields of a `GtkType', so
347     they are very efficient.
348
349   New types are registered with the `gtk_type_unique' function.  Any
350kind oftype can be registered with `gtk_type_unique' but there are
351convenience functions for most fundamental types.  Each fundamental type
352has its own interpretation of the rules below and these convenience
353functions should be used to automatically get the type registration
354right.  So, don't be put off by the apparent complexity of the interface
355to `gtk_type_unique'.  You will be using it only for new widgets, and
356there the rules are simple.
357
358   The `GtkTypeInfo' structure is used to communicate information to
359`gtk_type_unique' as opposed to passing in large numbers of parameters.
360
361     typedef struct _GtkTypeInfo GtkTypeInfo;
362     
363     struct _GtkTypeInfo
364     {
365       gchar *type_name;
366       guint object_size;
367       guint class_size;
368       GtkClassInitFunc class_init_func;
369       GtkObjectInitFunc object_init_func;
370       gpointer reserved_1;
371       gpointer reserved_2;
372       GtkClassInitFunc base_class_init_func;
373     }
374
375   * The `type_name' field refers to the name of the type.  This is the
376     same name that is used in the static definitions.  It is
377     convention for the type name to be closely related to the name of
378     the underlying C type. For example, the type name of the
379     `GtkObject' structure is "GtkObject", and the name of the
380     `GtkWindowType' enumeration is "GtkWindowType".  Note that the C
381     type corresponding to "GtkObject" is really a pointer to a
382     `GtkObject' struct, but the name has no "*" in it.
383
384   * The `object_size' field refers to the size in bytes of the C
385     structure for types that have such a structure. The easiest (and
386     portable) means of computing this size is by using the C `sizeof'
387     operator. For instance, the sizeof of the `GtkObject' structure is
388     computed by doing `sizeof (GtkObject)'.  When the type has no
389     associated structure or when you do not want to support the
390     `gtk_type_new' function for the new type, set `object_size' to 0.
391     Only types derived from GTK_TYPE_OBJECT can be handled by
392     `gtk_type_new', anyway.
393
394   * The `class_size' field refers to the size in bytes of the C
395     structure for the class.  Again, the `sizeof' operator should be
396     used to compute this value.  If you don't want to have a class
397     structure for this type, set the field to 0.  `gtk_type_class'
398     will then always return `NULL'.
399
400   * The `class_init_func' and `base_class_init_func' fields are
401     callbacks which are used by the type mechanism to initialize class
402     specific fields. The single argument these functions take is a
403     pointer to a class structure.  When you do not need one or both of
404     them, set the corresponding field to `NULL'.  The
405     `class_init_func' will be called at most once, right after the
406     class structure of size `class_size' has been allocated.  The
407     interaction between `class_init_func' and `base_class_init_func'
408     is only really useful for the full-fledged object system.  It is
409     described there *note Objects::.
410
411   * The `object_init_func' field is a callback which is used by the
412     type mechanism to initialize object specific fields for structures
413     that have been allocated via `gtk_type_new'. The single argument
414     this functions takes is a pointer to an object structure.  If you
415     do not want any special object initialization to take place, set
416     this to `NULL'.  All object initialization functions for all types
417     that are part of the inheritance chain are called, starting with
418     the most basic type.
419
420
421 - Function: guint gtk_type_unique (GtkType PARENT_TYPE, GtkTypeInfo
422          *TYPE_INFO)
423     The PARENT_TYPE is simply the new types parent type. If
424     PARENT_TYPE is GTK_TYPE_INVALID, then the new type is a new
425     fundamental type.  You should never register new fundamental types.
426     TYPE_INFO is a pointer to a structure which contains necessary
427     information for construction of the new type.
428
429     You can only register a specific name once.
430
431 - Function: gchar* gtk_type_name (GtkType TYPE)
432     The returned string is the name of TYPE as specified to
433     `gtk_type_unique'.
434
435 - Function: GtkType gtk_type_from_name (guchar *NAME)
436     Return the type associated with NAME. If there is no type
437     associated with NAME, then GTK_TYPE_INVALID will be returned.
438
439 - Function: GtkType gtk_type_parent (GtkType TYPE)
440     Returns the parent type of TYPE or GTK_TYPE_INVALID if TYPE is a
441     fundamental type.
442
443 - Function: gpointer gtk_type_class (GtkType TYPE)
444     Returns the initialized class structure for TYPE. The class
445     structure is actually created and initialized the first time it is
446     needed.  Refer to *note Objects:: for details on how this
447     initialization works for GTK_TYPE_OBJECT derived types.
448
449     The returned structure is shared by all objects of TYPE and, as
450     such, should not be modified.
451
452 - Function: gpointer gtk_type_new (GtkType TYPE)
453     Returns a new instance of an TYPE object.  This works only for
454     GTK_TYPE_OBJECT derived types.  Please see *note Objects::.
455
456 - Function: void gtk_type_describe_heritage (GtkType TYPE)
457     Prints the type heritage for TYPE. The heritage for a type
458     includes the type and all its parent types up the type tree.
459
460 - Function: void gtk_type_describe_tree (GtkType TYPE, gboolean
461          SHOW_SIZE)
462     Prints the type tree which starts at TYPE. SHOW_SIZE is a boolean
463     which determines whether type sizes are printed.
464
465 - Function: gboolean gtk_type_is_a (GtkType TYPE, GtkType IS_A_TYPE)
466     A predicate function which determines whether the relation TYPE
467     is_a IS_A_TYPE is true.
468
469   Values of all types can be handled uniformly by storing them into a
470`GtkArg' structure.  The `GtkArg' has the following fields:
471
472`gchar *name'
473     This can be used to give the value represented by this `GtkArg'
474     structure a name.  It is not used much.
475
476`GtkType type'
477     The type of this value.
478
479`union d'
480     A big union that has (at least conceptually) one member for each
481     fundamental type.  You should not access these members directly.
482     Rather, use the `GTK_VALUE_*' macros.  There is one macro for each
483     fundamental type, and its name is derived from the name of the
484     GtkFundamentalType enumeration members simply by replacing
485     "Gtk_TYPE" with "GTK_VALUE".  All `GTK_VALUE_*' macros take a
486     `GtkArg' structure as their only parameter (_not_ a pointer) and
487     evaluate to a lvalue.
488
489   For example, the accessor for the fundamental type GTK_TYPE_INT is
490called GTK_VALUE_INT and you could use it like this:
491
492     GtkArg value;
493     
494     value.name = NULL;
495     value.type = GTK_TYPE_INT;
496     GTK_VALUE_INT(value) = 7;
497
498
499File: gtk.info,  Node: Simple types,  Next: Enumerations and flags,  Prev: Basics,  Up: Types
500
501Simple Types
502============
503
504   The Gtk type system has a full set of the usual simple types:
505integers, floating point numbers, but also boolean and character.  You
506can not derive new types from these.
507
508Enum               Name         Description
509GTK_TYPE_NONE      "void"       A type without value.
510GTK_TYPE_CHAR      "char"       A 8-bit unsigned number
511                                representing a character.  Numbers
512                                    between 0 and 127 are ASCII,
513                                the rest is undefined.
514GTK_TYPE_BOOL      "gboolean"   The boolean type.  It is some
515                                small integer where the number 0
516                                   represents false and 1 is
517                                true.  No other values are
518                                allowed.
519GTK_TYPE_INT       "gint"       A signed integer with at least 32
520                                bits.
521GTK_TYPE_UINT      "guint"      A unsigned integer with at least
522                                32 bits.
523GTK_TYPE_LONG      "glong"      A signed integer with at least 32
524                                bits.
525GTK_TYPE_ULONG     "gulong"     A unsigned integer with at least
526                                32 bits.  This is large enough to
527                                    hold a coerced pointer.
528GTK_TYPE_FLOAT     "gfloat"     A single precision floating point
529                                number.
530GTK_TYPE_DOUBLE    "gfloat"     A souble precision floating point
531                                number.
532GTK_TYPE_POINTER   "gpointer"   A untyped pointer.  Do not use
533                                this if you can avoid it.
534
535   The values of these types are all represented `directly' with the C
536types that are indicated in the `name' column above.  *note Boxed
537types:: for a discussion of this.
538
539
540File: gtk.info,  Node: Enumerations and flags,  Next: Strings,  Prev: Simple types,  Up: Types
541
542Enumerations and Flags
543======================
544
545
546File: gtk.info,  Node: Strings,  Next: Boxed types,  Prev: Enumerations and flags,  Up: Types
547
548Strings
549=======
550
551
552File: gtk.info,  Node: Boxed types,  Next: Callbacks,  Prev: Strings,  Up: Types
553
554Boxed Types
555===========
556
557
558File: gtk.info,  Node: Callbacks,  Next: Composite types,  Prev: Boxed types,  Up: Types
559
560Callbacks
561=========
562
563
564File: gtk.info,  Node: Composite types,  Prev: Callbacks,  Up: Types
565
566Composite Types
567===============
568
569
570File: gtk.info,  Node: Objects,  Next: Signals,  Prev: Types,  Up: Top
571
572Objects
573*******
574
575Object functions
576================
577
578   The GtkObject type is the root of the type hierarchy used by GTK. It
579provides a minimal set of fields used to implement the actual object,
580class and signal mechanisms, as well as several utility routines which
581make dealing with objects easier.
582
583   For the adventurous, see *Note Object Implementation::.
584
585 - Function: guint gtk_object_get_type (void)
586     Returns the `GtkObject' type identifier.
587
588 - Function: void gtk_object_class_add_signals (GtkObjectClass *CLASS,
589          gint *SIGNALS, gint NSIGNALS)
590     Adds SIGNALS to the `signals' field in the GtkObjectClass
591     structure CLASS. *Note Signals::.
592
593 - Function: GtkObject* gtk_object_new (guint TYPE, ...)
594
595 - Function: GtkObject* gtk_object_newv (guint TYPE, guint NARGS,
596          GtkArg *ARGS)
597
598 - Function: void gtk_object_ref (GtkObject *OBJECT);
599
600 - Function: void gtk_object_unref (GtkObject *OBJECT);
601
602 - Function: void gtk_object_getv (GtkObject *OBJECT, guint NARGS,
603          GtkArg *ARGS)
604
605 - Function: void gtk_object_set (GtkObject *OBJECT, ...)
606
607 - Function: void gtk_object_setv (GtkObject *OBJECT, guint NARGS,
608          GtkArg *ARGS)
609
610 - Function: GtkArg* gtk_object_query_args (GtkType CLASS_TYPE, guint
611          *NARGS)
612
613 - Function: void gtk_object_add_arg_type (gchar *ARG_NAME, GtkType
614          ARG_TYPE, guint ARG_ID)
615
616 - Function: GtkType gtk_object_get_arg_type (gchar *ARG_NAME)
617
618 - Function: void gtk_object_destroy (GtkObject *OBJECT)
619     Performs checks to make sure it is alright to destroy OBJECT and
620     then emits the `destroy' signal. The check which is performed is to
621     make sure OBJECT is not already processing another signal. If this
622     were the case then destroying the object immediately would
623     undoubtedly cause problems as the other signal would not be able
624     to tell the object was destroyed. The solution is that if OBJECT
625     is processing another signal we mark OBJECT is needing to be
626     destroyed. When we finish processing of the other signal we check
627     whether the object needs to be destroyed.
628
629   The GtkObject type provides a mechanism for associating arbitrary
630amounts of data with an object. The data is associated with the object
631using a character string key. The functions `gtk_object_set_data',
632`gtk_object_get_data', and `gtk_object_remove_data' are the interface
633to this mechanism. Two other routines, `gtk_object_set_user_data' and
634`gtk_object_get_user_data', exist as convenience functions which simply
635use the same mechanism.
636
637 - Function: void gtk_object_set_data (GtkObject *OBJECT, const char
638          *KEY, gpointer DATA)
639     Associate DATA with KEY in the data list of OBJECT.
640
641 - Function: gpointer gtk_object_get_data (GtkObject *OBJECT, const
642          char *KEY)
643     Retrieve the data associated with KEY in the data list of OBJECT.
644
645 - Function: void gtk_object_remove_data (GtkObject *OBJECT, const char
646          *KEY)
647     Remove the data associated with KEY in the data list of OBJECT.
648
649 - Function: void gtk_object_set_user_data (GtkObject *OBJECT, gpointer
650          DATA)
651     Sets DATA into the `user_data' field of OBJECT.
652
653 - Function: gpointer gtk_object_get_user_data (GtkObject *OBJECT)
654     Returns the `user_data' field of OBJECT.
655
656   The GtkObject type also provides a mechanism for specifying
657initialization values for fields. This general mechanism is called
658object value stacks. The reason for using value stacks is that they can
659simplify the life of the programmer. For instance, by default widgets
660are non-visible when created. However, the "visible" value for widgets
661may be specified so that widgets are made visible when created. (FIXME:
662unfinished).
663
664 - Function: void gtk_object_value_stack_new (guint OBJECT_TYPE, const
665          gchar *VALUE_ID, GtkParamType VALUE_TYPE)
666
667 - Function: void gtk_object_push_value (guint OBJECT_TYPE, const gchar
668          *VALUE_ID, ...)
669     Push a value on the value stack specified by OBJECT_TYPE and
670     VALUE_ID. The type of value is implicitly given in the context of
671     OBJECT_TYPE and VALUE_ID. (That is, it is not specified explicitly
672     in the function call). Only a single extra argument is expected
673     which is the data which is to be placed on the stack.
674
675 - Function: void gtk_object_pop_value (guint OBJECT_TYPE, const gchar
676          *VALUE_ID)
677     Pop a value of the value stack specified by OBJECT_TYPE and
678     VALUE_ID.
679
680 - Function: gint gtk_object_peek_value (guint OBJECT_TYPE, const gchar
681          *VALUE_ID, gpointer DATA)
682     Peek at the value on the top of the value stack specified by
683     OBJECT_TYPE and VALUE_ID. The DATA argument is interpreted as the
684     location of where to place the "peeked" data. For instance, if the
685     peeked data is of type `GTK_PARAM_POINTER', then DATA will be a
686     pointer to a pointer. If the value stack is empty or does not
687     exist or an error occurs, `gtk_object_peek_value' will return
688     `FALSE'. On success it will return `TRUE'.
689
690
691File: gtk.info,  Node: Signals,  Next: Widgets,  Prev: Objects,  Up: Top
692
693Signals Overview
694****************
695
696   Signals are GTK's method for objects to perform callbacks. A signal
697is an event which occurs upon an object. The programmer can connect to a
698signal of an object which involves specifying a function to be called
699when that signal is emitted in the specified object.
700
701   When a signal is emitted, both the class function associated with the
702signal (when it was defined) and all signal handlers installed for that
703signal on the particular object emitting the signal are called. The
704widget programmer can specify whether the class function is to be called
705before after or both before and after the signal handlers installed by
706the widget user. The widget user can, however, specify that their signal
707handler is to be run after the class function (using the "_after"
708signal connection routines). Any signal handling function can emit the
709same signal on the same object while it is running causing that signal
710emission to either restart or to run recursively. Additionally, signal
711emission can be terminated prematurely. While both such abilities are
712rarely used, they do allow for greater flexibility in regards to
713signals. For instance, a programmer can attach to the key press event
714signal and intercept all tab key presses from a widget. This particular
715example is used in the file selection dialog to implement tab completion
716of filenames and prevent the entry widget from inserting the tab into
717its buffer.
718
719   Signals are selected using either an integer identifier or a
720character string name. It is convention to name the signal the same as
721the class function which is associated with it. There are two versions
722of most of the signal functions, one which takes an integer identifier
723and one which takes a character string name for the signal.
724
725 - Function: gint gtk_signal_new (gchar *NAME, GtkSignalRunType
726          RUN_TYPE, gint OBJECT_TYPE, gint FUNCTION_OFFSET,
727          GtkSignalMarshaller MARSHALLER, GtkParamType RETURN_VAL, gint
728          NPARAMS, ...)
729     Create a new signal and give it the character string identifier
730     NAME. NAME needs to be unique in the context of OBJECT_TYPE's
731     branch of the class hierarchy. That is, OBJECT_TYPE cannot create
732     a signal type with the same name as a signal type created by one
733     of its parent types.
734
735     RUN_TYPE specifies whether the class function should be run before
736     (`GTK_RUN_FIRST'), after (`GTK_RUN_LAST') or both before and after
737     normal signal handlers (`GTK_RUN_BOTH'). Additionally, the
738     `GTK_RUN_NO_RECURSE' value can be or'ed with any of those values to
739     specify that the signal should not be recursive. By default,
740     emitting the same signal on the same widget will cause the signal
741     to be emitted twice. However, if the `GTK_RUN_NO_RECURSE' flag is
742     specified, emitting the same signal on the same widget will cause
743     the current signal emission to be restarted. This allows the
744     widget programmer to specify the semantics of signal emission on a
745     per signal basis. (The `GTK_RUN_NO_RECURSE' flag is used by the
746     GtkAdjustment widget).
747
748     The FUNCTION_OFFSET is the byte offset from the start of the class
749     structure to the class function field within the class structure.
750     The easiest means to compute this offset is by using the
751     `GTK_SIGNAL_OFFSET' macro which takes the class structure type as
752     the first argument and the field as the second argument. For
753     example, `GTK_SIGNAL_OFFSET (GtkObjectClass, destroy)' will give
754     the offset of the `destroy' class function within the
755     `GtkObjectClass'. Note: An offset is specified instead of an
756     absolute location since there will be multiple instances of a class
757     structure being referenced. (The `GtkWidgetClass' structure "is a"
758     `GtkObjectClass' structure, etc.)
759
760     The MARSHALLER function is used to invoke a signal handler. Since
761     signal handlers may take different parameters and return values
762     and a general mechanism for invoking them is not apparent, the
763     approach of making the signal creator responsible for invoking the
764     signal handler was taken. (FIXME: unfinished).
765
766     The RETURN_VAL and NPARAMS and the remaining arguments specify the
767     return value and the arguments to the signal handler respectively.
768     Note: There is an implicit first argument to every signal handler
769     which is the widget the signal has been emitted from. The variable
770     argument list (...) specifies the types of the arguments. These
771     can be one of `GTK_PARAM_CHAR', `GTK_PARAM_SHORT',
772     `GTK_PARAM_INT', `GTK_PARAM_LONG', `GTK_PARAM_POINTER' or
773     `GTK_PARAM_FUNCTION'. It is undefined to specify `GTK_PARAM_NONE'
774     as an argument type, however it is OK to use `GTK_PARAM_NONE' for
775     RETURN_VAL. (This corresponds to returning a `void').
776
777     `gtk_signal_new' returns the integer identifier of the newly
778     created signal. Signal identifiers start numbering at 1 and
779     increase upwards. A value of -1 will be returned if an error
780     occurs.
781
782     *Note:* `gtk_signal_new' is only needed by widget writers. A
783     normal user of GTK will never needed to invoke this function.
784
785 - Function: gint gtk_signal_lookup (gchar *NAME, gint OBJECT_TYPE)
786     Returns the integer identifier for the signal referenced by NAME
787     and OBJECT_TYPE. If OBJECT_TYPE does not define the signal NAME,
788     then the signal is looked for in OBJECT_TYPE's parent type
789     recursively.
790
791 - Function: gchar* gtk_signal_name (gint SIGNAL_NUM)
792
793 - Function: gint gtk_signal_emit (GtkObject *OBJECT, gint SIGNAL_TYPE,
794          ...)
795     Emit the signal specified by the integer identifier SIGNAL_TYPE
796     from OBJECT. If an error occurs, `gtk_signal_emit' will return
797     `FALSE' and will return `TRUE' on success. The signal definition
798     determines the parameters passed in the variable argument list
799     (`...'). For example, if the signal is defined as:
800
801            gint (* event) (GtkWidget *widget, GdkEvent *event);
802
803     Then a call to emit the "event" signal would look like:
804
805            GdkEvent event;
806            gint return_val;
807            ...
808            gtk_signal_emit (some_object,
809                             gtk_signal_lookup ("event",
810                               GTK_OBJECT_TYPE (some_object)),
811                             &event, &return_val);
812
813     Notice that the `widget' argument is implicit in that the first
814     argument to every signal is a type derived from `GtkObject'. The
815     RETURN_VAL argument is actually a pointer to the return value type
816     since the signal mechanism needs to be able to place the return
817     value in an actual location. And lastly, the `gtk_signal_lookup'
818     call is normally avoided by using the `gtk_signal_emit_by_name'
819     function instead. `gtk_signal_emit' is normally used internally by
820     widgets which know the signal identifier (since they defined the
821     signal) and can therefore side-step the cost of calling
822     `gtk_signal_lookup'.
823
824 - Function: gint gtk_signal_emit_by_name (GtkObject *OBJECT, gchar
825          *NAME, ...)
826     Similar to `gtk_signal_emit' except that the signal is referenced
827     by NAME instead of by its integer identifier.
828
829 - Function: void gtk_signal_emit_stop (GtkObject *OBJECT, gint
830          SIGNAL_TYPE)
831     Stop the emission of the signal SIGNAL_TYPE on OBJECT. SIGNAL_TYPE
832     is the integer identifier for the signal and can be determined
833     using the function `gtk_signal_lookup'. Alternatively, the function
834     `gtk_signal_emit_stop_by_name' can be used to refer to the signal
835     by name. Attempting to stop the emission of a signal that isn't
836     being emitted does nothing.
837
838 - Function: void gtk_signal_emit_stop_by_name (GtkObject *OBJECT,
839          gchar *NAME)
840     Similar to `gtk_signal_emit_stop' except that the signal is
841     referenced by NAME instead of by its integer identifier.
842
843 - Function: gint gtk_signal_connect (GtkObject *OBJECT, gchar *NAME,
844          GtkSignalFunc FUNC, gpointer FUNC_DATA)
845     Connects a signal handling function to a signal emitting object.
846     FUNC is connected to the signal NAME emitted by OBJECT. The
847     arguments and returns type of FUNC should match the arguments and
848     return type of the signal NAME. However, FUNC may take the extra
849     argument of FUNC_DATA. Due to the C calling convention it is OK to
850     ignore the extra argument. (It is OK to ignore all the arguments
851     in fact).
852
853     `gtk_signal_connect' returns an integer identifier for the
854     connection which can be used to refer to it in the future.
855     Specifically it is useful for removing the connection and/or
856     blocking it from being used.
857
858 - Function: gint gtk_signal_connect_after (GtkObject *OBJECT, gchar
859          *NAME, GtkSignalFunc FUNC, gpointer FUNC_DATA)
860     Similar to `gtk_signal_connect' except the signal handler is
861     connected in the "after" slot. This allows a signal handler to be
862     guaranteed to run after other signal handlers connected to the same
863     signal on the same object and after the class function associated
864     with the signal.
865
866     Like `gtk_signal_connect', `gtk_signal_connect_after' returns an
867     integer identifier which can be used to refer to the connection.
868
869 - Function: gint gtk_signal_connect_object (GtkObject *OBJECT, gchar
870          *NAME, GtkSignalFunc FUNC, GtkObject *SLOT_OBJECT)
871     Connects FUNC to the signal NAME emitted by OBJECT. Similar to
872     `gtk_signal_connect' with the difference that SLOT_OBJECT is
873     passed as the first parameter to FUNC instead of the signal
874     emitting object. This can be useful for connecting a signal
875     emitted by one object to a signal in another object. A common
876     usage is to connect the "destroy" signal of dialog to the "clicked"
877     signal emitted by a "close" button in the dialog. That is, the
878     "clicked" signal emitted by the button will caused the "destroy"
879     signal to be emitted for the dialog. This is also the "right" way
880     to handle closing of a dialog since the "destroy" signal will be
881     sent if the dialog is deleted using a window manager function and
882     this enables the two methods of closing the window to be handled
883     by the same mechanism. Returns an integer identifier which can be
884     used to refer to the connection.
885
886 - Function: gint gtk_signal_connect_object_after (GtkObject *OBJECT,
887          gchar *NAME, GtkSignalFunc FUNC, GtkObject *SLOT_OBJECT)
888     Similar to `gtk_signal_connect_object' except the signal handler is
889     connected in the "after" slot. This allows a signal handler to be
890     guaranteed to run after other signal handlers connected to the same
891     signal on the same object and after the class function associated
892     with the signal. Returns an integer identifier which can be used
893     to refer to the connection.
894
895 - Function: gint gtk_signal_connect_interp (GtkObject *OBJECT, gchar
896          *NAME, GtkCallbackMarshal FUNC, gpointer DATA,
897          GtkDestroyNotify DESTROY_FUNC, gint AFTER)
898
899 - Function: void gtk_signal_disconnect (GtkObject *OBJECT, gint ID)
900     Disconnects a signal handler from an object. The signal handler is
901     identified by the integer ID which is returned by the
902     `gtk_signal_connect*' family of functions.
903
904 - Function: void gtk_signal_disconnect_by_data (GtkObject *OBJECT,
905          gpointer DATA)
906     Disconnects a signal handler from an object. The signal handler is
907     identified by the DATA argument specified as the FUNC_DATA
908     argument to the `gtk_signal_connect*' family of functions. For the
909     `gtk_signal_connect_object*' functions, DATA refers to the
910     SLOT_OBJECT.
911
912     *Note:* This will remove all signal handlers connected to OBJECT
913     which were connected using DATA as their FUNC_DATA argument.
914     Multiple signal handlers may be disconnected with this call.
915
916 - Function: void gtk_signal_handler_block (GtkObject *OBJECT, gint ID)
917     Blocks calling of a signal handler during signal emission. The
918     signal handler is identified by the integer ID which is returned
919     by the `gtk_signal_connect*' family of functions. If the signal is
920     already blocked no change is made.
921
922 - Function: void gtk_signal_handler_block_by_data (GtkObject *OBJECT,
923          gint DATA)
924     Blocks calling of a signal handler during signal emission. The
925     signal handler is identified by the DATA argument specified as the
926     FUNC_DATA argument to the `gtk_signal_connect*' family of
927     functions. For the `gtk_signal_connect_object*' functions, DATA
928     refers to the SLOT_OBJECT. If the signal is already blocked no
929     change is made.
930
931     *Note:* This will block all signal handlers connected to OBJECT
932     which were connected using DATA as their FUNC_DATA argument.
933     Multiple signal handlers may be blocked with this call.
934
935 - Function: void gtk_signal_handler_unblock (GtkObject *OBJECT, gint
936          ID)
937     Unblocks calling of a signal handler during signal emission. The
938     signal handler is identified by the integer ID which is returned
939     by the `gtk_signal_connect*' family of functions. If the signal is
940     already unblocked no change is made.
941
942 - Function: void gtk_signal_handler_unblock_by_data (GtkObject
943          *OBJECT, gint DATA)
944     Unblocks calling of a signal handler during signal emission. The
945     signal handler is identified by the DATA argument specified as the
946     FUNC_DATA argument to the `gtk_signal_connect*' family of
947     functions. For the `gtk_signal_connect_object*' functions, DATA
948     refers to the SLOT_OBJECT. If the signal is already unblocked no
949     change is made.
950
951     *Note:* This will unblock all signal handlers connected to OBJECT
952     which were connected using DATA as their FUNC_DATA argument.
953     Multiple signal handlers may be unblocked with this call.
954
955 - Function: void gtk_signal_handlers_destroy (GtkObject *OBJECT)
956     Destroy all of the signal handlers connected to OBJECT. There
957     should normally never be reason to call this function as it is
958     called automatically when OBJECT is destroyed.
959
960 - Function: void gtk_signal_default_marshaller (GtkObject *OBJECT,
961          GtkSignalFunc FUNC, gpointer FUNC_DATA, GtkSignalParam
962          *PARAMS)
963     `gtk_signal_new' requires a callback in order to actually call a
964     signal handler for a particular signal. The vast majority of
965     signals are of the particular form:
966
967            (* std_signal) (gpointer std_arg);
968
969     `gtk_signal_default_marshaller' is a signal marshaller which
970     marshals arguments for a signal of that form.
971
972 - Function: void gtk_signal_set_funcs (GtkSignalMarshal MARSHAL_FUNC,
973          GtkSignalDestroy DESTROY_FUN)
974
975
976File: gtk.info,  Node: Widgets,  Next: Other Objects,  Prev: Signals,  Up: Top
977
978Widget Overview
979***************
980
981   Widgets are the general term used to describe user interface
982objects. A widget defines a class interface that all user interface
983objects conform to. This interface allows a uniform method for dealing
984with operations common to all objects such as hiding and showing, size
985requisition and allocation and events.
986
987   The common interface that widgets must adhere to is described by the
988GtkWidget and GtkWidgetClass structure. For the purposes of using GTK
989these structures can be considered read-only and, for the most part,
990opaque.
991
992   All widget creation routines in GTK return pointers to GtkWidget
993structures. In reality, all widget creation routines create structures
994that can be viewed as equivalent to the GtkWidget structure, but often
995have contain additional information. *Note Object Implementation::.
996
997   The widgets available for use are implemented in a hierarchy. Several
998widgets exist solely as common bases for more specific widgets. For
999example, it is not possible to create a ruler widget itself, but the
1000ruler widget provides a base and functionality common to the horizontal
1001and vertical rulers.
1002
1003   The available widgets (in alphabetical order):
1004
1005* Menu:
1006
1007* GtkAlignment::                The alignment widget.
1008* GtkArrow::                    The arrow widget.
1009* GtkAspectFrame::              The aspect frame widget.
1010* GtkBin::                      The bin widget.
1011* GtkBox::                      The box widget.
1012* GtkButtonBox::                The button box widget.
1013* GtkButton::                   The button widget.
1014* GtkCheckButton::              The check button widget.
1015* GtkCheckMenuItem::            The check menu item widget.
1016* GtkCList::                    The compound list widget.
1017* GtkColorSelection::           The color selector widget.
1018* GtkCombo::                    The combo box widget.
1019* GtkContainer::                The container widget.
1020* GtkCTree::                    The multi-column tree widget.
1021* GtkCurve::                    The curve widget.
1022* GtkGammaCurve::               The gamma curve widget.
1023* GtkDialog::                   The dialog widget.
1024* GtkDrawingArea::              The drawing area widget.
1025* GtkEntry::                    The entry widget.
1026* GtkEventBox::                 The event box widget.
1027* GtkFileSelection::            The file selection dialog widget.
1028* GtkFixed::                    The fixed widget.
1029* GtkFrame::                    The frame widget.
1030* GtkGamma::                    The gamma widget.
1031* GtkHBox::                     The horizontal box widget.
1032* GtkHButtonBox::               The horizontal button box widget.
1033* GtkHPaned::                   The horizontal paned widget.
1034* GtkHRuler::                   The horizontal ruler widget.
1035* GtkHScale::                   The horizontal scale widget.
1036* GtkHScrollbar::               The horizontal scrollbar widget.
1037* GtkHSeparator::               The horizontal separator widget.
1038* GtkImage::                    The image widget.
1039* GtkInputDialog::              The input dialog widget.
1040* GtkItem::                     The item widget.
1041* GtkLabel::                    The label widget.
1042* GtkList::                     The list widget.
1043* GtkListItem::                 The list item widget.
1044* GtkMenu::                     The menu widget.
1045* GtkMenuBar::                  The menu bar widget.
1046* GtkMenuItem::                 The menu item widget.
1047* GtkMenuShell::                The menu shell widget.
1048* GtkMisc::                     The misc widget.
1049* GtkNotebook::                 The notebook widget.
1050* GtkOptionMenu::               The option menu widget.
1051* GtkPaned::                    The paned widget.
1052* GtkPixmap::                   The pixmap widget.
1053* GtkPreview::                  The preview widget.
1054* GtkProgressBar::              The progress bar widget.
1055* GtkRadioButton::              The radio button widget.
1056* GtkRadioMenuItem::            The radio menu item widget.
1057* GtkRange::                    The range widget.
1058* GtkRuler::                    The ruler widget.
1059* GtkScale::                    The scale widget.
1060* GtkScrollbar::                The scrollbar widget.
1061* GtkScrolledWindow::           The scrolled window widget.
1062* GtkSeparator::                The separator widget.
1063* GtkStatusbar::                The statusbar widget.
1064* GtkTable::                    The table widget.
1065* GtkText::                     The text widget.
1066* GtkToggleButton::             The toggle button widget.
1067* GtkToolbar::                  The tool bar widget.
1068* GtkTooltips::                 The tool tips widget.
1069* GtkTree::                     The tree widget.
1070* GtkTreeItem::                 The tree item widget.
1071* GtkVBox::                     The vertical box widget.
1072* GtkVButtonBox::               The vertical button box widget.
1073* GtkViewport::                 The viewport widget.
1074* GtkVPaned::                   The vertical paned widget.
1075* GtkVRuler::                   The vertical ruler widget.
1076* GtkVScale::                   The vertical scale widget.
1077* GtkVScrollbar::               The vertical scrollbar widget.
1078* GtkVSeparator::               The vertical separator widget.
1079* GtkWidget::                   The base widget type.
1080* GtkWindow::                   The window widget.
1081
Note: See TracBrowser for help on using the repository browser.