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