Commit 90146a59 authored by Bilal Elmoussaoui's avatar Bilal Elmoussaoui

Merge branch 'bilelmoussaoui/get-action' into 'master'

actions: add a get_action! macro

See merge request !1
parents 87d54fd0 cf75ce2a
Pipeline #157366 passed with stages
in 7 minutes and 11 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 = $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