From 67fb7bff8739d6e837a27ddaec372a383f7a4926 Mon Sep 17 00:00:00 2001 From: Eugenio Depalo Date: Tue, 28 May 2024 13:54:08 +0200 Subject: src/{main-window,settings}.vala: Add a setting to configure the user list alignment. Ported from slick-greeter by Mike Gabriel. --- .../org.ArcticaProject.arctica-greeter.gschema.xml | 9 +++++ src/main-window.vala | 44 ++++++++++++++++++---- src/settings.vala | 1 + 3 files changed, 47 insertions(+), 7 deletions(-) diff --git a/data/org.ArcticaProject.arctica-greeter.gschema.xml b/data/org.ArcticaProject.arctica-greeter.gschema.xml index 0af9d09..67f8e83 100644 --- a/data/org.ArcticaProject.arctica-greeter.gschema.xml +++ b/data/org.ArcticaProject.arctica-greeter.gschema.xml @@ -255,5 +255,14 @@ true Whether to enable the GeoClue-2.0 agent (enhances ayatana-indicator-display). + + + + + + + 'left' + Alignment of the main content + diff --git a/src/main-window.vala b/src/main-window.vala index 5332186..ad2700a 100644 --- a/src/main-window.vala +++ b/src/main-window.vala @@ -34,6 +34,7 @@ public class MainWindow : Gtk.Window private Background background; private Gtk.Box login_box; private Gtk.Box hbox; + private Gtk.Box content_box; private Gtk.Button back_button; private ShutdownDialog? shutdown_dialog = null; private bool do_resize; @@ -90,12 +91,40 @@ public class MainWindow : Gtk.Window ArcticaGreeter.add_style_class (menubar); ArcticaGreeter.add_style_class (menubox); + content_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); + content_box.expand = true; + content_box.show (); + login_box.add (content_box); + + var content_align = AGSettings.get_string(AGSettings.KEY_CONTENT_ALIGN); + var x_align = 0.5f; + + if (content_align == "left") + { + x_align = 0.0f; + } + else if (content_align == "right") + { + x_align = 1.0f; + } + + var align = new Gtk.Alignment (x_align, 0.0f, 0.0f, 1.0f); + + if (content_align == "center") + { + // offset for back button + align.margin_right = grid_size; + } + + align.show (); + content_box.add (align); + hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); hbox.expand = true; hbox.show (); - login_box.add (hbox); + align.add (hbox); - var align = new Gtk.Alignment (0.5f, 0.5f, 0.0f, 0.0f); + align = new Gtk.Alignment (0.5f, 0.5f, 0.0f, 0.0f); // Hack to avoid gtk 3.20's new allocate logic, which messes us up. align.resize_mode = Gtk.ResizeMode.QUEUE; align.set_size_request (grid_size, -1); @@ -185,12 +214,13 @@ public class MainWindow : Gtk.Window { base.size_allocate (allocation); - if (hbox != null) + if (content_box != null) { - hbox.margin_start = get_grid_offset (get_allocated_width ()) + grid_size; - hbox.margin_end = get_grid_offset (get_allocated_width ()); - hbox.margin_top = get_grid_offset (get_allocated_height ()); - hbox.margin_bottom = get_grid_offset (get_allocated_height ()); + var content_align = AGSettings.get_string(AGSettings.KEY_CONTENT_ALIGN); + content_box.margin_left = get_grid_offset (get_allocated_width ()) + (content_align == "left" ? grid_size : 0); + content_box.margin_right = get_grid_offset (get_allocated_width ()) + (content_align == "right" ? grid_size : 0); + content_box.margin_top = get_grid_offset (get_allocated_height ()); + content_box.margin_bottom = get_grid_offset (get_allocated_height ()); } } diff --git a/src/settings.vala b/src/settings.vala index 8447c0f..7d1ce8f 100644 --- a/src/settings.vala +++ b/src/settings.vala @@ -84,6 +84,7 @@ public class AGSettings : Object public const string KEY_PREFERRED_SESSIONS = "preferred-sessions"; public const string KEY_GEOCLUE_AGENT = "geoclue-agent"; public const string KEY_MAGNIFIER = "magnifier"; + public const string KEY_CONTENT_ALIGN = "content-align"; public static bool get_boolean (string key) { -- cgit v1.2.3