GNOME Bugzilla – Bug 745634
[GNotifications] Use themed icon as icon-name
Last modified: 2015-03-06 14:29:54 UTC
Created attachment 298571 [details] [review] Patch to fix this bug. For now FDONotificationsBackend supports only FileIcons as "image-path" hint. But it can support ThemedIcons through icon-name property. Here is a small patch to acheive support of ThemedIcons.
Created attachment 298581 [details] [review] Patch to fix this bug.
The desktop notification spec [1] doesn't support themed icons and clearly states that it only allows icons from local files (in the "Images" section). This patch sets themed icons as the application icon. We can't do that, because it's used in a different part of the notification UI and should always be the application's icon, so that the source of the notification is clear. The icon is set by the shell by looking at the "desktop-entry" hint. Sorry. What's your use case? Maybe we can solve it in a different way. Note that using themed icons works in GNOME shell, as it uses a different notification backend. [1] https://developer.gnome.org/notification-spec
I am writing a small Gtk-only battery applet (parsing UPower) for lightweight WM/DEs. And I want a way to set an icon name without using libnotify (or D-Bus directly). I am using notification daemon with following capabilites: ['body', 'body-markup', 'icon-static', 'image/svg+xml']. With my patch I can set themed icon for icon name property and show notification like "Battery is low" and UPower icon-name. Without a patch I need to use libnotify for this.
I want a way to set: https://developer.gnome.org/libnotify/0.7/NotifyNotification.html#NotifyNotification--icon-name via GNotifications. And provided a patch for this;)
Created attachment 298611 [details] Screen of notification without icon. I want to show UPower icon near a notification (this is will be exactly a XFCE systray icon).
Created attachment 298612 [details] This is I want to acheive. From xfce4-power-manager.
And what are you think about this (from [1]): The "app_icon" parameter and "image-path" hint should be either an URI (file:// is the only URI schema supported right now) or a name in a freedesktop.org-compliant icon theme (not a GTK+ stock ID).
(In reply to ria.freelander from comment #7) > And what are you think about this (from [1]): > The "app_icon" parameter and "image-path" hint should be either an URI > (file:// is the only URI schema supported right now) or a name in a > freedesktop.org-compliant icon theme (not a GTK+ stock ID). Oh indeed. The spec seems to be a bit unclear there. I'm fine with putting themed icons into the "image-path" hint if that's allowed.
Created attachment 298629 [details] [review] New patch What do you think about this patch: 1. It adds override_app_icon getter and setter (for possibility use g_notification_set_icon's GIcon as application icon) 2. It adds support of ThemedIcons to image-path property.
(In reply to ria.freelander from comment #9) > Created attachment 298629 [details] [review] [review] > New patch > > What do you think about this patch: > > 1. It adds override_app_icon getter and setter (for possibility use > g_notification_set_icon's GIcon as application icon) I don't think letting applications override their own icon in a notification is a good idea. This is why we allow setting an image independently of that. Again, why exactly do you need that? Does the notification server you're using not support image-path? > 2. It adds support of ThemedIcons to image-path property. This part makes sense. In your patch, please don't check for icon != NULL twice and remove the icon_name variable (there's no need for it anymore once you remove the override_app_icon stuff). Thanks for working on this.
1. I just checked notify-osd and xfce4-notifyd. It is not support image-path. I think for this notification servers overriding app icon is makes sense. 2. About checking - OK. 3. How GNotification determine application icon?
(In reply to ria.freelander from comment #11) > 1. I just checked notify-osd and xfce4-notifyd. It is not support > image-path. We should fix those servers, then. > I think for this notification servers overriding app icon is makes sense. Why? I see no practical reason for this other than that it can confuse people about where a notification comes from. > 3. How GNotification determine application icon? It doesn't need to. It sends the application id (for the fdo backend, in the "desktop-entry" hint) and it is up to the notification sever to open the desktop file and look for the icon.
Then you think that it is xfce4-notifyd and notify-osd fault to not supporting an "image-path" and "desktop-entry" property? I cannot fix all notification servers in the world to supporting this new hints.
(In reply to ria.freelander from comment #13) > Then you think that it is xfce4-notifyd and notify-osd fault to not > supporting an "image-path" and "desktop-entry" property? > I cannot fix all notification servers in the world to supporting this new > hints. And your solution to this is to add bad API into glib? Sorry, no. We have a spec for a reason. There are not that many notification servers "in the world" and they all already support showing images. Patching them is probably trivial.
Created attachment 298632 [details] [review] Image-path only patch As you requested, image-path only patch.
Created attachment 298633 [details] [review] Image-path only patch Sorry, but it was incorrect
I mistakely uploaded obsolete patch in comment 15. Sorry. Comment 16 contains correct patch.
Thanks. Your patch is missing a commit message and author. I can add the commit message, but do you prefer a real name other than "Ria Freelander"?
Created attachment 298635 [details] [review] With author info Feel free to add a commit message yourself
Thanks!
https://bugs.kde.org/show_bug.cgi?id=344885 KDE does not want to add image-path. It thinks that is GNOME extension. How can I prove them to add support of image-path?
you can't. this is the beauty of cross-desktop cooperation
So, GNotification become gnome-only. It is very ugly. And I will use Vala DBus to make notification myself. It is easier to make than force GLib support overriding app icon or force KDE to support image-path.
Speaking of cross-desktop cooperation, is there any effort from Gnome to propose the updates to the notification spec back to the original galago spec?
(In reply to mklapetek from comment #24) > Speaking of cross-desktop cooperation, is there any effort from Gnome to > propose the updates to the notification spec back to the original galago > spec? The galago project is not active anymore... libnotify has move to git.gnome.org long ago, and we consider this https://git.gnome.org/browse/libnotify/tree/docs/notification-spec.xml to be the canonical location of the spec nowadays.