Initial packaging for Tizen
[profile/ivi/gobject-introspection.git] / girepository / gisignalinfo.c
1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
2  * GObject introspection: Signal implementation
3  *
4  * Copyright (C) 2005 Matthias Clasen
5  * Copyright (C) 2008,2009 Red Hat, Inc.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22
23 #include <glib.h>
24
25 #include <girepository.h>
26 #include "girepository-private.h"
27 #include "gitypelib-internal.h"
28
29 /**
30  * SECTION:gisignalinfo
31  * @Short_description: Struct representing a signal
32  * @Title: GISignalInfo
33  *
34  * GISignalInfo represents a signal. It's a sub-struct of #GICallableInfo
35  * and contains a set of flags and a class closure.
36  *
37  * See #GICallableInfo for information on how to retreive arguments
38  * and other metadata from the signal.
39  *
40  * <refsect1 id="gi-gisignalinfo.struct-hierarchy" role="struct_hierarchy">
41  * <title role="struct_hierarchy.title">Struct hierarchy</title>
42  * <synopsis>
43  *   <link linkend="gi-GIBaseInfo">GIBaseInfo</link>
44  *    +----<link linkend="gi-GICallableInfo">GICallableInfo</link>
45  *          +----<link linkend="gi-GIFunctionInfo">GIFunctionInfo</link>
46  *          +----GISignalInfo
47  *          +----<link linkend="gi-GIVFuncInfo">GIVFuncInfo</link>
48  * </synopsis>
49  * </refsect1>
50  */
51
52 /**
53  * g_signal_info_get_flags:
54  * @info: a #GISignalInfo
55  *
56  * Obtain the flags for this signal info. See #GSignalFlags for
57  * more information about possible flag values.
58  *
59  * Returns: the flags
60  */
61 GSignalFlags
62 g_signal_info_get_flags (GISignalInfo *info)
63 {
64   GSignalFlags flags;
65   GIRealInfo *rinfo = (GIRealInfo *)info;
66   SignalBlob *blob;
67
68   g_return_val_if_fail (info != NULL, 0);
69   g_return_val_if_fail (GI_IS_SIGNAL_INFO (info), 0);
70
71   blob = (SignalBlob *)&rinfo->typelib->data[rinfo->offset];
72   flags = 0;
73
74   if (blob->run_first)
75     flags = flags | G_SIGNAL_RUN_FIRST;
76
77   if (blob->run_last)
78     flags = flags | G_SIGNAL_RUN_LAST;
79
80   if (blob->run_cleanup)
81     flags = flags | G_SIGNAL_RUN_CLEANUP;
82
83   if (blob->no_recurse)
84     flags = flags | G_SIGNAL_NO_RECURSE;
85
86   if (blob->detailed)
87     flags = flags | G_SIGNAL_DETAILED;
88
89   if (blob->action)
90     flags = flags | G_SIGNAL_ACTION;
91
92   if (blob->no_hooks)
93     flags = flags | G_SIGNAL_NO_HOOKS;
94
95   return flags;
96 }
97
98 /**
99  * g_signal_info_get_class_closure:
100  * @info: a #GISignalInfo
101  *
102  * Obtain the class closure for this signal if one is set. The class
103  * closure is a virtual function on the type that the signal belongs to.
104  * If the signal lacks a closure %NULL will be returned.
105  *
106  * Returns: (transfer full): the class closure or %NULL
107  */
108 GIVFuncInfo *
109 g_signal_info_get_class_closure (GISignalInfo *info)
110 {
111   GIRealInfo *rinfo = (GIRealInfo *)info;
112   SignalBlob *blob;
113
114   g_return_val_if_fail (info != NULL, 0);
115   g_return_val_if_fail (GI_IS_SIGNAL_INFO (info), 0);
116
117   blob = (SignalBlob *)&rinfo->typelib->data[rinfo->offset];
118
119   if (blob->has_class_closure)
120     return g_interface_info_get_vfunc ((GIInterfaceInfo *)rinfo->container, blob->class_closure);
121
122   return NULL;
123 }
124
125 /**
126  * g_signal_info_true_stops_emit:
127  * @info: a #GISignalInfo
128  *
129  * Obtain if the returning true in the signal handler will
130  * stop the emission of the signal.
131  *
132  * Returns: %TRUE if returning true stops the signal emission
133  */
134 gboolean
135 g_signal_info_true_stops_emit (GISignalInfo *info)
136 {
137   GIRealInfo *rinfo = (GIRealInfo *)info;
138   SignalBlob *blob;
139
140   g_return_val_if_fail (info != NULL, 0);
141   g_return_val_if_fail (GI_IS_SIGNAL_INFO (info), 0);
142
143   blob = (SignalBlob *)&rinfo->typelib->data[rinfo->offset];
144
145   return blob->true_stops_emit;
146 }
147