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
// Take a look at the license at the top of the repository in the LICENSE file.

use crate::{Shortcut, ShortcutAction, ShortcutTrigger};
use glib::IsA;

impl Shortcut {
    /// Creates a new [`Shortcut`][crate::Shortcut] that is triggered by @trigger and then activates
    /// @action with arguments given by @format_string.
    /// ## `trigger`
    /// The trigger that will trigger the shortcut
    /// ## `action`
    /// The action that will be activated upon
    ///   triggering
    /// ## `format_string`
    /// GVariant format string for arguments or [`None`] for
    ///   no arguments
    ///
    /// # Returns
    ///
    /// a new [`Shortcut`][crate::Shortcut]
    #[doc(alias = "gtk_shortcut_new_with_arguments")]
    #[doc(alias = "new_with_arguments")]
    pub fn with_arguments(
        trigger: Option<&impl IsA<ShortcutTrigger>>,
        action: Option<&impl IsA<ShortcutAction>>,
        args: &glib::Variant,
    ) -> Self {
        assert_initialized_main_thread!();
        let shortcut = Shortcut::new(trigger, action);
        shortcut.set_arguments(Some(args));
        shortcut
    }
}