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 private import peas.Engine;
32 private import peas.PluginInfo;
33 private import peas.c.functions;
34 public  import peas.c.types;
35 private import std.algorithm;
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(bool transferOwnership = false)
49 	{
50 		if (transferOwnership)
51 			ownedRef = false;
52 		return peasExtensionSet;
53 	}
54 
55 	/** the main Gtk struct as a void* */
56 	protected override void* getStruct()
57 	{
58 		return cast(void*)peasExtensionSet;
59 	}
60 
61 	/**
62 	 * Sets our main struct and passes it to the parent class.
63 	 */
64 	public this (PeasExtensionSet* peasExtensionSet, bool ownedRef = false)
65 	{
66 		this.peasExtensionSet = peasExtensionSet;
67 		super(cast(GObject*)peasExtensionSet, ownedRef);
68 	}
69 
70 
71 	/** */
72 	public static GType getType()
73 	{
74 		return peas_extension_set_get_type();
75 	}
76 
77 	/**
78 	 * Create a new #PeasExtensionSet for the @exten_type extension type.
79 	 *
80 	 * If @engine is %NULL, then the default engine will be used.
81 	 *
82 	 * Since libpeas 1.22, @exten_type can be an Abstract #GType
83 	 * and not just an Interface #GType.
84 	 *
85 	 * See peas_extension_set_new() for more information.
86 	 *
87 	 * Params:
88 	 *     engine = A #PeasEngine, or %NULL.
89 	 *     extenType = the extension #GType.
90 	 *     firstProperty = the name of the first property.
91 	 *     varArgs = the value of the first property, followed optionally by more
92 	 *         name/value pairs, followed by %NULL.
93 	 *
94 	 * Returns: a new instance of #PeasExtensionSet.
95 	 *
96 	 * Throws: ConstructionException GTK+ fails to create the object.
97 	 */
98 	public this(Engine engine, GType extenType, string firstProperty, void* varArgs)
99 	{
100 		auto p = peas_extension_set_new_valist((engine is null) ? null : engine.getEngineStruct(), extenType, Str.toStringz(firstProperty), varArgs);
101 
102 		if(p is null)
103 		{
104 			throw new ConstructionException("null returned by new_valist");
105 		}
106 
107 		this(cast(PeasExtensionSet*) p, true);
108 	}
109 
110 	/**
111 	 * Create a new #PeasExtensionSet for the @exten_type extension type.
112 	 *
113 	 * If @engine is %NULL, then the default engine will be used.
114 	 *
115 	 * Since libpeas 1.22, @exten_type can be an Abstract #GType
116 	 * and not just an Interface #GType.
117 	 *
118 	 * See peas_extension_set_new() for more information.
119 	 *
120 	 * Params:
121 	 *     engine = A #PeasEngine, or %NULL.
122 	 *     extenType = the extension #GType.
123 	 *     parameters = an array of #GParameter.
124 	 *
125 	 * Returns: a new instance of #PeasExtensionSet.
126 	 *
127 	 * Throws: ConstructionException GTK+ fails to create the object.
128 	 */
129 	public this(Engine engine, GType extenType, GParameter[] parameters)
130 	{
131 		auto p = peas_extension_set_newv((engine is null) ? null : engine.getEngineStruct(), extenType, cast(uint)parameters.length, parameters.ptr);
132 
133 		if(p is null)
134 		{
135 			throw new ConstructionException("null returned by newv");
136 		}
137 
138 		this(cast(PeasExtensionSet*) p, true);
139 	}
140 
141 	/**
142 	 * Calls @func for each #PeasExtension.
143 	 *
144 	 * Params:
145 	 *     func = A function call for each extension.
146 	 *     data = Optional data to be passed to the function or %NULL.
147 	 *
148 	 * Since: 1.2
149 	 */
150 	public void foreac(PeasExtensionSetForeachFunc func, void* data)
151 	{
152 		peas_extension_set_foreach(peasExtensionSet, func, data);
153 	}
154 
155 	/**
156 	 * Returns the #PeasExtension object corresponding to @info, or %NULL
157 	 * if the plugin doesn't provide such an extension.
158 	 *
159 	 * Params:
160 	 *     info = a #PeasPluginInfo
161 	 *
162 	 * Returns: a reference to a #PeasExtension or %NULL
163 	 */
164 	public PeasExtension* getExtension(PluginInfo info)
165 	{
166 		return peas_extension_set_get_extension(peasExtensionSet, (info is null) ? null : info.getPluginInfoStruct());
167 	}
168 
169 	/**
170 	 * The extension-added signal is emitted when a new extension has been
171 	 * added to the #PeasExtensionSet. It happens when a new plugin implementing
172 	 * the extension set's extension type is loaded.
173 	 *
174 	 * You should connect to this signal in order to set up the extensions when
175 	 * they are loaded. Note that this signal is not fired for extensions coming
176 	 * from plugins that were already loaded when the #PeasExtensionSet instance
177 	 * was created. You should set those up by yourself.
178 	 *
179 	 * Params:
180 	 *     info = A #PeasPluginInfo.
181 	 *     exten = A #PeasExtension.
182 	 */
183 	gulong addOnExtensionAdded(void delegate(PluginInfo, ObjectG, ExtensionSet) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
184 	{
185 		return Signals.connect(this, "extension-added", dlg, connectFlags ^ ConnectFlags.SWAPPED);
186 	}
187 
188 	/**
189 	 * The extension-removed signal is emitted when a new extension is about to be
190 	 * removed from the #PeasExtensionSet. It happens when a plugin implementing
191 	 * the extension set's extension type is unloaded, or when the
192 	 * #PeasExtensionSet itself is destroyed.
193 	 *
194 	 * You should connect to this signal in order to clean up the extensions
195 	 * when their plugin is unload. Note that this signal is not fired for the
196 	 * #PeasExtension instances still available when the #PeasExtensionSet
197 	 * instance is destroyed. You should clean those up by yourself.
198 	 *
199 	 * Params:
200 	 *     info = A #PeasPluginInfo.
201 	 *     exten = A #PeasExtension.
202 	 */
203 	gulong addOnExtensionRemoved(void delegate(PluginInfo, ObjectG, ExtensionSet) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
204 	{
205 		return Signals.connect(this, "extension-removed", dlg, connectFlags ^ ConnectFlags.SWAPPED);
206 	}
207 }