Wrote the README_GIT file to be a proper tutorial on git, repo.or.cz and gtkD.
[gtkD.git] / gtkD / src / gobject / TypeModule.d
blob441e0a79c13dc3a83010f6a13d5db7ae2aab752c
1 /*
2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = GTypeModule.html
26 * outPack = gobject
27 * outFile = TypeModule
28 * strct = GTypeModule
29 * realStrct=
30 * ctorStrct=
31 * clss = TypeModule
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - g_type_module_
40 * omit structs:
41 * omit prefixes:
42 * omit code:
43 * imports:
44 * - glib.Str
45 * - gobject.Enums
46 * - gobject.Flags
47 * structWrap:
48 * - GEnumValue* -> Enums
49 * - GFlagsValue* -> Flags
50 * module aliases:
51 * local aliases:
54 module gobject.TypeModule;
56 version(noAssert)
58 version(Tango)
60 import tango.io.Stdout; // use the tango loging?
64 private import gtkc.gobjecttypes;
66 private import gtkc.gobject;
69 private import glib.Str;
70 private import gobject.Enums;
71 private import gobject.Flags;
76 /**
77 * Description
78 * GTypeModule provides a simple implementation of the GTypePlugin
79 * interface. The model of GTypeModule is a dynamically loaded module
80 * which implements some number of types and interface
81 * implementations. When the module is loaded, it registers its types
82 * and interfaces using g_type_module_register_type() and
83 * g_type_module_add_interface(). As long as any instances of these
84 * types and interface implementations are in use, the module is kept
85 * loaded. When the types and interfaces are gone, the module may be
86 * unloaded. If the types and interfaces become used again, the module
87 * will be reloaded. Note that the last unref can not happen in module
88 * code, since that would lead to the caller's code being unloaded before
89 * g_object_unref() returns to it.
90 * Keeping track of whether the module should be loaded or not is done by
91 * using a use count - it starts at zero, and whenever it is greater than
92 * zero, the module is loaded. The use count is maintained internally by
93 * the type system, but also can be explicitly controlled by
94 * g_type_module_use() and g_type_module_unuse(). Typically, when loading
95 * a module for the first type, g_type_module_use() will be used to load
96 * it so that it can initialize its types. At some later point, when the
97 * module no longer needs to be loaded except for the type
98 * implementations it contains, g_type_module_unuse() is called.
99 * GTypeModule does not actually provide any implementation of module
100 * loading and unloading. To create a particular module type you must
101 * derive from GTypeModule and implement the load and unload functions
102 * in GTypeModuleClass.
104 private import gobject.ObjectG;
105 public class TypeModule : ObjectG
108 /** the main Gtk struct */
109 protected GTypeModule* gTypeModule;
112 public GTypeModule* getTypeModuleStruct()
114 return gTypeModule;
118 /** the main Gtk struct as a void* */
119 protected void* getStruct()
121 return cast(void*)gTypeModule;
125 * Sets our main struct and passes it to the parent class
127 public this (GTypeModule* gTypeModule)
129 version(noAssert)
131 if ( gTypeModule is null )
133 int zero = 0;
134 version(Tango)
136 Stdout("struct gTypeModule is null on constructor").newline;
138 else
140 printf("struct gTypeModule is null on constructor");
142 zero = zero / zero;
145 else
147 assert(gTypeModule !is null, "struct gTypeModule is null on constructor");
149 super(cast(GObject*)gTypeModule);
150 this.gTypeModule = gTypeModule;
159 * Increases the use count of a GTypeModule by one. If the
160 * use count was zero before, the plugin will be loaded.
161 * module:
162 * a GTypeModule
163 * Returns:
164 * FALSE if the plugin needed to be loaded and
165 * loading the plugin failed.
167 public int use()
169 // gboolean g_type_module_use (GTypeModule *module);
170 return g_type_module_use(gTypeModule);
174 * Decreases the use count of a GTypeModule by one. If the
175 * result is zero, the module will be unloaded. (However, the
176 * GTypeModule will not be freed, and types associated with the
177 * GTypeModule are not unregistered. Once a GTypeModule is
178 * initialized, it must exist forever.)
179 * module:
180 * a GTypeModule
182 public void unuse()
184 // void g_type_module_unuse (GTypeModule *module);
185 g_type_module_unuse(gTypeModule);
189 * Sets the name for a GTypeModule
190 * module:
191 * a GTypeModule.
192 * name:
193 * a human-readable name to use in error messages.
195 public void setName(char[] name)
197 // void g_type_module_set_name (GTypeModule *module, const gchar *name);
198 g_type_module_set_name(gTypeModule, Str.toStringz(name));
202 * Looks up or registers a type that is implemented with a particular
203 * type plugin. If a type with name type_name was previously registered,
204 * the GType identifier for the type is returned, otherwise the type
205 * is newly registered, and the resulting GType identifier returned.
206 * When reregistering a type (typically because a module is unloaded
207 * then reloaded, and reinitialized), module and parent_type must
208 * be the same as they were previously.
209 * As long as any instances of the type exist, the type plugin will
210 * not be unloaded.
211 * module:
212 * a GTypeModule
213 * parent_type:
214 * the type for the parent class
215 * type_name:
216 * name for the type
217 * type_info:
218 * type information structure
219 * flags:
220 * flags field providing details about the type
221 * Returns:
222 * the new or existing type ID
224 public GType registerType(GType parentType, char[] typeName, GTypeInfo* typeInfo, GTypeFlags flags)
226 // GType g_type_module_register_type (GTypeModule *module, GType parent_type, const gchar *type_name, const GTypeInfo *type_info, GTypeFlags flags);
227 return g_type_module_register_type(gTypeModule, parentType, Str.toStringz(typeName), typeInfo, flags);
231 * Registers an additional interface for a type, whose interface
232 * lives in the given type plugin. If the interface was already registered
233 * for the type in this plugin, nothing will be done.
234 * As long as any instances of the type exist, the type plugin will
235 * not be unloaded.
236 * module:
237 * a GTypeModule
238 * instance_type:
239 * type to which to add the interface.
240 * interface_type:
241 * interface type to add
242 * interface_info:
243 * type information structure
245 public void addInterface(GType instanceType, GType interfaceType, GInterfaceInfo* interfaceInfo)
247 // void g_type_module_add_interface (GTypeModule *module, GType instance_type, GType interface_type, const GInterfaceInfo *interface_info);
248 g_type_module_add_interface(gTypeModule, instanceType, interfaceType, interfaceInfo);
252 * Looks up or registers an enumeration that is implemented with a particular
253 * type plugin. If a type with name type_name was previously registered,
254 * the GType identifier for the type is returned, otherwise the type
255 * is newly registered, and the resulting GType identifier returned.
256 * As long as any instances of the type exist, the type plugin will
257 * not be unloaded.
258 * module:
259 * a GTypeModule
260 * name:
261 * name for the type
262 * _static_values:
263 * Returns:
264 * the new or existing type ID
265 * Since 2.6
267 public GType registerEnum(char[] name, Enums _StaticValues)
269 // GType g_type_module_register_enum (GTypeModule *module, const gchar *name, const GEnumValue *const _static_values);
270 return g_type_module_register_enum(gTypeModule, Str.toStringz(name), (_StaticValues is null) ? null : _StaticValues.getEnumsStruct());
274 * Looks up or registers a flags type that is implemented with a particular
275 * type plugin. If a type with name type_name was previously registered,
276 * the GType identifier for the type is returned, otherwise the type
277 * is newly registered, and the resulting GType identifier returned.
278 * As long as any instances of the type exist, the type plugin will
279 * not be unloaded.
280 * module:
281 * a GTypeModule
282 * name:
283 * name for the type
284 * _static_values:
285 * Returns:
286 * the new or existing type ID
287 * Since 2.6
289 public GType registerFlags(char[] name, Flags _StaticValues)
291 // GType g_type_module_register_flags (GTypeModule *module, const gchar *name, const GFlagsValue *const _static_values);
292 return g_type_module_register_flags(gTypeModule, Str.toStringz(name), (_StaticValues is null) ? null : _StaticValues.getFlagsStruct());