Skip to content

Commit

Permalink
Correct the binding of GTK menu events.
Browse files Browse the repository at this point in the history
  • Loading branch information
freakboy3742 committed Aug 24, 2019
1 parent 4ef8cb3 commit 924365a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/gtk/toga_gtk/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
from .window import Window


def gtk_menu_item_activate(cmd):
"""Convert a GTK menu item activation into a command invocation"""
def _handler(action, data):
cmd.action(cmd)
return _handler


class MainWindow(Window):
_IMPL_CLASS = Gtk.ApplicationWindow

Expand Down Expand Up @@ -138,7 +145,7 @@ def create_menus(self):
cmd_id = "command-%s" % id(cmd)
action = Gio.SimpleAction.new(cmd_id, None)
if cmd.action:
action.connect("activate", wrapped_handler(cmd, cmd.action))
action.connect("activate", gtk_menu_item_activate(cmd))
cmd._widgets.append(action)
self._actions[cmd] = action
self.native.add_action(action)
Expand Down

0 comments on commit 924365a

Please sign in to comment.