From 33d2f8d0461314c5eeaab2c74b10b545906e1491 Mon Sep 17 00:00:00 2001 From: Mihai Moldovan Date: Tue, 6 Dec 2022 05:10:29 +0100 Subject: 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. --- src/toggle-box.vala | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) (limited to 'src/toggle-box.vala') 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 ("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 ("%s".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); -- cgit v1.2.3