diff options
author | Mihai Moldovan <ionic@ionic.de> | 2022-12-06 05:10:29 +0100 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2023-02-06 08:30:01 +0100 |
commit | 33d2f8d0461314c5eeaab2c74b10b545906e1491 (patch) | |
tree | b550428b5d03ff49f8f9b8dab514d63dd64c9766 /src/toggle-box.vala | |
parent | 131bcb9889b9eb9b8eeb895f23ae1d53a25aefe8 (diff) | |
download | arctica-greeter-33d2f8d0461314c5eeaab2c74b10b545906e1491.tar.gz arctica-greeter-33d2f8d0461314c5eeaab2c74b10b545906e1491.tar.bz2 arctica-greeter-33d2f8d0461314c5eeaab2c74b10b545906e1491.zip |
misc src/: completely rework high contrast mode, add stub for big font mode.
This is a work-in-progress.
The reworked high contrast mode adds support for a configurable high
contrast GTK theme and changes a lot of widgets to change their color.
The big font mode is a stub currently.
Diffstat (limited to 'src/toggle-box.vala')
-rw-r--r-- | src/toggle-box.vala | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/src/toggle-box.vala b/src/toggle-box.vala index c157f60..518275f 100644 --- a/src/toggle-box.vala +++ b/src/toggle-box.vala @@ -70,8 +70,21 @@ public class ToggleBox : Gtk.Box " background-image: none;"+ "}\n"+ "button:hover,\n"+ - "button:hover:active {\n"+ + "button:active,\n" + + "button:hover:active,\n" + + "button.selected {\n"+ " background-color: %s;\n".printf(AGSettings.get_string (AGSettings.KEY_TOGGLEBOX_BUTTON_BGCOLOR))+ + "}\n" + + "button.high_contrast {\n" + + " background-color: %s;\n".printf ("rgba(70, 70, 70, 1.0)") + + " background-image: none;\n" + + " border-color: %s\n;".printf ("rgba(0, 0, 0, 1.0)") + + "}\n" + + "button.high_contrast:hover,\n" + + "button.high_contrast:active,\n" + + "button.high_contrast:hover:active,\n" + + "button.high_contrast.selected {\n" + + " background-color: %s;\n".printf ("rgba(0, 0, 0, 1.0)") + "}\n", -1); button.get_style_context ().add_provider (style, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); } @@ -113,9 +126,8 @@ public class ToggleBox : Gtk.Box selected_button = button; selected_key = selected_button.get_data<string> ("toggle-list-key"); - var bg_color = Gdk.RGBA (); - bg_color.parse (AGSettings.get_string (AGSettings.KEY_TOGGLEBOX_BUTTON_BGCOLOR)); - selected_button.override_background_color(Gtk.StateFlags.NORMAL, bg_color); + /* Handle color via CSS. */ + selected_button.get_style_context ().add_class ("selected"); } private Gtk.Button make_button (string key, string name_in, Gdk.Pixbuf? icon) @@ -140,7 +152,24 @@ public class ToggleBox : Gtk.Box } var label = new Gtk.Label (null); - label.set_markup ("<span font=\"%s %d\" fgcolor=\"%s\">%s</span>".printf (font_family, font_size+2, AGSettings.get_string (AGSettings.KEY_TOGGLEBOX_FONT_FGCOLOR), name)); + /* Font and other properties are being handled via CSS. */ + label.set_text (name); + try { + var style = new Gtk.CssProvider (); + style.load_from_data ("label {\n" + + " font-family: \"%s\", sans-serif;\n".printf (font_family) + + " font-size: %d;\n".printf (font_size + 2) + + " color: %s;\n".printf (AGSettings.get_string (AGSettings.KEY_TOGGLEBOX_FONT_FGCOLOR)) + + "}\n" + + "label.high_contrast {\n" + + " color: %s;\n".printf ("rgba(255, 255, 255, 1.0)") + + "}\n", -1); + label.get_style_context ().add_provider (style, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + } + catch (Error e) + { + debug ("Internal error loading session chooser label style: %s", e.message); + } label.halign = Gtk.Align.START; hbox.pack_start (label, true, true, 0); |