Re: Enable / disable a Gio::SimpleAction.



On 2020-10-05 17:07, Kjell Ahlstedt wrote:

Gio::SimpleActionGroup belongs to glibmm, not to gtkmm. Both gtkmm 2.x and gtkmm 3.x use glibmm versions from the glibmm-2.4 ABI series. I don't understand how you can do what you say you do in gtkmm 2.x. Haven't you used Gtk::ActionGroup and Gtk::Action?  Something like

    Glib::RefPtr<Gtk::ActionGroup> m_refActionGroup;
...
    m_refActionGroup->get_action("PlacepieceBlackPawn")->set_sensitive(row != 0 && row != 7);

Gtk::ActionGroup and Gtk::Action are deprecated in gtkmm 3.x and removed in gtkmm 4.x.

How do you add the Gio::SimpleAction to the Gio::SimpleActionGroup? I suppose you have a

	Glib::RefPtr<Gio::SimpleAction> refPlacepieceBlackPawn = ......
or a
	m_refActionGroup->add_action("PlacepieceBlackPawn");

that returns a Glib::RefPtr<Gio::SimpleAction>.	

Then it would be easy to save that Glib::RefPtr<Gio::SimpleAction>, so you don't need lookup_action().
If you prefer lookup_action(), this should work in gtkmm 3.x, but not in gtkmm 4.x:

	auto simple_action = Glib::RefPtr::cast_dynamic<Gio::SimpleAction>(m_refActionGroup->lookup_action("PlacepieceBlackPawn"));
Shall be
auto simple_action = Glib::RefPtr<Gio::SimpleAction>
::cast_dynamic(m_refActionGroup->lookup_action("PlacepieceBlackPawn"));
	if (simple_action)
	  simple_action->set_enabled(row != 0 && row != 7);




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