Add basic app menu with shortcut for closing (see #14)

This commit is contained in:
coderkun 2017-04-23 11:50:41 +02:00
parent e0d01f1f18
commit f7cbc25efc
7 changed files with 70 additions and 28 deletions

View file

@ -2,6 +2,7 @@
<gresources>
<gresource prefix="/de/coderkun/mcg">
<file>gtk.glade</file>
<file>menu.ui</file>
<file>mcg.css</file>
<file>noise-texture.png</file>
</gresource>

12
data/menu.ui Normal file
View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<menu id="app-menu">
<section>
<item>
<attribute name="action">app.quit</attribute>
<attribute name="label" translatable="yes">_Quit</attribute>
<attribute name="accel">&lt;Primary&gt;q</attribute>
</item>
</section>
</menu>
</interface>

Binary file not shown.

View file

@ -1,8 +1,8 @@
msgid ""
msgstr ""
"Project-Id-Version: MPDCoverGrid\n"
"POT-Creation-Date: 2017-04-22 14:55+0200\n"
"PO-Revision-Date: 2017-04-22 14:55+0200\n"
"POT-Creation-Date: 2017-04-23 11:44+0200\n"
"PO-Revision-Date: 2017-04-23 11:44+0200\n"
"Last-Translator: coderkun <olli@coderkun.de>\n"
"Language-Team: \n"
"Language: de\n"
@ -14,6 +14,7 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-SourceCharset: UTF-8\n"
"X-Poedit-SearchPath-0: data/gtk.glade\n"
"X-Poedit-SearchPath-1: data/menu.ui\n"
#: data/gtk.glade:21
msgid "Tracklist"
@ -55,50 +56,54 @@ msgstr "nach Titel"
msgid "sort by year"
msgstr "nach Jahr"
#: data/gtk.glade:435
#: data/gtk.glade:436
msgid "Enter hostname or IP address"
msgstr "Hostnamen oder IP-Adresse eingeben"
#: data/gtk.glade:447
#: data/gtk.glade:448
msgid "Enter URL or local path"
msgstr "URL oder lokalen Pfad eingeben"
#: data/gtk.glade:459
#: data/gtk.glade:460
msgid "Enter password or leave blank"
msgstr "Passwort eingeben oder leer lassen"
#: data/gtk.glade:484
#: data/gtk.glade:485
msgid "Host:"
msgstr "Host:"
#: data/gtk.glade:496
#: data/gtk.glade:497
msgid "Port:"
msgstr "Port:"
#: data/gtk.glade:508
#: data/gtk.glade:509
msgid "Password:"
msgstr "Passwort:"
#: data/gtk.glade:520
#: data/gtk.glade:521
msgid "Image Directory:"
msgstr "Bildordner:"
#: data/gtk.glade:544 data/gtk.glade:1200
#: data/gtk.glade:545 data/gtk.glade:1201
msgid "Server"
msgstr "Server"
#: data/gtk.glade:697 data/gtk.glade:1185
#: data/gtk.glade:698 data/gtk.glade:1186
msgid "Cover"
msgstr "Cover"
#: data/gtk.glade:808 data/gtk.glade:1234
#: data/gtk.glade:809 data/gtk.glade:1235
msgid "Playlist"
msgstr "Wiedergabeliste"
#: data/gtk.glade:835
#: data/gtk.glade:836
msgid "search library"
msgstr "durchsuche Bibliothek"
#: data/gtk.glade:976 data/gtk.glade:1289
#: data/gtk.glade:977 data/gtk.glade:1290
msgid "Library"
msgstr "Bibliothek"
#: data/menu.ui:7
msgid "_Quit"
msgstr "_Beenden"

Binary file not shown.

View file

@ -1,8 +1,8 @@
msgid ""
msgstr ""
"Project-Id-Version: MPDCoverGrid\n"
"POT-Creation-Date: 2017-04-22 14:55+0200\n"
"PO-Revision-Date: 2017-04-22 14:56+0200\n"
"POT-Creation-Date: 2017-04-23 11:44+0200\n"
"PO-Revision-Date: 2017-04-23 11:44+0200\n"
"Last-Translator: coderkun <olli@coderkun.de>\n"
"Language-Team: \n"
"Language: en\n"
@ -13,6 +13,7 @@ msgstr ""
"X-Poedit-Basepath: ../../..\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-SearchPath-0: data/gtk.glade\n"
"X-Poedit-SearchPath-1: data/menu.ui\n"
#: data/gtk.glade:21
msgid "Tracklist"
@ -54,50 +55,54 @@ msgstr "by Title"
msgid "sort by year"
msgstr "by Year"
#: data/gtk.glade:435
#: data/gtk.glade:436
msgid "Enter hostname or IP address"
msgstr "Enter hostname or IP address"
#: data/gtk.glade:447
#: data/gtk.glade:448
msgid "Enter URL or local path"
msgstr "Enter URL or local path"
#: data/gtk.glade:459
#: data/gtk.glade:460
msgid "Enter password or leave blank"
msgstr "Enter password or leave blank"
#: data/gtk.glade:484
#: data/gtk.glade:485
msgid "Host:"
msgstr "Host:"
#: data/gtk.glade:496
#: data/gtk.glade:497
msgid "Port:"
msgstr "Port:"
#: data/gtk.glade:508
#: data/gtk.glade:509
msgid "Password:"
msgstr "Password:"
#: data/gtk.glade:520
#: data/gtk.glade:521
msgid "Image Directory:"
msgstr "Image Directory:"
#: data/gtk.glade:544 data/gtk.glade:1200
#: data/gtk.glade:545 data/gtk.glade:1201
msgid "Server"
msgstr "Server"
#: data/gtk.glade:697 data/gtk.glade:1185
#: data/gtk.glade:698 data/gtk.glade:1186
msgid "Cover"
msgstr "Cover"
#: data/gtk.glade:808 data/gtk.glade:1234
#: data/gtk.glade:809 data/gtk.glade:1235
msgid "Playlist"
msgstr "Playlist"
#: data/gtk.glade:835
#: data/gtk.glade:836
msgid "search library"
msgstr "search library"
#: data/gtk.glade:976 data/gtk.glade:1289
#: data/gtk.glade:977 data/gtk.glade:1290
msgid "Library"
msgstr "Library"
#: data/menu.ui:7
msgid "_Quit"
msgstr "_Quit"

View file

@ -56,6 +56,8 @@ class Application(Gtk.Application):
self._load_css()
self._setup_locale()
self._load_ui()
self._setup_actions()
self._load_appmenu()
def do_activate(self):
@ -65,6 +67,10 @@ class Application(Gtk.Application):
self._window.present()
def on_quit(self, action, param):
self.quit()
def _setup_logging(self):
logging.basicConfig(
level=self._verbosity,
@ -105,5 +111,18 @@ class Application(Gtk.Application):
self._builder.add_from_resource(self._get_resource_path('gtk.glade'))
def _setup_actions(self):
action = Gio.SimpleAction.new("quit", None)
action.connect('activate', self.on_quit)
self.add_action(action)
def _load_appmenu(self):
builder = Gtk.Builder()
builder.set_translation_domain(Application.DOMAIN)
builder.add_from_resource(self._get_resource_path('menu.ui'))
self.set_app_menu(builder.get_object('app-menu'))
def _get_resource_path(self, path):
return "/{}/{}".format(Application.ID.replace('.', '/'), path)