Update to version 2.33.1
[profile/ivi/glib2.git] / docs / reference / gobject / html / GTypeModule.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <title>GTypeModule</title>
6 <meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
7 <link rel="home" href="index.html" title="GObject Reference Manual">
8 <link rel="up" href="rn01.html" title="API Reference">
9 <link rel="prev" href="GTypePlugin.html" title="GTypePlugin">
10 <link rel="next" href="gobject-The-Base-Object-Type.html" title="GObject">
11 <meta name="generator" content="GTK-Doc V1.18 (XML mode)">
12 <link rel="stylesheet" href="style.css" type="text/css">
13 </head>
14 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
15 <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
16 <tr valign="middle">
17 <td><a accesskey="p" href="GTypePlugin.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
18 <td><a accesskey="u" href="rn01.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
19 <td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
20 <th width="100%" align="center">GObject Reference Manual</th>
21 <td><a accesskey="n" href="gobject-The-Base-Object-Type.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
22 </tr>
23 <tr><td colspan="5" class="shortcuts">
24 <a href="#GTypeModule.synopsis" class="shortcut">Top</a>
25                    | 
26                   <a href="#GTypeModule.description" class="shortcut">Description</a>
27                    | 
28                   <a href="#GTypeModule.object-hierarchy" class="shortcut">Object Hierarchy</a>
29                    | 
30                   <a href="#GTypeModule.implemented-interfaces" class="shortcut">Implemented Interfaces</a>
31 </td></tr>
32 </table>
33 <div class="refentry">
34 <a name="GTypeModule"></a><div class="titlepage"></div>
35 <div class="refnamediv"><table width="100%"><tr>
36 <td valign="top">
37 <h2><span class="refentrytitle"><a name="GTypeModule.top_of_page"></a>GTypeModule</span></h2>
38 <p>GTypeModule — Type loading modules</p>
39 </td>
40 <td valign="top" align="right"></td>
41 </tr></table></div>
42 <div class="refsynopsisdiv">
43 <a name="GTypeModule.synopsis"></a><h2>Synopsis</h2>
44 <pre class="synopsis">
45 #include &lt;glib-object.h&gt;
46
47 struct              <a class="link" href="GTypeModule.html#GTypeModule-struct" title="struct GTypeModule">GTypeModule</a>;
48 struct              <a class="link" href="GTypeModule.html#GTypeModuleClass" title="struct GTypeModuleClass">GTypeModuleClass</a>;
49 <a href="./../glib/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a>            <a class="link" href="GTypeModule.html#g-type-module-use" title="g_type_module_use ()">g_type_module_use</a>                   (<em class="parameter"><code><a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a> *module</code></em>);
50 <span class="returnvalue">void</span>                <a class="link" href="GTypeModule.html#g-type-module-unuse" title="g_type_module_unuse ()">g_type_module_unuse</a>                 (<em class="parameter"><code><a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a> *module</code></em>);
51 <span class="returnvalue">void</span>                <a class="link" href="GTypeModule.html#g-type-module-set-name" title="g_type_module_set_name ()">g_type_module_set_name</a>              (<em class="parameter"><code><a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a> *module</code></em>,
52                                                          <em class="parameter"><code>const <a href="./../glib/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *name</code></em>);
53 <a class="link" href="gobject-Type-Information.html#GType" title="GType"><span class="returnvalue">GType</span></a>               <a class="link" href="GTypeModule.html#g-type-module-register-type" title="g_type_module_register_type ()">g_type_module_register_type</a>         (<em class="parameter"><code><a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a> *module</code></em>,
54                                                          <em class="parameter"><code><a class="link" href="gobject-Type-Information.html#GType" title="GType"><span class="type">GType</span></a> parent_type</code></em>,
55                                                          <em class="parameter"><code>const <a href="./../glib/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *type_name</code></em>,
56                                                          <em class="parameter"><code>const <a class="link" href="gobject-Type-Information.html#GTypeInfo" title="struct GTypeInfo"><span class="type">GTypeInfo</span></a> *type_info</code></em>,
57                                                          <em class="parameter"><code><a class="link" href="gobject-Type-Information.html#GTypeFlags" title="enum GTypeFlags"><span class="type">GTypeFlags</span></a> flags</code></em>);
58 <span class="returnvalue">void</span>                <a class="link" href="GTypeModule.html#g-type-module-add-interface" title="g_type_module_add_interface ()">g_type_module_add_interface</a>         (<em class="parameter"><code><a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a> *module</code></em>,
59                                                          <em class="parameter"><code><a class="link" href="gobject-Type-Information.html#GType" title="GType"><span class="type">GType</span></a> instance_type</code></em>,
60                                                          <em class="parameter"><code><a class="link" href="gobject-Type-Information.html#GType" title="GType"><span class="type">GType</span></a> interface_type</code></em>,
61                                                          <em class="parameter"><code>const <a class="link" href="gobject-Type-Information.html#GInterfaceInfo" title="struct GInterfaceInfo"><span class="type">GInterfaceInfo</span></a> *interface_info</code></em>);
62 <a class="link" href="gobject-Type-Information.html#GType" title="GType"><span class="returnvalue">GType</span></a>               <a class="link" href="GTypeModule.html#g-type-module-register-enum" title="g_type_module_register_enum ()">g_type_module_register_enum</a>         (<em class="parameter"><code><a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a> *module</code></em>,
63                                                          <em class="parameter"><code>const <a href="./../glib/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *name</code></em>,
64                                                          <em class="parameter"><code>const <a class="link" href="gobject-Enumeration-and-Flag-Types.html#GEnumValue" title="struct GEnumValue"><span class="type">GEnumValue</span></a> *const_static_values</code></em>);
65 <a class="link" href="gobject-Type-Information.html#GType" title="GType"><span class="returnvalue">GType</span></a>               <a class="link" href="GTypeModule.html#g-type-module-register-flags" title="g_type_module_register_flags ()">g_type_module_register_flags</a>        (<em class="parameter"><code><a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a> *module</code></em>,
66                                                          <em class="parameter"><code>const <a href="./../glib/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *name</code></em>,
67                                                          <em class="parameter"><code>const <a class="link" href="gobject-Enumeration-and-Flag-Types.html#GFlagsValue" title="struct GFlagsValue"><span class="type">GFlagsValue</span></a> *const_static_values</code></em>);
68 #define             <a class="link" href="GTypeModule.html#G-DEFINE-DYNAMIC-TYPE:CAPS" title="G_DEFINE_DYNAMIC_TYPE()">G_DEFINE_DYNAMIC_TYPE</a>               (TN,
69                                                          t_n,
70                                                          T_P)
71 #define             <a class="link" href="GTypeModule.html#G-DEFINE-DYNAMIC-TYPE-EXTENDED:CAPS" title="G_DEFINE_DYNAMIC_TYPE_EXTENDED()">G_DEFINE_DYNAMIC_TYPE_EXTENDED</a>      (TypeName,
72                                                          type_name,
73                                                          TYPE_PARENT,
74                                                          flags,
75                                                          CODE)
76 #define             <a class="link" href="GTypeModule.html#G-IMPLEMENT-INTERFACE-DYNAMIC:CAPS" title="G_IMPLEMENT_INTERFACE_DYNAMIC()">G_IMPLEMENT_INTERFACE_DYNAMIC</a>       (TYPE_IFACE,
77                                                          iface_init)
78 </pre>
79 </div>
80 <div class="refsect1">
81 <a name="GTypeModule.object-hierarchy"></a><h2>Object Hierarchy</h2>
82 <pre class="synopsis">
83   <a class="link" href="gobject-The-Base-Object-Type.html#GObject">GObject</a>
84    +----GTypeModule
85 </pre>
86 </div>
87 <div class="refsect1">
88 <a name="GTypeModule.implemented-interfaces"></a><h2>Implemented Interfaces</h2>
89 <p>
90 GTypeModule implements
91  <a class="link" href="GTypePlugin.html" title="GTypePlugin">GTypePlugin</a>.</p>
92 </div>
93 <div class="refsect1">
94 <a name="GTypeModule.description"></a><h2>Description</h2>
95 <p>
96 <a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a> provides a simple implementation of the <a class="link" href="GTypePlugin.html" title="GTypePlugin"><span class="type">GTypePlugin</span></a>
97 interface. The model of <a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a> is a dynamically loaded module
98 which implements some number of types and interface
99 implementations. When the module is loaded, it registers its types
100 and interfaces using <a class="link" href="GTypeModule.html#g-type-module-register-type" title="g_type_module_register_type ()"><code class="function">g_type_module_register_type()</code></a> and
101 <a class="link" href="GTypeModule.html#g-type-module-add-interface" title="g_type_module_add_interface ()"><code class="function">g_type_module_add_interface()</code></a>.  As long as any instances of these
102 types and interface implementations are in use, the module is kept
103 loaded. When the types and interfaces are gone, the module may be
104 unloaded. If the types and interfaces become used again, the module
105 will be reloaded. Note that the last unref cannot happen in module
106 code, since that would lead to the caller's code being unloaded before
107 <a class="link" href="gobject-The-Base-Object-Type.html#g-object-unref" title="g_object_unref ()"><code class="function">g_object_unref()</code></a> returns to it.
108 </p>
109 <p>
110 Keeping track of whether the module should be loaded or not is done by
111 using a use count - it starts at zero, and whenever it is greater than
112 zero, the module is loaded. The use count is maintained internally by
113 the type system, but also can be explicitly controlled by
114 <a class="link" href="GTypeModule.html#g-type-module-use" title="g_type_module_use ()"><code class="function">g_type_module_use()</code></a> and <a class="link" href="GTypeModule.html#g-type-module-unuse" title="g_type_module_unuse ()"><code class="function">g_type_module_unuse()</code></a>. Typically, when loading
115 a module for the first type, <a class="link" href="GTypeModule.html#g-type-module-use" title="g_type_module_use ()"><code class="function">g_type_module_use()</code></a> will be used to load
116 it so that it can initialize its types. At some later point, when the
117 module no longer needs to be loaded except for the type
118 implementations it contains, <a class="link" href="GTypeModule.html#g-type-module-unuse" title="g_type_module_unuse ()"><code class="function">g_type_module_unuse()</code></a> is called.
119 </p>
120 <p>
121 <a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a> does not actually provide any implementation of module
122 loading and unloading. To create a particular module type you must
123 derive from <a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a> and implement the load and unload functions
124 in <a class="link" href="GTypeModule.html#GTypeModuleClass" title="struct GTypeModuleClass"><span class="type">GTypeModuleClass</span></a>.
125 </p>
126 </div>
127 <div class="refsect1">
128 <a name="GTypeModule.details"></a><h2>Details</h2>
129 <div class="refsect2">
130 <a name="GTypeModule-struct"></a><h3>struct GTypeModule</h3>
131 <pre class="programlisting">struct GTypeModule {
132   gchar *name;
133 };
134 </pre>
135 <p>
136 The members of the <span class="structname">GTypeModule</span> structure should not 
137 be accessed directly, except for the <em class="parameter"><code>name</code></em> field.
138 </p>
139 <div class="variablelist"><table border="0">
140 <col align="left" valign="top">
141 <tbody><tr>
142 <td><p><span class="term"><a href="./../glib/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *<em class="structfield"><code><a name="GTypeModule-struct.name"></a>name</code></em>;</span></p></td>
143 <td>the name of the module</td>
144 </tr></tbody>
145 </table></div>
146 </div>
147 <hr>
148 <div class="refsect2">
149 <a name="GTypeModuleClass"></a><h3>struct GTypeModuleClass</h3>
150 <pre class="programlisting">struct GTypeModuleClass {
151   GObjectClass parent_class;
152
153   gboolean (* load)   (GTypeModule *module);
154   void     (* unload) (GTypeModule *module);
155 };
156 </pre>
157 <p>
158 In order to implement dynamic loading of types based on <a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a>, 
159 the <em class="parameter"><code>load</code></em> and <em class="parameter"><code>unload</code></em> functions in <a class="link" href="GTypeModule.html#GTypeModuleClass" title="struct GTypeModuleClass"><span class="type">GTypeModuleClass</span></a> must be implemented.
160 </p>
161 <div class="variablelist"><table border="0">
162 <col align="left" valign="top">
163 <tbody>
164 <tr>
165 <td><p><span class="term"><a class="link" href="gobject-The-Base-Object-Type.html#GObjectClass" title="struct GObjectClass"><span class="type">GObjectClass</span></a> <em class="structfield"><code><a name="GTypeModuleClass.parent-class"></a>parent_class</code></em>;</span></p></td>
166 <td>the parent class</td>
167 </tr>
168 <tr>
169 <td><p><span class="term"><em class="structfield"><code><a name="GTypeModuleClass.load"></a>load</code></em> ()</span></p></td>
170 <td>loads the module and registers one or more types using
171 <a class="link" href="GTypeModule.html#g-type-module-register-type" title="g_type_module_register_type ()"><code class="function">g_type_module_register_type()</code></a>.</td>
172 </tr>
173 <tr>
174 <td><p><span class="term"><em class="structfield"><code><a name="GTypeModuleClass.unload"></a>unload</code></em> ()</span></p></td>
175 <td>unloads the module</td>
176 </tr>
177 </tbody>
178 </table></div>
179 </div>
180 <hr>
181 <div class="refsect2">
182 <a name="g-type-module-use"></a><h3>g_type_module_use ()</h3>
183 <pre class="programlisting"><a href="./../glib/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a>            g_type_module_use                   (<em class="parameter"><code><a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a> *module</code></em>);</pre>
184 <p>
185 Increases the use count of a <a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a> by one. If the
186 use count was zero before, the plugin will be loaded.
187 If loading the plugin fails, the use count is reset to 
188 its prior value.
189 </p>
190 <div class="variablelist"><table border="0">
191 <col align="left" valign="top">
192 <tbody>
193 <tr>
194 <td><p><span class="term"><em class="parameter"><code>module</code></em> :</span></p></td>
195 <td>a <a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a>
196 </td>
197 </tr>
198 <tr>
199 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
200 <td>
201 <a href="./../glib/glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> if the plugin needed to be loaded and
202 loading the plugin failed.</td>
203 </tr>
204 </tbody>
205 </table></div>
206 </div>
207 <hr>
208 <div class="refsect2">
209 <a name="g-type-module-unuse"></a><h3>g_type_module_unuse ()</h3>
210 <pre class="programlisting"><span class="returnvalue">void</span>                g_type_module_unuse                 (<em class="parameter"><code><a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a> *module</code></em>);</pre>
211 <p>
212 Decreases the use count of a <a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a> by one. If the
213 result is zero, the module will be unloaded. (However, the
214 <a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a> will not be freed, and types associated with the
215 <a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a> are not unregistered. Once a <a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a> is
216 initialized, it must exist forever.)
217 </p>
218 <div class="variablelist"><table border="0">
219 <col align="left" valign="top">
220 <tbody><tr>
221 <td><p><span class="term"><em class="parameter"><code>module</code></em> :</span></p></td>
222 <td>a <a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a>
223 </td>
224 </tr></tbody>
225 </table></div>
226 </div>
227 <hr>
228 <div class="refsect2">
229 <a name="g-type-module-set-name"></a><h3>g_type_module_set_name ()</h3>
230 <pre class="programlisting"><span class="returnvalue">void</span>                g_type_module_set_name              (<em class="parameter"><code><a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a> *module</code></em>,
231                                                          <em class="parameter"><code>const <a href="./../glib/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *name</code></em>);</pre>
232 <p>
233 Sets the name for a <a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a>
234 </p>
235 <div class="variablelist"><table border="0">
236 <col align="left" valign="top">
237 <tbody>
238 <tr>
239 <td><p><span class="term"><em class="parameter"><code>module</code></em> :</span></p></td>
240 <td>a <a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a>.</td>
241 </tr>
242 <tr>
243 <td><p><span class="term"><em class="parameter"><code>name</code></em> :</span></p></td>
244 <td>a human-readable name to use in error messages.</td>
245 </tr>
246 </tbody>
247 </table></div>
248 </div>
249 <hr>
250 <div class="refsect2">
251 <a name="g-type-module-register-type"></a><h3>g_type_module_register_type ()</h3>
252 <pre class="programlisting"><a class="link" href="gobject-Type-Information.html#GType" title="GType"><span class="returnvalue">GType</span></a>               g_type_module_register_type         (<em class="parameter"><code><a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a> *module</code></em>,
253                                                          <em class="parameter"><code><a class="link" href="gobject-Type-Information.html#GType" title="GType"><span class="type">GType</span></a> parent_type</code></em>,
254                                                          <em class="parameter"><code>const <a href="./../glib/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *type_name</code></em>,
255                                                          <em class="parameter"><code>const <a class="link" href="gobject-Type-Information.html#GTypeInfo" title="struct GTypeInfo"><span class="type">GTypeInfo</span></a> *type_info</code></em>,
256                                                          <em class="parameter"><code><a class="link" href="gobject-Type-Information.html#GTypeFlags" title="enum GTypeFlags"><span class="type">GTypeFlags</span></a> flags</code></em>);</pre>
257 <p>
258 Looks up or registers a type that is implemented with a particular
259 type plugin. If a type with name <em class="parameter"><code>type_name</code></em> was previously registered,
260 the <a class="link" href="gobject-Type-Information.html#GType" title="GType"><span class="type">GType</span></a> identifier for the type is returned, otherwise the type
261 is newly registered, and the resulting <a class="link" href="gobject-Type-Information.html#GType" title="GType"><span class="type">GType</span></a> identifier returned.
262 </p>
263 <p>
264 When reregistering a type (typically because a module is unloaded
265 then reloaded, and reinitialized), <em class="parameter"><code>module</code></em> and <em class="parameter"><code>parent_type</code></em> must
266 be the same as they were previously.
267 </p>
268 <p>
269 As long as any instances of the type exist, the type plugin will
270 not be unloaded.
271 </p>
272 <div class="variablelist"><table border="0">
273 <col align="left" valign="top">
274 <tbody>
275 <tr>
276 <td><p><span class="term"><em class="parameter"><code>module</code></em> :</span></p></td>
277 <td>a <a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a>
278 </td>
279 </tr>
280 <tr>
281 <td><p><span class="term"><em class="parameter"><code>parent_type</code></em> :</span></p></td>
282 <td>the type for the parent class</td>
283 </tr>
284 <tr>
285 <td><p><span class="term"><em class="parameter"><code>type_name</code></em> :</span></p></td>
286 <td>name for the type</td>
287 </tr>
288 <tr>
289 <td><p><span class="term"><em class="parameter"><code>type_info</code></em> :</span></p></td>
290 <td>type information structure</td>
291 </tr>
292 <tr>
293 <td><p><span class="term"><em class="parameter"><code>flags</code></em> :</span></p></td>
294 <td>flags field providing details about the type</td>
295 </tr>
296 <tr>
297 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
298 <td>the new or existing type ID</td>
299 </tr>
300 </tbody>
301 </table></div>
302 </div>
303 <hr>
304 <div class="refsect2">
305 <a name="g-type-module-add-interface"></a><h3>g_type_module_add_interface ()</h3>
306 <pre class="programlisting"><span class="returnvalue">void</span>                g_type_module_add_interface         (<em class="parameter"><code><a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a> *module</code></em>,
307                                                          <em class="parameter"><code><a class="link" href="gobject-Type-Information.html#GType" title="GType"><span class="type">GType</span></a> instance_type</code></em>,
308                                                          <em class="parameter"><code><a class="link" href="gobject-Type-Information.html#GType" title="GType"><span class="type">GType</span></a> interface_type</code></em>,
309                                                          <em class="parameter"><code>const <a class="link" href="gobject-Type-Information.html#GInterfaceInfo" title="struct GInterfaceInfo"><span class="type">GInterfaceInfo</span></a> *interface_info</code></em>);</pre>
310 <p>
311 Registers an additional interface for a type, whose interface lives
312 in the given type plugin. If the interface was already registered
313 for the type in this plugin, nothing will be done.
314 </p>
315 <p>
316 As long as any instances of the type exist, the type plugin will
317 not be unloaded.
318 </p>
319 <div class="variablelist"><table border="0">
320 <col align="left" valign="top">
321 <tbody>
322 <tr>
323 <td><p><span class="term"><em class="parameter"><code>module</code></em> :</span></p></td>
324 <td>a <a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a>
325 </td>
326 </tr>
327 <tr>
328 <td><p><span class="term"><em class="parameter"><code>instance_type</code></em> :</span></p></td>
329 <td>type to which to add the interface.</td>
330 </tr>
331 <tr>
332 <td><p><span class="term"><em class="parameter"><code>interface_type</code></em> :</span></p></td>
333 <td>interface type to add</td>
334 </tr>
335 <tr>
336 <td><p><span class="term"><em class="parameter"><code>interface_info</code></em> :</span></p></td>
337 <td>type information structure</td>
338 </tr>
339 </tbody>
340 </table></div>
341 </div>
342 <hr>
343 <div class="refsect2">
344 <a name="g-type-module-register-enum"></a><h3>g_type_module_register_enum ()</h3>
345 <pre class="programlisting"><a class="link" href="gobject-Type-Information.html#GType" title="GType"><span class="returnvalue">GType</span></a>               g_type_module_register_enum         (<em class="parameter"><code><a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a> *module</code></em>,
346                                                          <em class="parameter"><code>const <a href="./../glib/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *name</code></em>,
347                                                          <em class="parameter"><code>const <a class="link" href="gobject-Enumeration-and-Flag-Types.html#GEnumValue" title="struct GEnumValue"><span class="type">GEnumValue</span></a> *const_static_values</code></em>);</pre>
348 <p>
349 Looks up or registers an enumeration that is implemented with a particular
350 type plugin. If a type with name <em class="parameter"><code>type_name</code></em> was previously registered,
351 the <a class="link" href="gobject-Type-Information.html#GType" title="GType"><span class="type">GType</span></a> identifier for the type is returned, otherwise the type
352 is newly registered, and the resulting <a class="link" href="gobject-Type-Information.html#GType" title="GType"><span class="type">GType</span></a> identifier returned.
353 </p>
354 <p>
355 As long as any instances of the type exist, the type plugin will
356 not be unloaded.
357 </p>
358 <div class="variablelist"><table border="0">
359 <col align="left" valign="top">
360 <tbody>
361 <tr>
362 <td><p><span class="term"><em class="parameter"><code>module</code></em> :</span></p></td>
363 <td>a <a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a>
364 </td>
365 </tr>
366 <tr>
367 <td><p><span class="term"><em class="parameter"><code>name</code></em> :</span></p></td>
368 <td>name for the type</td>
369 </tr>
370 <tr>
371 <td><p><span class="term"><em class="parameter"><code>const_static_values</code></em> :</span></p></td>
372 <td>an array of <a class="link" href="gobject-Enumeration-and-Flag-Types.html#GEnumValue" title="struct GEnumValue"><span class="type">GEnumValue</span></a> structs for the
373 possible enumeration values. The array is
374 terminated by a struct with all members being
375 0.</td>
376 </tr>
377 <tr>
378 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
379 <td>the new or existing type ID</td>
380 </tr>
381 </tbody>
382 </table></div>
383 <p class="since">Since 2.6</p>
384 </div>
385 <hr>
386 <div class="refsect2">
387 <a name="g-type-module-register-flags"></a><h3>g_type_module_register_flags ()</h3>
388 <pre class="programlisting"><a class="link" href="gobject-Type-Information.html#GType" title="GType"><span class="returnvalue">GType</span></a>               g_type_module_register_flags        (<em class="parameter"><code><a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a> *module</code></em>,
389                                                          <em class="parameter"><code>const <a href="./../glib/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *name</code></em>,
390                                                          <em class="parameter"><code>const <a class="link" href="gobject-Enumeration-and-Flag-Types.html#GFlagsValue" title="struct GFlagsValue"><span class="type">GFlagsValue</span></a> *const_static_values</code></em>);</pre>
391 <p>
392 Looks up or registers a flags type that is implemented with a particular
393 type plugin. If a type with name <em class="parameter"><code>type_name</code></em> was previously registered,
394 the <a class="link" href="gobject-Type-Information.html#GType" title="GType"><span class="type">GType</span></a> identifier for the type is returned, otherwise the type
395 is newly registered, and the resulting <a class="link" href="gobject-Type-Information.html#GType" title="GType"><span class="type">GType</span></a> identifier returned.
396 </p>
397 <p>
398 As long as any instances of the type exist, the type plugin will
399 not be unloaded.
400 </p>
401 <div class="variablelist"><table border="0">
402 <col align="left" valign="top">
403 <tbody>
404 <tr>
405 <td><p><span class="term"><em class="parameter"><code>module</code></em> :</span></p></td>
406 <td>a <a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a>
407 </td>
408 </tr>
409 <tr>
410 <td><p><span class="term"><em class="parameter"><code>name</code></em> :</span></p></td>
411 <td>name for the type</td>
412 </tr>
413 <tr>
414 <td><p><span class="term"><em class="parameter"><code>const_static_values</code></em> :</span></p></td>
415 <td>an array of <a class="link" href="gobject-Enumeration-and-Flag-Types.html#GFlagsValue" title="struct GFlagsValue"><span class="type">GFlagsValue</span></a> structs for the
416 possible flags values. The array is
417 terminated by a struct with all members being
418 0.</td>
419 </tr>
420 <tr>
421 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
422 <td>the new or existing type ID</td>
423 </tr>
424 </tbody>
425 </table></div>
426 <p class="since">Since 2.6</p>
427 </div>
428 <hr>
429 <div class="refsect2">
430 <a name="G-DEFINE-DYNAMIC-TYPE:CAPS"></a><h3>G_DEFINE_DYNAMIC_TYPE()</h3>
431 <pre class="programlisting">#define G_DEFINE_DYNAMIC_TYPE(TN, t_n, T_P)          G_DEFINE_DYNAMIC_TYPE_EXTENDED (TN, t_n, T_P, 0, {})
432 </pre>
433 <p>
434 A convenience macro for dynamic type implementations, which declares a
435 class initialization function, an instance initialization function (see 
436 <a class="link" href="gobject-Type-Information.html#GTypeInfo" title="struct GTypeInfo"><span class="type">GTypeInfo</span></a> for information about these) and a static variable named 
437 <em class="parameter"><code>t_n</code></em>_parent_class pointing to the parent class. Furthermore, 
438 it defines a <code class="function">*_get_type()</code> and a static 
439 <code class="function">*_register_type()</code> function for use in your
440 <code class="function"><code class="function">module_init()</code></code>.
441 See <a class="link" href="GTypeModule.html#G-DEFINE-DYNAMIC-TYPE-EXTENDED:CAPS" title="G_DEFINE_DYNAMIC_TYPE_EXTENDED()"><code class="function">G_DEFINE_DYNAMIC_TYPE_EXTENDED()</code></a> for an example.
442 </p>
443 <div class="variablelist"><table border="0">
444 <col align="left" valign="top">
445 <tbody>
446 <tr>
447 <td><p><span class="term"><em class="parameter"><code>TN</code></em> :</span></p></td>
448 <td>The name of the new type, in Camel case.</td>
449 </tr>
450 <tr>
451 <td><p><span class="term"><em class="parameter"><code>t_n</code></em> :</span></p></td>
452 <td>The name of the new type, in lowercase, with words
453 separated by '_'.</td>
454 </tr>
455 <tr>
456 <td><p><span class="term"><em class="parameter"><code>T_P</code></em> :</span></p></td>
457 <td>The <a class="link" href="gobject-Type-Information.html#GType" title="GType"><span class="type">GType</span></a> of the parent type.</td>
458 </tr>
459 </tbody>
460 </table></div>
461 <p class="since">Since 2.14</p>
462 </div>
463 <hr>
464 <div class="refsect2">
465 <a name="G-DEFINE-DYNAMIC-TYPE-EXTENDED:CAPS"></a><h3>G_DEFINE_DYNAMIC_TYPE_EXTENDED()</h3>
466 <pre class="programlisting">#define             G_DEFINE_DYNAMIC_TYPE_EXTENDED(TypeName, type_name, TYPE_PARENT, flags, CODE)</pre>
467 <p>
468 A more general version of <a class="link" href="GTypeModule.html#G-DEFINE-DYNAMIC-TYPE:CAPS" title="G_DEFINE_DYNAMIC_TYPE()"><code class="function">G_DEFINE_DYNAMIC_TYPE()</code></a> which
469 allows to specify <a class="link" href="gobject-Type-Information.html#GTypeFlags" title="enum GTypeFlags"><span class="type">GTypeFlags</span></a> and custom code.
470 </p>
471 <p>
472 </p>
473 <div class="informalexample"><pre class="programlisting">
474 G_DEFINE_DYNAMIC_TYPE_EXTENDED (GtkGadget,
475                                 gtk_gadget,
476                                 GTK_TYPE_THING,
477                                 0,
478                                 G_IMPLEMENT_INTERFACE_DYNAMIC (TYPE_GIZMO,
479                                                                gtk_gadget_gizmo_init));
480 </pre></div>
481 <p>
482 expands to
483 </p>
484 <div class="informalexample"><pre class="programlisting">
485 static void     gtk_gadget_init              (GtkGadget      *self);
486 static void     gtk_gadget_class_init        (GtkGadgetClass *klass);
487 static void     gtk_gadget_class_finalize    (GtkGadgetClass *klass);
488
489 static gpointer gtk_gadget_parent_class = NULL;
490 static GType    gtk_gadget_type_id = 0;
491
492 static void     gtk_gadget_class_intern_init (gpointer klass)
493 {
494   gtk_gadget_parent_class = g_type_class_peek_parent (klass); 
495   gtk_gadget_class_init ((GtkGadgetClass*) klass); 
496 }
497
498 GType
499 gtk_gadget_get_type (void)
500 {
501   return gtk_gadget_type_id;
502 }
503
504 static void
505 gtk_gadget_register_type (GTypeModule *type_module)
506 {
507   const GTypeInfo g_define_type_info = {
508     sizeof (GtkGadgetClass),
509     (GBaseInitFunc) NULL,
510     (GBaseFinalizeFunc) NULL,
511     (GClassInitFunc) gtk_gadget_class_intern_init,
512     (GClassFinalizeFunc) gtk_gadget_class_finalize,
513     NULL,   // class_data
514     sizeof (GtkGadget),
515     0,      // n_preallocs
516     (GInstanceInitFunc) gtk_gadget_init, 
517     NULL    // value_table
518   };
519   gtk_gadget_type_id = g_type_module_register_type (type_module,
520                                                     GTK_TYPE_THING,
521                                                     GtkGadget,
522                                                     &amp;g_define_type_info,
523                                                     (GTypeFlags) flags);
524   {
525     const GInterfaceInfo g_implement_interface_info = {
526       (GInterfaceInitFunc) gtk_gadget_gizmo_init
527     };
528     g_type_module_add_interface (type_module, g_define_type_id, TYPE_GIZMO, &amp;g_implement_interface_info);
529   }
530 }
531 </pre></div>
532 <p>
533 </p>
534 <div class="variablelist"><table border="0">
535 <col align="left" valign="top">
536 <tbody>
537 <tr>
538 <td><p><span class="term"><em class="parameter"><code>TypeName</code></em> :</span></p></td>
539 <td>The name of the new type, in Camel case.</td>
540 </tr>
541 <tr>
542 <td><p><span class="term"><em class="parameter"><code>type_name</code></em> :</span></p></td>
543 <td>The name of the new type, in lowercase, with words
544 separated by '_'.</td>
545 </tr>
546 <tr>
547 <td><p><span class="term"><em class="parameter"><code>TYPE_PARENT</code></em> :</span></p></td>
548 <td>The <a class="link" href="gobject-Type-Information.html#GType" title="GType"><span class="type">GType</span></a> of the parent type.</td>
549 </tr>
550 <tr>
551 <td><p><span class="term"><em class="parameter"><code>flags</code></em> :</span></p></td>
552 <td>
553 <a class="link" href="gobject-Type-Information.html#GTypeFlags" title="enum GTypeFlags"><span class="type">GTypeFlags</span></a> to pass to <a class="link" href="GTypeModule.html#g-type-module-register-type" title="g_type_module_register_type ()"><code class="function">g_type_module_register_type()</code></a>
554 </td>
555 </tr>
556 <tr>
557 <td><p><span class="term"><em class="parameter"><code>CODE</code></em> :</span></p></td>
558 <td>Custom code that gets inserted in the *_get_type() function.</td>
559 </tr>
560 </tbody>
561 </table></div>
562 <p class="since">Since 2.14</p>
563 </div>
564 <hr>
565 <div class="refsect2">
566 <a name="G-IMPLEMENT-INTERFACE-DYNAMIC:CAPS"></a><h3>G_IMPLEMENT_INTERFACE_DYNAMIC()</h3>
567 <pre class="programlisting">#define             G_IMPLEMENT_INTERFACE_DYNAMIC(TYPE_IFACE, iface_init)</pre>
568 <p>
569 A convenience macro to ease interface addition in the <em class="parameter"><code>_C_</code></em> section
570 of <a class="link" href="GTypeModule.html#G-DEFINE-DYNAMIC-TYPE-EXTENDED:CAPS" title="G_DEFINE_DYNAMIC_TYPE_EXTENDED()"><code class="function">G_DEFINE_DYNAMIC_TYPE_EXTENDED()</code></a>. See <a class="link" href="GTypeModule.html#G-DEFINE-DYNAMIC-TYPE-EXTENDED:CAPS" title="G_DEFINE_DYNAMIC_TYPE_EXTENDED()"><code class="function">G_DEFINE_DYNAMIC_TYPE_EXTENDED()</code></a>
571 for an example.
572 </p>
573 <p>
574 Note that this macro can only be used together with the
575 G_DEFINE_DYNAMIC_TYPE_EXTENDED macros, since it depends on variable
576 names from that macro.
577 </p>
578 <div class="variablelist"><table border="0">
579 <col align="left" valign="top">
580 <tbody>
581 <tr>
582 <td><p><span class="term"><em class="parameter"><code>TYPE_IFACE</code></em> :</span></p></td>
583 <td>The <a class="link" href="gobject-Type-Information.html#GType" title="GType"><span class="type">GType</span></a> of the interface to add</td>
584 </tr>
585 <tr>
586 <td><p><span class="term"><em class="parameter"><code>iface_init</code></em> :</span></p></td>
587 <td>The interface init function</td>
588 </tr>
589 </tbody>
590 </table></div>
591 <p class="since">Since 2.24</p>
592 </div>
593 </div>
594 <div class="refsect1">
595 <a name="GTypeModule.see-also"></a><h2>See Also</h2>
596 <div class="variablelist"><table border="0">
597 <col align="left" valign="top">
598 <tbody>
599 <tr>
600 <td><p><span class="term"><a class="link" href="GTypePlugin.html" title="GTypePlugin"><span class="type">GTypePlugin</span></a></span></p></td>
601 <td><p>The abstract type loader interface.</p></td>
602 </tr>
603 <tr>
604 <td><p><span class="term"><a href="./../glib/glib/glib-Dynamic-Loading-of-Modules.html#GModule"><span class="type">GModule</span></a></span></p></td>
605 <td><p>Portable mechanism for dynamically loaded modules.</p></td>
606 </tr>
607 </tbody>
608 </table></div>
609 </div>
610 </div>
611 <div class="footer">
612 <hr>
613           Generated by GTK-Doc V1.18</div>
614 </body>
615 </html>