From f7cbc25efc87dd1d6bb713d8b3bfc642c12b0d77 Mon Sep 17 00:00:00 2001 From: coderkun Date: Sun, 23 Apr 2017 11:50:41 +0200 Subject: [PATCH] Add basic app menu with shortcut for closing (see #14) --- data/de.coderkun.mcg.gresource.xml | 1 + data/menu.ui | 12 +++++++++++ locale/de/LC_MESSAGES/mcg.mo | Bin 1577 -> 1668 bytes locale/de/LC_MESSAGES/mcg.po | 33 +++++++++++++++++------------ locale/en/LC_MESSAGES/mcg.mo | Bin 1494 -> 1582 bytes locale/en/LC_MESSAGES/mcg.po | 33 +++++++++++++++++------------ mcg/application.py | 19 +++++++++++++++++ 7 files changed, 70 insertions(+), 28 deletions(-) create mode 100644 data/menu.ui diff --git a/data/de.coderkun.mcg.gresource.xml b/data/de.coderkun.mcg.gresource.xml index f11ba02..cc74286 100644 --- a/data/de.coderkun.mcg.gresource.xml +++ b/data/de.coderkun.mcg.gresource.xml @@ -2,6 +2,7 @@ gtk.glade + menu.ui mcg.css noise-texture.png diff --git a/data/menu.ui b/data/menu.ui new file mode 100644 index 0000000..1c9d77a --- /dev/null +++ b/data/menu.ui @@ -0,0 +1,12 @@ + + + +
+ + app.quit + _Quit + <Primary>q + +
+
+
diff --git a/locale/de/LC_MESSAGES/mcg.mo b/locale/de/LC_MESSAGES/mcg.mo index 134b06a8eee1c6de6d0c9fb77d0b533948bd3d8f..5111d9eb609c576a2a25b3291f62124cbb7f4a96 100644 GIT binary patch delta 657 zcmY+Bze_?<6vwZ>(o8GuH&j?r&|vk@L4+C#8p{x(&0hIHhZO3$w7AqCAdhHi&z1-x z2pglJsg`Ica&oFY2!cMxUSNlJ?&qF+@B5y6&p8Vm1j}z>_mRQ|@nQTGpTtib4A`7g zsWzxV4@|%TxB%t+Ivjy}_I?F+6CXn_tipD90e!FrMducxTUPf>+$=oW8&6Pvc(LOK z>?D4NUGU3}{jT452+IC648jBqz-3tH5osuTF|tbHd4^HA1jos*wwe>A4k4eaGIYRm z=!Z2Z0(Vd@@BsN#ok1$ofO77`UjMY?ZzwPJai|xDU)ud%2B$tu|ttJ)i$3<6+A~ZF*lcIpl2TB_?{GZ7Mq<=j)`I{zXm0n6& z!)EkRvS~4ED@~*MJ`DMkm>X_Jwriw;3Z${IGzPp`E>1HmfB_mng a)Ms~$LTLtpy8GFeSu~77)+kt49`gtI{X$~^ delta 567 zcmXw#F)u?=6vt2d`r5vy<+Z8|C{2tcN*7$R{(cW8#QU%S4`Bq4VG*7|)wzPy?bFo0FJ{aI00XM{Ndx& z$A7TQeH@sT;0%0Z_$8=1-xOEF6wbpR*n|m(P5Rp!8zpSBjKLik!(FHX9jE~gAfKJG zND&8>cj?c2KE8!D&hKFbzQ8H?>EmChhlLc0>2EbQYSe&IUCEMIGRpM2k@2t9aW&8o zl32285SbcEO&P)r6;W+Hpo+^TaXnNPq0(>~bIaKWmu7o~*23!gM!W4Ug2mB(@EmMq LTq}Hcm3-$PntUz! diff --git a/locale/de/LC_MESSAGES/mcg.po b/locale/de/LC_MESSAGES/mcg.po index 5afbf78..7209ae9 100644 --- a/locale/de/LC_MESSAGES/mcg.po +++ b/locale/de/LC_MESSAGES/mcg.po @@ -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 \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" diff --git a/locale/en/LC_MESSAGES/mcg.mo b/locale/en/LC_MESSAGES/mcg.mo index 70a23a78e46f4e5a69b2f96f329c686ed328373a..685ce84d757778e3f3cc0972ff9c6559883a47b2 100644 GIT binary patch delta 653 zcmY+By)Q#y6o=oow?0~*ta2oc)8L0Q?VH|FG=VjPIz7HGW5p0I1unAs5)wzSz-8K&_EH<9JgBsKaFJAru z+sHp*JN)+YP{7Umq0UEPE1ZTca2DPoA_FC$o33gcBS^p?jM3kuSV+MF_A;;7fQh)@*!Vw_5~+{k^#3)DRTt7&BbA{4 z!djjy<||kJYU5ucX@i)v{lG>8}sL`4l93|3Z?&1MjTS!y(N@*;*ZNJu2Y(xr)r zK`bI-5R;fC{Sz#{-^+FK&i&50_uPAa@7xtW^R4ev`oyp*K7oJWlXyGDf`y)021YP| zMX1^eRQ&?1!F6}O1B>K)FbfZ11dm_{kD=b_K;CWH1wopPYj}G3+CXq+uwz%--i-@042Qb@-vs;K-JyDkpA{epoVWyQy;~pRAOZMyMLp^D)%QerQ| diff --git a/locale/en/LC_MESSAGES/mcg.po b/locale/en/LC_MESSAGES/mcg.po index a238dce..aea4d94 100644 --- a/locale/en/LC_MESSAGES/mcg.po +++ b/locale/en/LC_MESSAGES/mcg.po @@ -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 \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" diff --git a/mcg/application.py b/mcg/application.py index d6770ab..38dba7a 100644 --- a/mcg/application.py +++ b/mcg/application.py @@ -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)