Gtk-rs, applications, builders and menus


I am trying to get the GTK+3 application menu working in Rust. In C++ I loaded the gio::Menu from an XML file using a builder and then used add_action to associate lambda expressions with the action attributes. Something very, very like:

auto menu_builder = Gtk::Builder::create();
if (menu_builder->add_from_resource("/me-tv/application_menu.xml")) {
	auto const application_menu = Glib::RefPtr<Gio::Menu>::cast_dynamic(menu_builder->get_object("application_menu"));
	if (!application_menu) { g_warning("Application menu not found."); }
	else { set_app_menu(application_menu); }
else { std::cout << "Could not load the menu UI string specification." << std::endl; }
add_action("about", []{ About::show(); }); // TODO Show the about top left not centred.
add_action("quit", [this]{ quit(); });

It’s those last two lines that have me flumoxed trying to port to Rust.

let menu_builder = gtk::Builder::new_from_string(include_str!("resources/application_menu.xml"));
let application_menu = menu_builder.get_object::<gio::MenuModel>("application_menu").unwrap();

gets the menu items on the menu, but how to get the actions associated with clicking the menus? There appears to be no equivalent add_action function/method in any of the traits to bind a closure to the action attribute of the menu model.

Unless I am just failing to “Google” things correctly.