有没有办法在 Windows 10 上触发来自 Vala MSYS2 的弹出通知?

Is there a way to trigger a pop-up notification from Vala MSYS2 on Windows 10?

我不喜欢Windows,我只是想看看Vala的跨平台性如何

当使用 libnoyify 我看到

    gavr@DESKTOP-B57MHT8 MINGW64 ~
$ ./notify.exe

** (notify.exe:6680): ERROR **: 15:50:47.138: notify.vala:13: Error: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.Notifications is unknown

在这样的代码中

    public static int main (string[] args) {
        string summary = "Short summary";
        string body = "A long description";
        string icon = "dialog-information";

        Notify.init ("My test app");

        try {
            Notify.Notification notification = new Notify.Notification (summary, body, icon);
            notification.show ();
        } catch (Error e) {
            error ("Error

: %s", e.message);
    }
    return 0;
}

那么有没有办法触发 Vala 的弹出通知?

我找到的都是this,但我觉得不适合Windows 10,好像2011年就停了

为了了解发生了什么,我将把它分解为 Vala、GTK+、系统通知和 D-Bus。

看起来您已经编译了您的程序并且 运行 它在 Windows 上。所以 Vala 和 C 编译器完成了他们的工作并生成了 运行s on Windows 的二进制文件。 Vala 通常与 GTK+ 图形工具包一起使用,而 GTK+ 使用不同的 GDK backends for things like creating windows and handling input. GTK+ also uses different Cairo backends 来跨平台呈现小部件。 GDK 和 Cairo 在 Windows 上使用 Windows API,在 macOS 上使用 Quartz API 等等。

系统范围的通知似乎不像 GDK 和 Cairo 那样跨平台。 Unix 的通用标准是 Freedesktop.org notification specification. This specification makes use of D-Bus 用于与系统范围通知实现的进程间通信。在 Linux 和其他类 Unix 平台上,这工作得很好。要求是 D-Bus 是 运行ning 并且有一个 org.freedesktop.Notifications.

的实现

在 Windows 我不确定 D-Bus 是否工作。 Windows 可能有 TCP 实现,但 Unix 套接字在 Unix 上使用。如果 D-Bus 可以在 Windows 上 运行,那么还需要一个 org.freedesktop.Notifications 的实现,将 D-Bus 消息转换为 Windows API 通知。所以这可能是可能的,但我找不到实现。

更新

正如@AlexB GIO 所指出的那样 GNotification provides cross platform system notifications. This includes org.freedesktop.Notifications, Flatpak, macOS and Windows. Unfortunately at the current time the Windows implementation is just a place holder. There is an issue to fix this