diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/animate-timer.vala | 4 | ||||
-rw-r--r-- | src/arctica-greeter.vala | 3 | ||||
-rw-r--r-- | src/background.vala | 59 | ||||
-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 | 110 | ||||
-rw-r--r-- | src/menubar.vala | 255 | ||||
-rw-r--r-- | src/prompt-box.vala | 140 | ||||
-rw-r--r-- | src/settings.vala | 29 | ||||
-rw-r--r-- | src/shutdown-dialog.vala | 10 | ||||
-rw-r--r-- | src/user-list.vala | 30 |
13 files changed, 379 insertions, 277 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index bb91f59..7ddcf57 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -91,7 +91,5 @@ arctica_greeter_LDADD = \ logo_generator_LDADD = $(arctica_greeter_LDADD) -arctica_greeter_vala.stamp: $(top_srcdir)/config.h - DISTCLEANFILES = \ Makefile.in diff --git a/src/animate-timer.vala b/src/animate-timer.vala index 9f92448..4879cb0 100644 --- a/src/animate-timer.vala +++ b/src/animate-timer.vala @@ -2,6 +2,7 @@ * * Copyright (C) 2011,2012 Canonical Ltd * Copyright (C) 2015 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> */ private class AnimateTimer : Object @@ -32,7 +34,7 @@ private class AnimateTimer : Object public const int SLOW = 1000; /* Good for animations that convey information that is only presented in the animation */ /* speed is in milliseconds */ - public unowned EasingFunc easing_func { get; private set; } + public unowned EasingFunc easing_func; public int speed { get; set; } public bool is_running { get { return timeout != 0; } } public double progress { get; private set; } 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..07dce7e 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 @@ -171,17 +173,43 @@ class BackgroundLoader : Object var target_aspect = (double) width / height; var aspect = (double) image.width / image.height; double scale, offset_x = 0, offset_y = 0; + string sPosition = AGSettings.get_string (AGSettings.KEY_BACKGROUND_POSITION); + if (aspect > target_aspect) { /* Fit height and trim sides */ scale = (double) height / image.height; - offset_x = (image.width * scale - width) / 2; + + if (sPosition == "center") + { + offset_x = (image.width * scale - width) / 2; + } + else if (sPosition == "top-left" || sPosition == "bottom-left") + { + offset_x = 0; + } + else if (sPosition == "top-right" || sPosition == "bottom-right") + { + offset_x = (image.width * scale - width); + } } else { /* Fit width and trim top and bottom */ scale = (double) width / image.width; - offset_y = (image.height * scale - height) / 2; + + if (sPosition == "center") + { + offset_y = (image.height * scale - height) / 2; + } + else if (sPosition == "top-left" || sPosition == "top-right") + { + offset_y = 0; + } + else if (sPosition == "bottom-left" || sPosition == "bottom-right") + { + offset_y = (image.height * scale - height); + } } var scaled_image = new Gdk.Pixbuf (image.colorspace, image.has_alpha, image.bits_per_sample, width, height); @@ -207,8 +235,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..621b115 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); @@ -117,39 +129,30 @@ public class MainWindow : Gtk.Window login_box.add (content_box); var content_align = AGSettings.get_string(AGSettings.KEY_CONTENT_ALIGN); - var x_align = 0.5f; + var x_align = Gtk.Align.CENTER; if (content_align == "left") { - x_align = 0.0f; + x_align = Gtk.Align.START; } else if (content_align == "right") { - x_align = 1.0f; + x_align = Gtk.Align.END; } - var align = new Gtk.Alignment (x_align, 0.0f, 0.0f, 1.0f); + hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); + hbox.expand = true; + hbox.show (); + hbox.halign = x_align; + hbox.valign = Gtk.Align.CENTER; if (content_align == "center") { // offset for back button - align.margin_right = greeter.grid_size; + hbox.margin_end = greeter.grid_size; } - align.show (); - content_box.add (align); - - hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); - hbox.expand = true; - hbox.show (); - align.add (hbox); - - align = new Gtk.Alignment (0.5f, 0.5f, 0.0f, 0.0f); - align.set_size_request (greeter.grid_size, -1); - align.margin_bottom = greeter.menubar_height; /* offset for menubar at top */ - align.show (); - hbox.add (align); - + content_box.add (hbox); back_button = new FlatButton (); back_button.get_accessible ().set_name (_("Back")); Gtk.button_set_focus_on_click (back_button, false); @@ -178,8 +181,14 @@ public class MainWindow : Gtk.Window back_button.add (image); back_button.clicked.connect (pop_list); - - align.add (back_button); + back_button.halign = Gtk.Align.CENTER; + back_button.valign = Gtk.Align.CENTER; + back_button.hexpand = false; + back_button.vexpand = false; + back_button.resize_mode = Gtk.ResizeMode.QUEUE; + back_button.set_size_request (greeter.grid_size, -1); + back_button.margin_bottom = greeter.menubar_height; + hbox.add (back_button); stack = new ListStack (); stack.show (); @@ -251,8 +260,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 +282,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 +333,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 +350,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 +611,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 +635,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 +658,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 +681,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/menubar.vala b/src/menubar.vala index 8ce73d7..0ba2903 100644 --- a/src/menubar.vala +++ b/src/menubar.vala @@ -101,7 +101,7 @@ private class IndicatorMenuItem : Gtk.MenuItem } } -public class MenuBar : Gtk.MenuBar +public class MenuBar : Gtk.Grid { public Background? background { get; construct; default = null; } public Gtk.Window? keyboard_window { get; private set; default = null; } @@ -112,70 +112,6 @@ public class MenuBar : Gtk.MenuBar Object (background: bg, accel_group: ag); } - public override bool draw (Cairo.Context c) - { - if (background != null) - { - /* Disable background drawing to see how it changes the visuals. */ - /* - int x, y; - background.translate_coordinates (this, 0, 0, out x, out y); - c.save (); - c.translate (x, y); - background.draw_full (c, Background.DrawFlags.NONE); - c.restore (); - */ - } - - /* Get the style and dimensions. */ - var style_ctx = this.get_style_context (); - - var w = this.get_allocated_width (); - var h = this.get_allocated_height (); - - /* Add a group. */ - c.push_group (); - - /* Draw the background normally. */ - style_ctx.render_background (c, 0, 0, w, h); - - /* Draw the frame normally. */ - style_ctx.render_frame (c, 0, 0, w, h); - - /* Go back to the original widget. */ - c.pop_group_to_source (); - - var agsettings = new AGSettings (); - if (agsettings.high_contrast) { - /* - * In case the high contrast mode is enabled, do not add any - * transparency. While the GTK theme might define one (even though - * it better should not, given that we are also switching to a - * high contrast theme), we certainly do not want to make the look - * fuzzy. - */ - c.paint (); - } - else { - /* - * And finally repaint it with additional transparency. - * Note that most GTK styles already define a transparency for OSD - * menus. We want to have something more transparent, but also - * make sure that it is not too transparent, so do not choose a - * value that is too low here - certainly not your desired final - * alpha value. - */ - c.paint_with_alpha (AGSettings.get_double (AGSettings.KEY_MENUBAR_ALPHA)); - } - - foreach (var child in get_children ()) - { - propagate_draw (child, c); - } - - return false; - } - public static void add_style_class (Gtk.Widget widget) { /* @@ -187,132 +123,64 @@ public class MenuBar : Gtk.MenuBar } private List<Indicator.Object> indicator_objects; + private Gtk.MenuBar pMenubar; construct { + // Assure that printf operates in C.UTF-8 locale for float-to-string conversions. + Intl.setlocale(LocaleCategory.NUMERIC, "C.UTF-8"); + + this.pMenubar = new Gtk.MenuBar (); + this.pMenubar.halign = Gtk.Align.END; + this.pMenubar.hexpand = true; + this.pMenubar.pack_direction = Gtk.PackDirection.RTL; + this.pMenubar.show (); + this.attach (this.pMenubar, 1, 0, 1, 1); + this.show (); add_style_class (this); - - /* Handle high contrast background color */ - var menubar_style = new Gtk.CssProvider (); + Gtk.CssProvider pGridProvider = new Gtk.CssProvider (); + Gtk.StyleContext pGridContext = this.get_style_context (); + Gdk.RGBA pBackground = getBackground (pGridContext, AGSettings.KEY_MENUBAR_BGCOLOR, AGSettings.KEY_MENUBAR_ALPHA); + int nBackgroundRed = (int)(pBackground.red * 255.0); + int nBackgroundGreen = (int)(pBackground.green * 255.0); + int nBackgroundBlue = (int)(pBackground.blue * 255.0); + Gdk.RGBA pShadow = getBackground (pGridContext, AGSettings.KEY_MENUBAR_SHADOW_COLOR, AGSettings.KEY_MENUBAR_SHADOW_ALPHA); + int nShadowRed = (int)(pShadow.red * 255.0); + int nShadowGreen = (int)(pShadow.green * 255.0); + int nShadowBlue = (int)(pShadow.blue * 255.0); + string sBackground = "* {background-color: rgba(%i, %i, %i, %f); border: none; box-shadow: 0px 5px 5px -5px rgba(%i, %i, %i, %f);}".printf (nBackgroundRed, nBackgroundGreen, nBackgroundBlue, pBackground.alpha, nShadowRed, nShadowGreen, nShadowBlue, pShadow.alpha); try { - menubar_style.load_from_data ("*.high_contrast { background-color: #ffffff; }", -1); + pGridProvider.load_from_data (sBackground + " *.high_contrast {background-color: #ffffff; color: #000000; text-shadow: none; box-shadow: none;}", -1); } catch (Error pError) { - error ("Panic: Failed adding high contrast background-color: %s", pError.message); + error ("Panic: Failed loading menubar grid colours: %s", pError.message); } - this.get_style_context ().add_provider (menubar_style, - Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - /* Add shadow. */ - var shadow_style = new Gtk.CssProvider (); + pGridContext.add_provider (pGridProvider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + + Gtk.CssProvider pMenubarProvider = new Gtk.CssProvider (); try { - Intl.setlocale(LocaleCategory.NUMERIC, "C.UTF-8"); - shadow_style.load_from_data ("* { box-shadow: 0px 0px 5px 5px rgba(0.2,0.2,0.2,%f); }".printf(AGSettings.get_double (AGSettings.KEY_MENUBAR_ALPHA)), -1); + pMenubarProvider.load_from_data ("* { background-color: transparent; } *.high_contrast { color: #000000; text-shadow: none; }", -1); } catch (Error pError) { - error ("Panic: Failed adding shadow: %s", pError.message); + error ("Panic: Failed loading menubar colours: %s", pError.message); } - this.get_style_context ().add_provider (shadow_style, - Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - - pack_direction = Gtk.PackDirection.RTL; + this.pMenubar.get_style_context ().add_provider (pMenubarProvider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); if (AGSettings.get_boolean (AGSettings.KEY_SHOW_HOSTNAME)) { - var hostname_item = new Gtk.MenuItem.with_label (Posix.utsname ().nodename); - append (hostname_item); - hostname_item.show (); - - /* - * Even though this (menu) item is insensitive, we want its label - * text to have the sensitive color as to not look out of place - * and difficult to read. - * - * There's a really weird bug that leads to always fetch the - * sensitive color after the widget (menuitem in this case) has - * been set to insensitive once - at least in this constructor. - * - * I haven't found a way to fix that, or, for that matter, what is - * actually causing the issue. Even waiting on the main event loop - * until all events are processed didn't help. - * - * We'll work around this issue by fetching the color before - * setting the widget to insensitive and call it proper. - */ - var insensitive_override_style = new Gtk.CssProvider (); - - /* - * First, fetch the associated GtkStyleContext and save the state, - * we'll override the state later on. - */ - var hostname_item_ctx = hostname_item.get_style_context (); - hostname_item_ctx.save (); - - try { - /* Get the actual color. */ - var sensitive_color = hostname_item_ctx.get_color (Gtk.StateFlags.NORMAL); - debug ("Directly fetched sensitive color: %s", sensitive_color.to_string ()); - - insensitive_override_style.load_from_data ("*:disabled { color: %s; } - *.high_contrast:disabled { color: #000000; }".printf(sensitive_color.to_string ()), -1); - } - catch (Error e) - { - debug ("Internal error loading hostname menu item text color: %s", e.message); - } - finally { - /* - * Restore the context, which we might have changed through the - * previous get_color () call. - */ - hostname_item_ctx.restore (); - } - - try { - /* And finally override the insensitive color. */ - hostname_item_ctx.add_provider (insensitive_override_style, - Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - - /* - * Just overriding the color for the Gtk.MenuItem widget - * doesn't help, we'll also apply it to the children. - * - * In theory, we could just use the get_child () method to - * fetch the only child we should ever have on that widget, - * namely a GtkAccelLabel, but that isn't future-proof enough, - * especially if that is ever extended into having a submenu. - * - * Thus, iterate over all children and override the style for - * all of them. - */ - if (gtk_is_container (hostname_item)) { - var children = hostname_item.get_children (); - foreach (Gtk.Widget element in children) { - var child_ctx = element.get_style_context (); - debug ("Adding override style provider to child widget %s", element.name); - child_ctx.add_provider (insensitive_override_style, - Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - } - } - } - catch (Error e) - { - debug ("Internal error overriding hostname menu item text color: %s", e.message); - } - - hostname_item.set_sensitive (false); - - /* The below does not work, so for now we need to stick to "set_right_justified" - hostname_item.set_hexpand (true); - hostname_item.set_halign (Gtk.Align.END);*/ - hostname_item.set_right_justified (true); + Gtk.Label pLabel = new Gtk.Label (Posix.utsname ().nodename); + pLabel.vexpand = true; + pLabel.margin_start = 6; + pLabel.show (); + this.attach (pLabel, 0, 0, 1, 1); } /* Prevent dragging the window by the menubar */ @@ -320,7 +188,7 @@ public class MenuBar : Gtk.MenuBar { var style = new Gtk.CssProvider (); style.load_from_data ("* {-GtkWidget-window-dragging: false;}", -1); - get_style_context ().add_provider (style, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + this.pMenubar.get_style_context ().add_provider (style, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); } catch (Error e) { @@ -330,6 +198,11 @@ public class MenuBar : Gtk.MenuBar setup_indicators (); } + public void select_first (bool bSearchSensitive) + { + this.pMenubar.select_first (bSearchSensitive); + } + public override void get_preferred_height (out int min, out int nat) { var greeter = new ArcticaGreeter (); @@ -337,6 +210,42 @@ public class MenuBar : Gtk.MenuBar nat = (int)Math.round(greeter.menubar_height - 8); } + private Gdk.RGBA getBackground (Gtk.StyleContext pContext, string sBackgroundKey, string sAlphaKey) + { + string sBackground = AGSettings.get_string (sBackgroundKey); + Gdk.RGBA pBackground; + + if (sBackground != "") + { + pBackground = Gdk.RGBA (); + pBackground.parse (sBackground); + } + else + { + bool bFound = pContext.lookup_color ("osd_bg", out pBackground); + + if (!bFound) + { + bFound = pContext.lookup_color ("dark_bg_color", out pBackground); + + if (!bFound) + { + pBackground = Gdk.RGBA (); + pBackground.parse ("#444444"); + debug ("Failed to retrieve osd_bg and dark_bg_color for %s - falling back to #444444", sBackgroundKey); + } + else + { + debug ("Failed to retrieve osd_bg for %s - falling back to dark_bg_color", sBackgroundKey); + } + } + } + + pBackground.alpha = AGSettings.get_double (sAlphaKey); + + return pBackground; + } + private Indicator.Object? load_indicator_file (string indicator_name) { string dir = Config.INDICATOR_FILE_DIR; @@ -482,7 +391,7 @@ public class MenuBar : Gtk.MenuBar { var index = get_indicator_index (object); var pos = 0; - foreach (var child in get_children ()) + foreach (var child in this.pMenubar.get_children ()) { if (!(child is IndicatorMenuItem)) break; @@ -499,19 +408,19 @@ public class MenuBar : Gtk.MenuBar var menuitem = new IndicatorMenuItem (entry); menuitem.set_data ("indicator-object", object); - insert (menuitem, pos); + this.pMenubar.insert (menuitem, pos); } private void indicator_removed_cb (Indicator.Object object, Indicator.ObjectEntry entry) { debug ("Removing indicator object %p", entry); - foreach (var child in get_children ()) + foreach (var child in this.pMenubar.get_children ()) { var menuitem = (IndicatorMenuItem) child; if (menuitem.entry == entry) { - remove (child); + this.pMenubar.remove (child); return; } } diff --git a/src/prompt-box.vala b/src/prompt-box.vala index 1254d14..fb3d4ab 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); @@ -246,13 +247,12 @@ public class PromptBox : FadableBox message_image = new CachedImage (null); message_image.set_from_icon_name("mail-unread", Gtk.IconSize.BUTTON); - - var align = new Gtk.Alignment (0.5f, 0.5f, 0.0f, 0.0f); - align.valign = Gtk.Align.START; - align.set_size_request (-1, greeter.grid_size); - align.add (message_image); - align.show (); - name_grid.attach (align, COL_NAME_MESSAGE, ROW_NAME, 1, 1); + message_image.halign = Gtk.Align.CENTER; + message_image.valign = Gtk.Align.START; + message_image.hexpand = false; + message_image.vexpand = false; + message_image.set_size_request (-1, greeter.grid_size); + name_grid.attach (message_image, COL_NAME_MESSAGE, ROW_NAME, 1, 1); option_button = new FlatButton (); var option_button_ctx = option_button.get_style_context (); @@ -321,7 +321,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 +333,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; @@ -343,12 +342,12 @@ public class PromptBox : FadableBox small_message_image = new CachedImage (null); small_message_image.set_from_icon_name("mail-unread", Gtk.IconSize.BUTTON); - - var align = new Gtk.Alignment (0.5f, 0.5f, 0.0f, 0.0f); - align.set_size_request (-1, greeter.grid_size); - align.add (small_message_image); - align.show (); - small_name_grid.attach (align, 2, 0, 1, 1); + small_message_image.halign = Gtk.Align.CENTER; + small_message_image.valign = Gtk.Align.CENTER; + small_message_image.hexpand = false; + small_message_image.vexpand = false; + small_message_image.set_size_request (-1, greeter.grid_size); + small_name_grid.attach (small_message_image, 2, 0, 1, 1); small_name_grid.show (); return small_name_grid; @@ -560,7 +559,19 @@ public class PromptBox : FadableBox ArcticaGreeter.add_style_class (w); last_row += 1; - box_grid.attach (w, COL_ENTRIES_START, last_row, COL_ENTRIES_WIDTH, 1); + bool bErrorBelow = AGSettings.get_boolean (AGSettings.KEY_ERROR_BELOW_ENTRY); + + if (has_errors && bErrorBelow) + { + Gtk.Widget pChild = box_grid.get_child_at (COL_ENTRIES_START, last_row-1); + box_grid.remove (pChild); + box_grid.attach (w, COL_ENTRIES_START, last_row-1, COL_ENTRIES_WIDTH, 1); + box_grid.attach (pChild, COL_ENTRIES_START, last_row, COL_ENTRIES_WIDTH, 1); + } + else + { + box_grid.attach (w, COL_ENTRIES_START, last_row, COL_ENTRIES_WIDTH, 1); + } update_prompt_visibility (w); queue_resize (); @@ -568,16 +579,27 @@ public class PromptBox : FadableBox public void add_message (string text, bool is_error) { - var label = new FadingLabel (text); - label.set_line_wrap (true); + var label = new FadingLabel (""); 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,25 +609,42 @@ public class PromptBox : FadableBox debug ("Internal error loading font style (%s, %dpt): %s", font_family, font_size-1, e.message); } - if (is_error) { + label.xalign = 0.0f; + label.set_data<bool> ("prompt-box-is-error", is_error); - /* red */ - Gdk.RGBA color = { 1.0f, 1.0f, 1.0f, 1.0f }; - color.parse ("#820900"); + // Wrap the text if needed + ArcticaGreeter pGreeter = new ArcticaGreeter (); + Pango.Context pContext = label.get_pango_context (); + Pango.Layout pLayout = new Pango.Layout (pContext); + Pango.FontDescription pDescription = null; + Gtk.StateFlags nFlags = style_ctx.get_state (); + style_ctx.get (nFlags, "font", out pDescription, null); + pLayout.set_font_description (pDescription); + StringBuilder pBuilder = new StringBuilder (); + string[] lWords = text.split (" "); + string sLine = ""; + + foreach (string sWord in lWords) + { + string sTest = sLine == "" ? sWord : sLine + " " + sWord; + pLayout.set_text (sTest, -1); + int nWidth = 0; + pLayout.get_size (out nWidth, null); - /* - * 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); + if (nWidth / Pango.SCALE > (pGreeter.grid_size * GreeterList.BOX_WIDTH - (int)(GreeterList.BORDER * pGreeter.scaling_factor_widgets * 8)) && sLine != "") + { + pBuilder.append (sLine + "\n"); + sLine = sWord; + } + else + { + sLine = sTest; + } } - label.xalign = 0.0f; - label.set_data<bool> ("prompt-box-is-error", is_error); + pBuilder.append (sLine); + label.set_text (pBuilder.str); + //~Wrap the text if needed attach_item (label); @@ -683,6 +722,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..2a89c38 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 @@ -57,6 +57,7 @@ public class AGSettings : Object public const string KEY_PLAY_READY_SOUND = "play-ready-sound"; public const string KEY_INDICATORS = "indicators"; public const string KEY_HIDDEN_USERS = "hidden-users"; + public const string KEY_HIDDEN_GROUPS = "hidden-groups"; public const string KEY_USER_FILTER= "user-filter"; public const string KEY_USER_FILTER_ALWAYS = "user-filter-always"; public const string KEY_GROUP_FILTER = "group-filter"; @@ -90,6 +91,19 @@ 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 const string KEY_ERROR_BELOW_ENTRY = "error-below-entry"; + public const string KEY_MENUBAR_BGCOLOR = "menubar-bgcolor"; + public const string KEY_BACKGROUND_POSITION = "background-position"; + public const string KEY_MENUBAR_SHADOW_COLOR = "menubar-shadow-color"; + public const string KEY_MENUBAR_SHADOW_ALPHA = "menubar-shadow-alpha"; public static bool get_boolean (string key) { @@ -97,19 +111,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 ()); } diff --git a/src/user-list.vala b/src/user-list.vala index 3936768..3abfb06 100644 --- a/src/user-list.vala +++ b/src/user-list.vala @@ -87,10 +87,28 @@ public class UserList : GreeterList } var hidden_users = AGSettings.get_strv (AGSettings.KEY_HIDDEN_USERS); + string[] lHiddenGroups = AGSettings.get_strv (AGSettings.KEY_HIDDEN_GROUPS); + if (!value) { foreach (var username in hidden_users) remove_entry (username); + + foreach (string sGroup in lHiddenGroups) + { + LightDM.UserList lUsers = LightDM.UserList.get_instance (); + + foreach (LightDM.User pUser in lUsers.users) + { + bool bInGroup = in_group (sGroup, pUser.name); + + if (bInGroup) + { + remove_entry (pUser.name); + } + } + } + return; } @@ -1126,6 +1144,18 @@ public class UserList : GreeterList foreach (var username in hidden_users) if (username == user.name) return; + + string[] lHiddenGroups = AGSettings.get_strv (AGSettings.KEY_HIDDEN_GROUPS); + + foreach (string sGroup in lHiddenGroups) + { + bool bInGroup = in_group (sGroup, user.name); + + if (bInGroup) + { + return; + } + } } var user_filter = AGSettings.get_strv (AGSettings.KEY_USER_FILTER); |