diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2023-02-06 10:50:34 +0100 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2023-02-06 10:50:34 +0100 |
commit | 642cbe7d3830c7dd27230ea84e86277243ccd7b7 (patch) | |
tree | 6d4f269e0389b8f12d267cb715dc663382763c82 /src/settings.vala | |
parent | b2fac08944adadd4b278a58a5fe363ef0df1e9c2 (diff) | |
parent | bf00dadc0584d911bf4c23cc4ab25e8a09c611ce (diff) | |
download | arctica-greeter-642cbe7d3830c7dd27230ea84e86277243ccd7b7.tar.gz arctica-greeter-642cbe7d3830c7dd27230ea84e86277243ccd7b7.tar.bz2 arctica-greeter-642cbe7d3830c7dd27230ea84e86277243ccd7b7.zip |
Merge remote-tracking branch 'gh-Ionic/feature/high-contrast-big-font'
Attributes GH PR #40: https://github.com/ArcticaProject/arctica-greeter/pull/40
Diffstat (limited to 'src/settings.vala')
-rw-r--r-- | src/settings.vala | 71 |
1 files changed, 70 insertions, 1 deletions
diff --git a/src/settings.vala b/src/settings.vala index 701d5a1..af753ce 100644 --- a/src/settings.vala +++ b/src/settings.vala @@ -2,6 +2,7 @@ * * Copyright (C) 2011,2012 Canonical Ltd * Copyright (C) 2015,2017 Mike Gabriel <mike.gabriel@das-netzwerkteam.de> + * Copyright (C) 2022 Mihai Moldovan <ionic@ionic.de> * * 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 @@ -20,7 +21,8 @@ * Mike Gabriel <mike.gabriel@das-netzwerkteam.de> */ -public class AGSettings +[SingleInstance] +public class AGSettings : Object { public const string KEY_BACKGROUND = "background"; public const string KEY_BACKGROUND_COLOR = "background-color"; @@ -29,6 +31,7 @@ public class AGSettings public const string KEY_SHOW_HOSTNAME = "show-hostname"; public const string KEY_LOGO = "logo"; public const string KEY_THEME_NAME = "theme-name"; + public const string KEY_HIGH_CONTRAST_THEME_NAME = "high-contrast-theme-name"; public const string KEY_ICON_THEME_NAME = "icon-theme-name"; public const string KEY_FONT_NAME = "font-name"; public const string KEY_XFT_ANTIALIAS = "xft-antialias"; @@ -37,6 +40,7 @@ public class AGSettings public const string KEY_XFT_RGBA = "xft-rgba"; public const string KEY_ONSCREEN_KEYBOARD = "onscreen-keyboard"; public const string KEY_HIGH_CONTRAST = "high-contrast"; + public const string KEY_BIG_FONT = "big-font"; public const string KEY_SCREEN_READER = "screen-reader"; public const string KEY_PLAY_READY_SOUND = "play-ready-sound"; public const string KEY_INDICATORS = "indicators"; @@ -49,6 +53,8 @@ public class AGSettings public const string KEY_TOGGLEBOX_FONT_FGCOLOR = "togglebox-font-fgcolor"; public const string KEY_TOGGLEBOX_BUTTON_BGCOLOR = "togglebox-button-bgcolor"; public const string KEY_ENABLE_HIDPI = "enable-hidpi"; + public const string KEY_MENUBAR_ALPHA = "menubar-alpha"; + public static bool get_boolean (string key) { @@ -105,5 +111,68 @@ public class AGSettings return gsettings.set_strv (key, value); } + public AGSettings () + { + } + + construct { + Gtk.Settings.get_default ().get ("gtk-theme-name", out this.default_theme_name_); + /* + debug ("Fetched default theme name in construct: %s", this.default_theme_name_); + */ + } + + public bool high_contrast { + get { + return this.high_contrast_; + } + + set { + debug ("Called high contrast setter with value %s", value.to_string ()); + this.high_contrast_ = value; + + /* Also sync back to dconf, so that this state is persistent. */ + set_boolean (AGSettings.KEY_HIGH_CONTRAST, value); + + var greeter = new ArcticaGreeter (); + greeter.switch_contrast (value); + + var settings = Gtk.Settings.get_default (); + if (value) + { + /* + debug ("Switching GTK Theme to high contrast theme \"%s\"", AGSettings.get_string (AGSettings.KEY_HIGH_CONTRAST_THEME_NAME)); + */ + settings.set ("gtk-theme-name", AGSettings.get_string (AGSettings.KEY_HIGH_CONTRAST_THEME_NAME)); + } + else + { + /* + debug ("Switching GTK Theme to default theme \"%s\"", this.default_theme_name_); + */ + settings.set ("gtk-theme-name", this.default_theme_name_); + } + } + } + + public bool big_font { + get { + return this.big_font_; + } + + set { + this.big_font_ = value; + + /* Also sync back to dconf, so that this state is persistent. */ + set_boolean (AGSettings.KEY_BIG_FONT, value); + + var greeter = new ArcticaGreeter (); + greeter.switch_font (value); + } + } + private const string SCHEMA = "org.ArcticaProject.arctica-greeter"; + private bool high_contrast_ = AGSettings.get_boolean (AGSettings.KEY_HIGH_CONTRAST); + private bool big_font_ = AGSettings.get_boolean (AGSettings.KEY_BIG_FONT); + private string default_theme_name_; } |