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