summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAylur <[email protected]>2024-07-26 19:22:01 +0200
committerAylur <[email protected]>2024-07-26 19:22:01 +0200
commit7757661ac79455f6765ddde7ea0239771bc9cfce (patch)
tree679298a560bd928c1a6973754c8e18caef7e0387
parent48ff8400966bcaef858b33d70c3d46cb08bfb75e (diff)
fix: synchronous constructor
-rw-r--r--src/notifd.vala35
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 {