diff --git a/data/media/task-list.lua b/data/media/task-list.lua
new file mode 100644
index 0000000..6a1b365
--- /dev/null
+++ b/data/media/task-list.lua
@@ -0,0 +1,135 @@
+local List = require 'pandoc.List'
+
+local M = {}
+
+local function is_html (format)
+ return format == 'html' or format == 'html4' or format == 'html5'
+end
+
+--- Create a ballot box for the given output format.
+function M.ballot_box (format)
+ if is_html(format) then
+ return pandoc.RawInline(
+ 'html',
+ ' '
+ )
+ elseif format == 'gfm' then
+ -- GFM includes raw HTML
+ return pandoc.RawInline('html', '[ ]')
+ elseif format == 'org' then
+ return pandoc.RawInline('org', '[ ]')
+ elseif format == 'latex' then
+ return pandoc.RawInline('tex', '$\\square$')
+ else
+ return pandoc.Str '☐'
+ end
+end
+
+--- Create a checked ballot box for the given output format.
+function M.ballot_box_with_check (format)
+ if is_html(format) then
+ return pandoc.RawInline(
+ 'html',
+ ' '
+ )
+ elseif format == 'gfm' then
+ -- GFM includes raw HTML
+ return pandoc.RawInline('html', '[x]')
+ elseif format == 'org' then
+ return pandoc.RawInline('org', '[X]')
+ elseif format == 'latex' then
+ return pandoc.RawInline('tex', '$\\rlap{$\\checkmark$}\\square$')
+ else
+ return pandoc.Str '☑'
+ end
+end
+
+--- Replace a Github-style task indicator with a bullet box representation
+--- suitable for the given output format.
+function M.todo_marker (inlines, format)
+ if (inlines[1] and inlines[1].text == '[' and
+ inlines[2] and inlines[2].t == 'Space' and
+ inlines[3] and inlines[3].text == ']') then
+ return M.ballot_box(format), 3
+ elseif (inlines[1] and
+ (inlines[1].text == '[x]' or
+ inlines[1].text == '[X]')) then
+ return M.ballot_box_with_check(format), 1
+ else
+ return nil, 0
+ end
+end
+
+M.css_styles = [[
+
+]]
+
+--- Add task-list CSS styles to the header.
+function M.add_task_list_css(meta)
+ local header_includes
+ if meta['header-includes'] and meta['header-includes'].t == 'MetaList' then
+ header_includes = meta['header-includes']
+ else
+ header_includes = pandoc.MetaList{meta['header-includes']}
+ end
+ header_includes[#header_includes + 1] =
+ pandoc.MetaBlocks{pandoc.RawBlock('html', M.css_styles)}
+ meta['header-includes'] = header_includes
+ return meta
+end
+
+--- Replace the todo marker in the given block, if any.
+function M.replace_todo_markers (blk, format)
+ if blk.t ~= 'Para' and blk.t ~= 'Plain' then
+ return blk
+ end
+ local inlines = blk.content
+ local box, num_inlines = M.todo_marker(inlines, format)
+ if box == nil then
+ return blk
+ end
+ local new_inlines = List:new{box}
+ for j = 1, #inlines do
+ new_inlines[j + 1] = inlines[j + num_inlines]
+ end
+ return pandoc[blk.t](new_inlines) -- create Plain or Para
+end
+
+--- Convert Github- and org-mode-style task markers in a BulletList.
+function M.modifyBulletList (list)
+ if not is_html(FORMAT) then
+ for _, item in ipairs(list.content) do
+ item[1] = M.replace_todo_markers(item[1], FORMAT)
+ end
+ return list
+ else
+ local res = List:new{pandoc.RawBlock('html', '
')}
+ for _, item in ipairs(list.content) do
+ local blk = M.replace_todo_markers(item[1], FORMAT)
+ if blk == item[1] then -- does not have a todo marker
+ res[#res + 1] = pandoc.RawBlock('html', '')
+ else
+ res[#res + 1] = pandoc.RawBlock('html', ' ')
+ item[1] = blk
+ end
+ res:extend(item)
+ res[#res + 1] = pandoc.RawBlock('html', ' ')
+ end
+ res[#res + 1] = pandoc.RawBlock('html', ' ')
+ return res
+ end
+end
+
+M[1] = {
+ BulletList = M.modifyBulletList,
+ Meta = is_html(FORMAT) and M.add_task_list_css or nil
+}
+
+return M
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
new file mode 100644
index 0000000..e43b1b6
--- /dev/null
+++ b/data/ui/App_menu.ui
@@ -0,0 +1,42 @@
+
+
+
+
diff --git a/data/ui/Shortcuts.ui b/data/ui/Shortcuts.ui
new file mode 100644
index 0000000..d3c6dee
--- /dev/null
+++ b/data/ui/Shortcuts.ui
@@ -0,0 +1,151 @@
+
+
+
+ True
+
+
+ True
+ shortcuts
+ 10
+
+
+ True
+ General
+
+
+ True
+ New
+ <Primary>n
+
+
+
+
+ True
+ Open
+ <Primary>o
+
+
+
+
+ True
+ Save
+ <Primary>s
+
+
+
+
+ True
+ Save as
+ <Shift><Primary>s
+
+
+
+
+ True
+ Quit
+ <Primary>w
+
+
+
+
+ True
+ Focus mode
+ <Primary>d
+
+
+
+
+ True
+ Fullscreen
+ F11
+
+
+
+
+ True
+ Preview
+ <Primary>p
+
+
+
+
+ True
+ Search
+ <Primary>f
+
+
+
+
+
+
+ True
+ Editor
+
+
+ True
+ Separator
+ <Primary>r
+
+
+
+
+ True
+ List item
+ <Primary>u
+
+
+
+
+ True
+ Italic
+ <Primary>i
+
+
+
+
+ True
+ Bold
+ <Primary>b
+
+
+
+
+ True
+ Header
+ <Primary>h
+
+
+
+
+ True
+ Cut
+ <Primary>x
+
+
+
+
+ True
+ Copy
+ <Primary>c
+
+
+
+
+ True
+ Paste
+ <Primary>v
+
+
+
+
+ True
+ Select all
+ <Primary>a
+
+
+
+
+
+
+
+
diff --git a/data/ui/UberwriterWindow.ui b/data/ui/UberwriterWindow.ui
index 460a6ac..f38db35 100644
--- a/data/ui/UberwriterWindow.ui
+++ b/data/ui/UberwriterWindow.ui
@@ -1,8 +1,7 @@
-
+
-
@@ -24,7 +23,7 @@
True
False
- format-text-capitalize
+ gtk-spell-check
True
@@ -52,662 +51,766 @@
True
False
Activate Regex
- find-location-symbolic
+ gtk-find
-
- True
- 800
- 500
- ../media/uberwriter.svg
+
+ True
+ False
-
+
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 108255b..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/MarkupBuffer.py b/uberwriter/MarkupBuffer.py
index 606e9d8..eb1311e 100644
--- a/uberwriter/MarkupBuffer.py
+++ b/uberwriter/MarkupBuffer.py
@@ -109,9 +109,9 @@ class MarkupBuffer():
# self.ftag = self.TextBuffer.create_tag("pix_front", pixels_above_lines = 100)
regex = {
- "ITALIC": re.compile(r"\*\w(.+?)\*| _\w(.+?)_ ", re.UNICODE), # *asdasd* // _asdasd asd asd_
- "STRONG": re.compile(r"\*{2}\w(.+?)\*{2}| [_]{2}\w(.+?)[_]{2} ", re.UNICODE), # **as das** // __asdasdasd asd ad a__
- "STRONGITALIC": re.compile(r"\*{3}\w(.+?)\*{3}| [_]{3}\w(.+?)[_]{3} "),
+ "ITALIC": re.compile(r"\*\w(.+?)\*| _\w(.+?)_ |\*(.)\*| _(.)_ ", re.UNICODE), # *asdasd* // _asdasd asd asd_
+ "STRONG": re.compile(r"\*{2}\w(.+?)\*{2}|\*{2}(.)\*{2}| [_]{2}\w(.+?)[_]{2} | [_]{2}(.)[_]{2} ", re.UNICODE), # **as das** // __asdasdasd asd ad a__
+ "STRONGITALIC": re.compile(r"\*{3}\w(.+?)\*{3}|\*{3}(.)\*{3}| [_]{3}\w(.+?)[_]{3} | [_]{3}(.)[_]{3} "),
"BLOCKQUOTE": re.compile(r"^([\>]+ )", re.MULTILINE),
"STRIKETHROUGH": re.compile(r"~~[^ `~\n].+?~~"),
"LIST": re.compile(r"^[\-\*\+] ", re.MULTILINE),
diff --git a/uberwriter/UberwriterWindow.py b/uberwriter/UberwriterWindow.py
index 1e91575..4f712e3 100644
--- a/uberwriter/UberwriterWindow.py
+++ b/uberwriter/UberwriterWindow.py
@@ -27,6 +27,8 @@ locale.textdomain('uberwriter')
import mimetypes
+import gi
+gi.require_version('WebKit2', '4.0')
from gi.repository import Gtk, Gdk, GObject, Gio # pylint: disable=E0611
from gi.repository import WebKit2 as WebKit
from gi.repository import Pango # pylint: disable=E0611
@@ -58,9 +60,9 @@ try:
except:
APT_ENABLED = False
-from uberwriter_lib import Window
+#from uberwriter_lib import Window
+from uberwriter_lib.AppWindow import Window
from uberwriter_lib import helpers
-from .AboutUberwriterDialog import AboutUberwriterDialog
from .UberwriterAdvancedExportDialog import UberwriterAdvancedExportDialog
# from .plugins.bibtex import BibTex
# Some Globals
@@ -72,8 +74,8 @@ CONFIG_PATH = os.path.expanduser("~/.config/uberwriter/")
# See texteditor_lib.Window.py for more details about how this class works
class UberwriterWindow(Window):
- __gtype_name__ = "UberwriterWindow"
-
+ #__gtype_name__ = "UberwriterWindow"
+
__gsignals__ = {
'save-file': (GObject.SIGNAL_ACTION, None, ()),
'open-file': (GObject.SIGNAL_ACTION, None, ()),
@@ -697,7 +699,9 @@ class UberwriterWindow(Window):
'-smart',
'-thtml',
'--mathjax',
+ '--lua-filter=' + helpers.get_media_path('task-list.lua'),
'-c', helpers.get_media_file('uberwriter.css')]
+ print(args)
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
@@ -722,7 +726,7 @@ class UberwriterWindow(Window):
# This saying that all links will be opened in default browser, \
# but local files are opened in appropriate apps:
- self.webview.connect("navigation-requested", self.on_click_link)
+ self.webview.connect("decide-policy", self.on_click_link)
else:
self.ScrolledWindow.remove(self.webview)
self.webview.destroy()
@@ -735,10 +739,11 @@ class UberwriterWindow(Window):
self.queue_draw()
return True
- def on_click_link(self, view, frame, req, data=None):
+ def on_click_link(self, web_view, decision, decision_type):
# This provide ability for self.webview to open links in default browser
- if(req.get_uri().startswith("http://")):
- webbrowser.open(req.get_uri())
+ if(web_view.get_uri().startswith(("http://","https://","www."))):
+ webbrowser.open(web_view.get_uri())
+ decision.ignore()
return True # Don't let the event "bubble up"
def dark_mode_toggled(self, widget, data=None):
@@ -791,9 +796,6 @@ class UberwriterWindow(Window):
def open_launchpad_translation(self, widget, data=None):
webbrowser.open("https://translations.launchpad.net/uberwriter")
- def open_launchpad_help(self, widget, data=None):
- webbrowser.open("https://answers.launchpad.net/uberwriter")
-
def open_pandoc_markdown(self, widget, data=None):
webbrowser.open("http://johnmacfarlane.net/pandoc/README.html#pandocs-markdown")
@@ -920,11 +922,13 @@ 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)
@@ -944,6 +948,7 @@ class UberwriterWindow(Window):
self.texlive_installed = False
self.set_name('UberwriterWindow')
+
self.use_headerbar = True
if self.use_headerbar == True:
@@ -986,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/__init__.py b/uberwriter/__init__.py
index eea85e2..c0e8571 100644
--- a/uberwriter/__init__.py
+++ b/uberwriter/__init__.py
@@ -13,50 +13,34 @@
# You should have received a copy of the GNU General Public License along
# with this program. If not, see .
### END LICENSE
-
-import optparse
+import sys
import locale
import os
from locale import gettext as _
locale.textdomain('uberwriter')
+import gi
+gi.require_version('Gtk', '3.0')
from gi.repository import Gtk # pylint: disable=E0611
from . import UberwriterWindow
-
-from uberwriter_lib import set_up_logging, get_version
-
-def parse_options():
- """Support for command line options"""
- parser = optparse.OptionParser(version="%%prog %s" % get_version())
- parser.add_option(
- "-v", "--verbose", action="count", dest="verbose",
- help=_("Show debug messages (-vv debugs uberwriter_lib also)"))
- parser.add_option(
- "-e", "--experimental-features", help="Use experimental features",
- action='store_true'
- )
- (options, args) = parser.parse_args()
-
- set_up_logging(options)
-
- # print args
-
- return options, args
+from uberwriter_lib import AppWindow
def main():
'constructor for your class instances'
- (options, args) = parse_options()
-
+ # (options, args) = parse_options()
+
# Run the application.
- if args:
- for arg in args:
- window = UberwriterWindow.UberwriterWindow()
- window.load_file(arg)
- else:
- window = UberwriterWindow.UberwriterWindow()
- if options.experimental_features:
- window.use_experimental_features(True)
- window.show()
- Gtk.main()
+ app = AppWindow.Application()
+
+ # ~ if args:
+ # ~ for arg in args:
+ # ~ pass
+ # ~ else:
+ # ~ pass
+ # ~ if options.experimental_features:
+ # ~ window.use_experimental_features(True)
+
+ app.run(sys.argv)
+
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
new file mode 100644
index 0000000..1d552c0
--- /dev/null
+++ b/uberwriter_lib/AppWindow.py
@@ -0,0 +1,195 @@
+# 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 argparse
+
+import locale
+import os
+from locale import gettext as _
+locale.textdomain('uberwriter')
+
+import gi
+gi.require_version('Gtk', '3.0')
+from gi.repository import GLib, Gio, Gtk, GdkPixbuf
+
+from . helpers import get_builder, show_uri, get_help_uri, get_media_path
+from uberwriter import UberwriterWindow
+from uberwriter_lib import set_up_logging
+
+class Window(Gtk.ApplicationWindow):
+
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+
+ # This will be in the windows group and have the "win" prefix
+ max_action = Gio.SimpleAction.new_stateful("maximize", None,
+ GLib.Variant.new_boolean(False))
+ max_action.connect("change-state", self.on_maximize_toggle)
+ self.add_action(max_action)
+
+ # Keep it in sync with the actual state
+ self.connect("notify::is-maximized",
+ lambda obj, pspec: max_action.set_state(
+ GLib.Variant.new_boolean(obj.props.is_maximized)))
+
+ self.set_default_size(800,500)
+
+ icon_file = get_media_path("uberwriter.svg")
+ self.set_icon_from_file(icon_file)
+
+ builder = get_builder('UberwriterWindow')
+ new_object = builder.get_object("grid1")
+
+ self.contents = new_object
+ self.add(self.contents)
+
+ self.finish_initializing(builder)
+
+ return super().__init__(*args, **kwargs)
+
+
+ def on_maximize_toggle(self, action, value):
+ action.set_state(value)
+ if value.get_boolean():
+ self.maximize()
+ else:
+ self.unmaximize()
+
+ 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
+
+
+class Application(Gtk.Application):
+
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, application_id="de.wolfvollprecht.UberWriter",
+ flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE,
+ **kwargs)
+ self.window = None
+
+ def do_startup(self):
+ Gtk.Application.do_startup(self)
+
+ action = Gio.SimpleAction.new("help", None)
+ action.connect("activate", self.on_help)
+ self.add_action(action)
+
+ action = Gio.SimpleAction.new("shortcuts", None)
+ action.connect("activate", self.on_shortcuts)
+ 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)
+ self.add_action(action)
+
+ builder = get_builder('App_menu')
+ self.set_app_menu(builder.get_object("app-menu"))
+
+
+ def do_activate(self):
+ # We only allow a single window and raise any existing ones
+ if not self.window:
+ # 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(application=self, title="UberWriter")
+ if len(self.args) > 0:
+ self.window.load_file(self.args[0])
+ if self.options.experimental_features:
+ self.window.use_experimental_features(True)
+
+
+ self.window.present()
+
+ def do_command_line(self, command_line):
+
+ """Support for command line options"""
+ parser = argparse.ArgumentParser()
+ parser.add_argument(
+ "-v", "--verbose", action="count", dest="verbose",
+ help=_("Show debug messages (-vv debugs uberwriter_lib also)"))
+ parser.add_argument(
+ "-e", "--experimental-features", help=_("Use experimental features"),
+ action='store_true'
+ )
+ (self.options, self.args) = parser.parse_known_args()
+
+ set_up_logging(self.options)
+
+ self.activate()
+ return 0
+
+
+ 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("Uberwriter website http://uberwriter.wolfvollprecht.de")
+ about_dialog.set_authors(["Wolf Vollprecht ",
+ "Manuel Genovés "])
+
+ logo_file = get_media_path("uberwriter.svg")
+ logo = GdkPixbuf.Pixbuf.new_from_file(logo_file)
+
+ about_dialog.set_logo(logo)
+
+ about_dialog.present()
+
+ def on_help(self, action, param):
+ self.window.open_pandoc_markdown(self)
+
+ def on_shortcuts(self, action, param):
+ builder = get_builder('Shortcuts')
+ builder.get_object("shortcuts").set_transient_for(self.window)
+ builder.get_object("shortcuts").show()
+
+ def on_quit(self, action, param):
+ self.quit()
+
+# ~ if __name__ == "__main__":
+ # ~ app = Application()
+ # ~ app.run(sys.argv)
diff --git a/uberwriter_lib/Window.py b/uberwriter_lib/Window.py
deleted file mode 100644
index fc22d40..0000000
--- a/uberwriter_lib/Window.py
+++ /dev/null
@@ -1,129 +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.ApplicationWindow):
- __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.
- """
- builder = get_builder('UberwriterWindow')
- new_object = builder.get_object("uberwriter_window")
- new_object.finish_initializing(builder)
- return new_object
-
- 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
-
diff --git a/uberwriter_lib/__init__.py b/uberwriter_lib/__init__.py
index 5ec5c82..05613f6 100644
--- a/uberwriter_lib/__init__.py
+++ b/uberwriter_lib/__init__.py
@@ -20,6 +20,6 @@
while keeping its api constant'''
from . helpers import set_up_logging
-from . Window import Window
+from . AppWindow import Window
from . uberwriterconfig import get_version