1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files.git)
// DO NOT EDIT

use crate::ShortcutAction;
use glib::translate::*;
use std::fmt;

glib::wrapper! {
    /// A [`Shortcut`][crate::Shortcut]Action that emits a signal.
    ///
    /// Signals that are used in this way are referred to as keybinding signals,
    /// and they are expected to be defined with the `G_SIGNAL_ACTION` flag.
    ///
    /// # Implements
    ///
    /// [`ShortcutActionExt`][trait@crate::prelude::ShortcutActionExt], [`trait@glib::ObjectExt`]
    #[doc(alias = "GtkSignalAction")]
    pub struct SignalAction(Object<ffi::GtkSignalAction, ffi::GtkSignalActionClass>) @extends ShortcutAction;

    match fn {
        type_ => || ffi::gtk_signal_action_get_type(),
    }
}

impl SignalAction {
    /// Creates an action that when activated, emits the given action signal
    /// on the provided widget.
    ///
    /// It will also unpack the args into arguments passed to the signal.
    /// ## `signal_name`
    /// name of the signal to emit
    ///
    /// # Returns
    ///
    /// a new [`ShortcutAction`][crate::ShortcutAction]
    #[doc(alias = "gtk_signal_action_new")]
    pub fn new(signal_name: &str) -> SignalAction {
        assert_initialized_main_thread!();
        unsafe { from_glib_full(ffi::gtk_signal_action_new(signal_name.to_glib_none().0)) }
    }

    /// Returns the name of the signal that will be emitted.
    ///
    /// # Returns
    ///
    /// the name of the signal to emit
    #[doc(alias = "gtk_signal_action_get_signal_name")]
    #[doc(alias = "get_signal_name")]
    pub fn signal_name(&self) -> glib::GString {
        unsafe {
            from_glib_none(ffi::gtk_signal_action_get_signal_name(
                self.to_glib_none().0,
            ))
        }
    }
}

impl fmt::Display for SignalAction {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.write_str("SignalAction")
    }
}