Enable / disable a Gio::SimpleAction.



In gtkmm 2.x I had,

    Glib::RefPtr<Gio::SimpleActionGroup> m_refActionGroup;

...

    m_refActionGroup->get_action("PlacepieceBlackPawn").set_sensitive(row != 0 && row != 7);

With gtkmm 3.x it seems that I am forced to do:

    
static_cast<Gio::SimpleAction*>(m_refActionGroup->lookup_action("PlacepieceBlackPawn").get())->set_enabled(row
 != 0 && row != 7);

Any other attempt (that would look at lot more sane and logical) gives a compile
error in a gtkmm header - or maybe I'm missing something?

The most logical thing would be for 'Gio::SimpleActionGroup::lookup_action' to return
a Glib::RefPtr<Gio::SimpleAction>, in which case I could do just:

     m_refActionGroup->lookup_action("PlacepieceBlackPawn")->set_enabled(row != 0 && row != 7);

The builtin cast of Glib::RefPtr isn't working, aka

    Glib::RefPtr<Gio::SimpleAction> action = m_refActionGroup->lookup_action("PlacepieceBlackPawn");

Neither is,

    
static_cast<Glib::RefPtr<Gio::SimpleAction>>(m_refActionGroup->lookup_action("PlacepieceBlackPawn"))->set_enabled(row
 != 0 && row != 7);

How am I supposed to get my Gio::SimpleAction back?

Carlo

PS lookup_action return a Gio::Action, which is a base class and doesn't have the set_enabled method.


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