diff options
-rw-r--r-- | data/org.ArcticaProject.arctica-greeter.gschema.xml | 6 | ||||
-rw-r--r-- | src/arctica-greeter.vala | 42 | ||||
-rw-r--r-- | src/settings.vala | 44 |
3 files changed, 64 insertions, 28 deletions
diff --git a/data/org.ArcticaProject.arctica-greeter.gschema.xml b/data/org.ArcticaProject.arctica-greeter.gschema.xml index b8085af..dad830a 100644 --- a/data/org.ArcticaProject.arctica-greeter.gschema.xml +++ b/data/org.ArcticaProject.arctica-greeter.gschema.xml @@ -90,13 +90,17 @@ <summary>GTK+ theme to use</summary> </key> <key name="high-contrast-theme-name" type="s"> - <default>'HighContrastInverse'</default> + <default>'HighContrast'</default> <summary>GTK+ theme to use in high contrast mode</summary> </key> <key name="icon-theme-name" type="s"> <default>'Numix'</default> <summary>Icon theme to use</summary> </key> + <key name="high-contrast-icon-theme-name" type="s"> + <default>'HighContrast'</default> + <summary>Icon theme to use in high contrast mode</summary> + </key> <key name="cursor-theme-name" type="s"> <default>'default'</default> <summary>Cursor theme to use</summary> diff --git a/src/arctica-greeter.vala b/src/arctica-greeter.vala index 245c1dc..d0f9902 100644 --- a/src/arctica-greeter.vala +++ b/src/arctica-greeter.vala @@ -1071,12 +1071,37 @@ public class ArcticaGreeter : Object /* Set GTK+ settings */ debug ("Setting GTK+ settings"); var settings = Gtk.Settings.get_default (); - var value = AGSettings.get_string (AGSettings.KEY_THEME_NAME); + + /* + * Keep a reference to an AGSettings instance for the whole program + * run, so that the SingleInstance property is working the way we'd + * like it to work. + * + * We want to do this before creating the actual greeter, since the + * latter is using AGSettings quite extensively. + * + * This might throw a Vala warning: "local variable `agsettings' + * declared but never used" if we don't use the variable, but this can + * safely be ignored. + */ + var agsettings = new AGSettings (); + string value = ""; + if (agsettings.high_contrast) + { + value = AGSettings.get_string (AGSettings.KEY_HIGH_CONTRAST_THEME_NAME); + } else { + value = AGSettings.get_string (AGSettings.KEY_THEME_NAME); + } if (value != ""){ debug ("Setting GTK theme: %s", value); settings.set ("gtk-theme-name", value, null); } - value = AGSettings.get_string (AGSettings.KEY_ICON_THEME_NAME); + if (agsettings.high_contrast) + { + value = AGSettings.get_string (AGSettings.KEY_HIGH_CONTRAST_ICON_THEME_NAME); + } else { + value = AGSettings.get_string (AGSettings.KEY_ICON_THEME_NAME); + } if (value != ""){ debug ("Setting icon theme: %s", value); settings.set ("gtk-icon-theme-name", value, null); @@ -1107,19 +1132,6 @@ public class ArcticaGreeter : Object if (value != "") settings.set ("gtk-xft-rgba", value, null); - /* - * Keep a reference to an AGSettings instance for the whole program - * run, so that the SingleInstance property is working the way we'd - * like it to work. - * - * We want to do this before creating the actual greeter, since the - * latter is using AGSettings quite extensively. - * - * This will throw a Vala warning: "local variable `agsettings' declared - * but never used". Which can be ignored. - */ - var agsettings = new AGSettings (); - debug ("Creating Arctica Greeter"); var greeter = new ArcticaGreeter (do_test_mode, do_test_highcontrast, do_test_bigfont); greeter.go(); diff --git a/src/settings.vala b/src/settings.vala index 7e8306d..656b52a 100644 --- a/src/settings.vala +++ b/src/settings.vala @@ -38,6 +38,7 @@ public class AGSettings : Object 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_HIGH_CONTRAST_ICON_THEME_NAME = "high-contrast-icon-theme-name"; public const string KEY_CURSOR_THEME_NAME = "cursor-theme-name"; public const string KEY_CURSOR_THEME_SIZE = "cursor-theme-size"; public const string KEY_FONT_NAME = "font-name"; @@ -140,10 +141,19 @@ public class AGSettings : Object } 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_); - */ + * This function is currently empty, but we'll keep it around, + * including this comment, because it's important to know what to do + * with it if it's needed. + * + * Since AGSettings is a SingleInstance class, this function will only + * be called once, as long as we make sure to create an instance early + * in the program cycle and keep a reference to it for the rest of its + * execution. + * + * In case you need to execute code once, whenever the first AGSettings + * instance is created, do it here. + */ } public bool high_contrast { @@ -162,20 +172,31 @@ public class AGSettings : Object greeter.switch_contrast (value); var settings = Gtk.Settings.get_default (); + var theme_name = ""; + var icon_theme_name = ""; + 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)); + + /* FIXME: We need to check for wrong theme names here and handle such flaws gracefully */ + + theme_name = AGSettings.get_string (AGSettings.KEY_HIGH_CONTRAST_THEME_NAME); + icon_theme_name = AGSettings.get_string (AGSettings.KEY_HIGH_CONTRAST_ICON_THEME_NAME); + debug ("Switching GTK Theme to high contrast theme \"%s\"", theme_name); + debug ("Switching icon theme to high contrast theme \"%s\"", icon_theme_name); } else { - /* - debug ("Switching GTK Theme to default theme \"%s\"", this.default_theme_name_); - */ - settings.set ("gtk-theme-name", this.default_theme_name_); + + /* FIXME: We need to check for wrong theme names here and handle such flaws gracefully */ + + theme_name = AGSettings.get_string (AGSettings.KEY_THEME_NAME); + icon_theme_name = AGSettings.get_string (AGSettings.KEY_ICON_THEME_NAME); + debug ("Switching GTK Theme to default theme \"%s\"", theme_name); + debug ("Switching icon theme to default icon theme \"%s\"", icon_theme_name); } + settings.set ("gtk-theme-name", theme_name); + settings.set ("gtk-icon-theme-name", icon_theme_name); } } @@ -198,5 +219,4 @@ public class AGSettings : Object 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_; } |