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 	alias foreac = foreach_;
142 	/**
143 	 * Calls @func for each #PeasExtension.
144 	 *
145 	 * Params:
146 	 *     func = A function call for each extension.
147 	 *     data = Optional data to be passed to the function or %NULL.
148 	 *
149 	 * Since: 1.2
150 	 */
151 	public void foreach_(PeasExtensionSetForeachFunc func, void* data)
152 	{
153 		peas_extension_set_foreach(peasExtensionSet, func, data);
154 	}
155 
156 	/**
157 	 * Returns the #PeasExtension object corresponding to @info, or %NULL
158 	 * if the plugin doesn't provide such an extension.
159 	 *
160 	 * Params:
161 	 *     info = a #PeasPluginInfo
162 	 *
163 	 * Returns: a reference to a #PeasExtension or %NULL
164 	 */
165 	public PeasExtension* getExtension(PluginInfo info)
166 	{
167 		return peas_extension_set_get_extension(peasExtensionSet, (info is null) ? null : info.getPluginInfoStruct());
168 	}
169 
170 	/**
171 	 * The extension-added signal is emitted when a new extension has been
172 	 * added to the #PeasExtensionSet. It happens when a new plugin implementing
173 	 * the extension set's extension type is loaded.
174 	 *
175 	 * You should connect to this signal in order to set up the extensions when
176 	 * they are loaded. Note that this signal is not fired for extensions coming
177 	 * from plugins that were already loaded when the #PeasExtensionSet instance
178 	 * was created. You should set those up by yourself.
179 	 *
180 	 * Params:
181 	 *     info = A #PeasPluginInfo.
182 	 *     exten = A #PeasExtension.
183 	 */
184 	gulong addOnExtensionAdded(void delegate(PluginInfo, ObjectG, ExtensionSet) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
185 	{
186 		return Signals.connect(this, "extension-added", dlg, connectFlags ^ ConnectFlags.SWAPPED);
187 	}
188 
189 	/**
190 	 * The extension-removed signal is emitted when a new extension is about to be
191 	 * removed from the #PeasExtensionSet. It happens when a plugin implementing
192 	 * the extension set's extension type is unloaded, or when the
193 	 * #PeasExtensionSet itself is destroyed.
194 	 *
195 	 * You should connect to this signal in order to clean up the extensions
196 	 * when their plugin is unload. Note that this signal is not fired for the
197 	 * #PeasExtension instances still available when the #PeasExtensionSet
198 	 * instance is destroyed. You should clean those up by yourself.
199 	 *
200 	 * Params:
201 	 *     info = A #PeasPluginInfo.
202 	 *     exten = A #PeasExtension.
203 	 */
204 	gulong addOnExtensionRemoved(void delegate(PluginInfo, ObjectG, ExtensionSet) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
205 	{
206 		return Signals.connect(this, "extension-removed", dlg, connectFlags ^ ConnectFlags.SWAPPED);
207 	}
208 }