Commit 387f4ee0 authored by Bilal Elmoussaoui's avatar Bilal Elmoussaoui

actions: add a get_action! macro

parent 87d54fd0
Pipeline #157362 passed with stage
in 2 minutes and 7 seconds
......@@ -43,3 +43,24 @@ macro_rules! stateful_action {
$actions_group.add_action(&simple_action);
};
}
#[macro_export]
macro_rules! get_action {
($actions:expr, @$name:ident) => {{
let $name = $actions
.lookup_action(stringify!($name))
.expect(&format!("Could not find action \"{}\"", stringify!($name)))
.downcast::<gio::SimpleAction>()
.unwrap();
$name
}};
($actions:expr, $name:ident) => {
let $name: gio::SimpleAction = $actions
.lookup_action(stringify!($name))
.expect(&format!("Could not find action \"{}\"", stringify!($name)))
.downcast::<gio::SimpleAction>()
.unwrap();
};
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment