From 2ce88698d3ce86a8ae3d742584b465df43ce275a Mon Sep 17 00:00:00 2001 From: somas95 Date: Sun, 1 Jul 2018 03:14:11 +0200 Subject: [PATCH] Add preferences dialog --- data/ui/Menu.ui | 1 + data/ui/Preferences.ui | 116 ++++++++++++++++++++++++++++ uberwriter_lib/AppWindow.py | 18 +++-- uberwriter_lib/PreferencesDialog.py | 12 +-- 4 files changed, 133 insertions(+), 14 deletions(-) create mode 100644 data/ui/Preferences.ui diff --git a/data/ui/Menu.ui b/data/ui/Menu.ui index bbdb56c..04781a0 100644 --- a/data/ui/Menu.ui +++ b/data/ui/Menu.ui @@ -36,6 +36,7 @@
Preferences + app.preferences
diff --git a/data/ui/Preferences.ui b/data/ui/Preferences.ui new file mode 100644 index 0000000..7928705 --- /dev/null +++ b/data/ui/Preferences.ui @@ -0,0 +1,116 @@ + + + + + + False + True + center-on-parent + True + + + True + False + Preferences + True + + + + + + + + True + True + False + False + + + True + False + center + center + 10 + 10 + 10 + 10 + 10 + 11 + + + True + False + start + start + Use dark mode + + + 0 + 0 + + + + + True + False + Autospellcheck + + + 0 + 1 + + + + + True + True + app.dark_mode + + + 1 + 0 + + + + + True + True + app.spellcheck + True + + + 1 + 1 + + + + + True + + + + + True + False + page 1 + + + False + + + + + + + + + + + + + + + + + + diff --git a/uberwriter_lib/AppWindow.py b/uberwriter_lib/AppWindow.py index 3bedd9e..503eda2 100644 --- a/uberwriter_lib/AppWindow.py +++ b/uberwriter_lib/AppWindow.py @@ -24,6 +24,7 @@ from . helpers import get_builder, show_uri, get_help_uri, get_media_path from uberwriter import UberwriterWindow from uberwriter.Settings import Settings from uberwriter_lib import set_up_logging +from uberwriter_lib.PreferencesDialog import PreferencesDialog from gettext import gettext as _ @@ -165,12 +166,6 @@ class Application(Gtk.Application): action.connect("activate", self.on_search) self.add_action(action) - action = Gio.SimpleAction.new_stateful("preview", - None, - GLib.Variant.new_boolean(False)) - action.connect("change-state", self.on_preview) - self.add_action(action) - action = Gio.SimpleAction.new_stateful("spellcheck", None, GLib.Variant.new_boolean(True)) @@ -211,6 +206,11 @@ class Application(Gtk.Application): action.connect("activate", self.on_html_copy) self.add_action(action) + action = Gio.SimpleAction.new("preferences", None) + action.connect("activate", self.on_preferences) + self.add_action(action) + + '''Shortcuts''' self.set_accels_for_action("app.focus_mode",["d"]) @@ -342,6 +342,12 @@ class Application(Gtk.Application): def on_html_copy(self, action, value): self.window.copy_html_to_clipboard() + + def on_preferences(self, action, value): + PreferencesWindow = PreferencesDialog() + PreferencesWindow.set_application(self) + PreferencesWindow.set_transient_for(self.window) + PreferencesWindow.show() def on_quit(self, action, param): self.quit() diff --git a/uberwriter_lib/PreferencesDialog.py b/uberwriter_lib/PreferencesDialog.py index 14d1c72..0d13d8e 100644 --- a/uberwriter_lib/PreferencesDialog.py +++ b/uberwriter_lib/PreferencesDialog.py @@ -25,7 +25,7 @@ logger = logging.getLogger('uberwriter_lib') from . helpers import get_builder, show_uri, get_help_uri -class PreferencesDialog(Gtk.Dialog): +class PreferencesDialog(Gtk.Window): __gtype_name__ = "PreferencesDialog" def __new__(cls): @@ -34,9 +34,9 @@ class PreferencesDialog(Gtk.Dialog): Returns a fully instantiated PreferencesDialog object. """ - builder = get_builder('PreferencesUberwriterDialog') - new_object = builder.get_object("preferences_uberwriter_dialog") - new_object.finish_initializing(builder) + builder = get_builder('Preferences') + new_object = builder.get_object("PreferencesWindow") + # new_object.finish_initializing(builder) return new_object def finish_initializing(self, builder): @@ -58,7 +58,3 @@ class PreferencesDialog(Gtk.Dialog): def on_btn_close_clicked(self, widget, data=None): self.destroy() - - def on_btn_help_clicked(self, widget, data=None): - show_uri(self, "ghelp:%s" % get_help_uri('preferences')) -