Need an override for g_action_map_add_action_entries()
Submitted by Micah Carrick
I've been tinkering with Gtk.Application.set_menubar() and Gtk.Application.set_app_menu() in Python and have encountered a few issues.
The g_action_map_add_action_entries() doesn't seem to play nice into python. (it wants a Gio.Action but gets StructMeta). Ideally it could work something like:
# window is Gtk.ApplicationWindow entries = [ ("fullscreen", window.activate_toggle, False, change_fullscreen_state), # etc. ] window.add_action_entries(entries)
I thought I could simple hack together a patch in gi/overrides/Gio.py similar to what is done with the Gtk.ActionGroup.add_actions(), but, all the GVariant stuff went over my head.
So this is what DOES work. It results in a lot of tedious typing.
# window is Gtk.ApplicationWindow action = Gio.SimpleAction.new_stateful("fullscreen", None, GLib.Variant("b", False)) action.connect("activate", window.activate_toggle) action.connect("change-state", self.change_fullscreen_state) window.add_action(action) # etc..
I think some of the other classes from GLib like GAction, GActionMap, and GSimpleAction might need some overrides too. That is, I assume we don't want Python applications directly using GLib.Variant? Or maybe we do? It seems to me the "pythonic" way is to make the GVariant based on the python type:
action = Gio.SimpleAction(state=False) action = Gio.SimpleAction(state='left')