diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/arctica-greeter.vala | 3 | ||||
-rw-r--r-- | src/background.vala | 29 | ||||
-rw-r--r-- | src/dash-box.vala | 8 | ||||
-rw-r--r-- | src/greeter-list.vala | 3 | ||||
-rw-r--r-- | src/list-stack.vala | 3 | ||||
-rw-r--r-- | src/main-window.vala | 74 | ||||
-rw-r--r-- | src/prompt-box.vala | 69 | ||||
-rw-r--r-- | src/settings.vala | 23 | ||||
-rw-r--r-- | src/shutdown-dialog.vala | 10 |
9 files changed, 156 insertions, 66 deletions
diff --git a/src/arctica-greeter.vala b/src/arctica-greeter.vala index 93c88e2..5eb8a59 100644 --- a/src/arctica-greeter.vala +++ b/src/arctica-greeter.vala @@ -2,7 +2,7 @@ * * Copyright (C) 2011 Canonical Ltd * Copyright (C) 2015-2017 Mike Gabriel <mike.gabriel@das-netzwerkteam.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 @@ -1144,7 +1144,6 @@ public class ArcticaGreeter : Object try { string[] argv; - Pid wm_message_pid = 0; Shell.parse_argv ("%s-message disable-keybindings".printf(wm), out argv); 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/greeter-list.vala b/src/greeter-list.vala index 04d4ed4..da4f3e9 100644 --- a/src/greeter-list.vala +++ b/src/greeter-list.vala @@ -283,7 +283,6 @@ public abstract class GreeterList : FadableBox protected void redraw_greeter_box () { - queue_allocate (); Gtk.Allocation allocation; greeter_box.get_allocation (out allocation); queue_draw_area (allocation.x, allocation.y, allocation.width, allocation.height); @@ -298,7 +297,6 @@ public abstract class GreeterList : FadableBox } selected_entry.add_message (text, is_error); - redraw_greeter_box (); } public DashEntry add_prompt (string text, bool secret = false) @@ -870,6 +868,7 @@ public abstract class GreeterList : FadableBox /* Limit the number of characters in case a cat is sitting on the keyboard... */ entry.max_length = MAX_FIELD_SIZE; + queue_resize (); } protected virtual void authentication_complete_cb () diff --git a/src/list-stack.vala b/src/list-stack.vala index d87b37a..4f74ea7 100644 --- a/src/list-stack.vala +++ b/src/list-stack.vala @@ -1,7 +1,7 @@ /* -*- Mode: Vala; indent-tabs-mode: nil; tab-width: 4 -*- * * Copyright (C) 2011,2012 Canonical Ltd - * 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 @@ -35,6 +35,7 @@ public class ListStack : Gtk.Fixed construct { + resize_mode = Gtk.ResizeMode.QUEUE; var greeter = new ArcticaGreeter(); width = greeter.grid_size * GreeterList.BOX_WIDTH; diff --git a/src/main-window.vala b/src/main-window.vala index fc8d95a..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); @@ -133,7 +145,7 @@ public class MainWindow : Gtk.Window if (content_align == "center") { // offset for back button - align.margin_right = greeter.grid_size; + align.margin_end = greeter.grid_size; } align.show (); @@ -145,6 +157,7 @@ public class MainWindow : Gtk.Window align.add (hbox); align = new Gtk.Alignment (0.5f, 0.5f, 0.0f, 0.0f); + align.resize_mode = Gtk.ResizeMode.QUEUE; align.set_size_request (greeter.grid_size, -1); align.margin_bottom = greeter.menubar_height; /* offset for menubar at top */ align.show (); @@ -251,8 +264,8 @@ public class MainWindow : Gtk.Window if (content_box != null) { var content_align = AGSettings.get_string(AGSettings.KEY_CONTENT_ALIGN); - content_box.margin_left = get_grid_offset (get_allocated_width ()) + (content_align == "left" ? greeter.grid_size : 0); - content_box.margin_right = get_grid_offset (get_allocated_width ()) + (content_align == "right" ? greeter.grid_size : 0); + content_box.margin_start = get_grid_offset (get_allocated_width ()) + (content_align == "left" ? greeter.grid_size : 0); + content_box.margin_end = get_grid_offset (get_allocated_width ()) + (content_align == "right" ? greeter.grid_size : 0); content_box.margin_top = get_grid_offset (get_allocated_height ()); content_box.margin_bottom = get_grid_offset (get_allocated_height ()); } @@ -273,6 +286,39 @@ public class MainWindow : Gtk.Window _set_struts (MenubarPositions.TOP, greeter.menubar_height); } + private void getScreenSize (out int nScreenWidth, out int nScreenHeight) + { + Gdk.Display pDisplay = Gdk.Display.get_default (); + int nMonitors = pDisplay.get_n_monitors (); + + if (nMonitors == 0) + { + nScreenWidth = 0; + nScreenHeight = 0; + + return; + } + + int x0 = int.MAX; + int y0 = int.MAX; + int x1 = int.MIN; + int y1 = int.MIN; + + for (int nMonitor = 0; nMonitor < nMonitors; nMonitor++) + { + Gdk.Monitor pMonitor = pDisplay.get_monitor (nMonitor); + Gdk.Rectangle cRectangle = pMonitor.get_geometry (); + + x0 = int.min (x0, cRectangle.x); + y0 = int.min (y0, cRectangle.y); + x1 = int.max (x1, cRectangle.x + cRectangle.width); + y1 = int.max (y1, cRectangle.y + cRectangle.height); + } + + nScreenWidth = x1 - x0; + nScreenHeight = y1 - y0; + } + private void _set_struts (uint position, long menubar_size) { if (!get_realized()) { @@ -291,6 +337,10 @@ public class MainWindow : Gtk.Window /* Subtract (non-scaled) 5px border + 2px extra spacing (to make indicator menus render nicely below menubar) */ menubar_size = menubar_size - 7; + int nScreenWidth = 0; + int nScreenHeight = 0; + getScreenSize (out nScreenWidth, out nScreenHeight); + // Struts dependent on position switch (position) { case MenubarPositions.TOP: @@ -304,13 +354,13 @@ public class MainWindow : Gtk.Window struts[Struts.LEFT_END] = (primary_monitor.y + primary_monitor.height) * scale - 1; break; case MenubarPositions.RIGHT: - struts[Struts.RIGHT] = (menubar_size + screen.get_width() - primary_monitor.x - primary_monitor.width) * scale; + struts[Struts.RIGHT] = (menubar_size + nScreenWidth - primary_monitor.x - primary_monitor.width) * scale; struts[Struts.RIGHT_START] = primary_monitor.y * scale; struts[Struts.RIGHT_END] = (primary_monitor.y + primary_monitor.height) * scale - 1; break; case MenubarPositions.BOTTOM: default: - struts[Struts.BOTTOM] = (menubar_size + screen.get_height() - primary_monitor.y - primary_monitor.height) * scale; + struts[Struts.BOTTOM] = (menubar_size + nScreenHeight - primary_monitor.y - primary_monitor.height) * scale; struts[Struts.BOTTOM_START] = primary_monitor.x * scale; struts[Struts.BOTTOM_END] = (primary_monitor.x + primary_monitor.width) * scale - 1; break; @@ -565,7 +615,7 @@ public class MainWindow : Gtk.Window DBusConnection pConnection = Bus.get_sync (BusType.SESSION); Variant pActive = new Variant.boolean (!bActive); Variant pTuple = new Variant("(sva{sv})", "onboard", pActive, null); - pConnection.call ("org.ayatana.indicator.a11y", "/org/ayatana/indicator/a11y", "org.gtk.Actions", "SetState", pTuple, null, DBusCallFlags.NONE, -1, null); + pConnection.call.begin ("org.ayatana.indicator.a11y", "/org/ayatana/indicator/a11y", "org.gtk.Actions", "SetState", pTuple, null, DBusCallFlags.NONE, -1, null); } catch (Error pError) { @@ -589,7 +639,7 @@ public class MainWindow : Gtk.Window DBusConnection pConnection = Bus.get_sync (BusType.SESSION); Variant pActive = new Variant.boolean (!bActive); Variant pTuple = new Variant("(sva{sv})", "contrast", pActive, null); - pConnection.call ("org.ayatana.indicator.a11y", "/org/ayatana/indicator/a11y", "org.gtk.Actions", "SetState", pTuple, null, DBusCallFlags.NONE, -1, null); + pConnection.call.begin ("org.ayatana.indicator.a11y", "/org/ayatana/indicator/a11y", "org.gtk.Actions", "SetState", pTuple, null, DBusCallFlags.NONE, -1, null); } catch (Error pError) { @@ -612,7 +662,7 @@ public class MainWindow : Gtk.Window DBusConnection pConnection = Bus.get_sync (BusType.SESSION); Variant pActive = new Variant.boolean (!bActive); Variant pTuple = new Variant("(sva{sv})", "orca", pActive, null); - pConnection.call ("org.ayatana.indicator.a11y", "/org/ayatana/indicator/a11y", "org.gtk.Actions", "SetState", pTuple, null, DBusCallFlags.NONE, -1, null); + pConnection.call.begin ("org.ayatana.indicator.a11y", "/org/ayatana/indicator/a11y", "org.gtk.Actions", "SetState", pTuple, null, DBusCallFlags.NONE, -1, null); } catch (Error pError) { @@ -635,7 +685,7 @@ public class MainWindow : Gtk.Window DBusConnection pConnection = Bus.get_sync (BusType.SESSION); Variant pActive = new Variant.boolean (!bActive); Variant pTuple = new Variant("(sva{sv})", "magnifier", pActive, null); - pConnection.call ("org.ayatana.indicator.a11y", "/org/ayatana/indicator/a11y", "org.gtk.Actions", "SetState", pTuple, null, DBusCallFlags.NONE, -1, null); + pConnection.call.begin ("org.ayatana.indicator.a11y", "/org/ayatana/indicator/a11y", "org.gtk.Actions", "SetState", pTuple, null, DBusCallFlags.NONE, -1, null); } catch (Error pError) { diff --git a/src/prompt-box.vala b/src/prompt-box.vala index 1254d14..b102887 100644 --- a/src/prompt-box.vala +++ b/src/prompt-box.vala @@ -2,7 +2,7 @@ * * Copyright (C) 2011,2012 Canonical Ltd * Copyright (C) 2015,2017 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 @@ -96,6 +96,7 @@ public class PromptBox : FadableBox construct { + resize_mode = Gtk.ResizeMode.QUEUE; var greeter = new ArcticaGreeter(); set_start_row (); @@ -222,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); @@ -321,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); @@ -333,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; @@ -569,15 +569,26 @@ public class PromptBox : FadableBox public void add_message (string text, bool is_error) { var label = new FadingLabel (text); - label.set_line_wrap (true); var style_ctx = label.get_style_context(); 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 d243188..fd568d7 100644 --- a/src/shutdown-dialog.vala +++ b/src/shutdown-dialog.vala @@ -2,7 +2,7 @@ * * Copyright (C) 2013 Canonical Ltd * Copyright (C) 2015,2016 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 @@ -306,7 +306,8 @@ public class ShutdownDialog : Gtk.Fixed var focused = pWindow.get_focus (); if ((null != focused) && (focused is DialogButton)) { - (focused as DialogButton).clicked (); + DialogButton pButton = (DialogButton) focused; + pButton.clicked (); } --default_action_time_supplemental; @@ -695,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); @@ -705,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 ()); } |