Which one is the best choice for the Gtk application: GNotification / NotifyNotification?

Want to show some notifications from my app, it seems that there are two API options for choosing: GNotification / NotifyNotification,

Which one is the best choice for the Gtk application: GNotification / NotifyNotification?
Could someone share your experience with it?

1 Like

Always use GNotification when writing a GTK application.

The libnotify API is for non-GTK code, or legacy applications.

1 Like

Is GNotification still the choice, if the application wants to work best in all ( non-GNOME ) environments ( Xfce / Solus budgie etc ) ?

Yes. GNotification will use the Shell notification API if it detects you’re using GNOME, otherwise it’ll fall back to the old freedesktop Notification API (which is what libnotify uses).

Great.

If an application ( rhythmbox in my case ) already has been written with libnotify client API, and it is working fine with GNOME Shell notification daemon, and other implementations, what would be a good reason to make the switch ?

First of all, because libnotify is generally deprecated and by and large unmaintained, since the introduction of GNotification.

Additionally, the Shell notification interface allows associating notifications to applications, which means the Shell will be able to launch your application if the user clicked on the notification; it also allows serialised icons, for sandboxed applications.

1 Like

Sounds good.

Also, libnotify doesn’t have an async API. The notification send call does synchronous d-bus calls which might cause the app to hang in some buggy notification servers.

I don’t see any information on this topic in g_application_send_notification() API.

The call can be moved to a GThread / GTask though.

Thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.