gpt4 book ai didi

gnome - 未调用 libnotify 操作回调

转载 作者:行者123 更新时间:2023-12-02 00:07:55 26 4
gpt4 key购买 nike

我正在尝试在 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“下载已完成”)能够创建在单击时执行操作的通知;我只是做得不对。

最佳答案

遇到了同样的问题。显然,您必须通过调用 gtk_main 或等效函数之一来使用 GTK 循环,而不是使用暂停/ sleep 或其他非 gtk 阻塞函数。

关于gnome - 未调用 libnotify 操作回调,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17218995/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com