diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2023-12-06 10:14:00 +0100 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2023-12-06 10:14:00 +0100 |
commit | ce35028dee2a14d667ce6fefea6258eb6d7daed9 (patch) | |
tree | 26c19a718d42bd08bcc2645e61bef7d846648aa6 /src/arctica-greeter.vala | |
parent | 09a1593bb2bd6ba70b308baa18cf2e3175008427 (diff) | |
parent | 64e0a76e9cbae6320535f906931da0f539748b95 (diff) | |
download | arctica-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
Diffstat (limited to 'src/arctica-greeter.vala')
-rw-r--r-- | src/arctica-greeter.vala | 40 |
1 files changed, 40 insertions, 0 deletions
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; + } + } } |