Ardour  9.0-pre0-582-g084a23a80d
gtktypeutils.h
Go to the documentation of this file.
1 /* GTK - The GIMP Toolkit
2  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19 
20 /*
21  * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
22  * file for a list of people on the GTK+ Team. See the ChangeLog
23  * files for a list of changes. These files are distributed with
24  * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
25  */
26 
27 #ifndef __GTK_TYPE_UTILS_H__
28 #define __GTK_TYPE_UTILS_H__
29 
30 #if defined(GTK_DISABLE_SINGLE_INCLUDES) && !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
31 #error "Only <gtk/gtk.h> can be included directly."
32 #endif
33 
34 /* enum types generated by glib-mkenums
35  */
36 #include <gtk/gtktypebuiltins.h>
37 
38 G_BEGIN_DECLS
39 
40 /* urg */
41 #define GTK_TYPE_IDENTIFIER (gtk_identifier_get_type ())
42 GType gtk_identifier_get_type (void) G_GNUC_CONST;
43 
44 /* --- typedefs --- */
45 /* here we come with some necessary forward declarations for structures and
46  * provide some fundamental function signatures
47  */
48 typedef struct _GtkArg GtkArg;
49 typedef struct _GtkObject GtkObject; /* object forward declaration */
50 #if !defined (GTK_DISABLE_DEPRECATED) || defined (GTK_COMPILATION)
51 typedef gboolean (*GtkFunction) (gpointer data);
52 typedef void (*GtkCallbackMarshal) (GtkObject *object,
53  gpointer data,
54  guint n_args,
55  GtkArg *args);
56 #endif
57 
58 /* This used to be defined in gtkitemfactory.h, but moved over here after
59  * the complete deprecation of that header
60  */
61 typedef gchar * (*GtkTranslateFunc) (const gchar *path,
62  gpointer func_data);
63 
64 
65 /* Everything below is deprecated and superseded by GType API
66  */
67 
68 #ifndef GTK_DISABLE_DEPRECATED
69 
70 /* Fundamental Types
71  * many of these are just aliases for GLib types to maintain
72  * compatibility
73  */
74 
75 #define GTK_TYPE_INVALID G_TYPE_INVALID
76 #define GTK_TYPE_NONE G_TYPE_NONE
77 #define GTK_TYPE_ENUM G_TYPE_ENUM
78 #define GTK_TYPE_FLAGS G_TYPE_FLAGS
79 
80 /* GtkArg types */
81 #define GTK_TYPE_CHAR G_TYPE_CHAR
82 #define GTK_TYPE_UCHAR G_TYPE_UCHAR
83 #define GTK_TYPE_BOOL G_TYPE_BOOLEAN
84 #define GTK_TYPE_INT G_TYPE_INT
85 #define GTK_TYPE_UINT G_TYPE_UINT
86 #define GTK_TYPE_LONG G_TYPE_LONG
87 #define GTK_TYPE_ULONG G_TYPE_ULONG
88 #define GTK_TYPE_FLOAT G_TYPE_FLOAT
89 #define GTK_TYPE_DOUBLE G_TYPE_DOUBLE
90 #define GTK_TYPE_STRING G_TYPE_STRING
91 #define GTK_TYPE_BOXED G_TYPE_BOXED
92 #define GTK_TYPE_POINTER G_TYPE_POINTER
93 
94 typedef GType GtkFundamentalType;
95 
96 /* --- type macros --- */
97 #define GTK_CLASS_NAME(class) (g_type_name (G_TYPE_FROM_CLASS (class)))
98 #define GTK_CLASS_TYPE(class) (G_TYPE_FROM_CLASS (class))
99 #define GTK_TYPE_IS_OBJECT(type) (g_type_is_a ((type), GTK_TYPE_OBJECT))
100 
101 /* outdated macros that really shouldn't e used anymore,
102  * use the GLib type system instead
103  */
104 #define GTK_TYPE_FUNDAMENTAL_LAST (G_TYPE_LAST_RESERVED_FUNDAMENTAL - 1)
105 #define GTK_TYPE_FUNDAMENTAL_MAX (G_TYPE_FUNDAMENTAL_MAX)
106 
107 #define GTK_FUNDAMENTAL_TYPE G_TYPE_FUNDAMENTAL
108 #define GTK_STRUCT_OFFSET G_STRUCT_OFFSET
109 
110 /* glib macro wrappers (compatibility) */
111 #define GTK_CHECK_CAST G_TYPE_CHECK_INSTANCE_CAST
112 #define GTK_CHECK_CLASS_CAST G_TYPE_CHECK_CLASS_CAST
113 #define GTK_CHECK_GET_CLASS G_TYPE_INSTANCE_GET_CLASS
114 #define GTK_CHECK_TYPE G_TYPE_CHECK_INSTANCE_TYPE
115 #define GTK_CHECK_CLASS_TYPE G_TYPE_CHECK_CLASS_TYPE
116 
117 /* glib type wrappers (compatibility) */
118 
119 typedef GType GtkType;
120 typedef GTypeInstance GtkTypeObject;
121 typedef GTypeClass GtkTypeClass;
122 typedef GBaseInitFunc GtkClassInitFunc;
123 typedef GInstanceInitFunc GtkObjectInitFunc;
124 typedef GSignalCMarshaller GtkSignalMarshaller;
125 
126 typedef void (*GtkDestroyNotify) (gpointer data);
127 typedef void (*GtkSignalFunc) (void);
128 
129 #define GTK_SIGNAL_FUNC(f) G_CALLBACK(f)
130 
131 #endif /* GTK_DISABLE_DEPRECATED */
132 
133 #if !defined (GTK_DISABLE_DEPRECATED) || defined (GTK_COMPILATION)
134 
135 /* Used by gtk_container_foreach_unmarshal () */
136 
137 /* GtkArg, used to hold differently typed values */
138 struct _GtkArg
139 {
140  GType type;
141  gchar *name;
142 
143  /* this union only defines the required storage types for
144  * the possibile values, thus there is no gint enum_data field,
145  * because that would just be a mere alias for gint int_data.
146  * use the GTK_VALUE_*() and GTK_RETLOC_*() macros to access
147  * the discrete memebers.
148  */
149  union {
150  /* flat values */
151  gchar char_data;
152  guchar uchar_data;
153  gboolean bool_data;
154  gint int_data;
155  guint uint_data;
156  glong long_data;
157  gulong ulong_data;
158  gfloat float_data;
159  gdouble double_data;
160  gchar *string_data;
162  gpointer pointer_data;
163 
164  /* structured values */
165  struct {
166  GCallback f;
167  gpointer d;
169  } d;
170 };
171 
172 /* argument value access macros, these must not contain casts,
173  * to allow the usage of these macros in combination with the
174  * address operator, e.g. &GTK_VALUE_CHAR (*arg)
175  */
176 #define GTK_VALUE_CHAR(a) ((a).d.char_data)
177 #define GTK_VALUE_UCHAR(a) ((a).d.uchar_data)
178 #define GTK_VALUE_BOOL(a) ((a).d.bool_data)
179 #define GTK_VALUE_INT(a) ((a).d.int_data)
180 #define GTK_VALUE_UINT(a) ((a).d.uint_data)
181 #define GTK_VALUE_LONG(a) ((a).d.long_data)
182 #define GTK_VALUE_ULONG(a) ((a).d.ulong_data)
183 #define GTK_VALUE_FLOAT(a) ((a).d.float_data)
184 #define GTK_VALUE_DOUBLE(a) ((a).d.double_data)
185 #define GTK_VALUE_STRING(a) ((a).d.string_data)
186 #define GTK_VALUE_ENUM(a) ((a).d.int_data)
187 #define GTK_VALUE_FLAGS(a) ((a).d.uint_data)
188 #define GTK_VALUE_BOXED(a) ((a).d.pointer_data)
189 #define GTK_VALUE_OBJECT(a) ((a).d.object_data)
190 #define GTK_VALUE_POINTER(a) ((a).d.pointer_data)
191 #define GTK_VALUE_SIGNAL(a) ((a).d.signal_data)
192 
193 #endif /* !GTK_DISABLE_DEPRECATED || GTK_COMPILATION */
194 
195 #ifndef GTK_DISABLE_DEPRECATED
196 
197 /* return location macros, these all narrow down to
198  * pointer types, because return values need to be
199  * passed by reference
200  */
201 #define GTK_RETLOC_CHAR(a) ((gchar*) (a).d.pointer_data)
202 #define GTK_RETLOC_UCHAR(a) ((guchar*) (a).d.pointer_data)
203 #define GTK_RETLOC_BOOL(a) ((gboolean*) (a).d.pointer_data)
204 #define GTK_RETLOC_INT(a) ((gint*) (a).d.pointer_data)
205 #define GTK_RETLOC_UINT(a) ((guint*) (a).d.pointer_data)
206 #define GTK_RETLOC_LONG(a) ((glong*) (a).d.pointer_data)
207 #define GTK_RETLOC_ULONG(a) ((gulong*) (a).d.pointer_data)
208 #define GTK_RETLOC_FLOAT(a) ((gfloat*) (a).d.pointer_data)
209 #define GTK_RETLOC_DOUBLE(a) ((gdouble*) (a).d.pointer_data)
210 #define GTK_RETLOC_STRING(a) ((gchar**) (a).d.pointer_data)
211 #define GTK_RETLOC_ENUM(a) ((gint*) (a).d.pointer_data)
212 #define GTK_RETLOC_FLAGS(a) ((guint*) (a).d.pointer_data)
213 #define GTK_RETLOC_BOXED(a) ((gpointer*) (a).d.pointer_data)
214 #define GTK_RETLOC_OBJECT(a) ((GtkObject**) (a).d.pointer_data)
215 #define GTK_RETLOC_POINTER(a) ((gpointer*) (a).d.pointer_data)
216 /* GTK_RETLOC_SIGNAL() - no such thing */
217 
218 /* type registration, it is recommended to use
219  * g_type_register_static() or
220  * g_type_register_dynamic() instead
221  */
222 typedef struct _GtkTypeInfo GtkTypeInfo;
223 
225 {
226  gchar *type_name;
227  guint object_size;
228  guint class_size;
231  gpointer reserved_1;
232  gpointer reserved_2;
234 };
235 
236 void gtk_type_init (GTypeDebugFlags debug_flags);
238  const GtkTypeInfo *gtkinfo);
239 gpointer gtk_type_class (GtkType type);
240 gpointer gtk_type_new (GtkType type);
241 
242 /* --- compatibility defines --- */
243 #define gtk_type_name(type) g_type_name (type)
244 #define gtk_type_from_name(name) g_type_from_name (name)
245 #define gtk_type_parent(type) g_type_parent (type)
246 #define gtk_type_is_a(type, is_a_type) g_type_is_a ((type), (is_a_type))
247 
248 /* enum/flags compatibility functions, we strongly
249  * recommend to use the glib enum/flags classes directly
250  */
251 typedef GEnumValue GtkEnumValue;
252 typedef GFlagsValue GtkFlagValue;
256  const gchar *value_name);
258  const gchar *value_name);
259 
260 #endif /* GTK_DISABLE_DEPRECATED */
261 
262 G_END_DECLS
263 
264 #endif /* __GTK_TYPE_UTILS_H__ */
GTypeClass GtkTypeClass
Definition: gtktypeutils.h:121
GtkFlagValue * gtk_type_flags_get_values(GtkType flags_type)
GType GtkType
Definition: gtktypeutils.h:119
void(* GtkCallbackMarshal)(GtkObject *object, gpointer data, guint n_args, GtkArg *args)
Definition: gtktypeutils.h:52
gboolean(* GtkFunction)(gpointer data)
Definition: gtktypeutils.h:51
GtkFlagValue * gtk_type_flags_find_value(GtkType flags_type, const gchar *value_name)
gpointer gtk_type_class(GtkType type)
void(* GtkSignalFunc)(void)
Definition: gtktypeutils.h:127
void(* GtkDestroyNotify)(gpointer data)
Definition: gtktypeutils.h:126
GFlagsValue GtkFlagValue
Definition: gtktypeutils.h:252
gpointer gtk_type_new(GtkType type)
GtkEnumValue * gtk_type_enum_find_value(GtkType enum_type, const gchar *value_name)
GSignalCMarshaller GtkSignalMarshaller
Definition: gtktypeutils.h:124
GType gtk_identifier_get_type(void) G_GNUC_CONST
GType GtkFundamentalType
Definition: gtktypeutils.h:94
GEnumValue GtkEnumValue
Definition: gtktypeutils.h:251
GBaseInitFunc GtkClassInitFunc
Definition: gtktypeutils.h:122
void gtk_type_init(GTypeDebugFlags debug_flags)
GtkType gtk_type_unique(GtkType parent_type, const GtkTypeInfo *gtkinfo)
GtkEnumValue * gtk_type_enum_get_values(GtkType enum_type)
GTypeInstance GtkTypeObject
Definition: gtktypeutils.h:120
GInstanceInitFunc GtkObjectInitFunc
Definition: gtktypeutils.h:123
gpointer d
Definition: gtktypeutils.h:167
guint uint_data
Definition: gtktypeutils.h:155
gpointer pointer_data
Definition: gtktypeutils.h:162
gdouble double_data
Definition: gtktypeutils.h:159
gboolean bool_data
Definition: gtktypeutils.h:153
guchar uchar_data
Definition: gtktypeutils.h:152
GtkObject * object_data
Definition: gtktypeutils.h:161
gint int_data
Definition: gtktypeutils.h:154
gulong ulong_data
Definition: gtktypeutils.h:157
struct _GtkArg::@59::@60 signal_data
GCallback f
Definition: gtktypeutils.h:166
gfloat float_data
Definition: gtktypeutils.h:158
glong long_data
Definition: gtktypeutils.h:156
gchar char_data
Definition: gtktypeutils.h:151
gchar * string_data
Definition: gtktypeutils.h:160
GType type
Definition: gtktypeutils.h:140
gchar * name
Definition: gtktypeutils.h:141
gchar * type_name
Definition: gtktypeutils.h:226
gpointer reserved_2
Definition: gtktypeutils.h:232
GtkClassInitFunc class_init_func
Definition: gtktypeutils.h:229
guint class_size
Definition: gtktypeutils.h:228
GtkObjectInitFunc object_init_func
Definition: gtktypeutils.h:230
gpointer reserved_1
Definition: gtktypeutils.h:231
GtkClassInitFunc base_class_init_func
Definition: gtktypeutils.h:233
guint object_size
Definition: gtktypeutils.h:227