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 module peas.ObjectModule; 26 27 private import glib.ConstructionException; 28 private import glib.Module; 29 private import glib.Str; 30 private import gobject.ObjectG; 31 private import gobject.TypeModule; 32 private import gobject.TypePluginIF; 33 private import gobject.TypePluginT; 34 private import peas.c.functions; 35 public import peas.c.types; 36 37 38 /** 39 * The #PeasObjectModule structure contains only private data and should only 40 * be accessed using the provided API. 41 */ 42 public class ObjectModule : TypeModule 43 { 44 /** the main Gtk struct */ 45 protected PeasObjectModule* peasObjectModule; 46 47 /** Get the main Gtk struct */ 48 public PeasObjectModule* getObjectModuleStruct(bool transferOwnership = false) 49 { 50 if (transferOwnership) 51 ownedRef = false; 52 return peasObjectModule; 53 } 54 55 /** the main Gtk struct as a void* */ 56 protected override void* getStruct() 57 { 58 return cast(void*)peasObjectModule; 59 } 60 61 protected override void setStruct(GObject* obj) 62 { 63 peasObjectModule = cast(PeasObjectModule*)obj; 64 super.setStruct(obj); 65 } 66 67 /** 68 * Sets our main struct and passes it to the parent class. 69 */ 70 public this (PeasObjectModule* peasObjectModule, bool ownedRef = false) 71 { 72 this.peasObjectModule = peasObjectModule; 73 super(cast(GTypeModule*)peasObjectModule, ownedRef); 74 } 75 76 77 /** */ 78 public static GType getType() 79 { 80 return peas_object_module_get_type(); 81 } 82 83 /** 84 * Creates a new #PeasObjectModule. 85 * 86 * Params: 87 * moduleName = The module name. 88 * path = The path. 89 * resident = If the module should be resident. 90 * 91 * Returns: a new #PeasObjectModule. 92 * 93 * Throws: ConstructionException GTK+ fails to create the object. 94 */ 95 public this(string moduleName, string path, bool resident) 96 { 97 auto p = peas_object_module_new(Str.toStringz(moduleName), Str.toStringz(path), resident); 98 99 if(p is null) 100 { 101 throw new ConstructionException("null returned by new"); 102 } 103 104 this(cast(PeasObjectModule*) p, true); 105 } 106 107 /** 108 * Creates a new #PeasObjectModule for an embedded plugin. 109 * 110 * Params: 111 * moduleName = The module name. 112 * 113 * Returns: a new #PeasObjectModule. 114 * 115 * Since: 1.18 116 * 117 * Throws: ConstructionException GTK+ fails to create the object. 118 */ 119 public this(string moduleName, string symbol) 120 { 121 auto p = peas_object_module_new_embedded(Str.toStringz(moduleName), Str.toStringz(symbol)); 122 123 if(p is null) 124 { 125 throw new ConstructionException("null returned by new_embedded"); 126 } 127 128 this(cast(PeasObjectModule*) p, true); 129 } 130 131 /** 132 * Creates a new #PeasObjectModule. 133 * 134 * Params: 135 * moduleName = The module name. 136 * path = The path. 137 * resident = If the module should be resident. 138 * localLinkage = Whether to load the module with local linkage. 139 * 140 * Returns: a new #PeasObjectModule. 141 * 142 * Since 1.14 143 * 144 * Throws: ConstructionException GTK+ fails to create the object. 145 */ 146 public this(string moduleName, string path, bool resident, bool localLinkage) 147 { 148 auto p = peas_object_module_new_full(Str.toStringz(moduleName), Str.toStringz(path), resident, localLinkage); 149 150 if(p is null) 151 { 152 throw new ConstructionException("null returned by new_full"); 153 } 154 155 this(cast(PeasObjectModule*) p, true); 156 } 157 158 /** 159 * Creates an object for the @exten_type passing @n_parameters 160 * and @parameters to the #PeasFactoryFunc. If @module does 161 * not provide a #PeasFactoryFunc for @exten_type then 162 * %NULL is returned. 163 * 164 * Since libpeas 1.22, @exten_type can be an Abstract #GType 165 * and not just an Interface #GType. 166 * 167 * Params: 168 * extenType = The #GType of the extension. 169 * parameters = The parameters. 170 * 171 * Returns: The created object, or %NULL. 172 */ 173 public ObjectG createObject(GType extenType, GParameter[] parameters) 174 { 175 auto p = peas_object_module_create_object(peasObjectModule, extenType, cast(uint)parameters.length, parameters.ptr); 176 177 if(p is null) 178 { 179 return null; 180 } 181 182 return ObjectG.getDObject!(ObjectG)(cast(GObject*) p, true); 183 } 184 185 /** 186 * Gets the library. 187 * 188 * Returns: the library. 189 */ 190 public Module getLibrary() 191 { 192 auto p = peas_object_module_get_library(peasObjectModule); 193 194 if(p is null) 195 { 196 return null; 197 } 198 199 return new Module(cast(GModule*) p); 200 } 201 202 /** 203 * Gets the module name. 204 * 205 * Returns: the module name. 206 */ 207 public string getModuleName() 208 { 209 return Str.toString(peas_object_module_get_module_name(peasObjectModule)); 210 } 211 212 /** 213 * Gets the path. 214 * 215 * Returns: the path. 216 */ 217 public string getPath() 218 { 219 return Str.toString(peas_object_module_get_path(peasObjectModule)); 220 } 221 222 /** 223 * Gets the symbol name used to register extension implementations. 224 * 225 * Returns: the symbol name. 226 * 227 * Since: 1.18 228 */ 229 public string getSymbol() 230 { 231 return Str.toString(peas_object_module_get_symbol(peasObjectModule)); 232 } 233 234 /** 235 * Determines if the module provides an extension for @exten_type. 236 * 237 * Since libpeas 1.22, @exten_type can be an Abstract #GType 238 * and not just an Interface #GType. 239 * 240 * Params: 241 * extenType = The #GType of the extension. 242 * 243 * Returns: if the module provides an extension for @exten_type. 244 */ 245 public bool providesObject(GType extenType) 246 { 247 return peas_object_module_provides_object(peasObjectModule, extenType) != 0; 248 } 249 250 /** 251 * Register an implementation for an extension type through a factory 252 * function @factory_func which will instantiate the extension when 253 * requested. 254 * 255 * This method is primarily meant to be used by native bindings (like gtkmm), 256 * creating native types which cannot be instantiated correctly using 257 * g_object_new(). For other uses, you will usually prefer relying on 258 * peas_object_module_register_extension_type(). 259 * 260 * Since libpeas 1.22, @exten_type can be an Abstract #GType 261 * and not just an Interface #GType. 262 * 263 * Params: 264 * extenType = The #GType of the extension you implement. 265 * factoryFunc = The #PeasFactoryFunc that will create the @exten_type 266 * instance when requested. 267 * userData = Data to pass to @func calls. 268 * destroyFunc = A #GDestroyNotify for @user_data. 269 */ 270 public void registerExtensionFactory(GType extenType, PeasFactoryFunc factoryFunc, void* userData, GDestroyNotify destroyFunc) 271 { 272 peas_object_module_register_extension_factory(peasObjectModule, extenType, factoryFunc, userData, destroyFunc); 273 } 274 275 /** 276 * Register @impl_type as an extension which implements @extension_type. 277 * 278 * Since libpeas 1.22, @exten_type can be an Abstract #GType 279 * and not just an Interface #GType. 280 * 281 * Params: 282 * extenType = The #GType of the extension you implement. 283 * implType = The #GType of your implementation of @exten_type. 284 */ 285 public void registerExtensionType(GType extenType, GType implType) 286 { 287 peas_object_module_register_extension_type(peasObjectModule, extenType, implType); 288 } 289 }