source: appstream-generator/build/girepo/gobject/Binding.d @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 2 years ago

Initial release

File size: 6.5 KB
Line 
1/*
2 * Licensed under the GNU Lesser General Public License Version 3
3 *
4 * This library is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the license, or
7 * (at your option) any later version.
8 *
9 * This software is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library.  If not, see <http://www.gnu.org/licenses/>.
16 */
17
18// generated automatically - do not change
19
20
21module gobject.Binding;
22
23private import gi.gobject;
24public  import gi.gobjecttypes;
25private import glib.Str;
26private import gobject.ObjectG;
27
28
29/**
30 * #GBinding is the representation of a binding between a property on a
31 * #GObject instance (or source) and another property on another #GObject
32 * instance (or target). Whenever the source property changes, the same
33 * value is applied to the target property; for instance, the following
34 * binding:
35 *
36 * |[<!-- language="C" -->
37 * g_object_bind_property (object1, "property-a",
38 * object2, "property-b",
39 * G_BINDING_DEFAULT);
40 * ]|
41 *
42 * will cause the property named "property-b" of @object2 to be updated
43 * every time g_object_set() or the specific accessor changes the value of
44 * the property "property-a" of @object1.
45 *
46 * It is possible to create a bidirectional binding between two properties
47 * of two #GObject instances, so that if either property changes, the
48 * other is updated as well, for instance:
49 *
50 * |[<!-- language="C" -->
51 * g_object_bind_property (object1, "property-a",
52 * object2, "property-b",
53 * G_BINDING_BIDIRECTIONAL);
54 * ]|
55 *
56 * will keep the two properties in sync.
57 *
58 * It is also possible to set a custom transformation function (in both
59 * directions, in case of a bidirectional binding) to apply a custom
60 * transformation from the source value to the target value before
61 * applying it; for instance, the following binding:
62 *
63 * |[<!-- language="C" -->
64 * g_object_bind_property_full (adjustment1, "value",
65 * adjustment2, "value",
66 * G_BINDING_BIDIRECTIONAL,
67 * celsius_to_fahrenheit,
68 * fahrenheit_to_celsius,
69 * NULL, NULL);
70 * ]|
71 *
72 * will keep the "value" property of the two adjustments in sync; the
73 * @celsius_to_fahrenheit function will be called whenever the "value"
74 * property of @adjustment1 changes and will transform the current value
75 * of the property before applying it to the "value" property of @adjustment2.
76 *
77 * Vice versa, the @fahrenheit_to_celsius function will be called whenever
78 * the "value" property of @adjustment2 changes, and will transform the
79 * current value of the property before applying it to the "value" property
80 * of @adjustment1.
81 *
82 * Note that #GBinding does not resolve cycles by itself; a cycle like
83 *
84 * |[
85 * object1:propertyA -> object2:propertyB
86 * object2:propertyB -> object3:propertyC
87 * object3:propertyC -> object1:propertyA
88 * ]|
89 *
90 * might lead to an infinite loop. The loop, in this particular case,
91 * can be avoided if the objects emit the #GObject::notify signal only
92 * if the value has effectively been changed. A binding is implemented
93 * using the #GObject::notify signal, so it is susceptible to all the
94 * various ways of blocking a signal emission, like g_signal_stop_emission()
95 * or g_signal_handler_block().
96 *
97 * A binding will be severed, and the resources it allocates freed, whenever
98 * either one of the #GObject instances it refers to are finalized, or when
99 * the #GBinding instance loses its last reference.
100 *
101 * Bindings for languages with garbage collection can use
102 * g_binding_unbind() to explicitly release a binding between the source
103 * and target properties, instead of relying on the last reference on the
104 * binding, source, and target instances to drop.
105 *
106 * #GBinding is available since GObject 2.26
107 *
108 * Since: 2.26
109 */
110public class Binding : ObjectG
111{
112        /** the main Gtk struct */
113        protected GBinding* gBinding;
114
115        /** Get the main Gtk struct */
116        public GBinding* getBindingStruct()
117        {
118                return gBinding;
119        }
120
121        /** the main Gtk struct as a void* */
122        protected override void* getStruct()
123        {
124                return cast(void*)gBinding;
125        }
126
127        protected override void setStruct(GObject* obj)
128        {
129                gBinding = cast(GBinding*)obj;
130                super.setStruct(obj);
131        }
132
133        /**
134         * Sets our main struct and passes it to the parent class.
135         */
136        public this (GBinding* gBinding, bool ownedRef = false)
137        {
138                this.gBinding = gBinding;
139                super(cast(GObject*)gBinding, ownedRef);
140        }
141
142
143        /** */
144        public static GType getType()
145        {
146                return g_binding_get_type();
147        }
148
149        /**
150         * Retrieves the flags passed when constructing the #GBinding.
151         *
152         * Returns: the #GBindingFlags used by the #GBinding
153         *
154         * Since: 2.26
155         */
156        public GBindingFlags getFlags()
157        {
158                return g_binding_get_flags(gBinding);
159        }
160
161        /**
162         * Retrieves the #GObject instance used as the source of the binding.
163         *
164         * Returns: the source #GObject
165         *
166         * Since: 2.26
167         */
168        public ObjectG getSource()
169        {
170                auto p = g_binding_get_source(gBinding);
171               
172                if(p is null)
173                {
174                        return null;
175                }
176               
177                return ObjectG.getDObject!(ObjectG)(cast(GObject*) p);
178        }
179
180        /**
181         * Retrieves the name of the property of #GBinding:source used as the source
182         * of the binding.
183         *
184         * Returns: the name of the source property
185         *
186         * Since: 2.26
187         */
188        public string getSourceProperty()
189        {
190                return Str.toString(g_binding_get_source_property(gBinding));
191        }
192
193        /**
194         * Retrieves the #GObject instance used as the target of the binding.
195         *
196         * Returns: the target #GObject
197         *
198         * Since: 2.26
199         */
200        public ObjectG getTarget()
201        {
202                auto p = g_binding_get_target(gBinding);
203               
204                if(p is null)
205                {
206                        return null;
207                }
208               
209                return ObjectG.getDObject!(ObjectG)(cast(GObject*) p);
210        }
211
212        /**
213         * Retrieves the name of the property of #GBinding:target used as the target
214         * of the binding.
215         *
216         * Returns: the name of the target property
217         *
218         * Since: 2.26
219         */
220        public string getTargetProperty()
221        {
222                return Str.toString(g_binding_get_target_property(gBinding));
223        }
224
225        /**
226         * Explicitly releases the binding between the source and the target
227         * property expressed by @binding.
228         *
229         * This function will release the reference that is being held on
230         * the @binding instance; if you want to hold on to the #GBinding instance
231         * after calling g_binding_unbind(), you will need to hold a reference
232         * to it.
233         *
234         * Since: 2.38
235         */
236        public void unbind()
237        {
238                g_binding_unbind(gBinding);
239        }
240}
Note: See TracBrowser for help on using the repository browser.