diff options
author | Aylur <[email protected]> | 2024-07-15 21:57:21 +0200 |
---|---|---|
committer | Aylur <[email protected]> | 2024-07-15 21:57:21 +0200 |
commit | be163b310398ad7f454d3ece574a476abfa216e9 (patch) | |
tree | 987d551633d3b2d39c2992a9b4dfb07967f2d5c2 /src/astal.vala | |
parent | 68b58c94094ebbb44e75be82ece77badaa0cd68f (diff) |
move message logic to Application class
Diffstat (limited to 'src/astal.vala')
-rw-r--r-- | src/astal.vala | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/astal.vala b/src/astal.vala index 3e94dfc..4f8021e 100644 --- a/src/astal.vala +++ b/src/astal.vala @@ -175,8 +175,7 @@ public class Application : Gtk.Application { } } - [DBus (visible=false)] - public string? message(string? msg) { + public string message(string? msg) throws DBusError, IOError { var client = new SocketClient(); if (msg == null) @@ -190,7 +189,7 @@ public class Application : Gtk.Application { return stream.read_upto("\x04", -1, null, null); } catch (Error err) { printerr(err.message); - return null; + return ""; } } @@ -280,6 +279,20 @@ public class Application : Gtk.Application { critical(err.message); } } + + public static string send_message(string instance, string message) throws IOError { + try { + IApplication proxy = Bus.get_proxy_sync( + BusType.SESSION, + "io.Astal." + instance, + "/io/Astal/Application" + ); + + return proxy.message(message); + } catch (Error err) { + throw new IOError.FAILED(@"could not write to app '$instance'"); + } + } } [DBus (name="org.freedesktop.DBus")] @@ -292,6 +305,7 @@ private interface IApplication : DBusProxy { public abstract void quit() throws GLib.Error; public abstract void inspector() throws GLib.Error; public abstract void toggle_window(string window) throws GLib.Error; + public abstract string message(string window) throws GLib.Error; } public async string read_sock(SocketConnection conn) { |