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