gsignal.h

Go to the documentation of this file.
00001 /* GObject - GLib Type, Object, Parameter and Signal Library
00002  * Copyright (C) 2000-2001 Red Hat, Inc.
00003  * Portions copyright (c) 2006 Nokia Corporation.  All rights reserved.
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Lesser General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2 of the License, or (at your option) any later version.
00009  *
00010  * This library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Lesser General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Lesser General
00016  * Public License along with this library; if not, write to the
00017  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
00018  * Boston, MA 02111-1307, USA.
00019  */
00020 #if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
00021 #error "Only <glib-object.h> can be included directly."
00022 #endif
00023 
00024 #ifndef __G_SIGNAL_H__
00025 #define __G_SIGNAL_H__
00026 
00027 #include <_ansi.h>
00028 #include        <gobject/gclosure.h>
00029 #include        <gobject/gvalue.h>
00030 #include        <gobject/gparam.h>
00031 #include        <gobject/gmarshal.h>
00032 
00033 G_BEGIN_DECLS
00034 
00035 /* --- typedefs --- */
00036 typedef struct _GSignalQuery             GSignalQuery;
00037 typedef struct _GSignalInvocationHint    GSignalInvocationHint;
00038 typedef GClosureMarshal                  GSignalCMarshaller;
00039 typedef gboolean (*GSignalEmissionHook) (GSignalInvocationHint *ihint,
00040                                          guint                  n_param_values,
00041                                          const GValue          *param_values,
00042                                          gpointer               data);
00043 typedef gboolean (*GSignalAccumulator)  (GSignalInvocationHint *ihint,
00044                                          GValue                *return_accu,
00045                                          const GValue          *handler_return,
00046                                          gpointer               data);
00047 
00048 
00049 /* --- run, match and connect types --- */
00050 typedef enum
00051 {
00052   G_SIGNAL_RUN_FIRST    = 1 << 0,
00053   G_SIGNAL_RUN_LAST     = 1 << 1,
00054   G_SIGNAL_RUN_CLEANUP  = 1 << 2,
00055   G_SIGNAL_NO_RECURSE   = 1 << 3,
00056   G_SIGNAL_DETAILED     = 1 << 4,
00057   G_SIGNAL_ACTION       = 1 << 5,
00058   G_SIGNAL_NO_HOOKS     = 1 << 6
00059 } GSignalFlags;
00060 #define G_SIGNAL_FLAGS_MASK  0x7f
00061 typedef enum
00062 {
00063   G_CONNECT_AFTER       = 1 << 0,
00064   G_CONNECT_SWAPPED     = 1 << 1
00065 } GConnectFlags;
00066 typedef enum
00067 {
00068   G_SIGNAL_MATCH_ID        = 1 << 0,
00069   G_SIGNAL_MATCH_DETAIL    = 1 << 1,
00070   G_SIGNAL_MATCH_CLOSURE   = 1 << 2,
00071   G_SIGNAL_MATCH_FUNC      = 1 << 3,
00072   G_SIGNAL_MATCH_DATA      = 1 << 4,
00073   G_SIGNAL_MATCH_UNBLOCKED = 1 << 5
00074 } GSignalMatchType;
00075 #define G_SIGNAL_MATCH_MASK  0x3f
00076 #define G_SIGNAL_TYPE_STATIC_SCOPE (G_TYPE_FLAG_RESERVED_ID_BIT)
00077 
00078 
00079 /* --- signal information --- */
00080 struct _GSignalInvocationHint
00081 {
00082   guint         signal_id;
00083   GQuark        detail;
00084   GSignalFlags  run_type;
00085 };
00086 struct _GSignalQuery
00087 {
00088   guint         signal_id;
00089   const gchar  *signal_name;
00090   GType         itype;
00091   GSignalFlags  signal_flags;
00092   GType         return_type; /* mangled with G_SIGNAL_TYPE_STATIC_SCOPE flag */
00093   guint         n_params;
00094   const GType  *param_types; /* mangled with G_SIGNAL_TYPE_STATIC_SCOPE flag */
00095 };
00096 
00097 
00098 /* --- signals --- */
00099 IMPORT_C guint                 g_signal_newv         (const gchar        *signal_name,
00100                                              GType               itype,
00101                                              GSignalFlags        signal_flags,
00102                                              GClosure           *class_closure,
00103                                              GSignalAccumulator  accumulator,
00104                                              gpointer            accu_data,
00105                                              GSignalCMarshaller  c_marshaller,
00106                                              GType               return_type,
00107                                              guint               n_params,
00108                                              GType              *param_types);
00109 IMPORT_C guint                 g_signal_new_valist   (const gchar        *signal_name,
00110                                              GType               itype,
00111                                              GSignalFlags        signal_flags,
00112                                              GClosure           *class_closure,
00113                                              GSignalAccumulator  accumulator,
00114                                              gpointer            accu_data,
00115                                              GSignalCMarshaller  c_marshaller,
00116                                              GType               return_type,
00117                                              guint               n_params,
00118                                              va_list             args);
00119 IMPORT_C guint                 g_signal_new          (const gchar        *signal_name,
00120                                              GType               itype,
00121                                              GSignalFlags        signal_flags,
00122                                              guint               class_offset,
00123                                              GSignalAccumulator  accumulator,
00124                                              gpointer            accu_data,
00125                                              GSignalCMarshaller  c_marshaller,
00126                                              GType               return_type,
00127                                              guint               n_params,
00128                                              ...);
00129 IMPORT_C void                  g_signal_emitv        (const GValue       *instance_and_params,
00130                                              guint               signal_id,
00131                                              GQuark              detail,
00132                                              GValue             *return_value);
00133 IMPORT_C void                  g_signal_emit_valist  (gpointer            instance,
00134                                              guint               signal_id,
00135                                              GQuark              detail,
00136                                              va_list             var_args);
00137 IMPORT_C void                  g_signal_emit         (gpointer            instance,
00138                                              guint               signal_id,
00139                                              GQuark              detail,
00140                                              ...);
00141 IMPORT_C void                  g_signal_emit_by_name (gpointer            instance,
00142                                              const gchar        *detailed_signal,
00143                                              ...);
00144 IMPORT_C guint                 g_signal_lookup       (const gchar        *name,
00145                                              GType               itype);
00146 IMPORT_C G_CONST_RETURN gchar* g_signal_name         (guint               signal_id);
00147 IMPORT_C void                  g_signal_query        (guint               signal_id,
00148                                              GSignalQuery       *query);
00149 IMPORT_C guint*                g_signal_list_ids     (GType               itype,
00150                                              guint              *n_ids);
00151 IMPORT_C gboolean             g_signal_parse_name   (const gchar        *detailed_signal,
00152                                              GType               itype,
00153                                              guint              *signal_id_p,
00154                                              GQuark             *detail_p,
00155                                              gboolean            force_detail_quark);
00156 IMPORT_C GSignalInvocationHint* g_signal_get_invocation_hint (gpointer    instance);
00157 
00158 
00159 /* --- signal emissions --- */
00160 IMPORT_C void   g_signal_stop_emission              (gpointer             instance,
00161                                              guint                signal_id,
00162                                              GQuark               detail);
00163 IMPORT_C void   g_signal_stop_emission_by_name      (gpointer             instance,
00164                                              const gchar         *detailed_signal);
00165 IMPORT_C gulong g_signal_add_emission_hook          (guint                signal_id,
00166                                              GQuark               detail,
00167                                              GSignalEmissionHook  hook_func,
00168                                              gpointer             hook_data,
00169                                              GDestroyNotify       data_destroy);
00170 IMPORT_C void   g_signal_remove_emission_hook       (guint                signal_id,
00171                                              gulong               hook_id);
00172 
00173 
00174 /* --- signal handlers --- */
00175 IMPORT_C gboolean g_signal_has_handler_pending        (gpointer           instance,
00176                                                guint              signal_id,
00177                                                GQuark             detail,
00178                                                gboolean           may_be_blocked);
00179 IMPORT_C gulong  g_signal_connect_closure_by_id       (gpointer           instance,
00180                                                guint              signal_id,
00181                                                GQuark             detail,
00182                                                GClosure          *closure,
00183                                                gboolean           after);
00184 IMPORT_C gulong  g_signal_connect_closure             (gpointer           instance,
00185                                                const gchar       *detailed_signal,
00186                                                GClosure          *closure,
00187                                                gboolean           after);
00188 IMPORT_C gulong  g_signal_connect_data                (gpointer           instance,
00189                                                const gchar       *detailed_signal,
00190                                                GCallback          c_handler,
00191                                                gpointer           data,
00192                                                GClosureNotify     destroy_data,
00193                                                GConnectFlags      connect_flags);
00194 IMPORT_C void    g_signal_handler_block               (gpointer           instance,
00195                                                gulong             handler_id);
00196 IMPORT_C void    g_signal_handler_unblock             (gpointer           instance,
00197                                                gulong             handler_id);
00198 IMPORT_C void    g_signal_handler_disconnect          (gpointer           instance,
00199                                                gulong             handler_id);
00200 IMPORT_C gboolean g_signal_handler_is_connected       (gpointer           instance,
00201                                                gulong             handler_id);
00202 IMPORT_C gulong  g_signal_handler_find                (gpointer           instance,
00203                                                GSignalMatchType   mask,
00204                                                guint              signal_id,
00205                                                GQuark             detail,
00206                                                GClosure          *closure,
00207                                                gpointer           func,
00208                                                gpointer           data);
00209 IMPORT_C guint   g_signal_handlers_block_matched      (gpointer           instance,
00210                                                GSignalMatchType   mask,
00211                                                guint              signal_id,
00212                                                GQuark             detail,
00213                                                GClosure          *closure,
00214                                                gpointer           func,
00215                                                gpointer           data);
00216 IMPORT_C guint   g_signal_handlers_unblock_matched    (gpointer           instance,
00217                                                GSignalMatchType   mask,
00218                                                guint              signal_id,
00219                                                GQuark             detail,
00220                                                GClosure          *closure,
00221                                                gpointer           func,
00222                                                gpointer           data);
00223 IMPORT_C guint   g_signal_handlers_disconnect_matched (gpointer           instance,
00224                                                GSignalMatchType   mask,
00225                                                guint              signal_id,
00226                                                GQuark             detail,
00227                                                GClosure          *closure,
00228                                                gpointer           func,
00229                                                gpointer           data);
00230 
00231 
00232 /* --- chaining for language bindings --- */
00233 IMPORT_C void   g_signal_override_class_closure       (guint              signal_id,
00234                                                GType              instance_type,
00235                                                GClosure          *class_closure);
00236 IMPORT_C void   g_signal_chain_from_overridden        (const GValue      *instance_and_params,
00237                                                GValue            *return_value);
00238 
00239 
00240 /* --- convenience --- */
00241 #define g_signal_connect(instance, detailed_signal, c_handler, data) \
00242     g_signal_connect_data ((instance), (detailed_signal), (c_handler), (data), NULL, (GConnectFlags) 0)
00243 #define g_signal_connect_after(instance, detailed_signal, c_handler, data) \
00244     g_signal_connect_data ((instance), (detailed_signal), (c_handler), (data), NULL, G_CONNECT_AFTER)
00245 #define g_signal_connect_swapped(instance, detailed_signal, c_handler, data) \
00246     g_signal_connect_data ((instance), (detailed_signal), (c_handler), (data), NULL, G_CONNECT_SWAPPED)
00247 #define g_signal_handlers_disconnect_by_func(instance, func, data)                                              \
00248     g_signal_handlers_disconnect_matched ((instance),                                                           \
00249                                           (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA),       \
00250                                           0, 0, NULL, (func), (data))
00251 #define g_signal_handlers_block_by_func(instance, func, data)                                                   \
00252     g_signal_handlers_block_matched      ((instance),                                                           \
00253                                           (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA),       \
00254                                           0, 0, NULL, (func), (data))
00255 #define g_signal_handlers_unblock_by_func(instance, func, data)                                                 \
00256     g_signal_handlers_unblock_matched    ((instance),                                                           \
00257                                           (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA),       \
00258                                           0, 0, NULL, (func), (data))
00259 
00260 
00261 IMPORT_C gboolean g_signal_accumulator_true_handled (GSignalInvocationHint *ihint,
00262                                             GValue                *return_accu,
00263                                             const GValue          *handler_return,
00264                                             gpointer               dummy);
00265 
00266 /*< private >*/
00267 IMPORT_C void    g_signal_handlers_destroy            (gpointer           instance);
00268 void     _g_signals_destroy                   (GType              itype);
00269 
00270 G_END_DECLS
00271 
00272 #endif /* __G_SIGNAL_H__ */

Copyright © Nokia Corporation 2001-2008
Back to top