gtk-rs / gtk-rs-core

Rust bindings for GNOME libraries
https://gtk-rs.org/gtk-rs-core
MIT License
293 stars 115 forks source link

[FEATURE REQUEST] Extend ActionMapExtManual::add_action_entries for usage with gio::SimpleActionGroup #1568

Open andy128k opened 2 weeks ago

andy128k commented 2 weeks ago

ActionMapExtManual::add_action_entries is defined like

fn add_action_entries(&self, entries: impl IntoIterator<Item = ActionEntry<Self>>)

This works well when an object implements gio::ActionMap (e.g. gtk::Application) and action handlers receive a reference to an object. But it's problematic to use this function with gio::SimpleActionGroup attached to an arbitrary widget, because it assumes that handlers receive a group and not a widget reference.

Could this function be extended and be generic over handlers' recipients' type?

bilelmoussaoui commented 2 weeks ago

That is basically the C API. A random widget doesn't necessarily implement GActionMap and it is probably easier to use the install_action helpers in this case