Committed the wrong thing yesterday.
[platform/upstream/glib.git] / gobject / gsignal.h
1 /* GObject - GLib Type, Object, Parameter and Signal Library
2  * Copyright (C) 2000 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 typedef gboolean (*GSignalAccumulator)  (GSignalInvocationHint *ihint,
42                                          GValue                *return_accu,
43                                          const GValue          *return_value);
44
45
46 /* --- run & match types --- */
47 typedef enum
48 {
49   G_SIGNAL_RUN_FIRST    = 1 << 0,
50   G_SIGNAL_RUN_LAST     = 1 << 1,
51   G_SIGNAL_RUN_CLEANUP  = 1 << 2,
52   G_SIGNAL_NO_RECURSE   = 1 << 3,
53   G_SIGNAL_DETAILED     = 1 << 4,
54   G_SIGNAL_ACTION       = 1 << 5,
55   G_SIGNAL_NO_HOOKS     = 1 << 6
56 } GSignalFlags;
57 #define G_SIGNAL_FLAGS_MASK  0x7f
58 typedef enum
59 {
60   G_SIGNAL_MATCH_ID        = 1 << 0,
61   G_SIGNAL_MATCH_DETAIL    = 1 << 1,
62   G_SIGNAL_MATCH_CLOSURE   = 1 << 2,
63   G_SIGNAL_MATCH_FUNC      = 1 << 3,
64   G_SIGNAL_MATCH_DATA      = 1 << 4,
65   G_SIGNAL_MATCH_UNBLOCKED = 1 << 5
66 } GSignalMatchType;
67 #define G_SIGNAL_MATCH_MASK  0x3f
68 #define G_SIGNAL_TYPE_STATIC_SCOPE (G_TYPE_FLAG_RESERVED_ID_BIT)
69
70
71 /* --- signal information --- */
72 struct _GSignalInvocationHint
73 {
74   guint         signal_id;
75   GQuark        detail;
76   GSignalFlags  run_type;
77 };
78 struct _GSignalQuery
79 {
80   guint         signal_id;
81   const gchar  *signal_name;
82   GType         itype;       /* mangled with G_SIGNAL_TYPE_STATIC_SCOPE flag */
83   GSignalFlags  signal_flags;
84   GType         return_type; /* mangled with G_SIGNAL_TYPE_STATIC_SCOPE flag */
85   guint         n_params;
86   const GType  *param_types;
87 };
88
89
90 /* --- signals --- */
91 guint                 g_signal_newv         (const gchar        *signal_name,
92                                              GType               itype,
93                                              GSignalFlags        signal_flags,
94                                              GClosure           *class_closure,
95                                              GSignalAccumulator  accumulator,
96                                              GSignalCMarshaller  c_marshaller,
97                                              GType               return_type,
98                                              guint               n_params,
99                                              GType              *param_types);
100 guint                 g_signal_new_valist   (const gchar        *signal_name,
101                                              GType               itype,
102                                              GSignalFlags        signal_flags,
103                                              GClosure           *class_closure,
104                                              GSignalAccumulator  accumulator,
105                                              GSignalCMarshaller  c_marshaller,
106                                              GType               return_type,
107                                              guint               n_params,
108                                              va_list             args);
109 guint                 g_signal_newc         (const gchar        *signal_name,
110                                              GType               itype,
111                                              GSignalFlags        signal_flags,
112                                              guint               class_offset,
113                                              GSignalAccumulator  accumulator,
114                                              GSignalCMarshaller  c_marshaller,
115                                              GType               return_type,
116                                              guint               n_params,
117                                              ...);
118 void                  g_signal_emitv        (const GValue       *instance_and_params,
119                                              guint               signal_id,
120                                              GQuark              detail,
121                                              GValue             *return_value);
122 void                  g_signal_emit_valist  (gpointer            instance,
123                                              guint               signal_id,
124                                              GQuark              detail,
125                                              va_list             var_args);
126 void                  g_signal_emit         (gpointer            instance,
127                                              guint               signal_id,
128                                              GQuark              detail,
129                                              ...);
130 void                  g_signal_emit_by_name (gpointer            instance,
131                                              const gchar        *detailed_signal,
132                                              ...);
133 guint                 g_signal_lookup       (const gchar        *name,
134                                              GType               itype);
135 G_CONST_RETURN gchar* g_signal_name         (guint               signal_id);
136 void                  g_signal_query        (guint               signal_id,
137                                              GSignalQuery       *query);
138 guint*                g_signal_list_ids     (GType               itype,
139                                              guint              *n_ids);
140
141
142 /* --- signal emissions --- */
143 void    g_signal_stop_emission                (gpointer           instance,
144                                                guint              signal_id,
145                                                GQuark             detail);
146 guint   g_signal_add_emission_hook_full       (guint              signal_id,
147                                                GClosure          *closure);
148 void    g_signal_remove_emission_hook         (guint              signal_id,
149                                                guint              hook_id);
150
151
152 /* --- signal handlers --- */
153 gboolean g_signal_has_handler_pending         (gpointer           instance,
154                                                guint              signal_id,
155                                                GQuark             detail,
156                                                gboolean           may_be_blocked);
157 #define g_signal_connect(instance, detailed_signal, c_handler, data) \
158         g_signal_connect_data (instance, detailed_signal, c_handler, data, NULL, FALSE, FALSE)
159 guint    g_signal_connect_closure_by_id       (gpointer           instance,
160                                                guint              signal_id,
161                                                GQuark             detail,
162                                                GClosure          *closure,
163                                                gboolean           after);
164 guint    g_signal_connect_closure             (gpointer           instance,
165                                                const gchar       *detailed_signal,
166                                                GClosure          *closure,
167                                                gboolean           after);
168 guint    g_signal_connect_data                (gpointer           instance,
169                                                const gchar       *detailed_signal,
170                                                GCallback          c_handler,
171                                                gpointer           data,
172                                                GClosureNotify     destroy_data,
173                                                gboolean           swapped,
174                                                gboolean           after);
175 void     g_signal_handler_block               (gpointer           instance,
176                                                guint              handler_id);
177 void     g_signal_handler_unblock             (gpointer           instance,
178                                                guint              handler_id);
179 void     g_signal_handler_disconnect          (gpointer           instance,
180                                                guint              handler_id);
181 guint    g_signal_handler_find                (gpointer           instance,
182                                                GSignalMatchType   mask,
183                                                guint              signal_id,
184                                                GQuark             detail,
185                                                GClosure          *closure,
186                                                gpointer           func,
187                                                gpointer           data);
188 guint    g_signal_handlers_block_matched      (gpointer           instance,
189                                                GSignalMatchType   mask,
190                                                guint              signal_id,
191                                                GQuark             detail,
192                                                GClosure          *closure,
193                                                gpointer           func,
194                                                gpointer           data);
195 guint    g_signal_handlers_unblock_matched    (gpointer           instance,
196                                                GSignalMatchType   mask,
197                                                guint              signal_id,
198                                                GQuark             detail,
199                                                GClosure          *closure,
200                                                gpointer           func,
201                                                gpointer           data);
202 guint    g_signal_handlers_disconnect_matched (gpointer           instance,
203                                                GSignalMatchType   mask,
204                                                guint              signal_id,
205                                                GQuark             detail,
206                                                GClosure          *closure,
207                                                gpointer           func,
208                                                gpointer           data);
209 gboolean g_signal_parse_name                  (const gchar       *detailed_signal,
210                                                GType              itype,
211                                                guint             *signal_id_p,
212                                                GQuark            *detail_p,
213                                                gboolean           force_detail_quark);
214
215
216 /*< private >*/
217 void     g_signal_handlers_destroy            (gpointer           instance);
218 void     _g_signals_destroy                   (GType              itype);
219
220
221 #ifdef __cplusplus
222 }
223 #endif /* __cplusplus */
224
225 #endif /* __G_SIGNAL_H__ */