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  * GBinding is the representation of a binding between a property on a
81  * GObject instance (or source) and another property on another GObject
82  * instance (or target). Whenever the source property changes, the same
83  * value is applied to the target property; for instance, the following
84  * binding:
85  *
86  * $(DDOC_COMMENT example)
87  *
88  * will cause object2:property-b to be updated every
89  * time g_object_set() or the specific accessor changes the value of
90  * object1:property-a.
91  *
92  * It is possible to create a bidirectional binding between two properties
93  * of two GObject instances, so that if either property changes, the
94  * other is updated as well, for instance:
95  *
96  * $(DDOC_COMMENT example)
97  *
98  * will keep the two properties in sync.
99  *
100  * It is also possible to set a custom transformation function (in both
101  * directions, in case of a bidirectional binding) to apply a custom
102  * transformation from the source value to the target value before
103  * applying it; for instance, the following binding:
104  *
105  * $(DDOC_COMMENT example)
106  *
107  * will keep the value property of the two adjustments
108  * in sync; the celsius_to_fahrenheit function will be
109  * called whenever the adjustment1:value property changes
110  * and will transform the current value of the property before applying it
111  * to the adjustment2:value property; vice versa, the
112  * fahrenheit_to_celsius function will be called whenever
113  * the adjustment2:value property changes, and will
114  * transform the current value of the property before applying it to the
115  * adjustment1:value.
116  *
117  * Note that GBinding does not resolve cycles by itself; a cycle like
118  *
119  * $(DDOC_COMMENT example)
120  *
121  * might lead to an infinite loop. The loop, in this particular case,
122  * can be avoided if the objects emit the "notify" signal only
123  * if the value has effectively been changed. A binding is implemented
124  * using the "notify" signal, so it is susceptible to all the
125  * various ways of blocking a signal emission, like g_signal_stop_emission()
126  * or g_signal_handler_block().
127  *
128  * A binding will be severed, and the resources it allocates freed, whenever
129  * either one of the GObject instances it refers to are finalized, or when
130  * the GBinding instance loses its last reference.
131  *
132  * Note
133  *
134  * Bindings for languages with garbage collection can use
135  * g_binding_unbind() to explicitly release a binding between the source
136  * and target properties, instead of relying on the last reference on the
137  * binding, source, and target instances to drop.
138  *
139  * GBinding is available since GObject 2.26
140  */
141 public class Binding : ObjectG
142 {
143 	
144 	/** the main Gtk struct */
145 	protected GBinding* gBinding;
146 	
147 	
148 	public GBinding* getBindingStruct()
149 	{
150 		return gBinding;
151 	}
152 	
153 	
154 	/** the main Gtk struct as a void* */
155 	protected override void* getStruct()
156 	{
157 		return cast(void*)gBinding;
158 	}
159 	
160 	/**
161 	 * Sets our main struct and passes it to the parent class
162 	 */
163 	public this (GBinding* gBinding)
164 	{
165 		super(cast(GObject*)gBinding);
166 		this.gBinding = gBinding;
167 	}
168 	
169 	protected override void setStruct(GObject* obj)
170 	{
171 		super.setStruct(obj);
172 		gBinding = cast(GBinding*)obj;
173 	}
174 	
175 	/**
176 	 */
177 	
178 	/**
179 	 * Retrieves the GObject instance used as the source of the binding
180 	 * Since 2.26
181 	 * Returns: the source GObject. [transfer none]
182 	 */
183 	public ObjectG getSource()
184 	{
185 		// GObject * g_binding_get_source (GBinding *binding);
186 		auto p = g_binding_get_source(gBinding);
187 		
188 		if(p is null)
189 		{
190 			return null;
191 		}
192 		
193 		return ObjectG.getDObject!(ObjectG)(cast(GObject*) p);
194 	}
195 	
196 	/**
197 	 * Retrieves the name of the property of "source" used as the source
198 	 * of the binding
199 	 * Since 2.26
200 	 * Returns: the name of the source property
201 	 */
202 	public string getSourceProperty()
203 	{
204 		// const gchar * g_binding_get_source_property (GBinding *binding);
205 		return Str.toString(g_binding_get_source_property(gBinding));
206 	}
207 	
208 	/**
209 	 * Retrieves the GObject instance used as the target of the binding
210 	 * Since 2.26
211 	 * Returns: the target GObject. [transfer none]
212 	 */
213 	public ObjectG getTarget()
214 	{
215 		// GObject * g_binding_get_target (GBinding *binding);
216 		auto p = g_binding_get_target(gBinding);
217 		
218 		if(p is null)
219 		{
220 			return null;
221 		}
222 		
223 		return ObjectG.getDObject!(ObjectG)(cast(GObject*) p);
224 	}
225 	
226 	/**
227 	 * Retrieves the name of the property of "target" used as the target
228 	 * of the binding
229 	 * Since 2.26
230 	 * Returns: the name of the target property
231 	 */
232 	public string getTargetProperty()
233 	{
234 		// const gchar * g_binding_get_target_property (GBinding *binding);
235 		return Str.toString(g_binding_get_target_property(gBinding));
236 	}
237 	
238 	/**
239 	 * Retrieves the flags passed when constructing the GBinding
240 	 * Since 2.26
241 	 * Returns: the GBindingFlags used by the GBinding
242 	 */
243 	public GBindingFlags getFlags()
244 	{
245 		// GBindingFlags g_binding_get_flags (GBinding *binding);
246 		return g_binding_get_flags(gBinding);
247 	}
248 	
249 	/**
250 	 * Explicitly releases the binding between the source and the target
251 	 * property expressed by binding.
252 	 * Note
253 	 * This function will release the reference that is being held on
254 	 * the binding instance; if you want to hold on to the GBinding instance
255 	 * after calling g_binding_unbind(), you will need to hold a reference
256 	 * to it.
257 	 * Since 2.38
258 	 */
259 	public void unbind()
260 	{
261 		// void g_binding_unbind (GBinding *binding);
262 		g_binding_unbind(gBinding);
263 	}
264 	
265 	/**
266 	 * Creates a binding between source_property on source and target_property
267 	 * on target. Whenever the source_property is changed the target_property is
268 	 * Since 2.26
269 	 * Params:
270 	 * source = the source GObject. [type GObject.Object]
271 	 * sourceProperty = the property on source to bind
272 	 * target = the target GObject. [type GObject.Object]
273 	 * targetProperty = the property on target to bind
274 	 * flags = flags to pass to GBinding
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 gObjectBindProperty(void* source, string sourceProperty, void* target, string targetProperty, GBindingFlags flags)
278 	{
279 		// GBinding * g_object_bind_property (gpointer source,  const gchar *source_property,  gpointer target,  const gchar *target_property,  GBindingFlags flags);
280 		auto p = g_object_bind_property(source, Str.toStringz(sourceProperty), target, Str.toStringz(targetProperty), flags);
281 		
282 		if(p is null)
283 		{
284 			return null;
285 		}
286 		
287 		return ObjectG.getDObject!(Binding)(cast(GBinding*) p);
288 	}
289 	
290 	/**
291 	 * Complete version of g_object_bind_property().
292 	 * Creates a binding between source_property on source and target_property
293 	 * on target, allowing you to set the transformation functions to be used by
294 	 * the binding.
295 	 * Since 2.26
296 	 * Params:
297 	 * source = the source GObject. [type GObject.Object]
298 	 * sourceProperty = the property on source to bind
299 	 * target = the target GObject. [type GObject.Object]
300 	 * targetProperty = the property on target to bind
301 	 * flags = flags to pass to GBinding
302 	 * transformTo = the transformation function
303 	 * from the source to the target, or NULL to use the default. [scope notified][allow-none]
304 	 * transformFrom = the transformation function
305 	 * from the target to the source, or NULL to use the default. [scope notified][allow-none]
306 	 * userData = custom data to be passed to the transformation functions,
307 	 * or NULL
308 	 * notify = function to be called when disposing the binding, to free the
309 	 * resources used by the transformation functions
310 	 * 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]
311 	 */
312 	public static Binding gObjectBindPropertyFull(void* source, string sourceProperty, void* target, string targetProperty, GBindingFlags flags, GBindingTransformFunc transformTo, GBindingTransformFunc transformFrom, void* userData, GDestroyNotify notify)
313 	{
314 		// 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);
315 		auto p = g_object_bind_property_full(source, Str.toStringz(sourceProperty), target, Str.toStringz(targetProperty), flags, transformTo, transformFrom, userData, notify);
316 		
317 		if(p is null)
318 		{
319 			return null;
320 		}
321 		
322 		return ObjectG.getDObject!(Binding)(cast(GBinding*) p);
323 	}
324 	
325 	/**
326 	 * Creates a binding between source_property on source and target_property
327 	 * on target, allowing you to set the transformation functions to be used by
328 	 * the binding.
329 	 * This function is the language bindings friendly version of
330 	 * g_object_bind_property_full(), using GClosures instead of
331 	 * function pointers.
332 	 * Rename to: g_object_bind_property_full
333 	 * Since 2.26
334 	 * Params:
335 	 * source = the source GObject. [type GObject.Object]
336 	 * sourceProperty = the property on source to bind
337 	 * target = the target GObject. [type GObject.Object]
338 	 * targetProperty = the property on target to bind
339 	 * flags = flags to pass to GBinding
340 	 * transformTo = a GClosure wrapping the transformation function
341 	 * from the source to the target, or NULL to use the default
342 	 * transformFrom = a GClosure wrapping the transformation function
343 	 * from the target to the source, or NULL to use the default
344 	 * 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]
345 	 */
346 	public static Binding gObjectBindPropertyWithClosures(void* source, string sourceProperty, void* target, string targetProperty, GBindingFlags flags, Closure transformTo, Closure transformFrom)
347 	{
348 		// 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);
349 		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());
350 		
351 		if(p is null)
352 		{
353 			return null;
354 		}
355 		
356 		return ObjectG.getDObject!(Binding)(cast(GBinding*) p);
357 	}
358 }