gtk4/auto/
signal_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 [`Shortcut`][crate::Shortcut]Action that emits a signal.
10    ///
11    /// Signals that are used in this way are referred to as keybinding signals,
12    /// and they are expected to be defined with the `G_SIGNAL_ACTION` flag.
13    ///
14    /// ## Properties
15    ///
16    ///
17    /// #### `signal-name`
18    ///  The name of the signal to emit.
19    ///
20    /// Readable | Writeable | Construct Only
21    ///
22    /// # Implements
23    ///
24    /// [`ShortcutActionExt`][trait@crate::prelude::ShortcutActionExt], [`trait@glib::ObjectExt`]
25    #[doc(alias = "GtkSignalAction")]
26    pub struct SignalAction(Object<ffi::GtkSignalAction, ffi::GtkSignalActionClass>) @extends ShortcutAction;
27
28    match fn {
29        type_ => || ffi::gtk_signal_action_get_type(),
30    }
31}
32
33impl SignalAction {
34    /// Creates an action that when activated, emits the given action signal
35    /// on the provided widget.
36    ///
37    /// It will also unpack the args into arguments passed to the signal.
38    /// ## `signal_name`
39    /// name of the signal to emit
40    ///
41    /// # Returns
42    ///
43    /// a new [`ShortcutAction`][crate::ShortcutAction]
44    #[doc(alias = "gtk_signal_action_new")]
45    pub fn new(signal_name: &str) -> SignalAction {
46        assert_initialized_main_thread!();
47        unsafe { from_glib_full(ffi::gtk_signal_action_new(signal_name.to_glib_none().0)) }
48    }
49
50    /// Returns the name of the signal that will be emitted.
51    ///
52    /// # Returns
53    ///
54    /// the name of the signal to emit
55    #[doc(alias = "gtk_signal_action_get_signal_name")]
56    #[doc(alias = "get_signal_name")]
57    #[doc(alias = "signal-name")]
58    pub fn signal_name(&self) -> glib::GString {
59        unsafe {
60            from_glib_none(ffi::gtk_signal_action_get_signal_name(
61                self.to_glib_none().0,
62            ))
63        }
64    }
65}