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