Re: how to connect Gio::SimpleAction signal
- From: Daniel Boles <dboles src gmail com>
- To: gtkmm-list <gtkmm-list gnome org>
- Subject: Re: how to connect Gio::SimpleAction signal
- Date: Fri, 15 Dec 2017 10:08:55 +0000
The idea I have is that, rather than specifically handling a click on the menu item, you just set an action that is to be invoked whenever the menu item is activated.
Then GIO/GTK+ handle making clicks, pressing Enter, etc on the item invoke that action - so you don't have to worry about handling those low-level events manually.
So you won't be tying click handlers to actions or anything: you just set the action on the menu item, and then you get standard click/key handlers for free, which activate the action when the menu item is activated.
What you do with the VariantBase in the action callback is to cast it to whatever type you know it has. That is the type of your action and therefore your menu item: bool for toggles, int or string for radio actions, etc. So something like
void
on_action_activated(Glib::VariantBase const& variant)
{
auto the_boolean = Glib::Variant<bool>::cast_dynamic(variant).get();
do_something_with(the_boolean);
}
I don't have a more specific example to hand, but this is the general idea of how I would ahndle it.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]