destruction cleanup. there's one ->finalize_hook member in the hooklist
[platform/upstream/glib.git] / gobject / gsignal.h
1 /* GObject - GLib Type, Object, Parameter and Signal Library
2  * Copyright (C) 2000-2001 Red Hat, Inc.
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
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.
18  */
19 #ifndef __G_SIGNAL_H__
20 #define __G_SIGNAL_H__
21
22
23 #include        <gobject/gclosure.h>
24 #include        <gobject/gvalue.h>
25 #include        <gobject/gparam.h>
26 #include        <gobject/gmarshal.h>
27
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif /* __cplusplus */
32
33
34 /* --- typedefs --- */
35 typedef struct _GSignalQuery             GSignalQuery;
36 typedef struct _GSignalInvocationHint    GSignalInvocationHint;
37 typedef GClosureMarshal                  GSignalCMarshaller;
38 typedef gboolean (*GSignalEmissionHook) (GSignalInvocationHint *ihint,
39                                          guint                  n_param_values,
40                                          const GValue          *param_values,
41                                          gpointer               data);
42 typedef gboolean (*GSignalAccumulator)  (GSignalInvocationHint *ihint,
43                                          GValue                *return_accu,
44                                          const GValue          *handler_return,
45                                          gpointer               data);
46
47
48 /* --- run & match types --- */
49 typedef enum
50 {
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
58 } GSignalFlags;
59 #define G_SIGNAL_FLAGS_MASK  0x7f
60 typedef enum
61 {
62   G_SIGNAL_MATCH_ID        = 1 << 0,
63   G_SIGNAL_MATCH_DETAIL    = 1 << 1,
64   G_SIGNAL_MATCH_CLOSURE   = 1 << 2,
65   G_SIGNAL_MATCH_FUNC      = 1 << 3,
66   G_SIGNAL_MATCH_DATA      = 1 << 4,
67   G_SIGNAL_MATCH_UNBLOCKED = 1 << 5
68 } GSignalMatchType;
69 #define G_SIGNAL_MATCH_MASK  0x3f
70 #define G_SIGNAL_TYPE_STATIC_SCOPE (G_TYPE_FLAG_RESERVED_ID_BIT)
71
72
73 /* --- signal information --- */
74 struct _GSignalInvocationHint
75 {
76   guint         signal_id;
77   GQuark        detail;
78   GSignalFlags  run_type;
79 };
80 struct _GSignalQuery
81 {
82   guint         signal_id;
83   const gchar  *signal_name;
84   GType         itype;       /* mangled with G_SIGNAL_TYPE_STATIC_SCOPE flag */
85   GSignalFlags  signal_flags;
86   GType         return_type; /* mangled with G_SIGNAL_TYPE_STATIC_SCOPE flag */
87   guint         n_params;
88   const GType  *param_types;
89 };
90
91
92 /* --- signals --- */
93 guint                 g_signal_newv         (const gchar        *signal_name,
94                                              GType               itype,
95                                              GSignalFlags        signal_flags,
96                                              GClosure           *class_closure,
97                                              GSignalAccumulator  accumulator,
98                                              gpointer            accu_data,
99                                              GSignalCMarshaller  c_marshaller,
100                                              GType               return_type,
101                                              guint               n_params,
102                                              GType              *param_types);
103 guint                 g_signal_new_valist   (const gchar        *signal_name,
104                                              GType               itype,
105                                              GSignalFlags        signal_flags,
106                                              GClosure           *class_closure,
107                                              GSignalAccumulator  accumulator,
108                                              gpointer            accu_data,
109                                              GSignalCMarshaller  c_marshaller,
110                                              GType               return_type,
111                                              guint               n_params,
112                                              va_list             args);
113 guint                 g_signal_newc         (const gchar        *signal_name,
114                                              GType               itype,
115                                              GSignalFlags        signal_flags,
116                                              guint               class_offset,
117                                              GSignalAccumulator  accumulator,
118                                              gpointer            accu_data,
119                                              GSignalCMarshaller  c_marshaller,
120                                              GType               return_type,
121                                              guint               n_params,
122                                              ...);
123 void                  g_signal_emitv        (const GValue       *instance_and_params,
124                                              guint               signal_id,
125                                              GQuark              detail,
126                                              GValue             *return_value);
127 void                  g_signal_emit_valist  (gpointer            instance,
128                                              guint               signal_id,
129                                              GQuark              detail,
130                                              va_list             var_args);
131 void                  g_signal_emit         (gpointer            instance,
132                                              guint               signal_id,
133                                              GQuark              detail,
134                                              ...);
135 void                  g_signal_emit_by_name (gpointer            instance,
136                                              const gchar        *detailed_signal,
137                                              ...);
138 guint                 g_signal_lookup       (const gchar        *name,
139                                              GType               itype);
140 G_CONST_RETURN gchar* g_signal_name         (guint               signal_id);
141 void                  g_signal_query        (guint               signal_id,
142                                              GSignalQuery       *query);
143 guint*                g_signal_list_ids     (GType               itype,
144                                              guint              *n_ids);
145 gboolean              g_signal_parse_name   (const gchar        *detailed_signal,
146                                              GType               itype,
147                                              guint              *signal_id_p,
148                                              GQuark             *detail_p,
149                                              gboolean            force_detail_quark);
150
151
152 /* --- signal emissions --- */
153 void    g_signal_stop_emission              (gpointer             instance,
154                                              guint                signal_id,
155                                              GQuark               detail);
156 guint   g_signal_add_emission_hook          (guint                signal_id,
157                                              GQuark               quark,
158                                              GSignalEmissionHook  hook_func,
159                                              gpointer             hook_data,
160                                              GDestroyNotify       data_destroy);
161 void    g_signal_remove_emission_hook       (guint                signal_id,
162                                              guint                hook_id);
163
164
165 /* --- signal handlers --- */
166 gboolean g_signal_has_handler_pending         (gpointer           instance,
167                                                guint              signal_id,
168                                                GQuark             detail,
169                                                gboolean           may_be_blocked);
170 guint    g_signal_connect_closure_by_id       (gpointer           instance,
171                                                guint              signal_id,
172                                                GQuark             detail,
173                                                GClosure          *closure,
174                                                gboolean           after);
175 guint    g_signal_connect_closure             (gpointer           instance,
176                                                const gchar       *detailed_signal,
177                                                GClosure          *closure,
178                                                gboolean           after);
179 guint    g_signal_connect_data                (gpointer           instance,
180                                                const gchar       *detailed_signal,
181                                                GCallback          c_handler,
182                                                gpointer           data,
183                                                GClosureNotify     destroy_data,
184                                                gboolean           swapped,
185                                                gboolean           after);
186 void     g_signal_handler_block               (gpointer           instance,
187                                                guint              handler_id);
188 void     g_signal_handler_unblock             (gpointer           instance,
189                                                guint              handler_id);
190 void     g_signal_handler_disconnect          (gpointer           instance,
191                                                guint              handler_id);
192 guint    g_signal_handler_find                (gpointer           instance,
193                                                GSignalMatchType   mask,
194                                                guint              signal_id,
195                                                GQuark             detail,
196                                                GClosure          *closure,
197                                                gpointer           func,
198                                                gpointer           data);
199 guint    g_signal_handlers_block_matched      (gpointer           instance,
200                                                GSignalMatchType   mask,
201                                                guint              signal_id,
202                                                GQuark             detail,
203                                                GClosure          *closure,
204                                                gpointer           func,
205                                                gpointer           data);
206 guint    g_signal_handlers_unblock_matched    (gpointer           instance,
207                                                GSignalMatchType   mask,
208                                                guint              signal_id,
209                                                GQuark             detail,
210                                                GClosure          *closure,
211                                                gpointer           func,
212                                                gpointer           data);
213 guint    g_signal_handlers_disconnect_matched (gpointer           instance,
214                                                GSignalMatchType   mask,
215                                                guint              signal_id,
216                                                GQuark             detail,
217                                                GClosure          *closure,
218                                                gpointer           func,
219                                                gpointer           data);
220
221
222 /* --- convenience --- */
223 #define g_signal_connectc(instance, detailed_signal, c_handler, data, swapped) \
224     g_signal_connect_data ((instance), (detailed_signal), (c_handler), (data), NULL, (swapped), FALSE)
225
226 /*< private >*/
227 void     g_signal_handlers_destroy            (gpointer           instance);
228 void     _g_signals_destroy                   (GType              itype);
229
230
231 #ifdef __cplusplus
232 }
233 #endif /* __cplusplus */
234
235 #endif /* __G_SIGNAL_H__ */