diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/arctica-greeter.vala | 40 | ||||
-rw-r--r-- | src/settings.vala | 1 |
2 files changed, 41 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; + } + } } 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) { |