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
38G_BEGIN_DECLS
39
40/* urg */
41#define GTK_TYPE_IDENTIFIER (gtk_identifier_get_type ())
42GType 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 */
48typedef struct _GtkArg GtkArg;
49typedef struct _GtkObject GtkObject; /* object forward declaration */
50#if !defined (GTK_DISABLE_DEPRECATED) || defined (GTK_COMPILATION)
51typedef gboolean (*GtkFunction) (gpointer data);
52typedef 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 */
61typedef 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
94typedef 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
119typedef GType GtkType;
120typedef GTypeInstance GtkTypeObject;
121typedef GTypeClass GtkTypeClass;
122typedef GBaseInitFunc GtkClassInitFunc;
123typedef GInstanceInitFunc GtkObjectInitFunc;
124typedef GSignalCMarshaller GtkSignalMarshaller;
125
126typedef void (*GtkDestroyNotify) (gpointer data);
127typedef 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 */
138struct _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;
161 GtkObject *object_data;
162 gpointer pointer_data;
163
164 /* structured values */
165 struct {
166 GCallback f;
167 gpointer d;
168 } signal_data;
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 */
222typedef struct _GtkTypeInfo GtkTypeInfo;
223
224struct _GtkTypeInfo
225{
226 gchar *type_name;
227 guint object_size;
228 guint class_size;
229 GtkClassInitFunc class_init_func;
230 GtkObjectInitFunc object_init_func;
231 gpointer reserved_1;
232 gpointer reserved_2;
233 GtkClassInitFunc base_class_init_func;
234};
235
236void gtk_type_init (GTypeDebugFlags debug_flags);
237GtkType gtk_type_unique (GtkType parent_type,
238 const GtkTypeInfo *gtkinfo);
239gpointer gtk_type_class (GtkType type);
240gpointer 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 */
251typedef GEnumValue GtkEnumValue;
252typedef GFlagsValue GtkFlagValue;
253GtkEnumValue* gtk_type_enum_get_values (GtkType enum_type);
254GtkFlagValue* gtk_type_flags_get_values (GtkType flags_type);
255GtkEnumValue* gtk_type_enum_find_value (GtkType enum_type,
256 const gchar *value_name);
257GtkFlagValue* gtk_type_flags_find_value (GtkType flags_type,
258 const gchar *value_name);
259
260#endif /* GTK_DISABLE_DEPRECATED */
261
262G_END_DECLS
263
264#endif /* __GTK_TYPE_UTILS_H__ */
265