问题
I'm trying to make use of the GLib.Notification api in Synapse project https://code.launchpad.net/~jeremy-munsch/synapse-project/fix-notification/+merge/273323
It is working on some DE, except gnome-shell.
My implementation is basically this :
var notification = new GLib.Notification (_("Synapse - Pastebin"));
notification.set_body (msg);
var gicon = GLib.Icon.new_for_string ("synapse");
notification.set_icon (gicon);
GLib.Application.get_default ().send_notification (null, notification);
I saw some other related info https://bugzilla.gnome.org/show_bug.cgi?id=710913 https://wiki.gnome.org/HowDoI/GNotification
On the last link :
Warning: gnome-shell uses desktop files to find extra information (app icon, name) about the sender of the notification. If you don't have a desktop file whose base name matches the application id, then your notification will not show up.
I don't really understand what exactly this concretely means/implies.
The app name is org.gnome.Synapse
The .desktopfile contains :
data/synapse.desktop.in http://paste.ubuntu.com/13287809/
data/synapse.desktop http://paste.ubuntu.com/13287846/
So what exactly are the prerequisites to make use of GLib.Notification ? (Bonus) what is the difference between the two desktop files with .in ?
回答1:
Your .desktop file needs to be named org.gnome.synapse.desktop and it will need to be installed first in order for Gnome to find it, usually in /usr/local/share/applications/appname
if you install it from source using make install
with root privileges.
As Jens observed in his comment, .in files are Makefile templates, in this case, Make processes the desktop.in file using gettext to localize it. The keys in the .in file that are prefixed with _
are parsed into the available translations from the source tree's po directory, the result of which you see in the .desktop file. Only the resulting .desktop file is actually installed.
I hope this helps.
来源:https://stackoverflow.com/questions/33723549/glib-notification-and-gnome-shell