diff --git a/manuskript/ui/__init__.py b/manuskript/ui/__init__.py index 0e8dd25e..5e63f4e5 100644 --- a/manuskript/ui/__init__.py +++ b/manuskript/ui/__init__.py @@ -3,4 +3,6 @@ from manuskript.ui.util import pixbufFromColor +from manuskript.ui.aboutDialog import AboutDialog from manuskript.ui.mainWindow import MainWindow +from manuskript.ui.settingsWindow import SettingsWindow diff --git a/manuskript/ui/aboutDialog.py b/manuskript/ui/aboutDialog.py new file mode 100644 index 00000000..0cc789bd --- /dev/null +++ b/manuskript/ui/aboutDialog.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +from manuskript.ui.abstractDialog import AbstractDialog + + +class AboutDialog(AbstractDialog): + + def __init__(self, mainWindow): + AbstractDialog.__init__(self, mainWindow, "ui/about.glade", "about_dialog") diff --git a/manuskript/ui/abstractDialog.py b/manuskript/ui/abstractDialog.py new file mode 100644 index 00000000..56b05921 --- /dev/null +++ b/manuskript/ui/abstractDialog.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +import gi + +gi.require_version("Gtk", "3.0") +gi.require_version("Handy", "1") + +from gi.repository import Gtk, Handy + +Handy.init() + + +class AbstractDialog: + + def __init__(self, mainWindow, uiTemplatePath, uiDialogId): + self.mainWindow = mainWindow + self.window = None + + self.builderTemplatePath = uiTemplatePath + self.builderObjectId = uiDialogId + + def initWindow(self, builder, window): + pass + + def __initWindow(self): + builder = Gtk.Builder() + builder.add_from_file(self.builderTemplatePath) + + self.window = builder.get_object(self.builderObjectId) + self.window.connect("destroy", self.__destroyWindow) + self.window.set_transient_for(self.mainWindow.window) + self.window.set_modal(True) + + self.initWindow(builder, self.window) + + def __destroyWindow(self, window: Gtk.Widget): + self.window = None + + def show(self): + if self.window is None: + self.__initWindow() + + self.window.show_all() + + def hide(self): + if self.window is None: + return + + self.window.hide() diff --git a/manuskript/ui/mainWindow.py b/manuskript/ui/mainWindow.py index 0eba05ca..c82c9dc3 100644 --- a/manuskript/ui/mainWindow.py +++ b/manuskript/ui/mainWindow.py @@ -13,6 +13,9 @@ Handy.init() from manuskript.data import Project from manuskript.ui.views import * +from manuskript.ui.aboutDialog import AboutDialog +from manuskript.ui.settingsWindow import SettingsWindow + class MainWindow: @@ -37,6 +40,15 @@ class MainWindow: slot.pack_start(view.widget, True, True, 0) return view + @classmethod + def bindMenuItem(cls, builder, id, action): + menuItem = builder.get_object(id) + + if menuItem is None: + return + + menuItem.connect("activate", action) + def __init__(self, path): self.project = Project(path) self.project.load() @@ -55,9 +67,24 @@ class MainWindow: self.outlineView = MainWindow.packViewIntoSlot(builder, "outline_slot", OutlineView) self.editorView = MainWindow.packViewIntoSlot(builder, "editor_slot", EditorView) + self.aboutDialog = AboutDialog(self) + self.settingsWindow = SettingsWindow(self) + + MainWindow.bindMenuItem(builder, "settings_menu_item", self.openSettings) + MainWindow.bindMenuItem(builder, "about_menu_item", self.openAbout) + + def openSettings(self, menuItem: Gtk.MenuItem): + self.settingsWindow.show() + + def openAbout(self, menuItem: Gtk.MenuItem): + self.aboutDialog.show() + def show(self): self.window.show_all() + def hide(self): + self.window.hide() + def run(self): self.show() Gtk.main() diff --git a/manuskript/ui/settingsWindow.py b/manuskript/ui/settingsWindow.py new file mode 100644 index 00000000..6ef93052 --- /dev/null +++ b/manuskript/ui/settingsWindow.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +from manuskript.ui.abstractDialog import AbstractDialog + + +class SettingsWindow(AbstractDialog): + + def __init__(self, mainWindow): + AbstractDialog.__init__(self, mainWindow, "ui/settings.glade", "settings_window") diff --git a/ui/about.glade b/ui/about.glade index 086216c8..ec36e328 100644 --- a/ui/about.glade +++ b/ui/about.glade @@ -26,8 +26,9 @@ along with Manuskript. If not, see . - + False + center-on-parent dialog Manuskript 0.12.0 diff --git a/ui/main.glade b/ui/main.glade index 77bbdc4b..7f80e10f 100644 --- a/ui/main.glade +++ b/ui/main.glade @@ -83,7 +83,7 @@ along with Manuskript. If not, see . True False - + True False _Open @@ -91,7 +91,7 @@ along with Manuskript. If not, see . - + True False _Recent @@ -99,7 +99,7 @@ along with Manuskript. If not, see . - + True False _Save @@ -107,7 +107,7 @@ along with Manuskript. If not, see . - + True False _Save as... @@ -115,7 +115,7 @@ along with Manuskript. If not, see . - + True False _Close project @@ -129,7 +129,7 @@ along with Manuskript. If not, see . - + True False _Import... @@ -137,7 +137,7 @@ along with Manuskript. If not, see . - + True False _Compile @@ -151,7 +151,7 @@ along with Manuskript. If not, see . - + True False _Quit @@ -173,7 +173,7 @@ along with Manuskript. If not, see . True False - + True False _Cut @@ -181,7 +181,7 @@ along with Manuskript. If not, see . - + True False _Copy @@ -189,7 +189,7 @@ along with Manuskript. If not, see . - + True False _Paste @@ -197,7 +197,7 @@ along with Manuskript. If not, see . - + True False _Delete @@ -205,7 +205,7 @@ along with Manuskript. If not, see . - + True False _Rename @@ -239,7 +239,7 @@ along with Manuskript. If not, see . True False - + True False _Level 1 (setext) @@ -247,7 +247,7 @@ along with Manuskript. If not, see . - + True False _Level 2 @@ -261,7 +261,7 @@ along with Manuskript. If not, see . - + True False _Level 1 (atx) @@ -269,7 +269,7 @@ along with Manuskript. If not, see . - + True False _Level 2 @@ -277,7 +277,7 @@ along with Manuskript. If not, see . - + True False _Level 3 @@ -285,7 +285,7 @@ along with Manuskript. If not, see . - + True False _Level 4 @@ -293,7 +293,7 @@ along with Manuskript. If not, see . - + True False _Level 5 @@ -301,7 +301,7 @@ along with Manuskript. If not, see . - + True False _Level 6 @@ -319,7 +319,7 @@ along with Manuskript. If not, see . - + True False _Bold @@ -327,7 +327,7 @@ along with Manuskript. If not, see . - + True False _Italic @@ -335,7 +335,7 @@ along with Manuskript. If not, see . - + True False _Strike @@ -343,7 +343,7 @@ along with Manuskript. If not, see . - + True False _Verbatim @@ -351,7 +351,7 @@ along with Manuskript. If not, see . - + True False _Superscript @@ -359,7 +359,7 @@ along with Manuskript. If not, see . - + True False _Subscript @@ -367,7 +367,7 @@ along with Manuskript. If not, see . - + True False _Comment line(s) @@ -381,7 +381,7 @@ along with Manuskript. If not, see . - + True False _Unordered list @@ -389,7 +389,7 @@ along with Manuskript. If not, see . - + True False _Ordered list @@ -397,7 +397,7 @@ along with Manuskript. If not, see . - + True False _Blockquote @@ -405,7 +405,7 @@ along with Manuskript. If not, see . - + True False _Comment block @@ -419,7 +419,7 @@ along with Manuskript. If not, see . - + True False _Clear formats @@ -437,7 +437,7 @@ along with Manuskript. If not, see . - + True False _Labels... @@ -445,7 +445,7 @@ along with Manuskript. If not, see . - + True False _Status... @@ -453,7 +453,7 @@ along with Manuskript. If not, see . - + True False _Settings @@ -475,7 +475,7 @@ along with Manuskript. If not, see . True False - + True False _Move Up @@ -483,7 +483,7 @@ along with Manuskript. If not, see . - + True False _Move Down @@ -497,7 +497,7 @@ along with Manuskript. If not, see . - + True False _Merge @@ -505,7 +505,7 @@ along with Manuskript. If not, see . - + True False _Split... @@ -513,7 +513,7 @@ along with Manuskript. If not, see . - + True False _Split at cursor @@ -545,22 +545,22 @@ along with Manuskript. If not, see . True False - + True False _Simple True True - radiomenuitem2 + mode_fiction_menu_item - + True False _Fiction True - radiomenuitem1 + mode_simple_menu_item @@ -574,7 +574,7 @@ along with Manuskript. If not, see . - + True False _Tree @@ -582,7 +582,7 @@ along with Manuskript. If not, see . - + True False _Index cards @@ -590,7 +590,7 @@ along with Manuskript. If not, see . - + True False _Structure @@ -612,7 +612,7 @@ along with Manuskript. If not, see . True False - + True False _Spellcheck @@ -620,7 +620,7 @@ along with Manuskript. If not, see . - + True False _Frequency Analyzer @@ -628,7 +628,7 @@ along with Manuskript. If not, see . - + True False _Dictionary @@ -650,7 +650,7 @@ along with Manuskript. If not, see . True False - + True False _Show help texts @@ -658,7 +658,7 @@ along with Manuskript. If not, see . - + True False _About diff --git a/ui/settings.glade b/ui/settings.glade index e9744778..5d7bbdef 100644 --- a/ui/settings.glade +++ b/ui/settings.glade @@ -94,24 +94,6 @@ along with Manuskript. If not, see . - - - spacedreams - - - - writingdesk - - - - Gentle Blues - - - - oldschool - - - @@ -280,9 +262,11 @@ along with Manuskript. If not, see . 1 10 - + False Settings + center-on-parent + dialog True @@ -2538,11 +2522,6 @@ along with Manuskript. If not, see . True False False - GTK_FONT_CHOOSER_LEVEL_FAMILY - Pick a font family - True - False - False True