diff options
author | Aylur <[email protected]> | 2024-07-26 19:22:01 +0200 |
---|---|---|
committer | Aylur <[email protected]> | 2024-07-26 19:22:01 +0200 |
commit | 7757661ac79455f6765ddde7ea0239771bc9cfce (patch) | |
tree | 679298a560bd928c1a6973754c8e18caef7e0387 | |
parent | 48ff8400966bcaef858b33d70c3d46cb08bfb75e (diff) |
fix: synchronous constructor
-rw-r--r-- | src/notifd.vala | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/src/notifd.vala b/src/notifd.vala index 45e5eb0..bb027f6 100644 --- a/src/notifd.vala +++ b/src/notifd.vala @@ -61,23 +61,27 @@ public class Notifd : Object { public signal void resolved(uint id, ClosedReason reason); construct { + // hack to make it synchronous + var loop = new MainLoop(); + Bus.own_name( BusType.SESSION, "org.freedesktop.Notifications", BusNameOwnerFlags.NONE, - try_daemon, - () => { - if (proxy != null) { - proxy.stop(); - proxy = null; - } - active(ActiveType.DAEMON); - }, - try_proxy + acquire_daemon, + on_daemon_acquired, + make_proxy ); + + active.connect(() => { + if (loop.is_running()) + loop.quit(); + }); + + loop.run(); } - private void try_daemon(DBusConnection conn) { + private void acquire_daemon(DBusConnection conn) { daemon = new Daemon().register(conn); daemon.notified.connect((id, replaced) => notified(id, replaced)); daemon.resolved.connect((id, reason) => resolved(id, reason)); @@ -88,8 +92,17 @@ public class Notifd : Object { }); } - private void try_proxy() { + private void on_daemon_acquired() { + if (proxy != null) { + proxy.stop(); + proxy = null; + } + active(ActiveType.DAEMON); + } + + private void make_proxy() { proxy = new DaemonProxy(); + if (proxy.start()) { active(ActiveType.PROXY); } else { |