From 0c2876861f314b9611ac35378291fae313f1a168 Mon Sep 17 00:00:00 2001 From: Evangelos Paterakis Date: Thu, 29 Dec 2022 22:04:45 +0200 Subject: [PATCH] feat(status)[a11y]: large font and line height options fix: #40 --- data/dev.geopjr.tooth.gschema.xml | 6 ++++++ data/style.css | 8 ++++++++ data/ui/dialogs/preferences.ui | 29 +++++++++++++++++++++++++++++ src/Dialogs/Preferences.vala | 4 ++++ src/Services/Settings.vala | 4 ++++ src/Widgets/Status.vala | 20 ++++++++++++++++++++ 6 files changed, 71 insertions(+) diff --git a/data/dev.geopjr.tooth.gschema.xml b/data/dev.geopjr.tooth.gschema.xml index bc0a79f..b08f05e 100644 --- a/data/dev.geopjr.tooth.gschema.xml +++ b/data/dev.geopjr.tooth.gschema.xml @@ -36,6 +36,12 @@ false + + false + + + false + false diff --git a/data/style.css b/data/style.css index c6c80ac..652806c 100644 --- a/data/style.css +++ b/data/style.css @@ -148,3 +148,11 @@ .ttl-box-no-shadow > revealer > box { box-shadow: none; } + +.ttl-status-font-large { + font-size: 18.333333333333332px; +} + +.ttl-status-line-height-large { + line-height: 1.4; +} diff --git a/data/ui/dialogs/preferences.ui b/data/ui/dialogs/preferences.ui index 7aff986..b8cc04d 100644 --- a/data/ui/dialogs/preferences.ui +++ b/data/ui/dialogs/preferences.ui @@ -166,6 +166,35 @@ + + + Status + + + Larger font size + larger_font_size + Makes the status font larger + + + center + + + + + + + Larger line height + larger_line_height + Makes the status line height larger + + + center + + + + + + diff --git a/src/Dialogs/Preferences.vala b/src/Dialogs/Preferences.vala index 0e23076..9af4dba 100644 --- a/src/Dialogs/Preferences.vala +++ b/src/Dialogs/Preferences.vala @@ -11,6 +11,8 @@ public class Tooth.Dialogs.Preferences : Adw.PreferencesWindow { [GtkChild] unowned Switch live_updates; [GtkChild] unowned Switch public_live_updates; [GtkChild] unowned Switch show_spoilers; + [GtkChild] unowned Switch larger_font_size; + [GtkChild] unowned Switch larger_line_height; static construct { typeof (ColorSchemeListModel).ensure (); @@ -47,6 +49,8 @@ public class Tooth.Dialogs.Preferences : Adw.PreferencesWindow { settings.bind ("live-updates", live_updates, "active", SettingsBindFlags.DEFAULT); settings.bind ("public-live-updates", public_live_updates, "active", SettingsBindFlags.DEFAULT); settings.bind ("show-spoilers", show_spoilers, "active", SettingsBindFlags.DEFAULT); + settings.bind ("larger-font-size", larger_font_size, "active", SettingsBindFlags.DEFAULT); + settings.bind ("larger-line-height", larger_line_height, "active", SettingsBindFlags.DEFAULT); } [GtkCallback] diff --git a/src/Services/Settings.vala b/src/Services/Settings.vala index a877328..d6f70bf 100644 --- a/src/Services/Settings.vala +++ b/src/Services/Settings.vala @@ -11,6 +11,8 @@ public class Tooth.Settings : GLib.Settings { public bool live_updates { get; set; } public bool public_live_updates { get; set; } public bool show_spoilers { get; set; } + public bool larger_font_size { get; set; } + public bool larger_line_height { get; set; } public bool aggressive_resolving { get; set; } public Settings () { @@ -24,6 +26,8 @@ public class Tooth.Settings : GLib.Settings { init ("live-updates"); init ("public-live-updates"); init ("show-spoilers"); + init ("larger-font-size"); + init ("larger-line-height"); init ("aggressive-resolving"); } diff --git a/src/Widgets/Status.vala b/src/Widgets/Status.vala index dac72f6..2dab373 100644 --- a/src/Widgets/Status.vala +++ b/src/Widgets/Status.vala @@ -71,6 +71,11 @@ public class Tooth.Widgets.Status : ListBoxRow { construct { open.connect (on_open); + if (settings.larger_font_size) + add_css_class("ttl-status-font-large"); + + if (settings.larger_line_height) + add_css_class("ttl-status-line-height-large"); rebuild_actions (); } @@ -215,6 +220,21 @@ public class Tooth.Widgets.Status : ListBoxRow { // status.formal.bind_property ("has-spoiler", this, "reveal-spoiler", BindingFlags.INVERT_BOOLEAN); + settings.notify["larger-font-size"].connect (() => { + if (settings.larger_font_size) { + add_css_class("ttl-status-font-large"); + } else { + remove_css_class("ttl-status-font-large"); + } + }); + settings.notify["larger-line-height"].connect (() => { + if (settings.larger_line_height) { + add_css_class("ttl-status-line-height-large"); + } else { + remove_css_class("ttl-status-line-height-large"); + } + }); + status.formal.bind_property ("has-spoiler", this, "reveal-spoiler", BindingFlags.SYNC_CREATE, (b, src, ref target) => { target.set_boolean (!src.get_boolean () || settings.show_spoilers); return true;