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