In GTK+ 2.x, "gtk_entry_get_text()" returns a "const gchar *"; assign
[obnox/wireshark/wip.git] / gtk / compat_macros.h
1 /* compat_macros.h
2  * GTK-related Global defines, etc.
3  *
4  * $Id: compat_macros.h,v 1.3 2002/11/15 23:50:06 oabad Exp $
5  *
6  * Ethereal - Network traffic analyzer
7  * By Gerald Combs <gerald@ethereal.com>
8  * Copyright 1998 Gerald Combs
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23  */
24
25 #ifndef __COMPAT_MACROS_H__
26 #define __COMPAT_MACROS_H__
27
28 /*
29  * helper macros fro gtk1.2/gtk2 compatibility :
30  * in gtk2, gtk_signal_xxx is deprecated in favor of g_signal_xxx
31  *          gtk_object_xxx is deprecated in favor of g_object_xxx
32  *          gtk_widget_set_usize is deprecated in favor of
33  *              gtk_widget_set_size_request
34  */
35 #if GTK_MAJOR_VERSION < 2
36
37 #define SIGNAL_CONNECT(widget, name, callback, arg) \
38 gtk_signal_connect(GTK_OBJECT(widget), name, GTK_SIGNAL_FUNC(callback), \
39                    (gpointer)(arg))
40
41 #define SIGNAL_CONNECT_OBJECT(widget, name, callback, arg) \
42 gtk_signal_connect_object(GTK_OBJECT(widget), name, GTK_SIGNAL_FUNC(callback), \
43                           (gpointer)(arg))
44
45 #define SIGNAL_DISCONNECT_BY_FUNC(object, func, data) \
46 gtk_signal_disconnect_by_func(GTK_OBJECT(object), func, data)
47
48 #define OBJECT_SET_DATA(widget, key, data) \
49 gtk_object_set_data(GTK_OBJECT(widget), key, data)
50
51 #define OBJECT_SET_DATA_FULL(widget, key, data, destroy) \
52 gtk_object_set_data_full(GTK_OBJECT(widget), key, (gpointer)(data), \
53                          (GtkDestroyNotify)(destroy))
54
55 #define OBJECT_GET_DATA(widget, key) \
56 gtk_object_get_data(GTK_OBJECT(widget), key)
57
58 #define WIDGET_SET_SIZE(widget, width, height) \
59 gtk_widget_set_usize(GTK_WIDGET(widget), width, height)
60
61 #define SIGNAL_EMIT_BY_NAME(widget, name) \
62 gtk_signal_emit_by_name(GTK_OBJECT(widget), name)
63
64 #define SIGNAL_EMIT_BY_NAME1(widget, name, arg) \
65 gtk_signal_emit_by_name(GTK_OBJECT(widget), name, arg)
66
67 #define SIGNAL_EMIT_STOP_BY_NAME(widget, name) \
68 gtk_signal_emit_stop_by_name(GTK_OBJECT(widget), name)
69
70 #define ITEM_FACTORY_ENTRY(path, accelerator, callback, action, type, data) \
71 {path, accelerator, GTK_MENU_FUNC(callback), action, type}
72
73 #define ITEM_FACTORY_STOCK_ENTRY(path, accelerator, callback, action, data) \
74 {path, accelerator, GTK_MENU_FUNC(callback), action, NULL}
75
76 #else /* GTK_MAJOR_VERSION >= 2 */
77
78 #define SIGNAL_CONNECT(widget, name, callback, arg) \
79 g_signal_connect(G_OBJECT(widget), name, G_CALLBACK(callback), \
80                  (gpointer)(arg))
81
82 #define SIGNAL_CONNECT_OBJECT(widget, name, callback, arg) \
83 g_signal_connect_swapped(G_OBJECT(widget), name, G_CALLBACK(callback), \
84                          (gpointer)(arg))
85
86 #define SIGNAL_DISCONNECT_BY_FUNC(object, func, data) \
87 g_signal_handlers_disconnect_by_func(G_OBJECT(object), func, data)
88
89 #define OBJECT_SET_DATA(widget, key, data) \
90 g_object_set_data(G_OBJECT(widget), key, data)
91
92 #define OBJECT_SET_DATA_FULL(widget, key, data, destroy) \
93 g_object_set_data_full(G_OBJECT(widget), key, (gpointer)(data), \
94                        (GDestroyNotify)(destroy))
95
96 #define OBJECT_GET_DATA(widget, key) \
97 g_object_get_data(G_OBJECT(widget), key)
98
99 #define WIDGET_SET_SIZE(widget, width, height) \
100 gtk_widget_set_size_request(GTK_WIDGET(widget), width, height)
101
102 #define SIGNAL_EMIT_BY_NAME(widget, name) \
103 g_signal_emit_by_name(G_OBJECT(widget), name)
104
105 #define SIGNAL_EMIT_BY_NAME1(widget, name, arg) \
106 g_signal_emit_by_name(G_OBJECT(widget), name, arg)
107
108 #define SIGNAL_EMIT_STOP_BY_NAME(widget, name) \
109 g_signal_stop_emission_by_name(G_OBJECT(widget), name)
110
111 #define ITEM_FACTORY_ENTRY(path, accelerator, callback, action, type, data) \
112 {path, accelerator, GTK_MENU_FUNC(callback), action, type, data}
113
114 #define ITEM_FACTORY_STOCK_ENTRY(path, accelerator, callback, action, data) \
115 {path, accelerator, GTK_MENU_FUNC(callback), action, "<StockItem>", data}
116
117 #endif /* GTK_MAJOR_VERSION */
118
119 #endif /* __COMPAT_MACROS_H__ */