Hi all, Recently I've converted my application to single-instance using GtkApplication and this is working well for me. But now I'm trying to make an app menu for GNOME Shell, and I am having difficulty doing it. I'm wondering if it's even implemented for python yet.
In my gtkbuilder UI file, I've got the menu defined exactly like in the example here: http://developer.gnome.org/gtk3/3.3/GtkApplication.html Then in my startup handler, i have this code: self.add_action_entries({'app.quit': lambda: self.quit()}, 1, None) self.set_app_menu(builder.get_object('app_menu')) This gives me this error: Traceback (most recent call last): File "/home/robru/Applications/gottengeography/gg/app.py", line 127, in startup self.add_action_entries({'app.quit': lambda: self.quit()}, 1, None) File "/usr/lib64/python2.7/site-packages/gi/types.py", line 43, in function return info.invoke(*args, **kwargs) TypeError: Expected Gio.ActionEntry, but got StructMeta So I try giving it the ActionEntry that it wants so badly: self.add_action_entries(Gio.ActionEntry(), 1, self) self.set_app_menu(builder.get_object('app_menu')) And this causes a segfault. I tried playing around with Gio.ActionEntry and found it quite lacking... in anything: >>> Gio.ActionEntry <class 'gi.repository.Gio.ActionEntry'> >>> foo = Gio.ActionEntry() >>> foo <void at 0x25369d0> >>> foo = Gio.ActionEntry('app.quit') Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: function takes at most 0 arguments (1 given) >>> foo.name >>> foo.name is None True >>> dir(foo) ['__class__', '__delattr__', '__dict__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__gtype__', '__hash__', '__info__', '__init__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'activate', 'change_state', 'name', 'padding', 'parameter_type', 'state'] >>> foo.name = 'app.quit' Traceback (most recent call last): File "<stdin>", line 1, in <module> RuntimeError: unable to set value for field >>> So I don't quite understand how this do-nothing is supposed to be used to make the app menu go. If I don't call set_app_menu, I get the default menu containing only quit, but if I call it, it just blanks the menu. How do I make the menu entries appear? How do I connect callbacks to the menu items? Thanks. -- http://exolucere.ca _______________________________________________ python-hackers-list mailing list [email protected] https://mail.gnome.org/mailman/listinfo/python-hackers-list
