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(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 @interface passing @n_parameters
160 	 * and @parameters to the #PeasFactoryFunc. If @module does
161 	 * not provide a #PeasFactoryFunc for @interface then
162 	 * %NULL is returned.
163 	 *
164 	 * Params:
165 	 *     iface = The #GType of the extension interface.
166 	 *     nParameters = The number of paramteters.
167 	 *     parameters = The parameters.
168 	 *
169 	 * Returns: The created object, or %NULL.
170 	 */
171 	public ObjectG createObject(GType iface, GParameter[] parameters)
172 	{
173 		auto p = peas_object_module_create_object(peasObjectModule, iface, cast(uint)parameters.length, parameters.ptr);
174 		
175 		if(p is null)
176 		{
177 			return null;
178 		}
179 		
180 		return ObjectG.getDObject!(ObjectG)(cast(GObject*) p, true);
181 	}
182 
183 	/**
184 	 * Gets the library.
185 	 *
186 	 * Returns: the library.
187 	 */
188 	public Module getLibrary()
189 	{
190 		auto p = peas_object_module_get_library(peasObjectModule);
191 		
192 		if(p is null)
193 		{
194 			return null;
195 		}
196 		
197 		return new Module(cast(GModule*) p);
198 	}
199 
200 	/**
201 	 * Gets the module name.
202 	 *
203 	 * Returns: the module name.
204 	 */
205 	public string getModuleName()
206 	{
207 		return Str.toString(peas_object_module_get_module_name(peasObjectModule));
208 	}
209 
210 	/**
211 	 * Gets the path.
212 	 *
213 	 * Returns: the path.
214 	 */
215 	public string getPath()
216 	{
217 		return Str.toString(peas_object_module_get_path(peasObjectModule));
218 	}
219 
220 	/**
221 	 * Gets the symbol name used to register extension implementations.
222 	 *
223 	 * Returns: the symbol name.
224 	 *
225 	 * Since: 1.18
226 	 */
227 	public string getSymbol()
228 	{
229 		return Str.toString(peas_object_module_get_symbol(peasObjectModule));
230 	}
231 
232 	/**
233 	 * Determines if the module provides an extension for @interface.
234 	 *
235 	 * Params:
236 	 *     iface = The #GType of the extension interface.
237 	 *
238 	 * Returns: if the module provides an extension for @interface.
239 	 */
240 	public bool providesObject(GType iface)
241 	{
242 		return peas_object_module_provides_object(peasObjectModule, iface) != 0;
243 	}
244 
245 	/**
246 	 * Register an implementation for an extension type through a factory
247 	 * function @factory_func which will instantiate the extension when
248 	 * requested.
249 	 *
250 	 * This method is primarily meant to be used by native bindings (like gtkmm),
251 	 * creating native types which cannot be instantiated correctly using
252 	 * g_object_new().  For other uses, you will usually prefer relying on
253 	 * peas_object_module_register_extension_type().
254 	 *
255 	 * Params:
256 	 *     ifaceType = The #GType of the extension interface you implement.
257 	 *     factoryFunc = The #PeasFactoryFunc that will create the @iface_type
258 	 *         instance when requested.
259 	 *     userData = Data to pass to @func calls.
260 	 *     destroyFunc = A #GDestroyNotify for @user_data.
261 	 */
262 	public void registerExtensionFactory(GType ifaceType, PeasFactoryFunc factoryFunc, void* userData, GDestroyNotify destroyFunc)
263 	{
264 		peas_object_module_register_extension_factory(peasObjectModule, ifaceType, factoryFunc, userData, destroyFunc);
265 	}
266 
267 	/**
268 	 * Register an extension type which implements the extension interface
269 	 * @iface_type.
270 	 *
271 	 * Params:
272 	 *     ifaceType = The #GType of the extension interface you implement.
273 	 *     extensionType = The #GType of your implementation of @iface_type.
274 	 */
275 	public void registerExtensionType(GType ifaceType, GType extensionType)
276 	{
277 		peas_object_module_register_extension_type(peasObjectModule, ifaceType, extensionType);
278 	}
279 }