allow disabling overlay within preferences window

ft.librem5
Manuel Genovés 2018-12-14 20:01:00 +01:00
parent 3fd91923ee
commit 56e718be15
3 changed files with 46 additions and 2 deletions

View File

@ -40,9 +40,10 @@
<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="halign">end</property>
<property name="valign">start</property>
<property name="label" translatable="yes">Use dark mode</property>
<property name="justify">right</property>
</object>
<packing>
<property name="left_attach">0</property>
@ -53,7 +54,9 @@
<object class="GtkLabel" id="Spellcheck_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="label" translatable="yes">Autospellcheck</property>
<property name="justify">right</property>
</object>
<packing>
<property name="left_attach">0</property>
@ -83,6 +86,31 @@
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="Gradient_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="label" translatable="yes">Draw scroll gradient</property>
<property name="justify">right</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="Gradient_switch">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="valign">start</property>
<property name="action_name">app.draw_gradient</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
</packing>
</child>
</object>
<packing>
<property name="tab_expand">True</property>

View File

@ -153,7 +153,7 @@ class UberwriterWindow(Gtk.ApplicationWindow):
# Let them disable it
if self.settings.get_value("gradient-overlay"):
self.scrolled_window.connect_after("draw", self.draw_gradient)
self.overlay = self.scrolled_window.connect_after("draw", self.draw_gradient)
self.smooth_scroll_starttime = 0
self.smooth_scroll_endtime = 0

View File

@ -98,6 +98,12 @@ class Application(Gtk.Application):
action.connect("change-state", self.on_spellcheck)
self.add_action(action)
action = Gio.SimpleAction.new_stateful("draw_gradient",
None,
GLib.Variant.new_boolean(True))
action.connect("change-state", self.on_draw_gradient)
self.add_action(action)
# Menu Actions
action = Gio.SimpleAction.new("new", None)
@ -235,6 +241,16 @@ class Application(Gtk.Application):
action.set_state(value)
self.window.toggle_spellcheck(value)
def on_draw_gradient(self, action, value):
action.set_state(value)
self.settings.set_value("gradient-overlay",
GLib.Variant("b", value))
if value:
self.window.overlay = self.window.scrolled_window.connect_after(
"draw", self.window.draw_gradient)
else:
self.window.scrolled_window.disconnect(self.window.overlay)
def on_new(self, _action, _value):
self.window.new_document()