diff --git a/authors.json b/authors.json new file mode 120000 index 0000000..3486aa0 --- /dev/null +++ b/authors.json @@ -0,0 +1 @@ +models/dop/authors.json \ No newline at end of file diff --git a/dub.json b/dub.json index 9805b74..58e4d7b 100644 --- a/dub.json +++ b/dub.json @@ -6,8 +6,11 @@ "description": "Take notes with touchscreen input.", "license": "AGPL-3.0/proprietary", "name": "drawofpages", - "targetType": "sourceLibrary", + "targetType": "library", "subPackages": [ "versGTK3" + ], + "stringImportPaths": [ + "models" ] } \ No newline at end of file diff --git a/models/dop/authors.json b/models/dop/authors.json new file mode 100644 index 0000000..23a9b2a --- /dev/null +++ b/models/dop/authors.json @@ -0,0 +1,13 @@ +{ + "authors": [ + "Marko Semet (Marko10_000)" + ], "translators": [ + "" + ], "artists": [ + "" + ], "documenters": [ + "Marko Semet (Marko10_000)" + ], + "copyright_infos": "", + "version": "0.2.0-dev" +} \ No newline at end of file diff --git a/source/dop/authorship.d b/source/dop/authorship.d new file mode 100644 index 0000000..03aa213 --- /dev/null +++ b/source/dop/authorship.d @@ -0,0 +1,105 @@ +/* DrawOfPages: Take notes with touchscreen input. + * Copyright (C) 2019 Marko Semet + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +module dop.authorship; + +private +{ + import std.algorithm; + import std.array; + import std.json; + + struct __DataLoader + { + string[] authors; + string[] translators; + string[] artists; + string[] documenters; + string copyright_infos; + string prog_version; + + /++ + + Loads a string list out of a json + + Params: + + data = The source json list + + Returns: The read list of strings. When empty null. + +/ + static string[] loadArray(JSONValue[] data) + { + auto result = data.map!((x) => x.str).filter!((x) => x.length != 0).array; + if(result.length == 0) + { + return null; + } + else + { + return result; + } + } + + /++ + + Load the base input from resource file "authors.json" + + Returns: The loaded values + +/ + static __DataLoader load() + { + __DataLoader result; + auto data = parseJSON(import("dop/authors.json")).object; + assert(data["authors"].type == JSONType.array); + result.authors = loadArray(data["authors"].array); + assert(data["translators"].type == JSONType.array); + result.translators = loadArray(data["translators"].array); + assert(data["artists"].type == JSONType.array); + result.artists = loadArray(data["artists"].array); + assert(data["documenters"].type == JSONType.array); + result.documenters = loadArray(data["documenters"].array); + assert(data["copyright_infos"].type == JSONType.string); + result.copyright_infos = data["copyright_infos"].str; + assert(data["version"].type == JSONType.string); + result.prog_version = data["version"].str; + return result; + } + } + enum __DataLoader __loader = __DataLoader.load(); +} + +public +{ + /++ + + List of the developers. + +/ + enum string[] authorship_authors = __loader.authors; + /++ + + List of the translators. + +/ + enum string[] authorship_translators = __loader.translators; + /++ + + List of the artists. + +/ + enum string[] authorship_artists = __loader.artists; + /++ + + List of the documenters. + +/ + enum string[] authorship_documenters = __loader.documenters; + /++ + + Additional copyright informations. + +/ + enum string authorship_copyright_infos = __loader.copyright_infos; + /++ + + The current programm version. + +/ + enum string programm_version = __loader.prog_version; +} \ No newline at end of file diff --git a/source/dop/processing/mainsystem.d b/source/dop/processing/mainsystem.d index 7bc8dec..d14a3d2 100644 --- a/source/dop/processing/mainsystem.d +++ b/source/dop/processing/mainsystem.d @@ -40,6 +40,11 @@ public + size = The new brush size +/ shared void setCurrentSize(float size); + + /++ + + Quit the application + +/ + shared void quit(); } /++ @@ -128,6 +133,14 @@ public this.__callbacks.setCurrentSize(size); return this.__currentSize; } + + /++ + + Quit the application + +/ + shared void quit() + { + this.__callbacks.quit(); + } } } } \ No newline at end of file diff --git a/versGTK3/models/MainWindow.glade b/versGTK3/models/MainWindow.glade index d3700d7..614a02d 100644 --- a/versGTK3/models/MainWindow.glade +++ b/versGTK3/models/MainWindow.glade @@ -13,6 +13,35 @@ + + True + False + False + + + gtk-info + True + False + True + True + + + + + True + False + + + + + gtk-quit + True + False + True + True + + + 0.01 9.9900000000000002 @@ -73,6 +102,22 @@ False DrawOfPages True + + + True + True + True + _mainMenu + none + False + + + + + + 1 + + True @@ -174,6 +219,7 @@ end + 1 @@ -182,4 +228,49 @@ + + False + dialog + MainApplication + DrawOfPages + --REPLACE-- + --GET-REPLACED-- + https://marko10-000.de/projects/drawofpages + --GET-REPLACED-- + --GET-REPLACED-- + --GET-REPLACED-- + --GET-REPLACED-- + image-missing + agpl-3-0-only + + + + + + False + vertical + 2 + + + False + end + + + + + + + + + False + False + 0 + + + + + + + + diff --git a/versGTK3/source/app.d b/versGTK3/source/app.d index d04fc8b..ee16f3a 100644 --- a/versGTK3/source/app.d +++ b/versGTK3/source/app.d @@ -21,6 +21,7 @@ import dop.structures.base; import gdk.Threads; import gio.Application: GioApplication = Application; import gtk.Application; +import gtk.Main; private { @@ -28,12 +29,12 @@ private { private { - void delegate(void delegate(DOP_MainWindow)) __runWithMainWindow; + void delegate(void delegate(DOP_MainWindow, Application)) __runWithMainWindow; } public { - shared this(void delegate(void delegate(DOP_MainWindow)) func) + shared this(void delegate(void delegate(DOP_MainWindow, Application)) func) in { assert(func !is null); @@ -45,16 +46,23 @@ private shared void setCurrentColor(ColorRGBA color) { - this.__runWithMainWindow(delegate void(DOP_MainWindow mw) { + this.__runWithMainWindow(delegate void(DOP_MainWindow mw, Application app) { mw.updateColor(); }); } shared void setCurrentSize(float size) { - this.__runWithMainWindow(delegate void(DOP_MainWindow mw) { + this.__runWithMainWindow(delegate void(DOP_MainWindow mw, Application app) { mw.updateSize(size); }); } + + shared void quit() + { + this.__runWithMainWindow(delegate void(DOP_MainWindow mw, Application app) { + app.quit(); + }); + } } } } @@ -70,9 +78,9 @@ int main(string[] args) DOP_MainWindow mainWindow = new DOP_MainWindow(app); // Create main system - baseCB = new shared Callbacks(delegate void(void delegate(DOP_MainWindow) func) { + baseCB = new shared Callbacks(delegate void(void delegate(DOP_MainWindow, Application) func) { threadsEnter(); - func(mainWindow); + func(mainWindow, app); threadsLeave(); }); ms = new shared MainSystem(baseCB); @@ -80,7 +88,6 @@ int main(string[] args) // Finalize main system init ms.finalizeInit(); - mainWindow.updateColor(); // Fix sizing render bug }); { // Finalize diff --git a/versGTK3/source/dop/gtk3/mainwindow.d b/versGTK3/source/dop/gtk3/mainwindow.d index 8186d7c..c30504d 100644 --- a/versGTK3/source/dop/gtk3/mainwindow.d +++ b/versGTK3/source/dop/gtk3/mainwindow.d @@ -20,11 +20,13 @@ private { import cairo.Context; + import dop.authorship; import dop.processing.mainsystem; import dop.structures.base; import gdk.RGBA; + import gtk.AboutDialog; import gtk.Application; import gtk.ApplicationWindow; import gtk.Builder; @@ -34,6 +36,7 @@ private import gtk.Image; import gtk.Label; import gtk.MenuButton; + import gtk.MenuItem; import gtk.Range; import gtk.Scale; import gtk.SpinButton; @@ -72,6 +75,10 @@ public Label __sizeInfo; MenuButton __sizeHelper; + AboutDialog __menuAboutDialog; + MenuItem __menuAbout; + MenuItem __menuQuit; + // // Colors // @@ -233,6 +240,57 @@ public } }); } + + { // Manage menu entries + this.__menuAboutDialog = cast(AboutDialog) this.__builder.getObject("AboutDialog"); + assert(this.__menuAboutDialog !is null); + this.__menuAbout = cast(MenuItem) this.__builder.getObject("MenuInfo"); + assert(this.__menuAbout !is null); + this.__menuQuit = cast(MenuItem) this.__builder.getObject("MenuQuit"); + assert(this.__menuQuit !is null); + + // Set infos + this.__menuAboutDialog.setArtists(authorship_artists); + this.__menuAboutDialog.setAuthors(authorship_authors); + this.__menuAboutDialog.setDocumenters(authorship_documenters); + { + string trans = format!("%(%s\n%)")(authorship_translators); + if(trans.length == 0) + { + this.__menuAboutDialog.setTranslatorCredits(null); + } + else + { + this.__menuAboutDialog.setTranslatorCredits(trans[0..$-1]); + } + } + { + string copyright = authorship_copyright_infos; + if(copyright.length > 0) + { + copyright ~= "\n\n"; + } + copyright ~= "Used library: GtkD(http://gtkd.org)"; + this.__menuAboutDialog.setCopyright(copyright); + } + this.__menuAboutDialog.setVersion(programm_version); + + // About + this.__menuAbout.addOnActivate(delegate void(MenuItem mi) { + if(mi == this.__menuAbout) + { + this.__menuAboutDialog.showAll(); + } + }); + + // Quit + this.__menuQuit.addOnActivate(delegate void(MenuItem mi) { + if(mi == this.__menuQuit) + { + this.__mainSystem.quit(); + } + }); + } } /++