glib/gobject/auto/binding.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{BindingFlags, ffi, translate::*};
6
7crate::wrapper! {
8 /// object1:propertyA
9 /// ```text
10 ///
11 /// might lead to an infinite loop. The loop, in this particular case,
12 /// can be avoided if the objects emit the `GObject::notify` signal only
13 /// if the value has effectively been changed. A binding is implemented
14 /// using the `GObject::notify` signal, so it is susceptible to all the
15 /// various ways of blocking a signal emission, like `signal_stop_emission()`
16 /// or `signal_handler_block()`.
17 ///
18 /// A binding will be severed, and the resources it allocates freed, whenever
19 /// either one of the `GObject` instances it refers to are finalized, or when
20 /// the #GBinding instance loses its last reference.
21 ///
22 /// Bindings for languages with garbage collection can use
23 /// [`unbind()`][Self::unbind()] to explicitly release a binding between the source
24 /// and target properties, instead of relying on the last reference on the
25 /// binding, source, and target instances to drop.
26 ///
27 /// ## Properties
28 ///
29 ///
30 /// #### `flags`
31 /// Flags to be used to control the #GBinding
32 ///
33 /// Readable | Writable | Construct Only
34 ///
35 ///
36 /// #### `source`
37 /// The #GObject that should be used as the source of the binding
38 ///
39 /// Readable | Writable | Construct Only
40 ///
41 ///
42 /// #### `source-property`
43 /// The name of the property of #GBinding:source that should be used
44 /// as the source of the binding.
45 ///
46 /// This should be in [canonical form][`ParamSpec`][crate::ParamSpec]#parameter-names] to get the
47 /// best performance.
48 ///
49 /// Readable | Writable | Construct Only
50 ///
51 ///
52 /// #### `target`
53 /// The #GObject that should be used as the target of the binding
54 ///
55 /// Readable | Writable | Construct Only
56 ///
57 ///
58 /// #### `target-property`
59 /// The name of the property of #GBinding:target that should be used
60 /// as the target of the binding.
61 ///
62 /// This should be in [canonical form][`ParamSpec`][crate::ParamSpec]#parameter-names] to get the
63 /// best performance.
64 ///
65 /// Readable | Writable | Construct Only
66 ///
67 /// # Implements
68 ///
69 /// [`ObjectExt`][trait@crate::prelude::ObjectExt]
70 #[doc(alias = "GBinding")]
71 pub struct Binding(Object<crate::gobject_ffi::GBinding>);
72
73 match fn {
74 type_ => || crate::gobject_ffi::g_binding_get_type(),
75 }
76}
77
78impl Binding {
79 /// Retrieves the flags passed when constructing the #GBinding.
80 ///
81 /// # Returns
82 ///
83 /// the #GBindingFlags used by the #GBinding
84 #[doc(alias = "g_binding_get_flags")]
85 #[doc(alias = "get_flags")]
86 pub fn flags(&self) -> BindingFlags {
87 unsafe {
88 from_glib(crate::gobject_ffi::g_binding_get_flags(
89 self.to_glib_none().0,
90 ))
91 }
92 }
93
94 /// Retrieves the name of the property of #GBinding:source used as the source
95 /// of the binding.
96 ///
97 /// # Returns
98 ///
99 /// the name of the source property
100 #[doc(alias = "g_binding_get_source_property")]
101 #[doc(alias = "get_source_property")]
102 #[doc(alias = "source-property")]
103 pub fn source_property(&self) -> crate::GString {
104 unsafe {
105 from_glib_none(crate::gobject_ffi::g_binding_get_source_property(
106 self.to_glib_none().0,
107 ))
108 }
109 }
110
111 /// Retrieves the name of the property of #GBinding:target used as the target
112 /// of the binding.
113 ///
114 /// # Returns
115 ///
116 /// the name of the target property
117 #[doc(alias = "g_binding_get_target_property")]
118 #[doc(alias = "get_target_property")]
119 #[doc(alias = "target-property")]
120 pub fn target_property(&self) -> crate::GString {
121 unsafe {
122 from_glib_none(crate::gobject_ffi::g_binding_get_target_property(
123 self.to_glib_none().0,
124 ))
125 }
126 }
127
128 /// Explicitly releases the binding between the source and the target
129 /// property expressed by @self.
130 ///
131 /// This function will release the reference that is being held on
132 /// the @self instance if the binding is still bound; if you want to hold on
133 /// to the #GBinding instance after calling g_binding_unbind(), you will need
134 /// to hold a reference to it.
135 ///
136 /// Note however that this function does not take ownership of @self, it
137 /// only unrefs the reference that was initially created by
138 /// g_object_bind_property() and is owned by the binding.
139 #[doc(alias = "g_binding_unbind")]
140 pub fn unbind(&self) {
141 unsafe {
142 crate::gobject_ffi::g_binding_unbind(self.to_glib_none().0);
143 }
144 }
145}
146
147unsafe impl Send for Binding {}
148unsafe impl Sync for Binding {}