Skip to content
Snippets Groups Projects
Commit cff2b768 authored by David Boddie's avatar David Boddie :speech_balloon:
Browse files

Add an About menu entry and dialog based on Gtk.AboutDialog

parent ca8f4cb9
Branches gtk-about-dialog
No related tags found
No related merge requests found
......@@ -65,6 +65,10 @@ class Application(Gtk.Application):
menu_button.set_menu_model(menu)
# Create actions for the app menu items.
about_action = Gio.SimpleAction.new('about', None)
about_action.connect('activate', self.on_about)
self.add_action(about_action)
new_game_action = Gio.SimpleAction.new('new_game', None)
new_game_action.connect('activate', self.on_new_game)
self.add_action(new_game_action)
......@@ -83,7 +87,8 @@ class Application(Gtk.Application):
try:
self.keyfile = GLib.KeyFile()
self.keyfile.load_from_file(self.keyfile_path,
GLib.KeyFileFlags(3))
GLib.KeyFileFlags.KEEP_COMMENTS |
GLib.KeyFileFlags.KEEP_TRANSLATIONS)
self.lowest_turns = self.keyfile.get_integer(
'general', 'lowest-turns'
)
......@@ -100,6 +105,21 @@ class Application(Gtk.Application):
def do_activate(self):
self.window.present()
def on_about(self, action, parameter):
dialog = Gtk.AboutDialog(
authors=['David Boddie'],
license_type=Gtk.License.GPL_3_0,
logo_icon_name='treasure',
transient_for=self.window,
modal=True
)
def close_dialog(dialog, response):
dialog.close()
dialog.connect('response', close_dialog)
dialog.run()
def on_quit(self, action, parameter):
self.quit()
......
......@@ -2,6 +2,10 @@
<interface>
<menu id="menu">
<section>
<item>
<attribute name="action">app.about</attribute>
<attribute name="label" translatable="yes">_About</attribute>
</item>
<item>
<attribute name="action">app.new_game</attribute>
<attribute name="label" translatable="yes">New Game</attribute>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment