Macro gtk_macros::action[][src]

macro_rules! action {
    ($actions_group:expr, $name:expr, $callback:expr) => { ... };
    ($actions_group:expr, $name:expr, $param_type:expr, $callback:expr) => { ... };
}

Create a new action

  • Before:

    Example:

    let widget = get_widget!(builder, gtk::Window, widget);
    let actions = gio::SimpleActionGroup::new();
    widget.insert_action_group("export", Some(&actions));
    
    let action = gio::SimpleAction::new("do", None);
    action.connect_activate(move |action, _| {
        // Do something
    });
    actions.add_action(&action);
  • After:

    Example:

    let widget = get_widget!(builder, gtk::Window, widget);
    let actions = gio::SimpleActionGroup::new();
    widget.insert_action_group("export", Some(&actions));
    action!(
        actions,
        "do",
        move |action, _| {
            // Do something
        },
    );