gtk4/shortcut.rs
1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use crate::{prelude::*, Shortcut, ShortcutAction, ShortcutTrigger};
4
5impl Shortcut {
6 /// Creates a new [`Shortcut`][crate::Shortcut] that is triggered by @trigger and then activates
7 /// @action with arguments given by @format_string.
8 /// ## `trigger`
9 /// The trigger that will trigger the shortcut
10 /// ## `action`
11 /// The action that will be activated upon
12 /// triggering
13 /// ## `format_string`
14 /// GVariant format string for arguments or [`None`] for
15 /// no arguments
16 ///
17 /// # Returns
18 ///
19 /// a new [`Shortcut`][crate::Shortcut]
20 #[doc(alias = "gtk_shortcut_new_with_arguments")]
21 #[doc(alias = "new_with_arguments")]
22 pub fn with_arguments(
23 trigger: Option<impl IsA<ShortcutTrigger>>,
24 action: Option<impl IsA<ShortcutAction>>,
25 args: &glib::Variant,
26 ) -> Self {
27 assert_initialized_main_thread!();
28 let shortcut = Shortcut::new(trigger, action);
29 shortcut.set_arguments(Some(args));
30 shortcut
31 }
32}