1 /* GObject - GLib Type, Object, Parameter and Signal Library
2 * Copyright (C) 2000-2001 Red Hat, Inc.
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.
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.
14 * You should have received a copy of the GNU Lesser General
15 * Public 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.
19 #if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
20 #error "Only <glib-object.h> can be included directly."
23 #ifndef __G_SIGNAL_H__
24 #define __G_SIGNAL_H__
26 #include <gobject/gclosure.h>
27 #include <gobject/gvalue.h>
28 #include <gobject/gparam.h>
29 #include <gobject/gmarshal.h>
34 /* --- typedefs --- */
35 typedef struct _GSignalQuery GSignalQuery;
36 typedef struct _GSignalInvocationHint GSignalInvocationHint;
37 typedef GClosureMarshal GSignalCMarshaller;
38 typedef gboolean (*GSignalEmissionHook) (GSignalInvocationHint *ihint,
40 const GValue *param_values,
42 typedef gboolean (*GSignalAccumulator) (GSignalInvocationHint *ihint,
44 const GValue *handler_return,
48 /* --- run, match and connect types --- */
51 G_SIGNAL_RUN_FIRST = 1 << 0,
52 G_SIGNAL_RUN_LAST = 1 << 1,
53 G_SIGNAL_RUN_CLEANUP = 1 << 2,
54 G_SIGNAL_NO_RECURSE = 1 << 3,
55 G_SIGNAL_DETAILED = 1 << 4,
56 G_SIGNAL_ACTION = 1 << 5,
57 G_SIGNAL_NO_HOOKS = 1 << 6
59 #define G_SIGNAL_FLAGS_MASK 0x7f
62 G_CONNECT_AFTER = 1 << 0,
63 G_CONNECT_SWAPPED = 1 << 1
67 G_SIGNAL_MATCH_ID = 1 << 0,
68 G_SIGNAL_MATCH_DETAIL = 1 << 1,
69 G_SIGNAL_MATCH_CLOSURE = 1 << 2,
70 G_SIGNAL_MATCH_FUNC = 1 << 3,
71 G_SIGNAL_MATCH_DATA = 1 << 4,
72 G_SIGNAL_MATCH_UNBLOCKED = 1 << 5
74 #define G_SIGNAL_MATCH_MASK 0x3f
75 #define G_SIGNAL_TYPE_STATIC_SCOPE (G_TYPE_FLAG_RESERVED_ID_BIT)
78 /* --- signal information --- */
79 struct _GSignalInvocationHint
83 GSignalFlags run_type;
88 const gchar *signal_name;
90 GSignalFlags signal_flags;
91 GType return_type; /* mangled with G_SIGNAL_TYPE_STATIC_SCOPE flag */
93 const GType *param_types; /* mangled with G_SIGNAL_TYPE_STATIC_SCOPE flag */
98 guint g_signal_newv (const gchar *signal_name,
100 GSignalFlags signal_flags,
101 GClosure *class_closure,
102 GSignalAccumulator accumulator,
104 GSignalCMarshaller c_marshaller,
108 guint g_signal_new_valist (const gchar *signal_name,
110 GSignalFlags signal_flags,
111 GClosure *class_closure,
112 GSignalAccumulator accumulator,
114 GSignalCMarshaller c_marshaller,
118 guint g_signal_new (const gchar *signal_name,
120 GSignalFlags signal_flags,
122 GSignalAccumulator accumulator,
124 GSignalCMarshaller c_marshaller,
128 void g_signal_emitv (const GValue *instance_and_params,
131 GValue *return_value);
132 void g_signal_emit_valist (gpointer instance,
136 void g_signal_emit (gpointer instance,
140 void g_signal_emit_by_name (gpointer instance,
141 const gchar *detailed_signal,
143 guint g_signal_lookup (const gchar *name,
145 G_CONST_RETURN gchar* g_signal_name (guint signal_id);
146 void g_signal_query (guint signal_id,
147 GSignalQuery *query);
148 guint* g_signal_list_ids (GType itype,
150 gboolean g_signal_parse_name (const gchar *detailed_signal,
154 gboolean force_detail_quark);
155 GSignalInvocationHint* g_signal_get_invocation_hint (gpointer instance);
158 /* --- signal emissions --- */
159 void g_signal_stop_emission (gpointer instance,
162 void g_signal_stop_emission_by_name (gpointer instance,
163 const gchar *detailed_signal);
164 gulong g_signal_add_emission_hook (guint signal_id,
166 GSignalEmissionHook hook_func,
168 GDestroyNotify data_destroy);
169 void g_signal_remove_emission_hook (guint signal_id,
173 /* --- signal handlers --- */
174 gboolean g_signal_has_handler_pending (gpointer instance,
177 gboolean may_be_blocked);
178 gulong g_signal_connect_closure_by_id (gpointer instance,
183 gulong g_signal_connect_closure (gpointer instance,
184 const gchar *detailed_signal,
187 gulong g_signal_connect_data (gpointer instance,
188 const gchar *detailed_signal,
191 GClosureNotify destroy_data,
192 GConnectFlags connect_flags);
193 void g_signal_handler_block (gpointer instance,
195 void g_signal_handler_unblock (gpointer instance,
197 void g_signal_handler_disconnect (gpointer instance,
199 gboolean g_signal_handler_is_connected (gpointer instance,
201 gulong g_signal_handler_find (gpointer instance,
202 GSignalMatchType mask,
208 guint g_signal_handlers_block_matched (gpointer instance,
209 GSignalMatchType mask,
215 guint g_signal_handlers_unblock_matched (gpointer instance,
216 GSignalMatchType mask,
222 guint g_signal_handlers_disconnect_matched (gpointer instance,
223 GSignalMatchType mask,
231 /* --- chaining for language bindings --- */
232 void g_signal_override_class_closure (guint signal_id,
234 GClosure *class_closure);
235 void g_signal_chain_from_overridden (const GValue *instance_and_params,
236 GValue *return_value);
239 /* --- convenience --- */
240 #define g_signal_connect(instance, detailed_signal, c_handler, data) \
241 g_signal_connect_data ((instance), (detailed_signal), (c_handler), (data), NULL, (GConnectFlags) 0)
242 #define g_signal_connect_after(instance, detailed_signal, c_handler, data) \
243 g_signal_connect_data ((instance), (detailed_signal), (c_handler), (data), NULL, G_CONNECT_AFTER)
244 #define g_signal_connect_swapped(instance, detailed_signal, c_handler, data) \
245 g_signal_connect_data ((instance), (detailed_signal), (c_handler), (data), NULL, G_CONNECT_SWAPPED)
246 #define g_signal_handlers_disconnect_by_func(instance, func, data) \
247 g_signal_handlers_disconnect_matched ((instance), G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, \
248 0, 0, NULL, (func), (data))
249 #define g_signal_handlers_block_by_func(instance, func, data) \
250 g_signal_handlers_block_matched ((instance), G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, \
251 0, 0, NULL, (func), (data))
252 #define g_signal_handlers_unblock_by_func(instance, func, data) \
253 g_signal_handlers_unblock_matched ((instance), G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, \
254 0, 0, NULL, (func), (data))
258 void g_signal_handlers_destroy (gpointer instance);
259 void _g_signals_destroy (GType itype);
263 #endif /* __G_SIGNAL_H__ */