From b7ca33a37de5dd2ecffa7575681c6009996b7ba2 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Tue, 1 Feb 2022 17:38:15 +0100 Subject: Initialize and use dbus interfaces async related #1155 --- main/src/ui/application.vala | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'main/src/ui/application.vala') diff --git a/main/src/ui/application.vala b/main/src/ui/application.vala index 4f97b7b3..62f01bcb 100644 --- a/main/src/ui/application.vala +++ b/main/src/ui/application.vala @@ -47,11 +47,21 @@ public class Dino.Ui.Application : Gtk.Application, Dino.Application { } NotificationEvents notification_events = stream_interactor.get_module(NotificationEvents.IDENTITY); - notification_events.register_notification_provider(new GNotificationsNotifier(stream_interactor)); - FreeDesktopNotifier? free_desktop_notifier = FreeDesktopNotifier.try_create(stream_interactor); - if (free_desktop_notifier != null) { - notification_events.register_notification_provider(free_desktop_notifier); - } + get_notifications_dbus.begin((_, res) => { + // It might take a bit to get the interface. NotificationEvents will queue any notifications in the meantime. + try { + DBusNotifications? dbus_notifications = get_notifications_dbus.end(res); + if (dbus_notifications != null) { + FreeDesktopNotifier free_desktop_notifier = new FreeDesktopNotifier(stream_interactor, dbus_notifications); + notification_events.register_notification_provider.begin(free_desktop_notifier); + } else { + notification_events.register_notification_provider.begin(new GNotificationsNotifier(stream_interactor)); + } + } catch (Error e) { + debug("Failed accessing fdo notification server: %s", e.message); + } + }); + notification_events.notify_content_item.connect((content_item, conversation) => { // Set urgency hint also if (normal) notifications are disabled // Don't set urgency hint in GNOME, produces "Window is active" notification -- cgit v1.2.3-54-g00ecf