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