gio/auto/property_action.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::{Action, ffi};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9 /// its state is the property value.
10 ///
11 /// For example, it might be useful to create a [`Action`][crate::Action] corresponding
12 /// to the `visible-child-name` property of a [`GtkStack`](https://docs.gtk.org/gtk4/class.Stack.html)
13 /// so that the current page can be switched from a menu. The active radio
14 /// indication in the menu is then directly determined from the active page of
15 /// the `GtkStack`.
16 ///
17 /// An anti-example would be binding the `active-id` property on a
18 /// [`GtkComboBox`](https://docs.gtk.org/gtk4/class.ComboBox.html). This is
19 /// because the state of the combo box itself is probably uninteresting and is
20 /// actually being used to control something else.
21 ///
22 /// Another anti-example would be to bind to the `visible-child-name`
23 /// property of a [`GtkStack`](https://docs.gtk.org/gtk4/class.Stack.html) if
24 /// this value is actually stored in [`Settings`][crate::Settings]. In that case, the
25 /// real source of the value is* [`Settings`][crate::Settings]. If you want
26 /// a [`Action`][crate::Action] to control a setting stored in [`Settings`][crate::Settings],
27 /// see [`SettingsExt::create_action()`][crate::prelude::SettingsExt::create_action()] instead, and possibly combine its
28 /// use with [`SettingsExtManual::bind()`][crate::prelude::SettingsExtManual::bind()].
29 ///
30 /// ## Properties
31 ///
32 ///
33 /// #### `enabled`
34 /// If @action is currently enabled.
35 ///
36 /// If the action is disabled then calls to g_action_activate() and
37 /// g_action_change_state() have no effect.
38 ///
39 /// Readable
40 ///
41 ///
42 /// #### `invert-boolean`
43 /// If [`true`], the state of the action will be the negation of the
44 /// property value, provided the property is boolean.
45 ///
46 /// Readable | Writable | Construct Only
47 ///
48 ///
49 /// #### `name`
50 /// The name of the action. This is mostly meaningful for identifying
51 /// the action once it has been added to a #GActionMap.
52 ///
53 /// Readable | Writable | Construct Only
54 ///
55 ///
56 /// #### `object`
57 /// The object to wrap a property on.
58 ///
59 /// The object must be a non-[`None`] #GObject with properties.
60 ///
61 /// Writable | Construct Only
62 ///
63 ///
64 /// #### `parameter-type`
65 /// The type of the parameter that must be given when activating the
66 /// action.
67 ///
68 /// Readable
69 ///
70 ///
71 /// #### `property-name`
72 /// The name of the property to wrap on the object.
73 ///
74 /// The property must exist on the passed-in object and it must be
75 /// readable and writable (and not construct-only).
76 ///
77 /// Writable | Construct Only
78 ///
79 ///
80 /// #### `state`
81 /// The state of the action, or [`None`] if the action is stateless.
82 ///
83 /// Readable
84 ///
85 ///
86 /// #### `state-type`
87 /// The #GVariantType of the state that the action has, or [`None`] if the
88 /// action is stateless.
89 ///
90 /// Readable
91 /// <details><summary><h4>Action</h4></summary>
92 ///
93 ///
94 /// #### `enabled`
95 /// If @action is currently enabled.
96 ///
97 /// If the action is disabled then calls to [`ActionExt::activate()`][crate::prelude::ActionExt::activate()] and
98 /// [`ActionExt::change_state()`][crate::prelude::ActionExt::change_state()] have no effect.
99 ///
100 /// Readable
101 ///
102 ///
103 /// #### `name`
104 /// The name of the action. This is mostly meaningful for identifying
105 /// the action once it has been added to a [type@Gio.ActionGroup]. It is immutable.
106 ///
107 /// Readable
108 ///
109 ///
110 /// #### `parameter-type`
111 /// The type of the parameter that must be given when activating the
112 /// action. This is immutable, and may be `NULL` if no parameter is needed when
113 /// activating the action.
114 ///
115 /// Readable
116 ///
117 ///
118 /// #### `state`
119 /// The state of the action, or `NULL` if the action is stateless.
120 ///
121 /// Readable
122 ///
123 ///
124 /// #### `state-type`
125 /// The [type@GLib.VariantType] of the state that the action has, or `NULL` if the
126 /// action is stateless. This is immutable.
127 ///
128 /// Readable
129 /// </details>
130 ///
131 /// # Implements
132 ///
133 /// [`trait@glib::ObjectExt`], [`ActionExt`][trait@crate::prelude::ActionExt]
134 #[doc(alias = "GPropertyAction")]
135 pub struct PropertyAction(Object<ffi::GPropertyAction>) @implements Action;
136
137 match fn {
138 type_ => || ffi::g_property_action_get_type(),
139 }
140}
141
142impl PropertyAction {
143 /// Creates a #GAction corresponding to the value of property
144 /// @property_name on @object.
145 ///
146 /// The property must be existent and readable and writable (and not
147 /// construct-only).
148 ///
149 /// This function takes a reference on @object and doesn't release it
150 /// until the action is destroyed.
151 /// ## `name`
152 /// the name of the action to create
153 /// ## `object`
154 /// the object that has the property
155 /// to wrap
156 /// ## `property_name`
157 /// the name of the property
158 ///
159 /// # Returns
160 ///
161 /// a new #GPropertyAction
162 #[doc(alias = "g_property_action_new")]
163 pub fn new(name: &str, object: &impl IsA<glib::Object>, property_name: &str) -> PropertyAction {
164 unsafe {
165 from_glib_full(ffi::g_property_action_new(
166 name.to_glib_none().0,
167 object.as_ref().to_glib_none().0,
168 property_name.to_glib_none().0,
169 ))
170 }
171 }
172
173 /// If [`true`], the state of the action will be the negation of the
174 /// property value, provided the property is boolean.
175 #[doc(alias = "invert-boolean")]
176 pub fn inverts_boolean(&self) -> bool {
177 ObjectExt::property(self, "invert-boolean")
178 }
179}