1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 /* 25 * Conversion parameters: 26 * inFile = GTypeModule.html 27 * outPack = gobject 28 * outFile = TypeModule 29 * strct = GTypeModule 30 * realStrct= 31 * ctorStrct= 32 * clss = TypeModule 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - g_type_module_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - glib.Str 47 * - gobject.Enums 48 * - gobject.Flags 49 * structWrap: 50 * - GEnumValue* -> Enums 51 * - GFlagsValue* -> Flags 52 * module aliases: 53 * local aliases: 54 * overrides: 55 */ 56 57 module gobject.TypeModule; 58 59 public import gtkc.gobjecttypes; 60 61 private import gtkc.gobject; 62 private import glib.ConstructionException; 63 private import gobject.ObjectG; 64 65 66 private import glib.Str; 67 private import gobject.Enums; 68 private import gobject.Flags; 69 70 71 72 private import gobject.ObjectG; 73 74 /** 75 * GTypeModule provides a simple implementation of the GTypePlugin 76 * interface. The model of GTypeModule is a dynamically loaded module 77 * which implements some number of types and interface 78 * implementations. When the module is loaded, it registers its types 79 * and interfaces using g_type_module_register_type() and 80 * g_type_module_add_interface(). As long as any instances of these 81 * types and interface implementations are in use, the module is kept 82 * loaded. When the types and interfaces are gone, the module may be 83 * unloaded. If the types and interfaces become used again, the module 84 * will be reloaded. Note that the last unref cannot happen in module 85 * code, since that would lead to the caller's code being unloaded before 86 * g_object_unref() returns to it. 87 * 88 * Keeping track of whether the module should be loaded or not is done by 89 * using a use count - it starts at zero, and whenever it is greater than 90 * zero, the module is loaded. The use count is maintained internally by 91 * the type system, but also can be explicitly controlled by 92 * g_type_module_use() and g_type_module_unuse(). Typically, when loading 93 * a module for the first type, g_type_module_use() will be used to load 94 * it so that it can initialize its types. At some later point, when the 95 * module no longer needs to be loaded except for the type 96 * implementations it contains, g_type_module_unuse() is called. 97 * 98 * GTypeModule does not actually provide any implementation of module 99 * loading and unloading. To create a particular module type you must 100 * derive from GTypeModule and implement the load and unload functions 101 * in GTypeModuleClass. 102 */ 103 public class TypeModule : ObjectG 104 { 105 106 /** the main Gtk struct */ 107 protected GTypeModule* gTypeModule; 108 109 110 public GTypeModule* getTypeModuleStruct() 111 { 112 return gTypeModule; 113 } 114 115 116 /** the main Gtk struct as a void* */ 117 protected override void* getStruct() 118 { 119 return cast(void*)gTypeModule; 120 } 121 122 /** 123 * Sets our main struct and passes it to the parent class 124 */ 125 public this (GTypeModule* gTypeModule) 126 { 127 super(cast(GObject*)gTypeModule); 128 this.gTypeModule = gTypeModule; 129 } 130 131 protected override void setStruct(GObject* obj) 132 { 133 super.setStruct(obj); 134 gTypeModule = cast(GTypeModule*)obj; 135 } 136 137 /** 138 */ 139 140 /** 141 * Increases the use count of a GTypeModule by one. If the 142 * use count was zero before, the plugin will be loaded. 143 * If loading the plugin fails, the use count is reset to 144 * its prior value. 145 * Returns: FALSE if the plugin needed to be loaded and loading the plugin failed. 146 */ 147 public int use() 148 { 149 // gboolean g_type_module_use (GTypeModule *module); 150 return g_type_module_use(gTypeModule); 151 } 152 153 /** 154 * Decreases the use count of a GTypeModule by one. If the 155 * result is zero, the module will be unloaded. (However, the 156 * GTypeModule will not be freed, and types associated with the 157 * GTypeModule are not unregistered. Once a GTypeModule is 158 * initialized, it must exist forever.) 159 */ 160 public void unuse() 161 { 162 // void g_type_module_unuse (GTypeModule *module); 163 g_type_module_unuse(gTypeModule); 164 } 165 166 /** 167 * Sets the name for a GTypeModule 168 * Params: 169 * name = a human-readable name to use in error messages. 170 */ 171 public void setName(string name) 172 { 173 // void g_type_module_set_name (GTypeModule *module, const gchar *name); 174 g_type_module_set_name(gTypeModule, Str.toStringz(name)); 175 } 176 177 /** 178 * Looks up or registers a type that is implemented with a particular 179 * type plugin. If a type with name type_name was previously registered, 180 * the GType identifier for the type is returned, otherwise the type 181 * is newly registered, and the resulting GType identifier returned. 182 * When reregistering a type (typically because a module is unloaded 183 * then reloaded, and reinitialized), module and parent_type must 184 * be the same as they were previously. 185 * As long as any instances of the type exist, the type plugin will 186 * not be unloaded. 187 * Params: 188 * parentType = the type for the parent class 189 * typeName = name for the type 190 * typeInfo = type information structure 191 * flags = flags field providing details about the type 192 * Returns: the new or existing type ID 193 */ 194 public GType registerType(GType parentType, string typeName, GTypeInfo* typeInfo, GTypeFlags flags) 195 { 196 // GType g_type_module_register_type (GTypeModule *module, GType parent_type, const gchar *type_name, const GTypeInfo *type_info, GTypeFlags flags); 197 return g_type_module_register_type(gTypeModule, parentType, Str.toStringz(typeName), typeInfo, flags); 198 } 199 200 /** 201 * Registers an additional interface for a type, whose interface lives 202 * in the given type plugin. If the interface was already registered 203 * for the type in this plugin, nothing will be done. 204 * As long as any instances of the type exist, the type plugin will 205 * not be unloaded. 206 * Params: 207 * instanceType = type to which to add the interface. 208 * interfaceType = interface type to add 209 * interfaceInfo = type information structure 210 */ 211 public void addInterface(GType instanceType, GType interfaceType, GInterfaceInfo* interfaceInfo) 212 { 213 // void g_type_module_add_interface (GTypeModule *module, GType instance_type, GType interface_type, const GInterfaceInfo *interface_info); 214 g_type_module_add_interface(gTypeModule, instanceType, interfaceType, interfaceInfo); 215 } 216 217 /** 218 * Looks up or registers an enumeration that is implemented with a particular 219 * type plugin. If a type with name type_name was previously registered, 220 * the GType identifier for the type is returned, otherwise the type 221 * is newly registered, and the resulting GType identifier returned. 222 * As long as any instances of the type exist, the type plugin will 223 * not be unloaded. 224 * Since 2.6 225 * Params: 226 * name = name for the type 227 * Returns: the new or existing type ID 228 */ 229 public GType registerEnum(string name, Enums _StaticValues) 230 { 231 // GType g_type_module_register_enum (GTypeModule *module, const gchar *name, const GEnumValue *const_static_values); 232 return g_type_module_register_enum(gTypeModule, Str.toStringz(name), (_StaticValues is null) ? null : _StaticValues.getEnumsStruct()); 233 } 234 235 /** 236 * Looks up or registers a flags type that is implemented with a particular 237 * type plugin. If a type with name type_name was previously registered, 238 * the GType identifier for the type is returned, otherwise the type 239 * is newly registered, and the resulting GType identifier returned. 240 * As long as any instances of the type exist, the type plugin will 241 * not be unloaded. 242 * Since 2.6 243 * Params: 244 * name = name for the type 245 * Returns: the new or existing type ID 246 */ 247 public GType registerFlags(string name, Flags _StaticValues) 248 { 249 // GType g_type_module_register_flags (GTypeModule *module, const gchar *name, const GFlagsValue *const_static_values); 250 return g_type_module_register_flags(gTypeModule, Str.toStringz(name), (_StaticValues is null) ? null : _StaticValues.getFlagsStruct()); 251 } 252 }