diff options
author | David King <amigadave@amigadave.com> | 2014-05-21 11:57:02 +0100 |
---|---|---|
committer | David King <amigadave@amigadave.com> | 2014-05-21 11:57:02 +0100 |
commit | 519fa77576ab32942a8e7b6379d4d28144bb6c23 (patch) | |
tree | 46cd128217da397b8e60af98aaf8607063c195c0 /python-gnome-app | |
parent | 279df35098654e78b8d678e65988aa701e0f71b6 (diff) | |
download | python-gnome-app-519fa77576ab32942a8e7b6379d4d28144bb6c23.tar.gz python-gnome-app-519fa77576ab32942a8e7b6379d4d28144bb6c23.tar.xz python-gnome-app-519fa77576ab32942a8e7b6379d4d28144bb6c23.zip |
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.
Diffstat (limited to 'python-gnome-app')
-rwxr-xr-x | python-gnome-app | 9 |
1 files changed, 9 insertions, 0 deletions
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("<Primary>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() |