Notification Daemon: support for themed icons in image-path hint
Let's say I'm a GApplication, and I send my notifications with g_application_send_notification.
Chances are that I want to set an icon for this notification, at least the GNotification API allows me that with g_notification_set_icon.
This method takes a GIcon
as a parameter, which means that I'm likely to write something like:
icon = g_themed_icon_new("edit-copy");
g_notification_set_icon(notif, icon);
g_application_send_notification(app, "notif-id", notif);
However, this doesn't work, and the notification displayed by GNOME has no icon. I've been looking in the details, and what happens on the client side (ie. in the glib implementation) is that the icon is actually saved in the image-path hint. Should image-path
be a themed icon name? This has been discussed in Bug 745634, and the answer was yes. Support for that was added in glib ec1edef3.
It's super easy to test that from the console:
IMAGE=edit-copy
# IMAGE=/usr/share/icons/Adwaita/48x48/actions/edit-copy.png
python -c "import dbus; print dbus.Bus().call_blocking(\
'org.freedesktop.Notifications', \
'/org/freedesktop/Notifications', \
'org.freedesktop.Notifications', \
'Notify', \
'susssasa{sv}i', \
('appname', 0, '', 'summary', 'body', [], {'image-path': '$IMAGE'}, -1))"
As you can see, the notification shows an icon only when image-path
is an absolute path.
My opinion is that it's quite confusing that g_notification_set_icon()
doesn't work for a GThemedIcon, since the API allows that, and support for that was explicitly added in glib a while ago (see link mentioned above).
I attach a patch, as it's super easy to add support for that.
Cheers,
Arnaud
notificationDaemon-add-support-for-themed-icons-in-the-image-path-hint.patch