``
问题
通知守护进程不支持图标名称。
在应用端,我使用 GApplication 发送通知。 我使用这种代码设置了一个图标:
icon = g_themed_icon_new("edit-copy");
g_notification_set_icon(notif, icon);
g_application_send_notification(app, "notif-id", notif);
这段代码基本上会使我的应用程序崩溃。 崩溃是由于 glib 中的错误引起的,该错误是由于 send_notification() 超时而触发的。 它超时是因为 Cinnamon 通知守护程序不再回复,并且可能也崩溃了。
我尽可能地跟踪它。 首先在调用方(即 glib),我们可以看到对 GThemedIcon 的支持在Bug 745634中讨论过,并在glib ec1edef3 中添加。
现在,如果您查看此文件,您会发现该实现最终会将图标保存在image-path
提示中。 这导致我们进行重现的步骤......
重现步骤
所以我们可以重新创建由g_application_send_notification()
发送的 dbus 调用。 至于图像,我们可以使用完整路径(如果调用者使用 GFileIcon,这就是你得到的),或者只是不带扩展名的文件名(如果调用者使用 GThemedIcon,这就是你得到的)。
设置完整路径有效:
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))"
设置图标名称没有,没有显示通知:
IMAGE=edit-copy
python -c ... # copy-paste the snippet above
其他信息
是否要在通知守护程序中支持主题图标由您决定,但至少通知守护程序应该优雅地处理应用程序在image-path
提示中发送的任何垃圾输入。
我在 Cinnamon Javascript 中添加了一些日志,最后在文件js/ui/notificationDaemon.js
:
} else if (hints['image-path']) {
return textureCache.load_uri_async(GLib.filename_to_uri(hints['image-path'], null), size, size);
此调用永远不会返回,因为GLib.filename_to_uri
引发了未处理的异常。 我注意到文件中有一些这样的调用,其中没有处理异常。
我添加了try
catch
语句,但是仍然没有显示通知。 我没有更进一步。
希望这会有所帮助,请随时 ping 我以获取更多详细信息。 干杯,
阿诺
@elboulangero你还在遇到这个问题吗?
@icarter09抱歉,我是在 Cinnamon VM 中进行一些测试时才发现的,当时用户报告了 Goodvibes 在 Cinnamon 上的崩溃。 我自己不经营 Cinnamon,所以我不能说。
话虽如此,你可以尝试上面的“重现步骤”,看看它是否仍然是一个问题
干杯
@icarter09是的,这仍然是一个问题,fedora 使用@itzexor WIP 来修复它
https://github.com/itzexor/Cinnamon/commit/d56f1cca19867dfa44b79e654f729d2f27319e1f
最有用的评论
@icarter09是的,这仍然是一个问题,fedora 使用@itzexor WIP 来修复它
https://github.com/itzexor/Cinnamon/commit/d56f1cca19867dfa44b79e654f729d2f27319e1f