From 519fa77576ab32942a8e7b6379d4d28144bb6c23 Mon Sep 17 00:00:00 2001 From: David King Date: Wed, 21 May 2014 11:57:02 +0100 Subject: Add an application menu Create a menu model, and add menu items into the model. Link the menu items to the "hello-world" and "quit" actions, which were added to the application. Set the menu to be the application menu. --- python-gnome-app | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/python-gnome-app b/python-gnome-app index a69f801..67d36d0 100755 --- a/python-gnome-app +++ b/python-gnome-app @@ -26,6 +26,15 @@ class PythonApp(Gtk.Application): self.add_accelerator("q", "app.quit", None) quit.connect("activate", self.on_quit) + appmenu = Gio.Menu.new() + section = Gio.Menu.new() + hello_world_item = Gio.MenuItem.new("Hello world!", "app.hello-world") + quit_item = Gio.MenuItem.new("Quit", "app.quit") + appmenu.append_section(None, section) + section.append_item(hello_world_item) + section.append_item(quit_item) + self.set_app_menu(appmenu) + def on_activate(self, app): self.window.show_all() -- cgit