Commit cf75ce2a authored by Bilal Elmoussaoui's avatar Bilal Elmoussaoui

get_action! no need to specify the type

we already cast it to a gio::SimpleAction
hence the compiler can figure out the type
parent 87d54fd0
......@@ -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