diff options
| author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2025-04-22 10:57:06 +0200 |
|---|---|---|
| committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2025-04-22 10:57:06 +0200 |
| commit | 2d6ade978be93c4d8c3e07bfe62d794bdc9266ef (patch) | |
| tree | 08aefe3ebe9989349933a230d8d02a4ed2f090b1 | |
| parent | 65ccc9ad9f8fa6186851b3e33a2747527355dae9 (diff) | |
| parent | 66148f445543aad68db282da75d932551bed9185 (diff) | |
| download | arctica-greeter-2d6ade978be93c4d8c3e07bfe62d794bdc9266ef.tar.gz arctica-greeter-2d6ade978be93c4d8c3e07bfe62d794bdc9266ef.tar.bz2 arctica-greeter-2d6ade978be93c4d8c3e07bfe62d794bdc9266ef.zip | |
Merge branch 'tari01-pr/prompt-box-tweaks'
Attributes GH PR #116: https://github.com/ArcticaProject/arctica-greeter/pull/116
| -rw-r--r-- | data/org.ArcticaProject.arctica-greeter.gschema.xml | 40 | ||||
| -rw-r--r-- | src/background.vala | 29 | ||||
| -rw-r--r-- | src/dash-box.vala | 8 | ||||
| -rw-r--r-- | src/main-window.vala | 18 | ||||
| -rw-r--r-- | src/prompt-box.vala | 65 | ||||
| -rw-r--r-- | src/settings.vala | 23 | ||||
| -rw-r--r-- | src/shutdown-dialog.vala | 5 |
7 files changed, 140 insertions, 48 deletions
diff --git a/data/org.ArcticaProject.arctica-greeter.gschema.xml b/data/org.ArcticaProject.arctica-greeter.gschema.xml index 68a2522..38be872 100644 --- a/data/org.ArcticaProject.arctica-greeter.gschema.xml +++ b/data/org.ArcticaProject.arctica-greeter.gschema.xml @@ -295,5 +295,45 @@ <default>'left'</default> <summary>Alignment of the main content</summary> </key> + <key name="dash-box-bgcolor" type="s"> + <default>'#1A1A1A'</default> + <summary>The background color of the dash box in #RRGGBB format.</summary> + </key> + <key name="dash-box-opacity" type="d"> + <range min="0.1" max="1.0"/> + <default>0.4</default> + <summary>The opacity of the dash box.</summary> + </key> + <key name="prompt-box-color-normal" type="s"> + <default>'#ffffff'</default> + <summary>The normal text color of the prompt box in #RRGGBB format.</summary> + </key> + <key name="prompt-box-color-error" type="s"> + <default>'#820900'</default> + <summary>The error text color of the prompt box in #RRGGBB format.</summary> + </key> + <key name="prompt-box-error-bg-opacity" type="d"> + <range min="0.0" max="1.0"/> + <default>1.0</default> + <summary>The background opacity of the error message in the prompt box.</summary> + </key> + <key name="logo-position" type="s"> + <choices> + <choice value='top-left'/> + <choice value='top-right'/> + <choice value='bottom-left'/> + <choice value='bottom-right'/> + </choices> + <default>'bottom-left'</default> + <summary>The position of the logo.</summary> + </key> + <key name="logo-offset-horizontal" type="i"> + <default>2</default> + <summary>The horizontal offset of the logo from the edge of the screen in grid units.</summary> + </key> + <key name="logo-offset-vertical" type="i"> + <default>1</default> + <summary>The vertical offset of the logo from the edge of the screen in grid units.</summary> + </key> </schema> </schemalist> diff --git a/src/background.vala b/src/background.vala index e6d52fa..bf1ca6f 100644 --- a/src/background.vala +++ b/src/background.vala @@ -2,6 +2,7 @@ * * Copyright (C) 2011,2012 Canonical Ltd * Copyright (C) 2015-2017 Mike Gabriel <mike.gabriel@das-netzwerkteam.de> + * Copyright (C) 2025 Robert Tari * * 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 @@ -18,6 +19,7 @@ * Authors: Robert Ancell <robert.ancell@canonical.com> * Michael Terry <michael.terry@canonical.com> * Mike Gabriel <mike.gabriel@das-netzwerkteam.de> + * Robert Tari <robert@tari.in> */ class BackgroundLoader : Object @@ -207,8 +209,31 @@ class BackgroundLoader : Object if (logo != null) { bc.save (); - var x = (int) (grid_x_offset + 2 * greeter.grid_size); - var y = (int) (image.height - 1 * greeter.grid_size - logo_height + grid_y_offset); + string sPosition = AGSettings.get_string (AGSettings.KEY_LOGO_POSITION); + int x = AGSettings.get_integer (AGSettings.KEY_LOGO_OFFSET_HORIZONTAL); + int y = AGSettings.get_integer (AGSettings.KEY_LOGO_OFFSET_VERTICAL); + + if (sPosition == "top-left") + { + x = (int) (grid_x_offset + (x * greeter.grid_size)); + y = (int) (grid_y_offset + ((y + 1) * greeter.grid_size)); + } + else if (sPosition == "top-right") + { + x = (int) (image.width - (x * greeter.grid_size) - logo_width + grid_x_offset); + y = (int) (grid_y_offset + ((y + 1) * greeter.grid_size)); + } + else if (sPosition == "bottom-left") + { + x = (int) (grid_x_offset + (x * greeter.grid_size)); + y = (int) (image.height - (y * greeter.grid_size) - logo_height + grid_y_offset); + } + else if (sPosition == "bottom-right") + { + x = (int) (image.width - (x * greeter.grid_size) - logo_width + grid_x_offset); + y = (int) (image.height - (y * greeter.grid_size) - logo_height + grid_y_offset); + } + bc.translate (x, y); bc.set_source_surface (logo, 0, 0); bc.paint_with_alpha (AGSettings.get_double (AGSettings.KEY_LOGO_ALPHA)); diff --git a/src/dash-box.vala b/src/dash-box.vala index 0772e3f..52dd7d4 100644 --- a/src/dash-box.vala +++ b/src/dash-box.vala @@ -2,7 +2,7 @@ * * Copyright (C) 2011,2012 Canonical Ltd * Copyright (C) 2015 Mike Gabriel <mike.gabriel@das-netzwerkteam.de> - * Copyright (C) 2023 Robert Tari + * Copyright (C) 2023-2025 Robert Tari * * 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 @@ -237,7 +237,11 @@ public class DashBox : Gtk.Box } else { - c.set_source_rgba (0.1, 0.1, 0.1, 0.4); + string sBackGround = AGSettings.get_string (AGSettings.KEY_DASHBOX_BGCOLOR); + Gdk.RGBA cBackground = {1.0, 1.0, 1.0, 1.0}; + cBackground.parse (sBackGround); + double fOpacity = AGSettings.get_double (AGSettings.KEY_DASHBOX_OPACITY); + c.set_source_rgba (cBackground.red, cBackground.green, cBackground.blue, fOpacity); } c.fill_preserve (); diff --git a/src/main-window.vala b/src/main-window.vala index 88c6e7f..e1e39d2 100644 --- a/src/main-window.vala +++ b/src/main-window.vala @@ -70,9 +70,21 @@ public class MainWindow : Gtk.Window var accel_group = new Gtk.AccelGroup (); add_accel_group (accel_group); - var bg_color = Gdk.RGBA (); - bg_color.parse (AGSettings.get_string (AGSettings.KEY_BACKGROUND_COLOR)); - override_background_color (Gtk.StateFlags.NORMAL, bg_color); + Gtk.StyleContext pContext = get_style_context (); + Gtk.CssProvider pProvider = new Gtk.CssProvider (); + string sColour = AGSettings.get_string (AGSettings.KEY_BACKGROUND_COLOR); + string sCss = "* {background-color: %s;}".printf (sColour); + + try + { + pProvider.load_from_data (sCss, -1); + pContext.add_provider (pProvider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + } + catch (Error pError) + { + warning ("Panic: Error loading style for main window: %s", pError.message); + } + get_accessible ().set_name (_("Login Screen")); ArcticaGreeter.add_style_class (this); diff --git a/src/prompt-box.vala b/src/prompt-box.vala index e29d6ef..b102887 100644 --- a/src/prompt-box.vala +++ b/src/prompt-box.vala @@ -223,8 +223,8 @@ public class PromptBox : FadableBox try { var color_provider = new Gtk.CssProvider (); - var css = "* { color: rgba(255, 255, 255, 1.0); }\n" + - ".high_contrast { color: rgba (0, 0, 0, 1.0); }"; + string sColor = AGSettings.get_string (AGSettings.KEY_PROMPTBOX_COLOR_NORMAL); + var css = "* { color: %s; } .high_contrast { color: rgba (0, 0, 0, 1.0); }".printf (sColor); color_provider.load_from_data (css, -1); style_ctx.add_provider (color_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); @@ -322,7 +322,7 @@ public class PromptBox : FadableBox try { var font_provider = new Gtk.CssProvider (); - var css = "* {font-family: %s; font-size: %dpt;}".printf (font_family, font_size); + var css = "* {color: #FFFFFF; font-family: %s; font-size: %dpt;}".printf (font_family, font_size); font_provider.load_from_data (css, -1); style_ctx.add_provider (font_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); @@ -334,7 +334,6 @@ public class PromptBox : FadableBox var greeter = new ArcticaGreeter(); - small_name_label.override_color (Gtk.StateFlags.NORMAL, { 1.0f, 1.0f, 1.0f, 1.0f }); small_name_label.yalign = 0.5f; small_name_label.xalign = 0.0f; small_name_label.margin_start = 2; @@ -576,8 +575,20 @@ public class PromptBox : FadableBox try { var font_provider = new Gtk.CssProvider (); - var css = "* {font-family: %s; font-size: %dpt; color: white} - *.high_contrast {color: black; }".printf (font_family, font_size-1); + var css = ""; + + if (is_error) + { + string sColor = AGSettings.get_string (AGSettings.KEY_PROMPTBOX_COLOR_ERROR); + double fOpacity = AGSettings.get_double (AGSettings.KEY_PROMPTBOX_ERROR_BG_OPACITY); + css = "* {font-family: %s; font-size: %dpt; color: %s; background-color: rgba(255, 255, 255, %f); text-shadow: none;}".printf (font_family, font_size-1, sColor, fOpacity); + } + else + { + string sColor = AGSettings.get_string (AGSettings.KEY_PROMPTBOX_COLOR_NORMAL); + css = "* {font-family: %s; font-size: %dpt; color: %s;} *.high_contrast {color: black; }".printf (font_family, font_size-1, sColor); + } + font_provider.load_from_data (css, -1); style_ctx.add_provider (font_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); @@ -587,23 +598,6 @@ public class PromptBox : FadableBox debug ("Internal error loading font style (%s, %dpt): %s", font_family, font_size-1, e.message); } - if (is_error) { - - /* red */ - Gdk.RGBA color = { 1.0f, 1.0f, 1.0f, 1.0f }; - color.parse ("#820900"); - - /* - * Overriding the background color will look ugly, but at least - * always make the text readable, which is probably important for - * error messages. - * We probably want to find a better way of handling this. - */ - Gdk.RGBA bg_color = { 1.0f, 1.0f, 1.0f, 1.0f }; - label.override_background_color (Gtk.StateFlags.NORMAL, bg_color); - label.override_color (Gtk.StateFlags.NORMAL, color); - } - label.xalign = 0.0f; label.set_data<bool> ("prompt-box-is-error", is_error); @@ -683,6 +677,31 @@ public class PromptBox : FadableBox } entry.respond.connect (entry_activate_cb); + Gtk.StyleContext pContext = entry.get_style_context (); + Gtk.CssProvider pProvider = new Gtk.CssProvider (); + string sKey = ""; + + if (has_errors) + { + sKey = AGSettings.KEY_PROMPTBOX_COLOR_ERROR; + } + else + { + sKey = AGSettings.KEY_PROMPTBOX_COLOR_NORMAL; + } + + string sColor = AGSettings.get_string (sKey); + string sCss = "entry {border: none; outline: none; box-shadow: 1px 0 %s inset, 0 1px %s inset, -1px 0 %s inset, 0 -1px %s inset;}".printf (sColor, sColor, sColor, sColor); + + try + { + pProvider.load_from_data (sCss, -1); + pContext.add_provider (pProvider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + } + catch (Error pError) + { + warning ("Panic: Error setting DashEntry border colour: %s", pError.message); + } attach_item (entry); diff --git a/src/settings.vala b/src/settings.vala index 1f046d4..414020d 100644 --- a/src/settings.vala +++ b/src/settings.vala @@ -3,7 +3,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> - * Copyright (C) 2023-2024 Robert Tari + * Copyright (C) 2023-2025 Robert Tari * * 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 @@ -90,6 +90,14 @@ public class AGSettings : Object public const string KEY_MAGNIFIER = "magnifier"; public const string KEY_CONTENT_ALIGN = "content-align"; public const string KEY_MAGNIFIER_POSITION = "magnifier-position"; + public const string KEY_DASHBOX_BGCOLOR = "dash-box-bgcolor"; + public const string KEY_DASHBOX_OPACITY = "dash-box-opacity"; + public const string KEY_PROMPTBOX_COLOR_NORMAL = "prompt-box-color-normal"; + public const string KEY_PROMPTBOX_COLOR_ERROR = "prompt-box-color-error"; + public const string KEY_PROMPTBOX_ERROR_BG_OPACITY = "prompt-box-error-bg-opacity"; + public const string KEY_LOGO_POSITION = "logo-position"; + public const string KEY_LOGO_OFFSET_HORIZONTAL = "logo-offset-horizontal"; + public const string KEY_LOGO_OFFSET_VERTICAL = "logo-offset-vertical"; public static bool get_boolean (string key) { @@ -97,19 +105,6 @@ public class AGSettings : Object return gsettings.get_boolean (key); } - /* LP: 1006497 - utility function to make sure we have the key before trying to read it (which will segfault if the key isn't there) */ - public static bool safe_get_boolean (string key, bool default) - { - var gsettings = new Settings (SCHEMA); - string[] keys = gsettings.list_keys (); - foreach (var k in keys) - if (k == key) - return gsettings.get_boolean (key); - - /* key not in child list */ - return default; - } - public static int get_integer (string key) { var gsettings = new Settings (SCHEMA); diff --git a/src/shutdown-dialog.vala b/src/shutdown-dialog.vala index ec565b9..fd568d7 100644 --- a/src/shutdown-dialog.vala +++ b/src/shutdown-dialog.vala @@ -696,7 +696,7 @@ private class DialogButton : Gtk.Button try { var font_provider = new Gtk.CssProvider (); - var css = "* {font-family: %s; font-size: %dpt;}".printf(font_family, font_size); + var css = "* {color: #FFFFFF; font-family: %s; font-size: %dpt;}".printf(font_family, font_size); font_provider.load_from_data (css, -1); style_ctx.add_provider (font_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); @@ -706,9 +706,6 @@ private class DialogButton : Gtk.Button debug ("Internal error loading font style (%s, %dpt): %s", font_family, font_size, e.message); } - l.override_color (Gtk.StateFlags.NORMAL, { 1.0f, 1.0f, 1.0f, 0.0f }); - l.override_color (Gtk.StateFlags.FOCUSED, { 1.0f, 1.0f, 1.0f, 1.0f }); - l.override_color (Gtk.StateFlags.ACTIVE, { 1.0f, 1.0f, 1.0f, 1.0f }); this.get_accessible ().set_name (l.get_text ()); } |
