diff options
author | Eugenio Depalo <eugeniodepalo@gmail.com> | 2024-05-28 13:54:08 +0200 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2024-05-28 14:06:59 +0200 |
commit | 67fb7bff8739d6e837a27ddaec372a383f7a4926 (patch) | |
tree | c07fa281312f3b0d7cbcf57c4018e44bde49e284 /src | |
parent | 6cf3cb2794e499a0d1c071e65137fe66693c5310 (diff) | |
download | arctica-greeter-67fb7bff8739d6e837a27ddaec372a383f7a4926.tar.gz arctica-greeter-67fb7bff8739d6e837a27ddaec372a383f7a4926.tar.bz2 arctica-greeter-67fb7bff8739d6e837a27ddaec372a383f7a4926.zip |
src/{main-window,settings}.vala: Add a setting to configure the user list alignment.
Ported from slick-greeter by Mike Gabriel.
Diffstat (limited to 'src')
-rw-r--r-- | src/main-window.vala | 44 | ||||
-rw-r--r-- | src/settings.vala | 1 |
2 files changed, 38 insertions, 7 deletions
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) { |