aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2023-03-01 13:46:07 +0100
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2023-03-01 13:46:07 +0100
commita4537a44bffc689d71714ac0d6b327877af237cc (patch)
tree7765df0861fe1a3cf755390e835c17d45f065f8f
parent5c9019b87b830f5d9d2b2f8aabfec26b345a1238 (diff)
downloadarctica-greeter-a4537a44bffc689d71714ac0d6b327877af237cc.tar.gz
arctica-greeter-a4537a44bffc689d71714ac0d6b327877af237cc.tar.bz2
arctica-greeter-a4537a44bffc689d71714ac0d6b327877af237cc.zip
src/flat-button.vala: Allow color-theming (etc.) of buttons created via the FlatButton class.
-rw-r--r--data/org.ArcticaProject.arctica-greeter.gschema.xml7
-rw-r--r--src/flat-button.vala26
-rw-r--r--src/settings.vala2
3 files changed, 33 insertions, 2 deletions
diff --git a/data/org.ArcticaProject.arctica-greeter.gschema.xml b/data/org.ArcticaProject.arctica-greeter.gschema.xml
index 3f10940..98ce440 100644
--- a/data/org.ArcticaProject.arctica-greeter.gschema.xml
+++ b/data/org.ArcticaProject.arctica-greeter.gschema.xml
@@ -16,6 +16,13 @@
<key name="togglebox-button-bgcolor" type="s">
<default>'#2F70C6'</default>
<summary>Font foreground color (e.g. #202020) for selected session names in session list</summary>
+ <key name="flatbutton-bgcolor" type="s">
+ <default>'#4B1635'</default>
+ <summary>Background color (e.g. #391C31) of flat buttons (e.g. the session chooser icon)</summary>
+ </key>
+ <key name="flatbutton-bordercolor" type="s">
+ <default>'#4B1635'</default>
+ <summary>Border color (e.g. #391C31) of flat buttons (e.g. the session chooser icon)</summary>
</key>
<key name="draw-user-backgrounds" type="b">
<default>true</default>
diff --git a/src/flat-button.vala b/src/flat-button.vala
index cf846b8..4b989b7 100644
--- a/src/flat-button.vala
+++ b/src/flat-button.vala
@@ -29,8 +29,30 @@ public class FlatButton : Gtk.Button
try
{
var style = new Gtk.CssProvider ();
- style.load_from_data ("* {outline-width: 1px;
- }", -1);
+ style.load_from_data ("GtkButton, button {\n" +
+ " border-width: 1px;\n" +
+ " background-color: %s;\n".printf(AGSettings.get_string (AGSettings.KEY_FLATBUTTON_BGCOLOR)) +
+ " border-color: %s\n;".printf(AGSettings.get_string (AGSettings.KEY_FLATBUTTON_BORDERCOLOR)) +
+ "}\n" +
+ "button:hover,\n" +
+ "button:active,\n" +
+ "button:hover:active,\n" +
+ "button.selected:hover,\n" +
+ "button.selected {\n" +
+ " border-width: 1px;\n" +
+ " background-color: %s;\n".printf(AGSettings.get_string (AGSettings.KEY_FLATBUTTON_BGCOLOR)) +
+ " border-color: %s\n;".printf(AGSettings.get_string (AGSettings.KEY_FLATBUTTON_BORDERCOLOR)) +
+ "}\n" +
+ "button.high_contrast {\n" +
+ " background-color: %s;\n".printf ("rgba(70, 70, 70, 1.0)") +
+ " 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);
get_style_context ().add_provider (style, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
}
catch (Error e)
diff --git a/src/settings.vala b/src/settings.vala
index 9eef320..c90f3da 100644
--- a/src/settings.vala
+++ b/src/settings.vala
@@ -55,6 +55,8 @@ public class AGSettings : Object
public const string KEY_REMOTE_SERVICE_CONFIGURE_URI = "remote-service-configure-uri";
public const string KEY_TOGGLEBOX_FONT_FGCOLOR = "togglebox-font-fgcolor";
public const string KEY_TOGGLEBOX_BUTTON_BGCOLOR = "togglebox-button-bgcolor";
+ public const string KEY_FLATBUTTON_BGCOLOR = "flatbutton-bgcolor";
+ public const string KEY_FLATBUTTON_BORDERCOLOR = "flatbutton-bordercolor";
public const string KEY_ENABLE_HIDPI = "enable-hidpi";
public const string KEY_MENUBAR_ALPHA = "menubar-alpha";