Add main menu with information about the programm

master
Marko Semet 2019-12-23 03:25:18 +01:00
parent 112eb9b441
commit 19c1c2bc09
8 changed files with 299 additions and 8 deletions

1
authors.json 120000
View File

@ -0,0 +1 @@
models/dop/authors.json

View File

@ -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"
]
}

View File

@ -0,0 +1,13 @@
{
"authors": [
"Marko Semet (Marko10_000)"
], "translators": [
""
], "artists": [
""
], "documenters": [
"Marko Semet (Marko10_000)"
],
"copyright_infos": "",
"version": "0.2.0-dev"
}

View File

@ -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 <https://www.gnu.org/licenses/>.
*/
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;
}

View File

@ -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();
}
}
}
}

View File

@ -13,6 +13,35 @@
</object>
</child>
</object>
<object class="GtkMenu" id="_mainMenu">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="reserve_toggle_size">False</property>
<child>
<object class="GtkImageMenuItem" id="MenuInfo">
<property name="label">gtk-info</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
<child>
<object class="GtkSeparatorMenuItem">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="MenuQuit">
<property name="label">gtk-quit</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
</object>
<object class="GtkAdjustment" id="_sizeMover">
<property name="lower">0.01</property>
<property name="upper">9.9900000000000002</property>
@ -73,6 +102,22 @@
<property name="can_focus">False</property>
<property name="title" translatable="yes">DrawOfPages</property>
<property name="show_close_button">True</property>
<child>
<object class="GtkMenuButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="popup">_mainMenu</property>
<property name="direction">none</property>
<property name="use_popover">False</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButtonBox">
<property name="visible">True</property>
@ -174,6 +219,7 @@
</object>
<packing>
<property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child>
</object>
@ -182,4 +228,49 @@
<placeholder/>
</child>
</object>
<object class="GtkAboutDialog" id="AboutDialog">
<property name="can_focus">False</property>
<property name="type_hint">dialog</property>
<property name="attached_to">MainApplication</property>
<property name="program_name">DrawOfPages</property>
<property name="version">--REPLACE--</property>
<property name="copyright" translatable="yes">--GET-REPLACED--</property>
<property name="website">https://marko10-000.de/projects/drawofpages</property>
<property name="authors">--GET-REPLACED--</property>
<property name="documenters">--GET-REPLACED--</property>
<property name="translator_credits" translatable="yes">--GET-REPLACED--</property>
<property name="artists">--GET-REPLACED--</property>
<property name="logo_icon_name">image-missing</property>
<property name="license_type">agpl-3-0-only</property>
<child>
<placeholder/>
</child>
<child internal-child="vbox">
<object class="GtkBox">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
</interface>

View File

@ -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

View File

@ -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();
}
});
}
}
/++