From bae0c846e987c405547bac5a13d4e17fb393e8dc Mon Sep 17 00:00:00 2001 From: somas95 Date: Thu, 22 Mar 2018 01:21:58 +0100 Subject: [PATCH] Window refactoring, added appmenu and abou dialog Signed-off-by: somas95 --- data/ui/AboutUberwriterDialog.ui | 51 --- data/ui/App_menu.ui | 23 +- data/ui/UberwriterWindow.ui | 633 +++++++++++++++------------- data/ui/about_uberwriter_dialog.xml | 9 - data/ui/uberwriter_window.xml | 8 - po/uberwriter.pot | 354 ++++++---------- uberwriter/AboutUberwriterDialog.py | 35 -- uberwriter/UberwriterWindow.py | 5 + uberwriter_lib/AboutDialog.py | 50 --- uberwriter_lib/AppWindow.py | 47 ++- uberwriter_lib/Window.py | 139 ------ 11 files changed, 535 insertions(+), 819 deletions(-) delete mode 100644 data/ui/AboutUberwriterDialog.ui delete mode 100644 data/ui/about_uberwriter_dialog.xml delete mode 100644 data/ui/uberwriter_window.xml delete mode 100644 uberwriter/AboutUberwriterDialog.py delete mode 100644 uberwriter_lib/AboutDialog.py delete mode 100644 uberwriter_lib/Window.py diff --git a/data/ui/AboutUberwriterDialog.ui b/data/ui/AboutUberwriterDialog.ui deleted file mode 100644 index 45b73f2..0000000 --- a/data/ui/AboutUberwriterDialog.ui +++ /dev/null @@ -1,51 +0,0 @@ - - - - - https://launchpad.net/uberwriter# Copyright (C) 2012, Wolf Vollprecht <w.vollprecht@gmail.com> -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 3, as published -# by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranties of -# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR -# PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see <http://www.gnu.org/licenses/>. -False - 5 - ../media/uberwriter.svg - normal - UberWriter - 12.07.9 - Copyright (C) 2012, Wolf Vollprecht <w.vollprecht@gmail.com> - Copyright (C) 2012, Wolf Vollprecht <w.vollprecht@gmail.com> - ../media/uberwriter.svg - - - True - False - vertical - 2 - - - True - False - end - - - False - True - end - 0 - - - - - - - - - \ No newline at end of file diff --git a/data/ui/App_menu.ui b/data/ui/App_menu.ui index 416efc0..9846d72 100644 --- a/data/ui/App_menu.ui +++ b/data/ui/App_menu.ui @@ -2,29 +2,34 @@
- Change label - String 1 - - - String 2 - - - String 3 + New window
+
+ + _Shortcuts + + + app.help + Pandoc _Help + + app.about _About diff --git a/data/ui/UberwriterWindow.ui b/data/ui/UberwriterWindow.ui index 2ef1285..80388fc 100644 --- a/data/ui/UberwriterWindow.ui +++ b/data/ui/UberwriterWindow.ui @@ -25,310 +25,385 @@ False format-text-capitalize + + True + False + gtk-spell-check + + + + text/plain + text/x-markdown + + + + True + False + Open Replace + gtk-find-and-replace + + + True + False + gtk-find-and-replace + + + True + False + Activate Regex + find-location-symbolic + True False - - True - False - - + True False - - + + True False - - + _File + True + + True False - False - - - - - - - True - False - False - - - - - - - True - False - - - - - True - False - False - - + + + _New True False - - + True + False + + + + + + + _Open + True + False + True + False + + + + + + + True + False + Open Recent File + True + + + + + Open examples + True + False + False + + True False - + + + True + False + _Quick markdown tutorial + True + + + - - - - - True - False - - - - - True - False - False - - - - - - - True - False - False - - - - - - - True - False - - - - - True - False - False - - - - - - True - False - False - - - - - - True - False - False - - - - - - True - False - - - - - - True - False - - - - - True - False - - - - - - True - False - - - - - True - False - False - + + + True + False + + + + + _Save + True + False + True + False + + + + + + + Save _As + True + False + True + False + + + + + + + True + False + + + + + Export as HTML + True + False + False + + + + + + Export as PDF + True + False + False + + + + + + Export as ODT + True + False + False + + + + + + True + False + Advanced Export... + True + + + + + + True + False + + + + + True + False + Copy Raw HTML to Clipboard + True + + + + + + True + False + + + + + _Quit + True + False + True + False + + + - - - - - True - False - - + + True False - - + _View + True + + True False - - - - - - - True - False - - - - - - - False - - - - - - True - False - Light text on a dark background - - - - - - True - False - Switch to preview mode - - - - - - - True - False - Open Search and Replace - - - - - - - False - - - - - False - True - True - - - - - - False - - - - - False - True - - + + + True + False + Focus Mode + + + + + + + True + False + Fullscreen + + + + + + + False + Sidebar + + + + + + True + False + Light text on a dark background + Dark Mode + + + + + + True + False + Switch to preview mode + Preview + + + + + + + True + False + Open Search and Replace + Search and Replace ... + True + + + + + + + False + + + + + False + Use Typewritermode (experimental) + True + True + + + + + + False + + + + + False + Auto _Spellcheck + True + True + + + + - - - - - True - False - - + + True False - - + _Help + True + + True False - - - - - - True - False - - - - - True - False - - - - - - True - False - - - - - - True - False - - - - - - True - False - - - - - - True - False - - - - - True - False - False + + + True + False + Contents + + + + + + True + False + + + + + True + False + Short Markdown Tutorial + + + + + + True + False + Open Pandoc Online Markdown Help ... + + + + + + True + False + Get Help Online... + True + + + + + + True + False + Translate This Application... + True + + + + + + True + False + + + + + gtk-about + True + False + True + False + + - - 0 0 @@ -825,32 +900,4 @@ - - True - False - gtk-spell-check - - - - text/plain - text/x-markdown - - - - True - False - Open Replace - gtk-find-and-replace - - - True - False - gtk-find-and-replace - - - True - False - Activate Regex - find-location-symbolic - diff --git a/data/ui/about_uberwriter_dialog.xml b/data/ui/about_uberwriter_dialog.xml deleted file mode 100644 index d19a1d1..0000000 --- a/data/ui/about_uberwriter_dialog.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - diff --git a/data/ui/uberwriter_window.xml b/data/ui/uberwriter_window.xml deleted file mode 100644 index 364c697..0000000 --- a/data/ui/uberwriter_window.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - diff --git a/po/uberwriter.pot b/po/uberwriter.pot index 6453a30..7a9a5e3 100644 --- a/po/uberwriter.pot +++ b/po/uberwriter.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-05-19 23:56+0200\n" +"POT-Creation-Date: 2018-03-21 20:10+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -25,95 +25,168 @@ msgstr "" msgid "UberWriter, a simple and distraction free Markdown Editor" msgstr "" -#: ../uberwriter/UberwriterInlinePreview.py:172 -msgid "Website is not available" -msgstr "" - -#: ../uberwriter/UberwriterInlinePreview.py:174 -msgid "Website is available" -msgstr "" - -#: ../uberwriter/UberwriterInlinePreview.py:414 -msgid "Open Link in Webbrowser" -msgstr "" - -#: ../uberwriter/UberwriterInlinePreview.py:470 -msgid "No matching footnote found" -msgstr "" - -#: ../uberwriter/UberwriterWindow.py:343 +#: ../uberwriter/UberwriterWindow.py:354 msgid "Save your File" msgstr "" -#: ../uberwriter/UberwriterWindow.py:489 +#: ../uberwriter/UberwriterWindow.py:500 msgid "You can not export to PDF." msgstr "" -#: ../uberwriter/UberwriterWindow.py:491 +#: ../uberwriter/UberwriterWindow.py:502 msgid "" "Please install texlive from the software center." msgstr "" -#: ../uberwriter/UberwriterWindow.py:521 +#: ../uberwriter/UberwriterWindow.py:532 msgid "MarkDown or Plain Text" msgstr "" -#: ../uberwriter/UberwriterWindow.py:524 +#: ../uberwriter/UberwriterWindow.py:535 msgid "Open a .md-File" msgstr "" -#: ../uberwriter/UberwriterWindow.py:546 +#: ../uberwriter/UberwriterWindow.py:557 msgid "You have not saved your changes." msgstr "" -#: ../uberwriter/UberwriterWindow.py:548 +#: ../uberwriter/UberwriterWindow.py:559 msgid "Close without Saving" msgstr "" -#: ../uberwriter/UberwriterWindow.py:549 +#: ../uberwriter/UberwriterWindow.py:560 msgid "Cancel" msgstr "" -#: ../uberwriter/UberwriterWindow.py:550 +#: ../uberwriter/UberwriterWindow.py:561 msgid "Save now" msgstr "" -#: ../uberwriter/UberwriterWindow.py:551 +#: ../uberwriter/UberwriterWindow.py:562 msgid "Unsaved changes" msgstr "" -#: ../uberwriter/UberwriterWindow.py:617 +#: ../uberwriter/UberwriterWindow.py:628 msgid "You can not enable the Spell Checker." msgstr "" -#: ../uberwriter/UberwriterWindow.py:619 +#: ../uberwriter/UberwriterWindow.py:630 msgid "" "Please install 'hunspell' or 'aspell' dictionarys for your language from the " "software center." msgstr "" -#: ../uberwriter_lib/gtkspellcheck/spellcheck.py:507 -msgid "(no suggestions)" +#: ../data/ui/AboutUberwriterDialog.ui.h:1 +msgid "" +"# Copyright (C) 2012, Wolf Vollprecht \n" +"# This program is free software: you can redistribute it and/or modify it \n" +"# under the terms of the GNU General Public License version 3, as " +"published \n" +"# by the Free Software Foundation.\n" +"# \n" +"# This program is distributed in the hope that it will be useful, but \n" +"# WITHOUT ANY WARRANTY; without even the implied warranties of \n" +"# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR \n" +"# PURPOSE. See the GNU General Public License for more details.\n" +"# \n" +"# You should have received a copy of the GNU General Public License along \n" +"# with this program. If not, see .\n" msgstr "" -#: ../uberwriter_lib/gtkspellcheck/spellcheck.py:544 -#: ../uberwriter_lib/gtkspellcheck/spellcheck.py:547 -msgid "Add \"{}\" to Dictionary" +#: ../data/ui/AboutUberwriterDialog.ui.h:14 +msgid "Copyright (C) 2012, Wolf Vollprecht " msgstr "" -#: ../uberwriter_lib/gtkspellcheck/spellcheck.py:551 -#: ../uberwriter_lib/gtkspellcheck/spellcheck.py:553 -msgid "Ignore All" +#: ../data/ui/UberwriterWindow.ui.h:1 +msgid "Next Match" msgstr "" -#: ../uberwriter_lib/gtkspellcheck/spellcheck.py:568 -#: ../uberwriter_lib/gtkspellcheck/spellcheck.py:570 -msgid "Languages" +#: ../data/ui/UberwriterWindow.ui.h:2 +msgid "Light text on a dark background" msgstr "" -#: ../uberwriter_lib/gtkspellcheck/spellcheck.py:586 -#: ../uberwriter_lib/gtkspellcheck/spellcheck.py:589 -msgid "Suggestions" +#: ../data/ui/UberwriterWindow.ui.h:3 +msgid "Switch to preview mode" +msgstr "" + +#: ../data/ui/UberwriterWindow.ui.h:4 +msgid "Open Search and Replace" +msgstr "" + +#: ../data/ui/UberwriterWindow.ui.h:5 +msgid "Focus Mode" +msgstr "" + +#: ../data/ui/UberwriterWindow.ui.h:6 +msgid "Go into focus mode" +msgstr "" + +#: ../data/ui/UberwriterWindow.ui.h:7 +msgid "Fullscreen" +msgstr "" + +#: ../data/ui/UberwriterWindow.ui.h:8 +msgid "Go into fullscreen mode" +msgstr "" + +#: ../data/ui/UberwriterWindow.ui.h:9 +msgid "Preview" +msgstr "" + +#: ../data/ui/UberwriterWindow.ui.h:10 +msgid "Show HTML preview" +msgstr "" + +#: ../data/ui/UberwriterWindow.ui.h:11 +msgid "Words:" +msgstr "" + +#: ../data/ui/UberwriterWindow.ui.h:12 +msgid "Characters:" +msgstr "" + +#: ../data/ui/UberwriterWindow.ui.h:13 +msgid "Previous Match" +msgstr "" + +#: ../data/ui/UberwriterWindow.ui.h:14 +msgid "Case Sensitive" +msgstr "" + +#: ../data/ui/UberwriterWindow.ui.h:15 +msgid "Replace" +msgstr "" + +#: ../data/ui/UberwriterWindow.ui.h:16 +msgid "Replace all" +msgstr "" + +#: ../data/ui/UberwriterWindow.ui.h:17 +msgid "Open Replace" +msgstr "" + +#: ../data/ui/UberwriterWindow.ui.h:18 +msgid "Activate Regex" +msgstr "" + +#: ../uberwriter/FormatShortcuts.py:88 +msgid "emphasized text" +msgstr "" + +#: ../uberwriter/FormatShortcuts.py:90 +msgid "strong text" +msgstr "" + +#: ../uberwriter/FormatShortcuts.py:92 +msgid "striked out text" +msgstr "" + +#: ../uberwriter/FormatShortcuts.py:106 +msgid "List item" +msgstr "" + +#: ../uberwriter/FormatShortcuts.py:187 +msgid "Heading" msgstr "" #: ../data/ui/UberwriterAdvancedExportDialog.ui.h:1 @@ -229,195 +302,46 @@ msgstr "" msgid "Commandline Reference" msgstr "" -#: ../data/ui/AboutUberwriterDialog.ui.h:1 -msgid "" -"# Copyright (C) 2012, Wolf Vollprecht \n" -"# This program is free software: you can redistribute it and/or modify it \n" -"# under the terms of the GNU General Public License version 3, as " -"published \n" -"# by the Free Software Foundation.\n" -"# \n" -"# This program is distributed in the hope that it will be useful, but \n" -"# WITHOUT ANY WARRANTY; without even the implied warranties of \n" -"# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR \n" -"# PURPOSE. See the GNU General Public License for more details.\n" -"# \n" -"# You should have received a copy of the GNU General Public License along \n" -"# with this program. If not, see .\n" +#: ../uberwriter/UberwriterInlinePreview.py:186 +msgid "Website is not available" msgstr "" -#: ../data/ui/AboutUberwriterDialog.ui.h:14 -msgid "Copyright (C) 2012, Wolf Vollprecht " +#: ../uberwriter/UberwriterInlinePreview.py:188 +msgid "Website is available" msgstr "" -#: ../data/ui/UberwriterWindow.ui.h:1 -msgid "Case Sensitive" +#: ../uberwriter/UberwriterInlinePreview.py:432 +msgid "Open Link in Webbrowser" msgstr "" -#: ../data/ui/UberwriterWindow.ui.h:2 -msgid "Activate Regex" +#: ../uberwriter/UberwriterInlinePreview.py:488 +msgid "No matching footnote found" msgstr "" -#: ../data/ui/UberwriterWindow.ui.h:3 -msgid "_File" +#: ../uberwriter_lib/gtkspellcheck/spellcheck.py:507 +msgid "(no suggestions)" msgstr "" -#: ../data/ui/UberwriterWindow.ui.h:4 -msgid "Open Recent File" +#: ../uberwriter_lib/gtkspellcheck/spellcheck.py:544 +#: ../uberwriter_lib/gtkspellcheck/spellcheck.py:547 +msgid "Add \"{}\" to Dictionary" msgstr "" -#: ../data/ui/UberwriterWindow.ui.h:5 -msgid "Export as ODT" +#: ../uberwriter_lib/gtkspellcheck/spellcheck.py:551 +#: ../uberwriter_lib/gtkspellcheck/spellcheck.py:553 +msgid "Ignore All" msgstr "" -#: ../data/ui/UberwriterWindow.ui.h:6 -msgid "Advanced Export..." +#: ../uberwriter_lib/gtkspellcheck/spellcheck.py:568 +#: ../uberwriter_lib/gtkspellcheck/spellcheck.py:570 +msgid "Languages" msgstr "" -#: ../data/ui/UberwriterWindow.ui.h:7 -msgid "Copy Raw HTML to Clipboard" +#: ../uberwriter_lib/gtkspellcheck/spellcheck.py:586 +#: ../uberwriter_lib/gtkspellcheck/spellcheck.py:589 +msgid "Suggestions" msgstr "" -#: ../data/ui/UberwriterWindow.ui.h:8 -msgid "_View" -msgstr "" - -#: ../data/ui/UberwriterWindow.ui.h:9 -msgid "Light text on a dark background" -msgstr "" - -#: ../data/ui/UberwriterWindow.ui.h:10 -msgid "Dark Mode" -msgstr "" - -#: ../data/ui/UberwriterWindow.ui.h:11 -msgid "Switch to preview mode" -msgstr "" - -#: ../data/ui/UberwriterWindow.ui.h:12 -msgid "Preview" -msgstr "" - -#: ../data/ui/UberwriterWindow.ui.h:13 -msgid "Open Search and Replace" -msgstr "" - -#: ../data/ui/UberwriterWindow.ui.h:14 -msgid "Search and Replace ..." -msgstr "" - -#: ../data/ui/UberwriterWindow.ui.h:15 -msgid "Auto _Spellcheck" -msgstr "" - -#: ../data/ui/UberwriterWindow.ui.h:16 -msgid "_Help" -msgstr "" - -#: ../data/ui/UberwriterWindow.ui.h:17 -msgid "Contents" -msgstr "" - -#: ../data/ui/UberwriterWindow.ui.h:18 -msgid "Short Markdown Tutorial" -msgstr "" - -#: ../data/ui/UberwriterWindow.ui.h:19 -msgid "Open Pandoc Online Markdown Help ..." -msgstr "" - -#: ../data/ui/UberwriterWindow.ui.h:20 -msgid "Get Help Online..." -msgstr "" - -#: ../data/ui/UberwriterWindow.ui.h:21 -msgid "Translate This Application..." -msgstr "" - -#: ../data/ui/UberwriterWindow.ui.h:22 -msgid "Next Match" -msgstr "" - -#: ../data/ui/UberwriterWindow.ui.h:23 -msgid "Normal" -msgstr "" - -#: ../data/ui/UberwriterWindow.ui.h:24 -msgid "Previous Match" -msgstr "" - -#: ../data/ui/UberwriterWindow.ui.h:25 -msgid "Active" -msgstr "" - -#: ../data/ui/UberwriterWindow.ui.h:26 -msgid "toolbutton" -msgstr "" - -#: ../data/ui/UberwriterWindow.ui.h:27 -msgid "Open Replace" -msgstr "" - -#: ../data/ui/UberwriterWindow.ui.h:28 -msgid "Replace with" -msgstr "" - -#: ../data/ui/UberwriterWindow.ui.h:29 -msgid "Replace" -msgstr "" - -#: ../data/ui/UberwriterWindow.ui.h:30 -msgid "Replace All" -msgstr "" - -#: ../data/ui/UberwriterWindow.ui.h:31 -msgid "Focus Mode" -msgstr "" - -#: ../data/ui/UberwriterWindow.ui.h:32 -msgid "Go into focus mode" -msgstr "" - -#: ../data/ui/UberwriterWindow.ui.h:33 -msgid "Fullscreen" -msgstr "" - -#: ../data/ui/UberwriterWindow.ui.h:34 -msgid "Go into fullscreen mode" -msgstr "" - -#: ../data/ui/UberwriterWindow.ui.h:35 -msgid "Show HTML preview" -msgstr "" - -#: ../data/ui/UberwriterWindow.ui.h:36 -msgid "Words:" -msgstr "" - -#: ../data/ui/UberwriterWindow.ui.h:37 -msgid "Characters:" -msgstr "" - -#: ../uberwriter/__init__.py:35 +#: ../uberwriter/__init__.py:36 msgid "Show debug messages (-vv debugs uberwriter_lib also)" msgstr "" - -#: ../uberwriter/FormatShortcuts.py:88 -msgid "emphasized text" -msgstr "" - -#: ../uberwriter/FormatShortcuts.py:90 -msgid "strong text" -msgstr "" - -#: ../uberwriter/FormatShortcuts.py:92 -msgid "striked out text" -msgstr "" - -#: ../uberwriter/FormatShortcuts.py:106 -msgid "List item" -msgstr "" - -#: ../uberwriter/FormatShortcuts.py:187 -msgid "Heading" -msgstr "" diff --git a/uberwriter/AboutUberwriterDialog.py b/uberwriter/AboutUberwriterDialog.py deleted file mode 100644 index d576e53..0000000 --- a/uberwriter/AboutUberwriterDialog.py +++ /dev/null @@ -1,35 +0,0 @@ -# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- -### BEGIN LICENSE -# Copyright (C) 2012, Wolf Vollprecht -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 3, as published -# by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranties of -# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR -# PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -### END LICENSE - -import locale -from locale import gettext as _ -locale.textdomain('uberwriter') - -import logging -logger = logging.getLogger('uberwriter') - -from uberwriter_lib.AboutDialog import AboutDialog - -# See uberwriter_lib.AboutDialog.py for more details about how this class works. -class AboutUberwriterDialog(AboutDialog): - __gtype_name__ = "AboutUberwriterDialog" - - def finish_initializing(self, builder): # pylint: disable=E1002 - """Set up the about dialog""" - super(AboutUberwriterDialog, self).finish_initializing(builder) - - # Code for other initialization actions should be added here. - diff --git a/uberwriter/UberwriterWindow.py b/uberwriter/UberwriterWindow.py index f8d3fae..d1fa51e 100644 --- a/uberwriter/UberwriterWindow.py +++ b/uberwriter/UberwriterWindow.py @@ -921,11 +921,14 @@ class UberwriterWindow(Window): def finish_initializing(self, builder): # pylint: disable=E1002 """Set up the main window""" + super(UberwriterWindow, self).finish_initializing(builder) + self.AboutDialog = AboutUberwriterDialog self.UberwriterAdvancedExportDialog = UberwriterAdvancedExportDialog self.builder = builder + self.connect('save-file', self.save_document) self.connect('save-file-as', self.save_document_as) @@ -945,6 +948,7 @@ class UberwriterWindow(Window): self.texlive_installed = False self.set_name('UberwriterWindow') + self.use_headerbar = True if self.use_headerbar == True: @@ -987,6 +991,7 @@ class UberwriterWindow(Window): self.char_count = builder.get_object('char_count') self.menubar = builder.get_object('menubar1') self.menubar.hide() + # Wire up buttons self.fullscreen_button = builder.get_object('fullscreen_toggle') diff --git a/uberwriter_lib/AboutDialog.py b/uberwriter_lib/AboutDialog.py deleted file mode 100644 index 262ccb5..0000000 --- a/uberwriter_lib/AboutDialog.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- -### BEGIN LICENSE -# Copyright (C) 2012, Wolf Vollprecht -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 3, as published -# by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranties of -# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR -# PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -### END LICENSE - -### DO NOT EDIT THIS FILE ### - -from gi.repository import Gtk # pylint: disable=E0611 - -from . helpers import get_builder - -class AboutDialog(Gtk.AboutDialog): - __gtype_name__ = "AboutDialog" - - def __new__(cls): - """Special static method that's automatically called by Python when - constructing a new instance of this class. - - Returns a fully instantiated AboutDialog object. - """ - builder = get_builder('AboutUberwriterDialog') - new_object = builder.get_object("about_uberwriter_dialog") - new_object.finish_initializing(builder) - return new_object - - def finish_initializing(self, builder): - """Called while initializing this instance in __new__ - - finish_initalizing should be called after parsing the ui definition - and creating a AboutDialog object with it in order - to finish initializing the start of the new AboutUberwriterDialog - instance. - - Put your initialization code in here and leave __init__ undefined. - """ - # Get a reference to the builder and set up the signals. - self.builder = builder - self.ui = builder.get_ui(self) - diff --git a/uberwriter_lib/AppWindow.py b/uberwriter_lib/AppWindow.py index 43deada..17a91a0 100644 --- a/uberwriter_lib/AppWindow.py +++ b/uberwriter_lib/AppWindow.py @@ -1,8 +1,20 @@ +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see <http://www.gnu.org/licenses/>. + import sys import gi gi.require_version('Gtk', '3.0') -from gi.repository import GLib, Gio, Gtk +from gi.repository import GLib, Gio, Gtk, GdkPixbuf from . helpers import get_builder, show_uri, get_help_uri from uberwriter import UberwriterWindow @@ -35,7 +47,7 @@ class Window(Gtk.ApplicationWindow): self.finish_initializing(builder) - return self + return super().__init__(*args, **kwargs) def on_maximize_toggle(self, action, value): @@ -91,9 +103,13 @@ class Application(Gtk.Application): def do_startup(self): Gtk.Application.do_startup(self) - # ~ action = Gio.SimpleAction.new("about", None) - # ~ action.connect("activate", self.on_about) - # ~ self.add_action(action) + action = Gio.SimpleAction.new("help", None) + action.connect("activate", self.on_quit) + self.add_action(action) + + action = Gio.SimpleAction.new("about", None) + action.connect("activate", self.on_about) + self.add_action(action) action = Gio.SimpleAction.new("quit", None) action.connect("activate", self.on_quit) @@ -109,7 +125,7 @@ class Application(Gtk.Application): # Windows are associated with the application # when the last one is closed the application shuts down # self.window = Window(application=self, title="UberWriter") - self.window = UberwriterWindow.UberwriterWindow() + self.window = UberwriterWindow.UberwriterWindow(application=self, title="UberWriter") self.window.present() @@ -123,10 +139,21 @@ class Application(Gtk.Application): self.activate() return 0 - # TODO - # ~ def on_about(self, action, param): - # ~ about_dialog = Gtk.AboutDialog(transient_for=self.window, modal=True) - # ~ about_dialog.present() + + def on_about(self, action, param): + about_dialog = Gtk.AboutDialog(transient_for=self.window, modal=True) + about_dialog.set_program_name("Uberwriter") + about_dialog.set_version("TODO.beta") + about_dialog.set_copyright("Copyright (C) 2018, Wolf Vollprecht") + about_dialog.set_license_type(Gtk.License.GPL_3_0) + about_dialog.set_website("http://uberwriter.wolfvollprecht.de") + about_dialog.set_authors(["Wolf Vollprecht"]) + + logo = GdkPixbuf.Pixbuf.new_from_file("data/media/uberwriter.svg") + + about_dialog.set_logo(logo) + + about_dialog.present() def on_quit(self, action, param): self.quit() diff --git a/uberwriter_lib/Window.py b/uberwriter_lib/Window.py deleted file mode 100644 index a474121..0000000 --- a/uberwriter_lib/Window.py +++ /dev/null @@ -1,139 +0,0 @@ -# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- -### BEGIN LICENSE -# Copyright (C) 2012, Wolf Vollprecht -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 3, as published -# by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranties of -# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR -# PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -### END LICENSE - -### DO NOT EDIT THIS FILE ### - -from gi.repository import Gio, Gtk # pylint: disable=E0611 -import logging -logger = logging.getLogger('uberwriter_lib') - -from . helpers import get_builder, show_uri, get_help_uri - -# This class is meant to be subclassed by UberwriterWindow. It provides -# common functions and some boilerplate. -class Window(Gtk.Application): - __gtype_name__ = "Window" - - # To construct a new instance of this method, the following notable - # methods are called in this order: - # __new__(cls) - # __init__(self) - # finish_initializing(self, builder) - # __init__(self) - # - # For this reason, it's recommended you leave __init__ empty and put - # your initialization code in finish_initializing - - def __new__(cls): - """Special static method that's automatically called by Python when - constructing a new instance of this class. - - Returns a fully instantiated BaseUberwriterWindow object. - """ - App = Gtk.Application() - window = Gtk.ApplicationWindow() - - - builder = get_builder('UberwriterWindow') - new_object = builder.get_object("grid1") - window.add(new_object) - App.window = window - App.window.present() - #window.finish_initializing(builder) - - return App - - def finish_initializing(self, builder): - """Called while initializing this instance in __new__ - - finish_initializing should be called after parsing the UI definition - and creating a UberwriterWindow object with it in order to finish - initializing the start of the new UberwriterWindow instance. - """ - # Get a reference to the builder and set up the signals. - self.builder = builder - self.ui = builder.get_ui(self, True) - self.PreferencesDialog = None # class - self.preferences_dialog = None # instance - self.AboutDialog = None # class - - # self.settings = Gio.Settings("net.launchpad.uberwriter") - # self.settings.connect('changed', self.on_preferences_changed) - - # Optional application indicator support - # Run 'quickly add indicator' to get started. - # More information: - # http://owaislone.org/quickly-add-indicator/ - # https://wiki.ubuntu.com/DesktopExperienceTeam/ApplicationIndicators - try: - from uberwriter import indicator - # self is passed so methods of this class can be called from indicator.py - # Comment this next line out to disable appindicator - self.indicator = indicator.new_application_indicator(self) - except ImportError: - pass - - - - def on_mnu_contents_activate(self, widget, data=None): - show_uri(self, "ghelp:%s" % get_help_uri()) - - def on_mnu_about_activate(self, widget, data=None): - """Display the about box for uberwriter.""" - if self.AboutDialog is not None: - about = self.AboutDialog() # pylint: disable=E1102 - response = about.run() - about.destroy() - - def on_mnu_preferences_activate(self, widget, data=None): - """Display the preferences window for uberwriter.""" - - """ From the PyGTK Reference manual - Say for example the preferences dialog is currently open, - and the user chooses Preferences from the menu a second time; - use the present() method to move the already-open dialog - where the user can see it.""" - if self.preferences_dialog is not None: - logger.debug('show existing preferences_dialog') - self.preferences_dialog.present() - elif self.PreferencesDialog is not None: - logger.debug('create new preferences_dialog') - self.preferences_dialog = self.PreferencesDialog() # pylint: disable=E1102 - self.preferences_dialog.connect('destroy', self.on_preferences_dialog_destroyed) - self.preferences_dialog.show() - # destroy command moved into dialog to allow for a help button - - def on_mnu_close_activate(self, widget, data=None): - """Signal handler for closing the UberwriterWindow.""" - self.destroy() - - def on_destroy(self, widget, data=None): - """Called when the UberwriterWindow is closed.""" - # Clean up code for saving application state should be added here. - Gtk.main_quit() - - def on_preferences_changed(self, settings, key, data=None): - logger.debug('preference changed: %s = %s' % (key, str(settings.get_value(key)))) - - def on_preferences_dialog_destroyed(self, widget, data=None): - '''only affects gui - - logically there is no difference between the user closing, - minimising or ignoring the preferences dialog''' - logger.debug('on_preferences_dialog_destroyed') - # to determine whether to create or present preferences_dialog - self.preferences_dialog = None -