Hi Kjell, thank you so much for helping me out!
I'm not sure what you mean with doing LinuxChessboardWidget(......) : Glib::ObjectBase("myWidgetClass") since Glib::ObjectBase is a base class of Gio::ActionMap, I can't call that from LinuxChessboardWidget no? What I have is the following: class LinuxChessApplication : public Gtk::Application { ... void on_menu_file_exit(); Where 'Exit' is not related to a single window, but is application wide (it closes all windows and exits the application). I add this with add_action to Gtk::Application. Then I have: class LinuxChessWindow : public Gtk::ApplicationWindow { ... void on_menu_file_load(); void on_menu_file_save(); void on_menu_game_new(); void on_menu_game_clear(); void on_menu_game_export(); void on_menu_game_undo(); void on_menu_game_flip(); void on_menu_mode_editposition(); void on_menu_mode_editgame(); These are added, using add_action, to Gtk::ApplicationWindow. So, I am using what you said. But, then I have: class LinuxChessboardWidget : public cwmm::ChessPositionWidget { ... void on_menu_mode_showcandidates(); void on_menu_mode_showreachables(); void on_menu_mode_showattacked(); void on_menu_mode_showdefendables(); void on_menu_mode_showdefended_black(); void on_menu_mode_showdefended_white(); void on_menu_mode_showmoves(); void on_menu_mode_placepieces(); It is possible, though silly imho, to add those member funtions to LinuxChessWindow (all those would do is call the member functions of its LinuxChessboardWidget). So, I rather register these directly. I couldn't think of another way than to derive LinuxChessboardWidget from Gio::ActionMap, like Gtk::Application and Gtk::ApplicationWindow. Should I add a Gio::SimpleActionGroup to LinuxChessboardWidget instead and add them to that? If I do that, then how can get this Gio::SimpleActionGroup to be used for my menu? And under what name would do I have to refer to them in the `ui_info` xml string that I use for my Gtk::Builder? Or should I use a separate Gtk::Builder? With 'name' I mean that the menu entries that are added to Gtk::Application are refered to as "app.*" and those that are added to Gtk::ApplicationWindow are refered to as "win.*". I'd like it when the methods of LinuxChessboardWidget can be refered to as -say- "chessboard.*". On Sun, 26 Jul 2020 11:06:53 +0200 Kjell Ahlstedt <kjellahlst...@gmail.com> wrote: > Gio::ActionMap is an interface. That's why its constructor is > protected. An interface can't be instantiated by itself. It must be > implemented by a class which can be instantiated. If you really must > implement Gio::ActionMap in your class (which I doubt), there is one > or (probably) two errors. > > First, interfaces must come before the widget class in the list of > base classes. > > class LinuxChessboardWidget : public Gio::ActionMap, public > cwmm::ChessPositionWidget > > This is opposite to what's done in gtkmm's classes that wrap gtk > classes. > > Second, your constructor must call a special Glib::ObjectBase > constructor that registers your class with its own GType in glib's > GType system. For instance > > LinuxChessboardWidget(......) : Glib::ObjectBase("myWidgetClass") > ..... // Or whatever you want to call it. > > This is an unusual way of using Gio::ActionMap. I don't know if these > are the only necessary changes. Much more common is to use one of the > classes that already implement Gio::ActionMap: > Gio::SimpleActionGroup, Gtk::Application (via Gio::Application) or > Gtk::ApplicationWindow. > _______________________________________________ gtkmm-list mailing list gtkmm-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtkmm-list