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