gtk4/auto/actionable.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
5#[cfg(feature = "v4_10")]
6#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
7use crate::Accessible;
8use crate::{Buildable, ConstraintTarget, Widget, ffi};
9use glib::{
10 prelude::*,
11 signal::{SignalHandlerId, connect_raw},
12 translate::*,
13};
14use std::boxed::Box as Box_;
15
16#[cfg(feature = "v4_10")]
17#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
18glib::wrapper! {
19 /// prefix that are associated with the
20 /// [`ApplicationWindow`][crate::ApplicationWindow] or [`Application`][crate::Application], but other action groups that
21 /// are added with [`WidgetExt::insert_action_group()`][crate::prelude::WidgetExt::insert_action_group()] will be consulted
22 /// as well.
23 ///
24 /// ## Properties
25 ///
26 ///
27 /// #### `action-name`
28 /// The name of the action with which this widget should be associated.
29 ///
30 /// Readable | Writable
31 ///
32 ///
33 /// #### `action-target`
34 /// The target value of the actionable widget's action.
35 ///
36 /// Readable | Writable
37 /// <details><summary><h4>Widget</h4></summary>
38 ///
39 ///
40 /// #### `can-focus`
41 /// Whether the widget or any of its descendents can accept
42 /// the input focus.
43 ///
44 /// This property is meant to be set by widget implementations,
45 /// typically in their instance init function.
46 ///
47 /// Readable | Writable
48 ///
49 ///
50 /// #### `can-target`
51 /// Whether the widget can receive pointer events.
52 ///
53 /// Readable | Writable
54 ///
55 ///
56 /// #### `css-classes`
57 /// A list of css classes applied to this widget.
58 ///
59 /// Readable | Writable
60 ///
61 ///
62 /// #### `css-name`
63 /// The name of this widget in the CSS tree.
64 ///
65 /// This property is meant to be set by widget implementations,
66 /// typically in their instance init function.
67 ///
68 /// Readable | Writable | Construct Only
69 ///
70 ///
71 /// #### `cursor`
72 /// The cursor used by @widget.
73 ///
74 /// Readable | Writable
75 ///
76 ///
77 /// #### `focus-on-click`
78 /// Whether the widget should grab focus when it is clicked with the mouse.
79 ///
80 /// This property is only relevant for widgets that can take focus.
81 ///
82 /// Readable | Writable
83 ///
84 ///
85 /// #### `focusable`
86 /// Whether this widget itself will accept the input focus.
87 ///
88 /// Readable | Writable
89 ///
90 ///
91 /// #### `halign`
92 /// How to distribute horizontal space if widget gets extra space.
93 ///
94 /// Readable | Writable
95 ///
96 ///
97 /// #### `has-default`
98 /// Whether the widget is the default widget.
99 ///
100 /// Readable
101 ///
102 ///
103 /// #### `has-focus`
104 /// Whether the widget has the input focus.
105 ///
106 /// Readable
107 ///
108 ///
109 /// #### `has-tooltip`
110 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
111 /// signal on @widget.
112 ///
113 /// A true value indicates that @widget can have a tooltip, in this case
114 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
115 /// determine whether it will provide a tooltip or not.
116 ///
117 /// Readable | Writable
118 ///
119 ///
120 /// #### `height-request`
121 /// Overrides for height request of the widget.
122 ///
123 /// If this is -1, the natural request will be used.
124 ///
125 /// Readable | Writable
126 ///
127 ///
128 /// #### `hexpand`
129 /// Whether to expand horizontally.
130 ///
131 /// Readable | Writable
132 ///
133 ///
134 /// #### `hexpand-set`
135 /// Whether to use the `hexpand` property.
136 ///
137 /// Readable | Writable
138 ///
139 ///
140 /// #### `layout-manager`
141 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
142 /// the preferred size of the widget, and allocate its children.
143 ///
144 /// This property is meant to be set by widget implementations,
145 /// typically in their instance init function.
146 ///
147 /// Readable | Writable
148 ///
149 ///
150 /// #### `limit-events`
151 /// Makes this widget act like a modal dialog, with respect to
152 /// event delivery.
153 ///
154 /// Global event controllers will not handle events with targets
155 /// inside the widget, unless they are set up to ignore propagation
156 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
157 ///
158 /// Readable | Writable
159 ///
160 ///
161 /// #### `margin-bottom`
162 /// Margin on bottom side of widget.
163 ///
164 /// This property adds margin outside of the widget's normal size
165 /// request, the margin will be added in addition to the size from
166 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
167 ///
168 /// Readable | Writable
169 ///
170 ///
171 /// #### `margin-end`
172 /// Margin on end of widget, horizontally.
173 ///
174 /// This property supports left-to-right and right-to-left text
175 /// directions.
176 ///
177 /// This property adds margin outside of the widget's normal size
178 /// request, the margin will be added in addition to the size from
179 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
180 ///
181 /// Readable | Writable
182 ///
183 ///
184 /// #### `margin-start`
185 /// Margin on start of widget, horizontally.
186 ///
187 /// This property supports left-to-right and right-to-left text
188 /// directions.
189 ///
190 /// This property adds margin outside of the widget's normal size
191 /// request, the margin will be added in addition to the size from
192 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
193 ///
194 /// Readable | Writable
195 ///
196 ///
197 /// #### `margin-top`
198 /// Margin on top side of widget.
199 ///
200 /// This property adds margin outside of the widget's normal size
201 /// request, the margin will be added in addition to the size from
202 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
203 ///
204 /// Readable | Writable
205 ///
206 ///
207 /// #### `name`
208 /// The name of the widget.
209 ///
210 /// Readable | Writable
211 ///
212 ///
213 /// #### `opacity`
214 /// The requested opacity of the widget.
215 ///
216 /// Readable | Writable
217 ///
218 ///
219 /// #### `overflow`
220 /// How content outside the widget's content area is treated.
221 ///
222 /// This property is meant to be set by widget implementations,
223 /// typically in their instance init function.
224 ///
225 /// Readable | Writable
226 ///
227 ///
228 /// #### `parent`
229 /// The parent widget of this widget.
230 ///
231 /// Readable
232 ///
233 ///
234 /// #### `receives-default`
235 /// Whether the widget will receive the default action when it is focused.
236 ///
237 /// Readable | Writable
238 ///
239 ///
240 /// #### `root`
241 /// The [`Root`][crate::Root] widget of the widget tree containing this widget.
242 ///
243 /// This will be `NULL` if the widget is not contained in a root widget.
244 ///
245 /// Readable
246 ///
247 ///
248 /// #### `scale-factor`
249 /// The scale factor of the widget.
250 ///
251 /// Readable
252 ///
253 ///
254 /// #### `sensitive`
255 /// Whether the widget responds to input.
256 ///
257 /// Readable | Writable
258 ///
259 ///
260 /// #### `tooltip-markup`
261 /// Sets the text of tooltip to be the given string, which is marked up
262 /// with Pango markup.
263 ///
264 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
265 ///
266 /// This is a convenience property which will take care of getting the
267 /// tooltip shown if the given string is not `NULL`:
268 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
269 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
270 /// the default signal handler.
271 ///
272 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
273 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
274 ///
275 /// Readable | Writable
276 ///
277 ///
278 /// #### `tooltip-text`
279 /// Sets the text of tooltip to be the given string.
280 ///
281 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
282 ///
283 /// This is a convenience property which will take care of getting the
284 /// tooltip shown if the given string is not `NULL`:
285 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
286 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
287 /// the default signal handler.
288 ///
289 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
290 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
291 ///
292 /// Readable | Writable
293 ///
294 ///
295 /// #### `valign`
296 /// How to distribute vertical space if widget gets extra space.
297 ///
298 /// Readable | Writable
299 ///
300 ///
301 /// #### `vexpand`
302 /// Whether to expand vertically.
303 ///
304 /// Readable | Writable
305 ///
306 ///
307 /// #### `vexpand-set`
308 /// Whether to use the `vexpand` property.
309 ///
310 /// Readable | Writable
311 ///
312 ///
313 /// #### `visible`
314 /// Whether the widget is visible.
315 ///
316 /// Readable | Writable
317 ///
318 ///
319 /// #### `width-request`
320 /// Overrides for width request of the widget.
321 ///
322 /// If this is -1, the natural request will be used.
323 ///
324 /// Readable | Writable
325 /// </details>
326 /// <details><summary><h4>Accessible</h4></summary>
327 ///
328 ///
329 /// #### `accessible-role`
330 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
331 ///
332 /// The accessible role cannot be changed once set.
333 ///
334 /// Readable | Writable
335 /// </details>
336 ///
337 /// # Implements
338 ///
339 /// [`ActionableExt`][trait@crate::prelude::ActionableExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`ActionableExtManual`][trait@crate::prelude::ActionableExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual]
340 #[doc(alias = "GtkActionable")]
341 pub struct Actionable(Interface<ffi::GtkActionable, ffi::GtkActionableInterface>) @requires Widget, Accessible, Buildable, ConstraintTarget;
342
343 match fn {
344 type_ => || ffi::gtk_actionable_get_type(),
345 }
346}
347
348#[cfg(not(feature = "v4_10"))]
349glib::wrapper! {
350 #[doc(alias = "GtkActionable")]
351 pub struct Actionable(Interface<ffi::GtkActionable, ffi::GtkActionableInterface>) @requires Widget, Buildable, ConstraintTarget;
352
353 match fn {
354 type_ => || ffi::gtk_actionable_get_type(),
355 }
356}
357
358impl Actionable {
359 pub const NONE: Option<&'static Actionable> = None;
360}
361
362/// Trait containing all [`struct@Actionable`] methods.
363///
364/// # Implementors
365///
366/// [`Actionable`][struct@crate::Actionable], [`Button`][struct@crate::Button], [`CheckButton`][struct@crate::CheckButton], [`LinkButton`][struct@crate::LinkButton], [`ListBoxRow`][struct@crate::ListBoxRow], [`LockButton`][struct@crate::LockButton], [`Switch`][struct@crate::Switch], [`ToggleButton`][struct@crate::ToggleButton]
367pub trait ActionableExt: IsA<Actionable> + 'static {
368 /// Gets the action name for @self.
369 ///
370 /// # Returns
371 ///
372 /// the action name
373 #[doc(alias = "gtk_actionable_get_action_name")]
374 #[doc(alias = "get_action_name")]
375 #[doc(alias = "action-name")]
376 fn action_name(&self) -> Option<glib::GString> {
377 unsafe {
378 from_glib_none(ffi::gtk_actionable_get_action_name(
379 self.as_ref().to_glib_none().0,
380 ))
381 }
382 }
383
384 /// Gets the current target value of @self.
385 ///
386 /// # Returns
387 ///
388 /// the current target value
389 #[doc(alias = "gtk_actionable_get_action_target_value")]
390 #[doc(alias = "get_action_target_value")]
391 #[doc(alias = "action-target")]
392 fn action_target_value(&self) -> Option<glib::Variant> {
393 unsafe {
394 from_glib_none(ffi::gtk_actionable_get_action_target_value(
395 self.as_ref().to_glib_none().0,
396 ))
397 }
398 }
399
400 /// for actions on the
401 /// containing [`ApplicationWindow`][crate::ApplicationWindow] or its associated [`Application`][crate::Application],
402 /// respectively. This is the same form used for actions in the [`gio::Menu`][crate::gio::Menu]
403 /// associated with the window.
404 /// ## `action_name`
405 /// an action name
406 #[doc(alias = "gtk_actionable_set_action_name")]
407 #[doc(alias = "action-name")]
408 fn set_action_name(&self, action_name: Option<&str>) {
409 unsafe {
410 ffi::gtk_actionable_set_action_name(
411 self.as_ref().to_glib_none().0,
412 action_name.to_glib_none().0,
413 );
414 }
415 }
416
417 /// s state
418 /// is now equal to the target value of the button, the button will now
419 /// be rendered as active (and the other buttons, with different targets,
420 /// rendered inactive).
421 /// ## `target_value`
422 /// a [`glib::Variant`][struct@crate::glib::Variant] to set as the target value
423 #[doc(alias = "gtk_actionable_set_action_target_value")]
424 #[doc(alias = "action-target")]
425 fn set_action_target_value(&self, target_value: Option<&glib::Variant>) {
426 unsafe {
427 ffi::gtk_actionable_set_action_target_value(
428 self.as_ref().to_glib_none().0,
429 target_value.to_glib_none().0,
430 );
431 }
432 }
433
434 /// Sets the action-name and associated string target value of an
435 /// actionable widget.
436 ///
437 /// @detailed_action_name is a string in the format accepted by
438 /// [`gio::Action::parse_detailed_name()`][crate::gio::Action::parse_detailed_name()].
439 /// ## `detailed_action_name`
440 /// the detailed action name
441 #[doc(alias = "gtk_actionable_set_detailed_action_name")]
442 fn set_detailed_action_name(&self, detailed_action_name: &str) {
443 unsafe {
444 ffi::gtk_actionable_set_detailed_action_name(
445 self.as_ref().to_glib_none().0,
446 detailed_action_name.to_glib_none().0,
447 );
448 }
449 }
450
451 #[doc(alias = "action-name")]
452 fn connect_action_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
453 unsafe extern "C" fn notify_action_name_trampoline<
454 P: IsA<Actionable>,
455 F: Fn(&P) + 'static,
456 >(
457 this: *mut ffi::GtkActionable,
458 _param_spec: glib::ffi::gpointer,
459 f: glib::ffi::gpointer,
460 ) {
461 unsafe {
462 let f: &F = &*(f as *const F);
463 f(Actionable::from_glib_borrow(this).unsafe_cast_ref())
464 }
465 }
466 unsafe {
467 let f: Box_<F> = Box_::new(f);
468 connect_raw(
469 self.as_ptr() as *mut _,
470 c"notify::action-name".as_ptr(),
471 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
472 notify_action_name_trampoline::<Self, F> as *const (),
473 )),
474 Box_::into_raw(f),
475 )
476 }
477 }
478
479 #[doc(alias = "action-target")]
480 fn connect_action_target_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
481 unsafe extern "C" fn notify_action_target_trampoline<
482 P: IsA<Actionable>,
483 F: Fn(&P) + 'static,
484 >(
485 this: *mut ffi::GtkActionable,
486 _param_spec: glib::ffi::gpointer,
487 f: glib::ffi::gpointer,
488 ) {
489 unsafe {
490 let f: &F = &*(f as *const F);
491 f(Actionable::from_glib_borrow(this).unsafe_cast_ref())
492 }
493 }
494 unsafe {
495 let f: Box_<F> = Box_::new(f);
496 connect_raw(
497 self.as_ptr() as *mut _,
498 c"notify::action-target".as_ptr(),
499 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
500 notify_action_target_trampoline::<Self, F> as *const (),
501 )),
502 Box_::into_raw(f),
503 )
504 }
505 }
506}
507
508impl<O: IsA<Actionable>> ActionableExt for O {}