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.ExtensionSet;
26 
27 private import glib.ConstructionException;
28 private import glib.Str;
29 private import gobject.ObjectG;
30 private import gobject.Signals;
31 public  import gtkc.gdktypes;
32 private import peas.Engine;
33 private import peas.PluginInfo;
34 private import peasc.peas;
35 public  import peasc.peastypes;
36 
37 
38 /**
39  * The #PeasExtensionSet structure contains only private data and should only
40  * be accessed using the provided API.
41  */
42 public class ExtensionSet : ObjectG
43 {
44 	/** the main Gtk struct */
45 	protected PeasExtensionSet* peasExtensionSet;
46 
47 	/** Get the main Gtk struct */
48 	public PeasExtensionSet* getExtensionSetStruct()
49 	{
50 		return peasExtensionSet;
51 	}
52 
53 	/** the main Gtk struct as a void* */
54 	protected override void* getStruct()
55 	{
56 		return cast(void*)peasExtensionSet;
57 	}
58 
59 	protected override void setStruct(GObject* obj)
60 	{
61 		peasExtensionSet = cast(PeasExtensionSet*)obj;
62 		super.setStruct(obj);
63 	}
64 
65 	/**
66 	 * Sets our main struct and passes it to the parent class.
67 	 */
68 	public this (PeasExtensionSet* peasExtensionSet, bool ownedRef = false)
69 	{
70 		this.peasExtensionSet = peasExtensionSet;
71 		super(cast(GObject*)peasExtensionSet, ownedRef);
72 	}
73 
74 
75 	/** */
76 	public static GType getType()
77 	{
78 		return peas_extension_set_get_type();
79 	}
80 
81 	/**
82 	 * Create a new #PeasExtensionSet for the @exten_type extension type.
83 	 *
84 	 * If @engine is %NULL, then the default engine will be used.
85 	 *
86 	 * See peas_extension_set_new() for more information.
87 	 *
88 	 * Params:
89 	 *     engine = A #PeasEngine, or %NULL.
90 	 *     extenType = the extension #GType.
91 	 *     firstProperty = the name of the first property.
92 	 *     varArgs = the value of the first property, followed optionally by more
93 	 *         name/value pairs, followed by %NULL.
94 	 *
95 	 * Return: a new instance of #PeasExtensionSet.
96 	 *
97 	 * Throws: ConstructionException GTK+ fails to create the object.
98 	 */
99 	public this(Engine engine, GType extenType, string firstProperty, void* varArgs)
100 	{
101 		auto p = peas_extension_set_new_valist((engine is null) ? null : engine.getEngineStruct(), extenType, Str.toStringz(firstProperty), varArgs);
102 		
103 		if(p is null)
104 		{
105 			throw new ConstructionException("null returned by new_valist");
106 		}
107 		
108 		this(cast(PeasExtensionSet*) p, true);
109 	}
110 
111 	/**
112 	 * Create a new #PeasExtensionSet for the @exten_type extension type.
113 	 *
114 	 * If @engine is %NULL, then the default engine will be used.
115 	 *
116 	 * See peas_extension_set_new() for more information.
117 	 *
118 	 * Params:
119 	 *     engine = A #PeasEngine, or %NULL.
120 	 *     extenType = the extension #GType.
121 	 *     nParameters = the length of the @parameters array.
122 	 *     parameters = an array of #GParameter.
123 	 *
124 	 * Return: a new instance of #PeasExtensionSet.
125 	 *
126 	 * Throws: ConstructionException GTK+ fails to create the object.
127 	 */
128 	public this(Engine engine, GType extenType, GParameter[] parameters)
129 	{
130 		auto p = peas_extension_set_newv((engine is null) ? null : engine.getEngineStruct(), extenType, cast(uint)parameters.length, parameters.ptr);
131 		
132 		if(p is null)
133 		{
134 			throw new ConstructionException("null returned by newv");
135 		}
136 		
137 		this(cast(PeasExtensionSet*) p, true);
138 	}
139 
140 	/**
141 	 * Calls @func for each #PeasExtension.
142 	 *
143 	 * Params:
144 	 *     func = A function call for each extension.
145 	 *     data = Optional data to be passed to the function or %NULL.
146 	 *
147 	 * Since: 1.2
148 	 */
149 	public void foreac(PeasExtensionSetForeachFunc func, void* data)
150 	{
151 		peas_extension_set_foreach(peasExtensionSet, func, data);
152 	}
153 
154 	/**
155 	 * Returns the #PeasExtension object corresponding to @info, or %NULL
156 	 * if the plugin doesn't provide such an extension.
157 	 *
158 	 * Params:
159 	 *     info = a #PeasPluginInfo
160 	 *
161 	 * Return: a reference to a #PeasExtension or %NULL
162 	 */
163 	public PeasExtension* getExtension(PluginInfo info)
164 	{
165 		return peas_extension_set_get_extension(peasExtensionSet, (info is null) ? null : info.getPluginInfoStruct());
166 	}
167 
168 	int[string] connectedSignals;
169 
170 	void delegate(PluginInfo, ObjectG, ExtensionSet)[] onExtensionAddedListeners;
171 	/**
172 	 * The extension-added signal is emitted when a new extension has been
173 	 * added to the #PeasExtensionSet. It happens when a new plugin implementing
174 	 * the extension set's extension type is loaded.
175 	 *
176 	 * You should connect to this signal in order to set up the extensions when
177 	 * they are loaded. Note that this signal is not fired for extensions coming
178 	 * from plugins that were already loaded when the #PeasExtensionSet instance
179 	 * was created. You should set those up by yourself.
180 	 *
181 	 * Params:
182 	 *     info = A #PeasPluginInfo.
183 	 *     exten = A #PeasExtension.
184 	 */
185 	void addOnExtensionAdded(void delegate(PluginInfo, ObjectG, ExtensionSet) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
186 	{
187 		if ( "extension-added" !in connectedSignals )
188 		{
189 			Signals.connectData(
190 				this,
191 				"extension-added",
192 				cast(GCallback)&callBackExtensionAdded,
193 				cast(void*)this,
194 				null,
195 				connectFlags);
196 			connectedSignals["extension-added"] = 1;
197 		}
198 		onExtensionAddedListeners ~= dlg;
199 	}
200 	extern(C) static void callBackExtensionAdded(PeasExtensionSet* extensionsetStruct, PeasPluginInfo* info, GObject* exten, ExtensionSet _extensionset)
201 	{
202 		foreach ( void delegate(PluginInfo, ObjectG, ExtensionSet) dlg; _extensionset.onExtensionAddedListeners )
203 		{
204 			dlg(ObjectG.getDObject!(PluginInfo)(info), ObjectG.getDObject!(ObjectG)(exten), _extensionset);
205 		}
206 	}
207 
208 	void delegate(PluginInfo, ObjectG, ExtensionSet)[] onExtensionRemovedListeners;
209 	/**
210 	 * The extension-removed signal is emitted when a new extension is about to be
211 	 * removed from the #PeasExtensionSet. It happens when a plugin implementing
212 	 * the extension set's extension type is unloaded, or when the
213 	 * #PeasExtensionSet itself is destroyed.
214 	 *
215 	 * You should connect to this signal in order to clean up the extensions
216 	 * when their plugin is unload. Note that this signal is not fired for the
217 	 * #PeasExtension instances still available when the #PeasExtensionSet
218 	 * instance is destroyed. You should clean those up by yourself.
219 	 *
220 	 * Params:
221 	 *     info = A #PeasPluginInfo.
222 	 *     exten = A #PeasExtension.
223 	 */
224 	void addOnExtensionRemoved(void delegate(PluginInfo, ObjectG, ExtensionSet) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
225 	{
226 		if ( "extension-removed" !in connectedSignals )
227 		{
228 			Signals.connectData(
229 				this,
230 				"extension-removed",
231 				cast(GCallback)&callBackExtensionRemoved,
232 				cast(void*)this,
233 				null,
234 				connectFlags);
235 			connectedSignals["extension-removed"] = 1;
236 		}
237 		onExtensionRemovedListeners ~= dlg;
238 	}
239 	extern(C) static void callBackExtensionRemoved(PeasExtensionSet* extensionsetStruct, PeasPluginInfo* info, GObject* exten, ExtensionSet _extensionset)
240 	{
241 		foreach ( void delegate(PluginInfo, ObjectG, ExtensionSet) dlg; _extensionset.onExtensionRemovedListeners )
242 		{
243 			dlg(ObjectG.getDObject!(PluginInfo)(info), ObjectG.getDObject!(ObjectG)(exten), _extensionset);
244 		}
245 	}
246 }