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