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  * Conversion parameters:
26  * inFile  = GstChildProxy.html
27  * outPack = gstreamer
28  * outFile = ChildProxyT
29  * strct   = GstChildProxy
30  * realStrct=
31  * ctorStrct=
32  * clss    = ChildProxyT
33  * interf  = ChildProxyIF
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * 	- TStruct
38  * extend  = 
39  * implements:
40  * prefixes:
41  * 	- gst_child_proxy_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- glib.Str
48  * 	- gobject.ObjectG
49  * 	- gobject.ParamSpec
50  * 	- gobject.Value
51  * structWrap:
52  * 	- GObject* -> ObjectG
53  * 	- GParamSpec* -> ParamSpec
54  * 	- GValue* -> Value
55  * module aliases:
56  * local aliases:
57  * overrides:
58  */
59 
60 module gstreamer.ChildProxyT;
61 
62 public  import gstreamerc.gstreamertypes;
63 
64 public import gstreamerc.gstreamer;
65 public import glib.ConstructionException;
66 public import gobject.ObjectG;
67 
68 public import gobject.Signals;
69 public  import gtkc.gdktypes;
70 public import glib.Str;
71 public import gobject.ObjectG;
72 public import gobject.ParamSpec;
73 public import gobject.Value;
74 
75 
76 
77 /**
78  * This interface abstracts handling of property sets for elements with
79  * children. Imagine elements such as mixers or polyphonic generators. They all
80  * have multiple GstPad or some kind of voice objects. Another use case are
81  * container elements like GstBin.
82  * The element implementing the interface acts as a parent for those child
83  * objects.
84  *
85  * By implementing this interface the child properties can be accessed from the
86  * parent element by using gst_child_proxy_get() and gst_child_proxy_set().
87  *
88  * Property names are written as "child-name::property-name". The whole naming
89  * scheme is recursive. Thus "child1::child2::property" is valid too, if
90  * "child1" and "child2" implement the GstChildProxy interface.
91  */
92 public template ChildProxyT(TStruct)
93 {
94 	
95 	/** the main Gtk struct */
96 	protected GstChildProxy* gstChildProxy;
97 	
98 	
99 	/** Get the main Gtk struct */
100 	public GstChildProxy* getChildProxyTStruct()
101 	{
102 		return cast(GstChildProxy*)getStruct();
103 	}
104 	
105 	
106 	/**
107 	 */
108 	int[string] connectedSignals;
109 	
110 	void delegate(ObjectG, string, ChildProxyIF)[] _onChildAddedListeners;
111 	@property void delegate(ObjectG, string, ChildProxyIF)[] onChildAddedListeners()
112 	{
113 		return  _onChildAddedListeners;
114 	}
115 	/**
116 	 * Will be emitted after the object was added to the child_proxy.
117 	 */
118 	void addOnChildAdded(void delegate(ObjectG, string, ChildProxyIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
119 	{
120 		if ( !("child-added" in connectedSignals) )
121 		{
122 			Signals.connectData(
123 			getStruct(),
124 			"child-added",
125 			cast(GCallback)&callBackChildAdded,
126 			cast(void*)cast(ChildProxyIF)this,
127 			null,
128 			connectFlags);
129 			connectedSignals["child-added"] = 1;
130 		}
131 		_onChildAddedListeners ~= dlg;
132 	}
133 	extern(C) static void callBackChildAdded(GstChildProxy* childProxyStruct, GObject* object, gchar* name, ChildProxyIF _childProxyIF)
134 	{
135 		foreach ( void delegate(ObjectG, string, ChildProxyIF) dlg ; _childProxyIF.onChildAddedListeners )
136 		{
137 			dlg(ObjectG.getDObject!(ObjectG)(object), Str.toString(name), _childProxyIF);
138 		}
139 	}
140 	
141 	void delegate(ObjectG, string, ChildProxyIF)[] _onChildRemovedListeners;
142 	@property void delegate(ObjectG, string, ChildProxyIF)[] onChildRemovedListeners()
143 	{
144 		return  _onChildRemovedListeners;
145 	}
146 	/**
147 	 * Will be emitted after the object was removed from the child_proxy.
148 	 * See Also
149 	 * GstBin
150 	 */
151 	void addOnChildRemoved(void delegate(ObjectG, string, ChildProxyIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
152 	{
153 		if ( !("child-removed" in connectedSignals) )
154 		{
155 			Signals.connectData(
156 			getStruct(),
157 			"child-removed",
158 			cast(GCallback)&callBackChildRemoved,
159 			cast(void*)cast(ChildProxyIF)this,
160 			null,
161 			connectFlags);
162 			connectedSignals["child-removed"] = 1;
163 		}
164 		_onChildRemovedListeners ~= dlg;
165 	}
166 	extern(C) static void callBackChildRemoved(GstChildProxy* childProxyStruct, GObject* object, gchar* name, ChildProxyIF _childProxyIF)
167 	{
168 		foreach ( void delegate(ObjectG, string, ChildProxyIF) dlg ; _childProxyIF.onChildRemovedListeners )
169 		{
170 			dlg(ObjectG.getDObject!(ObjectG)(object), Str.toString(name), _childProxyIF);
171 		}
172 	}
173 	
174 	
175 	/**
176 	 * Gets the number of child objects this parent contains.
177 	 * Returns: the number of child objects MT safe.
178 	 */
179 	public uint getChildrenCount()
180 	{
181 		// guint gst_child_proxy_get_children_count (GstChildProxy *parent);
182 		return gst_child_proxy_get_children_count(getChildProxyTStruct());
183 	}
184 	
185 	/**
186 	 * Looks up a child element by the given name.
187 	 * This virtual method has a default implementation that uses GstObject
188 	 * together with gst_object_get_name(). If the interface is to be used with
189 	 * GObjects, this methods needs to be overridden.
190 	 * Params:
191 	 * name = the childs name
192 	 * Returns: the child object or NULL if not found. Unref after usage. MT safe. [transfer full]
193 	 */
194 	public ObjectG getChildByName(string name)
195 	{
196 		// GObject * gst_child_proxy_get_child_by_name (GstChildProxy *parent,  const gchar *name);
197 		auto p = gst_child_proxy_get_child_by_name(getChildProxyTStruct(), Str.toStringz(name));
198 		
199 		if(p is null)
200 		{
201 			return null;
202 		}
203 		
204 		return ObjectG.getDObject!(ObjectG)(cast(GObject*) p);
205 	}
206 	
207 	/**
208 	 * Fetches a child by its number.
209 	 * Params:
210 	 * index = the childs position in the child list
211 	 * Returns: the child object or NULL if not found (index too high). Unref after usage. MT safe. [transfer full]
212 	 */
213 	public ObjectG getChildByIndex(uint index)
214 	{
215 		// GObject * gst_child_proxy_get_child_by_index (GstChildProxy *parent,  guint index);
216 		auto p = gst_child_proxy_get_child_by_index(getChildProxyTStruct(), index);
217 		
218 		if(p is null)
219 		{
220 			return null;
221 		}
222 		
223 		return ObjectG.getDObject!(ObjectG)(cast(GObject*) p);
224 	}
225 	
226 	/**
227 	 * Looks up which object and GParamSpec would be effected by the given name.
228 	 * MT safe.
229 	 * Params:
230 	 * name = name of the property to look up
231 	 * target = pointer to a GObject that
232 	 * takes the real object to set property on. [out][allow-none][transfer full]
233 	 * pspec = pointer to take the GParamSpec
234 	 * describing the property. [out][allow-none][transfer none]
235 	 * Returns: TRUE if target and pspec could be found. FALSE otherwise. In that case the values for pspec and target are not modified. Unref target after usage. For plain GObjects target is the same as object.
236 	 */
237 	public int lookup(string name, out ObjectG target, out ParamSpec pspec)
238 	{
239 		// gboolean gst_child_proxy_lookup (GstChildProxy *object,  const gchar *name,  GObject **target,  GParamSpec **pspec);
240 		GObject* outtarget = null;
241 		GParamSpec* outpspec = null;
242 		
243 		auto p = gst_child_proxy_lookup(getChildProxyTStruct(), Str.toStringz(name), &outtarget, &outpspec);
244 		
245 		target = ObjectG.getDObject!(ObjectG)(outtarget);
246 		pspec = ObjectG.getDObject!(ParamSpec)(outpspec);
247 		return p;
248 	}
249 	
250 	/**
251 	 * Gets a single property using the GstChildProxy mechanism.
252 	 * You are responsible for freeing it by calling g_value_unset()
253 	 * Params:
254 	 * name = name of the property
255 	 * value = a GValue that should take the result. [out caller-allocates]
256 	 */
257 	public void getProperty(string name, Value value)
258 	{
259 		// void gst_child_proxy_get_property (GstChildProxy *object,  const gchar *name,  GValue *value);
260 		gst_child_proxy_get_property(getChildProxyTStruct(), Str.toStringz(name), (value is null) ? null : value.getValueStruct());
261 	}
262 	
263 	/**
264 	 * Gets properties of the parent object and its children.
265 	 * Params:
266 	 * firstPropertyName = name of the first property to get
267 	 * varArgs = return location for the first property, followed optionally by more name/return location pairs, followed by NULL
268 	 */
269 	public void getValist(string firstPropertyName, void* varArgs)
270 	{
271 		// void gst_child_proxy_get_valist (GstChildProxy *object,  const gchar *first_property_name,  va_list var_args);
272 		gst_child_proxy_get_valist(getChildProxyTStruct(), Str.toStringz(firstPropertyName), varArgs);
273 	}
274 	
275 	/**
276 	 * Sets a single property using the GstChildProxy mechanism.
277 	 * Params:
278 	 * name = name of the property to set
279 	 * value = new GValue for the property
280 	 */
281 	public void setProperty(string name, Value value)
282 	{
283 		// void gst_child_proxy_set_property (GstChildProxy *object,  const gchar *name,  const GValue *value);
284 		gst_child_proxy_set_property(getChildProxyTStruct(), Str.toStringz(name), (value is null) ? null : value.getValueStruct());
285 	}
286 	
287 	/**
288 	 * Sets properties of the parent object and its children.
289 	 * Params:
290 	 * firstPropertyName = name of the first property to set
291 	 * varArgs = value for the first property, followed optionally by more name/value pairs, followed by NULL
292 	 */
293 	public void setValist(string firstPropertyName, void* varArgs)
294 	{
295 		// void gst_child_proxy_set_valist (GstChildProxy *object,  const gchar *first_property_name,  va_list var_args);
296 		gst_child_proxy_set_valist(getChildProxyTStruct(), Str.toStringz(firstPropertyName), varArgs);
297 	}
298 	
299 	/**
300 	 * Emits the "child-added" signal.
301 	 * Params:
302 	 * child = the newly added child
303 	 * name = the name of the new child
304 	 */
305 	public void childAdded(ObjectG child, string name)
306 	{
307 		// void gst_child_proxy_child_added (GstChildProxy *parent,  GObject *child,  const gchar *name);
308 		gst_child_proxy_child_added(getChildProxyTStruct(), (child is null) ? null : child.getObjectGStruct(), Str.toStringz(name));
309 	}
310 	
311 	/**
312 	 * Emits the "child-removed" signal.
313 	 * Params:
314 	 * child = the removed child
315 	 * name = the name of the old child
316 	 * Signal Details
317 	 * The "child-added" signal
318 	 * void user_function (GstChildProxy *child_proxy,
319 	 *  GObject *object,
320 	 *  gchar *name,
321 	 *  gpointer user_data) : Run First
322 	 * Will be emitted after the object was added to the child_proxy.
323 	 * name = the name of the new child
324 	 */
325 	public void childRemoved(ObjectG child, string name)
326 	{
327 		// void gst_child_proxy_child_removed (GstChildProxy *parent,  GObject *child,  const gchar *name);
328 		gst_child_proxy_child_removed(getChildProxyTStruct(), (child is null) ? null : child.getObjectGStruct(), Str.toStringz(name));
329 	}
330 }