After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 745634 - [GNotifications] Use themed icon as icon-name
[GNotifications] Use themed icon as icon-name
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gapplication
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2015-03-04 19:26 UTC by ria.freelander
Modified: 2015-03-06 14:29 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to fix this bug. (1.67 KB, patch)
2015-03-04 19:26 UTC, ria.freelander
none Details | Review
Patch to fix this bug. (1.72 KB, patch)
2015-03-04 21:01 UTC, ria.freelander
none Details | Review
Screen of notification without icon. (1.48 MB, image/png)
2015-03-05 10:13 UTC, ria.freelander
  Details
This is I want to acheive. (1.48 MB, image/png)
2015-03-05 10:18 UTC, ria.freelander
  Details
New patch (5.84 KB, patch)
2015-03-05 11:40 UTC, ria.freelander
none Details | Review
Image-path only patch (5.84 KB, patch)
2015-03-05 12:34 UTC, ria.freelander
none Details | Review
Image-path only patch (1.63 KB, patch)
2015-03-05 12:36 UTC, ria.freelander
none Details | Review
With author info (1.77 KB, patch)
2015-03-05 13:07 UTC, ria.freelander
none Details | Review

Description ria.freelander 2015-03-04 19:26:43 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.
Comment 1 ria.freelander 2015-03-04 21:01:51 UTC
Created attachment 298581 [details] [review]
Patch to fix this bug.
Comment 2 Lars Karlitski 2015-03-05 09:57:19 UTC
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
Comment 3 ria.freelander 2015-03-05 10:04:22 UTC
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.
Comment 4 ria.freelander 2015-03-05 10:06:46 UTC
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;)
Comment 5 ria.freelander 2015-03-05 10:13:05 UTC
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).
Comment 6 ria.freelander 2015-03-05 10:18:35 UTC
Created attachment 298612 [details]
This is I want to acheive.

From xfce4-power-manager.
Comment 7 ria.freelander 2015-03-05 10:21:12 UTC
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).
Comment 8 Lars Karlitski 2015-03-05 10:44:45 UTC
(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.
Comment 9 ria.freelander 2015-03-05 11:40:55 UTC
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.
Comment 10 Lars Karlitski 2015-03-05 11:56:32 UTC
(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.
Comment 11 ria.freelander 2015-03-05 12:00:14 UTC
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?
Comment 12 Lars Karlitski 2015-03-05 12:11:40 UTC
(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.
Comment 13 ria.freelander 2015-03-05 12:16:46 UTC
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.
Comment 14 Lars Karlitski 2015-03-05 12:28:11 UTC
(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.
Comment 15 ria.freelander 2015-03-05 12:34:54 UTC
Created attachment 298632 [details] [review]
Image-path only patch

As you requested, image-path only patch.
Comment 16 ria.freelander 2015-03-05 12:36:28 UTC
Created attachment 298633 [details] [review]
Image-path only patch

Sorry, but it was incorrect
Comment 17 ria.freelander 2015-03-05 12:38:11 UTC
I mistakely uploaded obsolete patch in comment 15. Sorry. Comment 16 contains correct patch.
Comment 18 Lars Karlitski 2015-03-05 13:00:42 UTC
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"?
Comment 19 ria.freelander 2015-03-05 13:07:22 UTC
Created attachment 298635 [details] [review]
With author info

Feel free to add a commit message yourself
Comment 20 Lars Karlitski 2015-03-05 13:55:59 UTC
Thanks!
Comment 21 ria.freelander 2015-03-06 12:10:13 UTC
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?
Comment 22 Matthias Clasen 2015-03-06 13:17:14 UTC
you can't. this is the beauty of cross-desktop cooperation
Comment 23 ria.freelander 2015-03-06 13:21:49 UTC
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.
Comment 24 mklapetek 2015-03-06 14:06:02 UTC
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?
Comment 25 Matthias Clasen 2015-03-06 14:29:54 UTC
(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.