added newly added gobject/ headers.
[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 /* --- macros --- */
34 #define G_SIGNAL_HINT_ID(hint)          ((hint) >> 8) 
35 #define G_SIGNAL_HINT_RUN_TYPE(hint)    ((hint) & 0xff)
36
37
38 /* --- run & match types --- */
39 typedef enum
40 {
41   G_SIGNAL_RUN_FIRST    = 1 << 0,
42   G_SIGNAL_RUN_LAST     = 1 << 1,
43   G_SIGNAL_RUN_CLEANUP  = 1 << 2,
44   G_SIGNAL_NO_RECURSE   = 1 << 3,
45   G_SIGNAL_ACTION       = 1 << 4,
46   G_SIGNAL_NO_HOOKS     = 1 << 5
47 } GSignalType;
48 typedef enum
49 {
50   G_SIGNAL_MATCH_ID        = 1 << 0,
51   G_SIGNAL_MATCH_CLOSURE   = 1 << 1,
52   G_SIGNAL_MATCH_FUNC      = 1 << 2,
53   G_SIGNAL_MATCH_DATA      = 1 << 3,
54   G_SIGNAL_MATCH_UNBLOCKED = 1 << 4,
55   G_SIGNAL_MATCH_MASK      = 0x1f
56 } GSignalMatchType;
57
58
59 /* --- signal queries --- */
60 typedef struct _GSignalQuery GSignalQuery;
61 struct  _GSignalQuery
62 {
63   guint         signal_id;
64   const gchar  *signal_name;
65   GType         itype;
66   GSignalType   signal_flags;
67   GType         return_type;
68   guint         n_params;
69   const GType  *param_types;
70 };
71
72
73 /* --- function types --- */
74 typedef gboolean  (*GSignalEmissionHook)        (guint          signal_id,
75                                                  guint          n_values,
76                                                  const GValue  *values);
77 typedef gboolean  (*GSignalAccumulator)         (guint          signal_id,
78                                                  GValue        *return_accu,
79                                                  const GValue  *return_value);
80 typedef GClosureMarshal                 GSignalCMarshaller;
81
82
83 /* --- signals --- */
84 guint   g_signal_newv                   (const gchar            *signal_name,
85                                          GType                   itype,
86                                          GSignalType             signal_flags,
87                                          GClosure               *class_closure,
88                                          GSignalAccumulator      accumulator,
89                                          GSignalCMarshaller      c_marshaller,
90                                          GType                   return_type,
91                                          guint                   n_params,
92                                          GType                  *param_types);
93 void    g_signal_emitv                  (const GValue           *instance_and_params,
94                                          guint                   signal_id,
95                                          GValue                 *return_value);
96 guint   g_signal_lookup                 (const gchar            *name,
97                                          GType                   itype);
98 gchar*  g_signal_name                   (guint                   signal_id);
99 void    g_signal_query                  (guint                   signal_id,
100                                          GSignalQuery           *query);
101
102
103 /* --- signal handlers --- */
104 guint    g_signal_connect_closure       (gpointer                instance,
105                                          guint                   signal_id,
106                                          GClosure               *closure,
107                                          gboolean                after);
108 void     g_signal_handler_disconnect    (gpointer                instance,
109                                          guint                   handler_id);
110 void     g_signal_handler_block         (gpointer                instance,
111                                          guint                   handler_id);
112 void     g_signal_handler_unblock       (gpointer                instance,
113                                          guint                   handler_id);
114 guint    g_signal_handler_find          (gpointer                instance,
115                                          GSignalMatchType        mask,
116                                          guint                   signal_id,
117                                          GClosure               *closure,
118                                          gpointer                func,
119                                          gpointer                data);
120 gboolean g_signal_has_handler_pending   (gpointer                instance,
121                                          guint                   signal_id,
122                                          gboolean                may_be_blocked);
123
124
125 /* --- signal emissions --- */
126 void    g_signal_stop_emission          (gpointer                instance,
127                                          guint                   signal_id);
128 guint   g_signal_add_emission_hook_full (guint                   signal_id,
129                                          GClosure               *closure);
130 void    g_signal_remove_emission_hook   (guint                   signal_id,
131                                          guint                   hook_id);
132
133 /*< private >*/
134 void    g_signal_handlers_destroy       (gpointer               instance);
135 void    g_signals_destroy               (GType                  itype);
136
137
138 #ifdef __cplusplus
139 }
140 #endif /* __cplusplus */
141
142 #endif /* __G_SIGNAL_H__ */