aboutsummaryrefslogtreecommitdiff
path: root/src/main-window.vala
diff options
context:
space:
mode:
Diffstat (limited to 'src/main-window.vala')
-rw-r--r--src/main-window.vala197
1 files changed, 168 insertions, 29 deletions
diff --git a/src/main-window.vala b/src/main-window.vala
index cc72aef..621b115 100644
--- a/src/main-window.vala
+++ b/src/main-window.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
@@ -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;
@@ -553,6 +599,99 @@ public class MainWindow : Gtk.Window
return true;
}
break;
+
+ case Gdk.Key.k:
+
+ if ((event.state & Gdk.ModifierType.CONTROL_MASK) != 0)
+ {
+ bool bActive = AGSettings.get_boolean (AGSettings.KEY_ONSCREEN_KEYBOARD);
+
+ try
+ {
+ DBusConnection pConnection = Bus.get_sync (BusType.SESSION);
+ Variant pActive = new Variant.boolean (!bActive);
+ Variant pTuple = new Variant("(sva{sv})", "onboard", pActive, 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)
+ {
+ warning ("%s", pError.message);
+ }
+
+ return true;
+ }
+
+ break;
+
+ case Gdk.Key.h:
+
+ if ((event.state & Gdk.ModifierType.CONTROL_MASK) != 0)
+ {
+ AGSettings pSettings = new AGSettings ();
+ bool bActive = pSettings.high_contrast;
+
+ try
+ {
+ DBusConnection pConnection = Bus.get_sync (BusType.SESSION);
+ Variant pActive = new Variant.boolean (!bActive);
+ Variant pTuple = new Variant("(sva{sv})", "contrast", pActive, 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)
+ {
+ warning ("%s", pError.message);
+ }
+
+ return true;
+ }
+
+ break;
+
+ case Gdk.Key.s:
+
+ if ((event.state & Gdk.ModifierType.CONTROL_MASK) != 0)
+ {
+ bool bActive = AGSettings.get_boolean (AGSettings.KEY_SCREEN_READER);
+
+ try
+ {
+ DBusConnection pConnection = Bus.get_sync (BusType.SESSION);
+ Variant pActive = new Variant.boolean (!bActive);
+ Variant pTuple = new Variant("(sva{sv})", "orca", pActive, 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)
+ {
+ warning ("%s", pError.message);
+ }
+
+ return true;
+ }
+
+ break;
+
+ case Gdk.Key.m:
+
+ if ((event.state & Gdk.ModifierType.CONTROL_MASK) != 0)
+ {
+ bool bActive = AGSettings.get_boolean (AGSettings.KEY_MAGNIFIER);
+
+ try
+ {
+ DBusConnection pConnection = Bus.get_sync (BusType.SESSION);
+ Variant pActive = new Variant.boolean (!bActive);
+ Variant pTuple = new Variant("(sva{sv})", "magnifier", pActive, 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)
+ {
+ warning ("%s", pError.message);
+ }
+
+ return true;
+ }
+
+ break;
}
return base.key_press_event (event);