aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2023-12-06 10:14:00 +0100
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2023-12-06 10:14:00 +0100
commitce35028dee2a14d667ce6fefea6258eb6d7daed9 (patch)
tree26c19a718d42bd08bcc2645e61bef7d846648aa6
parent09a1593bb2bd6ba70b308baa18cf2e3175008427 (diff)
parent64e0a76e9cbae6320535f906931da0f539748b95 (diff)
downloadarctica-greeter-ce35028dee2a14d667ce6fefea6258eb6d7daed9.tar.gz
arctica-greeter-ce35028dee2a14d667ce6fefea6258eb6d7daed9.tar.bz2
arctica-greeter-ce35028dee2a14d667ce6fefea6258eb6d7daed9.zip
Merge branch 'tari01-pr/add-magnifier'
Attributes GH PR #99: https://github.com/ArcticaProject/arctica-greeter/pull/99
-rw-r--r--data/org.ArcticaProject.arctica-greeter.gschema.xml4
-rw-r--r--src/arctica-greeter.vala40
-rw-r--r--src/settings.vala1
3 files changed, 45 insertions, 0 deletions
diff --git a/data/org.ArcticaProject.arctica-greeter.gschema.xml b/data/org.ArcticaProject.arctica-greeter.gschema.xml
index d4544bc..0af9d09 100644
--- a/data/org.ArcticaProject.arctica-greeter.gschema.xml
+++ b/data/org.ArcticaProject.arctica-greeter.gschema.xml
@@ -150,6 +150,10 @@
<default>false</default>
<summary>Whether to enable the onscreen keyboard.</summary>
</key>
+ <key name="magnifier" type="b">
+ <default>false</default>
+ <summary>Whether to enable the screen magnifier.</summary>
+ </key>
<key name="high-contrast" type="b">
<default>false</default>
<summary>Whether to use a high contrast theme.</summary>
diff --git a/src/arctica-greeter.vala b/src/arctica-greeter.vala
index 1f9bbfa..7e7fd47 100644
--- a/src/arctica-greeter.vala
+++ b/src/arctica-greeter.vala
@@ -1438,9 +1438,24 @@ public class DBusServer : Object
private ArcticaGreeter pGreeter;
private Pid nOrca = 0;
private Pid nOnBoard = 0;
+ private Pid nMagnifier = 0;
private Gtk.Socket pSocket = null;
private bool high_contrast_osk = AGSettings.get_boolean(AGSettings.KEY_HIGH_CONTRAST);
+ private void onMagnifierClosed (Pid nPid, int nStatus)
+ {
+ nMagnifier = 0;
+
+ try
+ {
+ this.pConnection.emit_signal (null, "/org/ayatana/greeter", "org.ayatana.greeter", "MagnifierClosed", null);
+ }
+ catch (Error pError)
+ {
+ error ("Panic: Could not send magnifier closed signal: %s", pError.message);
+ }
+ }
+
private void closePid (ref Pid nPid, int nMultiplier)
{
if (nPid > 0)
@@ -1464,6 +1479,7 @@ public class DBusServer : Object
{
closePid (ref nOnBoard, -1);
closePid (ref nOrca, 1);
+ closePid (ref nMagnifier, 1);
}
public DBusServer (DBusConnection pConnection, ArcticaGreeter pGreeter)
@@ -1701,6 +1717,7 @@ public class DBusServer : Object
else
{
closePid (ref nOrca, 1);
+ nOrca = 0;
}
}
@@ -1713,4 +1730,27 @@ public class DBusServer : Object
debug ("High-Contrast mode toggled (new state: %b), refreshing OSK, as well.", bActive);
ToggleOnBoard (AGSettings.get_boolean (AGSettings.KEY_ONSCREEN_KEYBOARD));
}
+
+ public void ToggleMagnifier (bool bActive) throws GLib.DBusError, GLib.IOError
+ {
+ AGSettings.set_boolean (AGSettings.KEY_MAGNIFIER, bActive);
+
+ if (bActive)
+ {
+ try
+ {
+ Process.spawn_async (null, {"magnus"}, null, SpawnFlags.SEARCH_PATH | SpawnFlags.DO_NOT_REAP_CHILD, null, out nMagnifier);
+ GLib.ChildWatch.add (nMagnifier, onMagnifierClosed);
+ }
+ catch (Error pError)
+ {
+ warning ("Failed to run magnifier: %s", pError.message);
+ }
+ }
+ else
+ {
+ closePid (ref nMagnifier, 1);
+ nMagnifier = 0;
+ }
+ }
}
diff --git a/src/settings.vala b/src/settings.vala
index 74e6e40..8447c0f 100644
--- a/src/settings.vala
+++ b/src/settings.vala
@@ -83,6 +83,7 @@ public class AGSettings : Object
public const string KEY_SHUTDOWN_DIALOG_TIMEOUT = "shutdown-dialog-timeout";
public const string KEY_PREFERRED_SESSIONS = "preferred-sessions";
public const string KEY_GEOCLUE_AGENT = "geoclue-agent";
+ public const string KEY_MAGNIFIER = "magnifier";
public static bool get_boolean (string key)
{