use g_signal_newc
[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 #define G_SIGNAL_FLAGS_MASK  0x7f
57 } GSignalFlags;
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 #define G_SIGNAL_MATCH_MASK  0x3f
67 } GSignalMatchType;
68
69
70 /* --- signal information --- */
71 struct _GSignalInvocationHint
72 {
73   guint         signal_id;
74   GQuark        detail;
75   GSignalFlags  run_type;
76 };
77 struct _GSignalQuery
78 {
79   guint         signal_id;
80   const gchar  *signal_name;
81   GType         itype;
82   GSignalFlags  signal_flags;
83   GType         return_type;
84   guint         n_params;
85   const GType  *param_types;
86 };
87
88
89 /* --- signals --- */
90 guint   g_signal_newv                         (const gchar       *signal_name,
91                                                GType              itype,
92                                                GSignalFlags       signal_flags,
93                                                GClosure          *class_closure,
94                                                GSignalAccumulator accumulator,
95                                                GSignalCMarshaller c_marshaller,
96                                                GType              return_type,
97                                                guint              n_params,
98                                                GType             *param_types);
99 guint   g_signal_new_valist                   (const gchar       *signal_name,
100                                                GType              itype,
101                                                GSignalFlags       signal_flags,
102                                                GClosure          *class_closure,
103                                                GSignalAccumulator accumulator,
104                                                GSignalCMarshaller c_marshaller,
105                                                GType              return_type,
106                                                guint              n_params,
107                                                va_list            args);
108 guint   g_signal_newc                         (const gchar       *signal_name,
109                                                GType              itype,
110                                                GSignalFlags       signal_flags,
111                                                guint              class_offset,
112                                                GSignalAccumulator accumulator,
113                                                GSignalCMarshaller c_marshaller,
114                                                GType              return_type,
115                                                guint              n_params,
116                                                ...);
117 void    g_signal_emitv                        (const GValue      *instance_and_params,
118                                                guint              signal_id,
119                                                GQuark             detail,
120                                                GValue            *return_value);
121 void    g_signal_emit_valist                  (gpointer           instance,
122                                                guint              signal_id,
123                                                GQuark             detail,
124                                                va_list            var_args);
125 void    g_signal_emit                         (gpointer           instance,
126                                                guint              signal_id,
127                                                GQuark             detail,
128                                                ...);
129 void    g_signal_emit_by_name                 (gpointer           instance,
130                                                const gchar       *detailed_signal,
131                                                ...);
132 guint   g_signal_lookup                       (const gchar       *name,
133                                                GType              itype);
134 gchar*  g_signal_name                         (guint              signal_id);
135 void    g_signal_query                        (guint              signal_id,
136                                                GSignalQuery      *query);
137 guint*  g_signal_list_ids                     (GType              itype,
138                                                guint             *n_ids);
139
140 /* --- signal emissions --- */
141 void    g_signal_stop_emission                (gpointer           instance,
142                                                guint              signal_id,
143                                                GQuark             detail);
144 guint   g_signal_add_emission_hook_full       (guint              signal_id,
145                                                GClosure          *closure);
146 void    g_signal_remove_emission_hook         (guint              signal_id,
147                                                guint              hook_id);
148
149
150 /* --- signal handlers --- */
151 gboolean g_signal_has_handler_pending         (gpointer           instance,
152                                                guint              signal_id,
153                                                GQuark             detail,
154                                                gboolean           may_be_blocked);
155 guint    g_signal_connect_closure_by_id       (gpointer           instance,
156                                                guint              signal_id,
157                                                GQuark             detail,
158                                                GClosure          *closure,
159                                                gboolean           after);
160 guint    g_signal_connect_closure             (gpointer           instance,
161                                                const gchar       *detailed_signal,
162                                                GClosure          *closure,
163                                                gboolean           after);
164 guint    g_signal_connect_data                (gpointer           instance,
165                                                const gchar       *detailed_signal,
166                                                GCallback          c_handler,
167                                                gpointer           data,
168                                                GClosureNotify     destroy_data,
169                                                gboolean           swapped,
170                                                gboolean           after);
171 void     g_signal_handler_block               (gpointer           instance,
172                                                guint              handler_id);
173 void     g_signal_handler_unblock             (gpointer           instance,
174                                                guint              handler_id);
175 void     g_signal_handler_disconnect          (gpointer           instance,
176                                                guint              handler_id);
177 guint    g_signal_handler_find                (gpointer           instance,
178                                                GSignalMatchType   mask,
179                                                guint              signal_id,
180                                                GQuark             detail,
181                                                GClosure          *closure,
182                                                gpointer           func,
183                                                gpointer           data);
184 guint    g_signal_handlers_block_matched      (gpointer           instance,
185                                                GSignalMatchType   mask,
186                                                guint              signal_id,
187                                                GQuark             detail,
188                                                GClosure          *closure,
189                                                gpointer           func,
190                                                gpointer           data);
191 guint    g_signal_handlers_unblock_matched    (gpointer           instance,
192                                                GSignalMatchType   mask,
193                                                guint              signal_id,
194                                                GQuark             detail,
195                                                GClosure          *closure,
196                                                gpointer           func,
197                                                gpointer           data);
198 guint    g_signal_handlers_disconnect_matched (gpointer           instance,
199                                                GSignalMatchType   mask,
200                                                guint              signal_id,
201                                                GQuark             detail,
202                                                GClosure          *closure,
203                                                gpointer           func,
204                                                gpointer           data);
205 gboolean g_signal_parse_name                  (const gchar       *detailed_signal,
206                                                GType              itype,
207                                                guint             *signal_id_p,
208                                                GQuark            *detail_p,
209                                                gboolean           force_detail_quark);
210
211
212 /*< private >*/
213 void     g_signal_handlers_destroy            (gpointer           instance);
214 void     _g_signals_destroy                   (GType              itype);
215
216
217 #ifdef __cplusplus
218 }
219 #endif /* __cplusplus */
220
221 #endif /* __G_SIGNAL_H__ */