gtk4/auto/
named_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::{ffi, ShortcutAction};
6use glib::translate::*;
7
8glib::wrapper! {
9    /// Activates a named action.
10    ///
11    /// See [`WidgetClassExt::install_action()`][crate::subclass::prelude::WidgetClassExt::install_action()] and
12    /// [`WidgetExt::insert_action_group()`][crate::prelude::WidgetExt::insert_action_group()] for ways
13    /// to associate named actions with widgets.
14    ///
15    /// ## Properties
16    ///
17    ///
18    /// #### `action-name`
19    ///  The name of the action to activate.
20    ///
21    /// Readable | Writeable | Construct Only
22    ///
23    /// # Implements
24    ///
25    /// [`ShortcutActionExt`][trait@crate::prelude::ShortcutActionExt], [`trait@glib::ObjectExt`]
26    #[doc(alias = "GtkNamedAction")]
27    pub struct NamedAction(Object<ffi::GtkNamedAction, ffi::GtkNamedActionClass>) @extends ShortcutAction;
28
29    match fn {
30        type_ => || ffi::gtk_named_action_get_type(),
31    }
32}
33
34impl NamedAction {
35    /// Creates an action that when activated, activates
36    /// the named action on the widget.
37    ///
38    /// It also passes the given arguments to it.
39    ///
40    /// See [`WidgetExt::insert_action_group()`][crate::prelude::WidgetExt::insert_action_group()] for
41    /// how to add actions to widgets.
42    /// ## `name`
43    /// the detailed name of the action
44    ///
45    /// # Returns
46    ///
47    /// a new [`ShortcutAction`][crate::ShortcutAction]
48    #[doc(alias = "gtk_named_action_new")]
49    pub fn new(name: &str) -> NamedAction {
50        assert_initialized_main_thread!();
51        unsafe { from_glib_full(ffi::gtk_named_action_new(name.to_glib_none().0)) }
52    }
53
54    /// Returns the name of the action that will be activated.
55    ///
56    /// # Returns
57    ///
58    /// the name of the action to activate
59    #[doc(alias = "gtk_named_action_get_action_name")]
60    #[doc(alias = "get_action_name")]
61    #[doc(alias = "action-name")]
62    pub fn action_name(&self) -> glib::GString {
63        unsafe { from_glib_none(ffi::gtk_named_action_get_action_name(self.to_glib_none().0)) }
64    }
65}