Re: how to connect Gio::SimpleAction signal



Hi Daniel, Thanks for your replay.
I found two things while perusing the documentation:
1. I nedd to connect either the signal_activate or signal_state_changed
of the SimpleAction if I don't want default behavior.
2. There's a 'TODO' note saying that documentation is needed about how
to connect the signals.

I'm still playing around with things, but what I really need is a
tutorial about how to use Variant/BariantBase. I'm getting stuck every
time I run into it. There doesn't seem to be much explanation about
it. I assumed it was along the lines of void*, where you can use it for
any data type. Is there something to explain how to use it? A good
example about this stuff would really be appreciated.
Thanks for your help,
Marty


On Fri, 2017-12-15 at 10:08 +0000, Daniel Boles wrote:
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.


_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
https://mail.gnome.org/mailman/listinfo/gtkmm-list


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]