renamed owen's g_type_signals(), added required mutex locks.
[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
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif /* __cplusplus */
31
32
33 /* --- typedefs --- */
34 typedef struct _GSignalQuery             GSignalQuery;
35 typedef struct _GSignalInvocationHint    GSignalInvocationHint;
36 typedef GClosureMarshal                  GSignalCMarshaller;
37 typedef gboolean (*GSignalEmissionHook) (GSignalInvocationHint *ihint,
38                                          guint                  n_param_values,
39                                          const GValue          *param_values);
40 typedef gboolean (*GSignalAccumulator)  (GSignalInvocationHint *ihint,
41                                          GValue                *return_accu,
42                                          const GValue          *return_value);
43
44
45 /* --- run & match types --- */
46 typedef enum
47 {
48   G_SIGNAL_RUN_FIRST    = 1 << 0,
49   G_SIGNAL_RUN_LAST     = 1 << 1,
50   G_SIGNAL_RUN_CLEANUP  = 1 << 2,
51   G_SIGNAL_NO_RECURSE   = 1 << 3,
52   G_SIGNAL_DETAILED     = 1 << 4,
53   G_SIGNAL_ACTION       = 1 << 5,
54   G_SIGNAL_NO_HOOKS     = 1 << 6
55 #define G_SIGNAL_FLAGS_MASK  0x7f
56 } GSignalFlags;
57 typedef enum
58 {
59   G_SIGNAL_MATCH_ID        = 1 << 0,
60   G_SIGNAL_MATCH_DETAIL    = 1 << 1,
61   G_SIGNAL_MATCH_CLOSURE   = 1 << 2,
62   G_SIGNAL_MATCH_FUNC      = 1 << 3,
63   G_SIGNAL_MATCH_DATA      = 1 << 4,
64   G_SIGNAL_MATCH_UNBLOCKED = 1 << 5
65 #define G_SIGNAL_MATCH_MASK  0x3f
66 } GSignalMatchType;
67
68
69 /* --- signal information --- */
70 struct _GSignalInvocationHint
71 {
72   guint         signal_id;
73   GQuark        detail;
74   GSignalFlags  run_type;
75 };
76 struct _GSignalQuery
77 {
78   guint         signal_id;
79   const gchar  *signal_name;
80   GType         itype;
81   GSignalFlags  signal_flags;
82   GType         return_type;
83   guint         n_params;
84   const GType  *param_types;
85 };
86
87
88 /* --- signals --- */
89 guint   g_signal_newv                   (const gchar            *signal_name,
90                                          GType                   itype,
91                                          GSignalFlags            signal_flags,
92                                          GClosure               *class_closure,
93                                          GSignalAccumulator      accumulator,
94                                          GSignalCMarshaller      c_marshaller,
95                                          GType                   return_type,
96                                          guint                   n_params,
97                                          GType                  *param_types);
98 void    g_signal_emitv                  (const GValue           *instance_and_params,
99                                          guint                   signal_id,
100                                          GQuark                  detail,
101                                          GValue                 *return_value);
102 guint   g_signal_lookup                 (const gchar            *name,
103                                          GType                   itype);
104 gchar*  g_signal_name                   (guint                   signal_id);
105 void    g_signal_query                  (guint                   signal_id,
106                                          GSignalQuery           *query);
107 guint*  g_signal_list_ids               (GType                   itype,
108                                          guint                  *n_ids);
109
110 /* --- signal handlers --- */
111 guint    g_signal_connect_closure       (gpointer                instance,
112                                          guint                   signal_id,
113                                          GQuark                  detail,
114                                          GClosure               *closure,
115                                          gboolean                after);
116 void     g_signal_handler_disconnect    (gpointer                instance,
117                                          guint                   handler_id);
118 void     g_signal_handler_block         (gpointer                instance,
119                                          guint                   handler_id);
120 void     g_signal_handler_unblock       (gpointer                instance,
121                                          guint                   handler_id);
122 guint    g_signal_handler_find          (gpointer                instance,
123                                          GSignalMatchType        mask,
124                                          guint                   signal_id,
125                                          GQuark                  detail,
126                                          GClosure               *closure,
127                                          gpointer                func,
128                                          gpointer                data);
129 gboolean g_signal_has_handler_pending   (gpointer                instance,
130                                          guint                   signal_id,
131                                          GQuark                  detail,
132                                          gboolean                may_be_blocked);
133
134
135 /* --- signal emissions --- */
136 void    g_signal_stop_emission          (gpointer                instance,
137                                          guint                   signal_id,
138                                          GQuark                  detail);
139 guint   g_signal_add_emission_hook_full (guint                   signal_id,
140                                          GClosure               *closure);
141 void    g_signal_remove_emission_hook   (guint                   signal_id,
142                                          guint                   hook_id);
143
144 /*< private >*/
145 void    g_signal_handlers_destroy       (gpointer               instance);
146 void    g_signals_destroy               (GType                  itype);
147
148
149 #ifdef __cplusplus
150 }
151 #endif /* __cplusplus */
152
153 #endif /* __G_SIGNAL_H__ */