Gtk.Application does not use overridden add_action_entries
The following piece of code is causing problems:
class Application(Gtk.Application):
def __init__(self, *args, **kwargs):
super().__init__(
*args,
application_id="my.app",
flags=Gio.ApplicationFlags.FLAGS_NONE,
**kwargs
)
def do_startup(self):
Gtk.Application.do_startup(self)
# this may need to be checked on other platforms as well
if platform.system() == 'Darwin':
appmenus_str = pkg_resources.resource_string('myapp', 'data/menus-appmenu.ui').decode("utf-8")
builder = Gtk.Builder.new_from_string(appmenus_str, -1)
self.set_app_menu(builder.get_object("app-menu"))
commonmenus_str = pkg_resources.resource_string('myapp', 'data/menus-common.ui').decode("utf-8")
builder = Gtk.Builder.new_from_string(commonmenus_str, -1)
self.set_menubar(builder.get_object("menubar"))
action_entries = (
("about", self.on_about),
("quit", self.on_quit),
("new", lambda *_: self.do_activate()),
("help-url", self.on_help_url, "s")
)
self.add_action_entries(action_entries)
# add accelerators
accelerators = (
("app.quit", ("<Primary>Q")),
("app.new", ("<Primary>N")),
("win.close", ("<Primary>W")),
)
for accel in accelerators:
self.set_accels_for_action(*accel)
When running this, I get:
Traceback (most recent call last):
File "/path/to/my/app/application.py", line 43, in do_startup
self.add_action_entries(action_entries)
TypeError: Item 0: argument self: Expected Gio.ActionEntry, but got tuple
I would have expected this to work, but perhaps I'm wrong... Shouldn't the overridden version of Gio.ActionMap. self.add_action_entries be used in this case? I am using pygobject 3.36.1.