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 = GBinding.html 27 * outPack = gobject 28 * outFile = Binding 29 * strct = GBinding 30 * realStrct= 31 * ctorStrct= 32 * clss = Binding 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - g_binding_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - glib.Str 47 * - gobject.ObjectG 48 * - gobject.Closure 49 * - gobject.Value 50 * structWrap: 51 * - GBinding* -> Binding 52 * - GClosure* -> Closure 53 * - GObject* -> ObjectG 54 * - GValue* -> Value 55 * - gpointer -> ObjectG 56 * module aliases: 57 * local aliases: 58 * overrides: 59 */ 60 61 module gobject.Binding; 62 63 public import gtkc.gobjecttypes; 64 65 private import gtkc.gobject; 66 private import glib.ConstructionException; 67 private import gobject.ObjectG; 68 69 70 private import glib.Str; 71 private import gobject.ObjectG; 72 private import gobject.Closure; 73 private import gobject.Value; 74 75 76 77 private import gobject.ObjectG; 78 79 /** 80 * Description 81 * GBinding is the representation of a binding between a property on a 82 * GObject instance (or source) and another property on another GObject 83 * instance (or target). Whenever the source property changes, the same 84 * value is applied to the target property; for instance, the following 85 * binding: 86 * $(DDOC_COMMENT example) 87 * will cause object2:property-b to be updated every 88 * time g_object_set() or the specific accessor changes the value of 89 * object1:property-a. 90 * It is possible to create a bidirectional binding between two properties 91 * of two GObject instances, so that if either property changes, the 92 * other is updated as well, for instance: 93 * $(DDOC_COMMENT example) 94 * will keep the two properties in sync. 95 * It is also possible to set a custom transformation function (in both 96 * directions, in case of a bidirectional binding) to apply a custom 97 * transformation from the source value to the target value before 98 * applying it; for instance, the following binding: 99 * $(DDOC_COMMENT example) 100 * will keep the value property of the two adjustments 101 * in sync; the celsius_to_fahrenheit function will be 102 * called whenever the adjustment1:value property changes 103 * and will transform the current value of the property before applying it 104 * to the adjustment2:value property; vice versa, the 105 * fahrenheit_to_celsius function will be called whenever 106 * the adjustment2:value property changes, and will 107 * transform the current value of the property before applying it to the 108 * adjustment1:value. 109 * Note that GBinding does not resolve cycles by itself; a cycle like 110 * $(DDOC_COMMENT example) 111 * might lead to an infinite loop. The loop, in this particular case, 112 * can be avoided if the objects emit the "notify" signal only 113 * if the value has effectively been changed. A binding is implemented 114 * using the "notify" signal, so it is susceptible to all the 115 * various ways of blocking a signal emission, like g_signal_stop_emission() 116 * or g_signal_handler_block(). 117 * A binding will be severed, and the resources it allocates freed, whenever 118 * either one of the GObject instances it refers to are finalized, or when 119 * the GBinding instance loses its last reference. 120 * GBinding is available since GObject 2.26 121 */ 122 public class Binding : ObjectG 123 { 124 125 /** the main Gtk struct */ 126 protected GBinding* gBinding; 127 128 129 public GBinding* getBindingStruct() 130 { 131 return gBinding; 132 } 133 134 135 /** the main Gtk struct as a void* */ 136 protected override void* getStruct() 137 { 138 return cast(void*)gBinding; 139 } 140 141 /** 142 * Sets our main struct and passes it to the parent class 143 */ 144 public this (GBinding* gBinding) 145 { 146 super(cast(GObject*)gBinding); 147 this.gBinding = gBinding; 148 } 149 150 protected override void setStruct(GObject* obj) 151 { 152 super.setStruct(obj); 153 gBinding = cast(GBinding*)obj; 154 } 155 156 /** 157 */ 158 159 /** 160 * Retrieves the GObject instance used as the source of the binding 161 * Since 2.26 162 * Returns: the source GObject. [transfer none] 163 */ 164 public ObjectG getSource() 165 { 166 // GObject * g_binding_get_source (GBinding *binding); 167 auto p = g_binding_get_source(gBinding); 168 169 if(p is null) 170 { 171 return null; 172 } 173 174 return ObjectG.getDObject!(ObjectG)(cast(GObject*) p); 175 } 176 177 /** 178 * Retrieves the name of the property of "source" used as the source 179 * of the binding 180 * Since 2.26 181 * Returns: the name of the source property 182 */ 183 public string getSourceProperty() 184 { 185 // const gchar * g_binding_get_source_property (GBinding *binding); 186 return Str.toString(g_binding_get_source_property(gBinding)); 187 } 188 189 /** 190 * Retrieves the GObject instance used as the target of the binding 191 * Since 2.26 192 * Returns: the target GObject. [transfer none] 193 */ 194 public ObjectG getTarget() 195 { 196 // GObject * g_binding_get_target (GBinding *binding); 197 auto p = g_binding_get_target(gBinding); 198 199 if(p is null) 200 { 201 return null; 202 } 203 204 return ObjectG.getDObject!(ObjectG)(cast(GObject*) p); 205 } 206 207 /** 208 * Retrieves the name of the property of "target" used as the target 209 * of the binding 210 * Since 2.26 211 * Returns: the name of the target property 212 */ 213 public string getTargetProperty() 214 { 215 // const gchar * g_binding_get_target_property (GBinding *binding); 216 return Str.toString(g_binding_get_target_property(gBinding)); 217 } 218 219 /** 220 * Retrieves the flags passed when constructing the GBinding 221 * Since 2.26 222 * Returns: the GBindingFlags used by the GBinding 223 */ 224 public GBindingFlags getFlags() 225 { 226 // GBindingFlags g_binding_get_flags (GBinding *binding); 227 return g_binding_get_flags(gBinding); 228 } 229 230 /** 231 * Creates a binding between source_property on source and target_property 232 * on target. Whenever the source_property is changed the target_property is 233 * Since 2.26 234 * Params: 235 * source = the source GObject 236 * sourceProperty = the property on source to bind 237 * target = the target GObject 238 * targetProperty = the property on target to bind 239 * flags = flags to pass to GBinding 240 * Returns: the GBinding instance representing the binding between the two GObject instances. The binding is released whenever the GBinding reference count reaches zero. [transfer none] 241 */ 242 public static Binding gObjectBindProperty(void* source, string sourceProperty, void* target, string targetProperty, GBindingFlags flags) 243 { 244 // GBinding * g_object_bind_property (gpointer source, const gchar *source_property, gpointer target, const gchar *target_property, GBindingFlags flags); 245 auto p = g_object_bind_property(source, Str.toStringz(sourceProperty), target, Str.toStringz(targetProperty), flags); 246 247 if(p is null) 248 { 249 return null; 250 } 251 252 return ObjectG.getDObject!(Binding)(cast(GBinding*) p); 253 } 254 255 /** 256 * Complete version of g_object_bind_property(). 257 * Creates a binding between source_property on source and target_property 258 * on target, allowing you to set the transformation functions to be used by 259 * the binding. 260 * Since 2.26 261 * Params: 262 * source = the source GObject 263 * sourceProperty = the property on source to bind 264 * target = the target GObject 265 * targetProperty = the property on target to bind 266 * flags = flags to pass to GBinding 267 * transformTo = the transformation function 268 * from the source to the target, or NULL to use the default. [scope notified][allow-none] 269 * transformFrom = the transformation function 270 * from the target to the source, or NULL to use the default. [scope notified][allow-none] 271 * userData = custom data to be passed to the transformation functions, 272 * or NULL 273 * notify = function to be called when disposing the binding, to free the 274 * resources used by the transformation functions 275 * Returns: the GBinding instance representing the binding between the two GObject instances. The binding is released whenever the GBinding reference count reaches zero. [transfer none] 276 */ 277 public static Binding gObjectBindPropertyFull(void* source, string sourceProperty, void* target, string targetProperty, GBindingFlags flags, GBindingTransformFunc transformTo, GBindingTransformFunc transformFrom, void* userData, GDestroyNotify notify) 278 { 279 // GBinding * g_object_bind_property_full (gpointer source, const gchar *source_property, gpointer target, const gchar *target_property, GBindingFlags flags, GBindingTransformFunc transform_to, GBindingTransformFunc transform_from, gpointer user_data, GDestroyNotify notify); 280 auto p = g_object_bind_property_full(source, Str.toStringz(sourceProperty), target, Str.toStringz(targetProperty), flags, transformTo, transformFrom, userData, notify); 281 282 if(p is null) 283 { 284 return null; 285 } 286 287 return ObjectG.getDObject!(Binding)(cast(GBinding*) p); 288 } 289 290 /** 291 * Creates a binding between source_property on source and target_property 292 * on target, allowing you to set the transformation functions to be used by 293 * the binding. 294 * This function is the language bindings friendly version of 295 * g_object_bind_property_full(), using GClosures instead of 296 * function pointers. 297 * Rename to: g_object_bind_property_full 298 * Since 2.26 299 * Params: 300 * source = the source GObject 301 * sourceProperty = the property on source to bind 302 * target = the target GObject 303 * targetProperty = the property on target to bind 304 * flags = flags to pass to GBinding 305 * transformTo = a GClosure wrapping the transformation function 306 * from the source to the target, or NULL to use the default 307 * transformFrom = a GClosure wrapping the transformation function 308 * from the target to the source, or NULL to use the default 309 * Returns: the GBinding instance representing the binding between the two GObject instances. The binding is released whenever the GBinding reference count reaches zero. [transfer none] 310 */ 311 public static Binding gObjectBindPropertyWithClosures(void* source, string sourceProperty, void* target, string targetProperty, GBindingFlags flags, Closure transformTo, Closure transformFrom) 312 { 313 // GBinding * g_object_bind_property_with_closures (gpointer source, const gchar *source_property, gpointer target, const gchar *target_property, GBindingFlags flags, GClosure *transform_to, GClosure *transform_from); 314 auto p = g_object_bind_property_with_closures(source, Str.toStringz(sourceProperty), target, Str.toStringz(targetProperty), flags, (transformTo is null) ? null : transformTo.getClosureStruct(), (transformFrom is null) ? null : transformFrom.getClosureStruct()); 315 316 if(p is null) 317 { 318 return null; 319 } 320 321 return ObjectG.getDObject!(Binding)(cast(GBinding*) p); 322 } 323 }