Add preferences dialog

webkit2png
somas95 2018-07-01 03:14:11 +02:00
parent 96731ef8f6
commit 2ce88698d3
4 changed files with 133 additions and 14 deletions

View File

@ -36,6 +36,7 @@
<section>
<item>
<attribute name="label" translatable="yes">Preferences</attribute>
<attribute name="action">app.preferences</attribute>
</item>
</section>
<section>

View File

@ -0,0 +1,116 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkWindow" id="PreferencesWindow">
<property name="can_focus">False</property>
<property name="modal">True</property>
<property name="window_position">center-on-parent</property>
<property name="skip_taskbar_hint">True</property>
<child type="titlebar">
<object class="GtkHeaderBar" id="Preferences_hb">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="title" translatable="yes">Preferences</property>
<property name="show_close_button">True</property>
<child>
<placeholder/>
</child>
</object>
</child>
<child>
<object class="GtkNotebook" id="Preferences_nb">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="show_tabs">False</property>
<property name="show_border">False</property>
<child>
<object class="GtkGrid" id="Grid1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="margin_left">10</property>
<property name="margin_right">10</property>
<property name="margin_top">10</property>
<property name="margin_bottom">10</property>
<property name="row_spacing">10</property>
<property name="column_spacing">11</property>
<child>
<object class="GtkLabel" id="Dark_mode_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="valign">start</property>
<property name="label" translatable="yes">Use dark mode</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="Spellcheck_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Autospellcheck</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="Dark_mode_switch">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="action_name">app.dark_mode</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="Spellcheck_switch">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="action_name">app.spellcheck</property>
<property name="active">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
</object>
<packing>
<property name="tab_expand">True</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel" id="Label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">page 1</property>
</object>
<packing>
<property name="tab_fill">False</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child type="tab">
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child type="tab">
<placeholder/>
</child>
</object>
</child>
</object>
</interface>

View File

@ -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",["<Ctl>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()

View File

@ -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'))