【发布时间】:2013-06-20 16:33:49
【问题描述】:
我正在尝试在 gnome 中创建一个简单的通知,单击该通知将执行一些代码。我在下面的代码编译并运行,但单击通知气泡没有任何作用。我发现的所有代码示例都表明这应该可以工作。
#include <stdlib.h>
#include <stdio.h>
#include <libnotify/notify.h>
void action(NotifyNotification *n, gchar *action, gpointer data) {
system("gnome-terminal &");
}
int main(int argc, char **argv) {
gtk_init(&argc, &argv);
notify_init("MyApp");
NotifyNotification *notification;
notification = notify_notification_new("mynotification", "Hello", NULL, NULL);
notify_notification_add_action(notification, "DoAction", "default",
(NotifyActionCallback)action, NULL, NULL);
notify_notification_show(notification, NULL);
pause();
}
编译:
gcc main.c `pkg-config --cflags --libs libnotify`
我使用的是 RHEL 6.4,gnome 2.82.2。其他应用程序(例如 firefox“下载完成”)能够创建通知,在单击时执行操作;我只是在某种程度上做得不对。
【问题讨论】: