From 102013d12d1ec336ff5f60e266fe6431d7874581 Mon Sep 17 00:00:00 2001 From: TheJackiMonster Date: Thu, 15 Sep 2022 20:38:43 +0200 Subject: [PATCH] Added startup window as basic ui Signed-off-by: TheJackiMonster --- manuskript/ui/__init__.py | 1 + manuskript/ui/abstractDialog.py | 9 + manuskript/ui/mainWindow.py | 21 ++ manuskript/ui/startupWindow.py | 26 ++ ui/main.glade | 10 +- ui/startup.glade | 550 ++++++++++++++++++++++++++++++++ 6 files changed, 616 insertions(+), 1 deletion(-) create mode 100644 manuskript/ui/startupWindow.py create mode 100644 ui/startup.glade diff --git a/manuskript/ui/__init__.py b/manuskript/ui/__init__.py index 5e63f4e5..7d9d2a54 100644 --- a/manuskript/ui/__init__.py +++ b/manuskript/ui/__init__.py @@ -6,3 +6,4 @@ from manuskript.ui.util import pixbufFromColor from manuskript.ui.aboutDialog import AboutDialog from manuskript.ui.mainWindow import MainWindow from manuskript.ui.settingsWindow import SettingsWindow +from manuskript.ui.startupWindow import StartupWindow diff --git a/manuskript/ui/abstractDialog.py b/manuskript/ui/abstractDialog.py index 315454df..453d6973 100644 --- a/manuskript/ui/abstractDialog.py +++ b/manuskript/ui/abstractDialog.py @@ -37,6 +37,9 @@ class AbstractDialog: def _destroyWindow(self, window: Gtk.Widget): self.window = None + if not self.mainWindow.isVisible(): + self.mainWindow.close() + def show(self): if self.window is None: self.__initWindow() @@ -48,3 +51,9 @@ class AbstractDialog: return self.window.hide() + + def isVisible(self): + if self.window is None: + return False + + return self.window.get_property("visible") diff --git a/manuskript/ui/mainWindow.py b/manuskript/ui/mainWindow.py index 8f0f40a1..336bc10c 100644 --- a/manuskript/ui/mainWindow.py +++ b/manuskript/ui/mainWindow.py @@ -16,6 +16,7 @@ from manuskript.ui.views import * from manuskript.ui.tools import * from manuskript.ui.aboutDialog import AboutDialog from manuskript.ui.settingsWindow import SettingsWindow +from manuskript.ui.startupWindow import StartupWindow class MainWindow: @@ -78,10 +79,14 @@ class MainWindow: self.outlineView = MainWindow.packViewIntoSlot(builder, "outline_slot", OutlineView) self.editorView = MainWindow.packViewIntoSlot(builder, "editor_slot", EditorView) + self.startupWindow = StartupWindow(self) self.aboutDialog = AboutDialog(self) self.frequencyWindow = FrequencyWindow(self) self.settingsWindow = SettingsWindow(self) + MainWindow.bindMenuItem(builder, "open_menu_item", self.openProject) + MainWindow.bindMenuItem(builder, "save_menu_item", self.saveProject) + MainWindow.bindMenuItem(builder, "close_menu_item", self.closeProject) MainWindow.bindMenuItem(builder, "settings_menu_item", self.openSettings) MainWindow.bindMenuItem(builder, "frequency_menu_item", self.openFrequency) MainWindow.bindMenuItem(builder, "about_menu_item", self.openAbout) @@ -89,6 +94,16 @@ class MainWindow: def getProject(self): return self.project + def openProject(self, menuItem: Gtk.MenuItem): + pass + + def saveProject(self, menuItem: Gtk.MenuItem): + self.getProject().save() + + def closeProject(self, menuItem: Gtk.MenuItem): + self.hide() + self.startupWindow.show() + def getSettings(self): return self.getProject().settings @@ -107,9 +122,15 @@ class MainWindow: def hide(self): self.window.hide() + def isVisible(self): + return self.window.get_property("visible") + def run(self): self.show() Gtk.main() + def close(self): + self.window.destroy() + def _notifyProperty(self, window, property): print(property.name) diff --git a/manuskript/ui/startupWindow.py b/manuskript/ui/startupWindow.py new file mode 100644 index 00000000..b6335fa3 --- /dev/null +++ b/manuskript/ui/startupWindow.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +import gi + +gi.require_version("Gtk", "3.0") +from gi.repository import GObject, Gtk, Handy + +from manuskript.ui.abstractDialog import AbstractDialog + + +class StartupWindow(AbstractDialog): + + def __init__(self, mainWindow): + AbstractDialog.__init__(self, mainWindow, "ui/startup.glade", "startup_window") + + self.headerBar = None + self.templateLeaflet = None + + def initWindow(self, builder, window): + self.headerBar = builder.get_object("header_bar") + self.templateLeaflet = builder.get_object("template_leaflet") + + self.templateLeaflet.bind_property("folded", self.headerBar, "show-close-button", + GObject.BindingFlags.SYNC_CREATE | + GObject.BindingFlags.INVERT_BOOLEAN) diff --git a/ui/main.glade b/ui/main.glade index 04dd794f..5b6c52e4 100644 --- a/ui/main.glade +++ b/ui/main.glade @@ -1,5 +1,5 @@ - + + + + + True + False + 10 + mru + + + + + + + + + + + template_store + + + template_store + + + template_store + + + False + + + True + False + vertical + + + True + False + + + True + False + Manuskript + True + + + + + False + True + 0 + + + + + True + False + + + True + False + _File + True + + + True + False + + + True + False + + + + + True + False + + + + + True + False + + + + + True + False + + + + + + + + + True + False + _Help + True + + + True + False + + + True + False + + + + + True + False + + + + + + + + + False + True + 1 + + + + + True + False + 4 + 4 + 4 + 2 + True + True + + + 250 + True + True + 2 + in + + + True + False + + + True + False + vertical + + + True + False + Fiction + + + False + True + 0 + + + + + True + True + fiction_store + False + + + + + + + + + 1 + + + + + + + False + True + 1 + + + + + True + False + Non-fiction + + + False + True + 2 + + + + + True + True + nonfiction_store + False + + + + + + + + + 1 + + + + + + + False + True + 3 + + + + + True + False + Demo projects + + + False + True + 4 + + + + + True + True + demo_store + False + + + + + + + + + 1 + + + + + + + False + True + 5 + + + + + + + + + + + 300 + True + False + True + 2 + vertical + 4 + + + True + True + in + + + True + False + + + True + False + + + + + + + True + True + 0 + + + + + True + False + 4 + + + True + False + Total: ? words (~? pages) + end + 0 + + + True + True + 0 + + + + + Add level + True + True + True + + + False + True + 1 + + + + + Add word count + True + True + True + + + False + True + 2 + + + + + False + True + 1 + + + + + + + True + True + 2 + + + + + True + False + 4 + 4 + 2 + 4 + vertical + 8 + + + Next time, automatically open last project + True + True + False + 4 + True + + + False + True + 0 + + + + + True + False + end + 9 + + + True + True + True + + + True + False + 6 + + + True + False + document-open-symbolic + + + False + True + 0 + + + + + True + False + Open... + + + False + True + 1 + + + + + + + False + True + 0 + + + + + True + True + False + True + recent_chooser_menu + False + + + True + False + 6 + + + True + False + document-open-recent-symbolic + + + False + True + 0 + + + + + True + False + Recent + + + False + True + 1 + + + + + + + False + True + 1 + + + + + True + True + True + + + True + False + 6 + + + True + False + document-new-symbolic + + + False + True + 0 + + + + + True + False + Create + + + False + True + 1 + + + + + + + False + True + 2 + + + + + False + True + 1 + + + + + False + True + 3 + + + + + +