我正试图通过GNotification显示通知:
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gtk/gtk.h>
#define ICON_PATH "/path/trash_16x16.gif"
int main(int argc, char *argv[]) {
GApplication *app;
app = g_application_new ("org." PACKAGE, G_APPLICATION_FLAGS_NONE);
if (!app) {
g_print ("Error app\n");
} else {
if (g_application_register (app, NULL, NULL)) {
GNotification *notification;
GFile *file;
GIcon *icon;
notification = g_notification_new (PACKAGE);
g_notification_set_body (notification, "Hello world");
file = g_file_new_for_path (ICON_PATH);
icon = g_file_icon_new (file);
g_notification_set_icon (notification, G_ICON (icon));
g_application_send_notification (app, NULL, notification);
g_object_unref (icon);
g_object_unref (file);
g_object_unref (notification);
g_object_unref (app);
g_print ("yes!\n");
} else {
g_print ("ok, no luck\n");
}
}
return 0;
}
上面的代码正确显示了通知中的标题和正文,但是图标没有显示,有什么想法吗?