set_action_target_value() does not allow None as value
either the docs are wrong or the method set_action_target_value(None)
fails. Although docs say None is a valid value.
Not working example:
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gio
class TestWindow(Gtk.ApplicationWindow):
def __init__(self):
Gtk.Window.__init__(self, title="Demo")
self.set_border_width(10)
act = Gio.SimpleAction.new('quit', None)
act.connect("activate", self._quit)
self.add_action(act)
self.grid = Gtk.Grid()
self.button = Gtk.Button(label='Popup')
self.button.connect('clicked', self._popup)
self.grid.add(self.button)
self.button2 = Gtk.Button(label='Popup2')
self.button2.set_action_name('win.quit')
self.grid.add(self.button2)
self.add(self.grid)
self.show_all()
def _popup(self, widget):
menu = Gtk.Menu()
item = Gtk.MenuItem()
item.set_label('quit')
item.set_action_name('win.quit')
item.set_action_target_value(None)
menu.attach(item, 0, 1, 0, 1)
menu.show_all()
menu.popup_at_pointer(None)
def _quit(self, action, param):
Gtk.main_quit()
win = TestWindow()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()
Edited by lovetox