2013-06-20 3 views
2

gnome에서 클릭 할 때 일부 코드를 실행할 간단한 알림을 작성하려고합니다. 아래에있는 코드를 컴파일하고 실행하지만 알림 풍선을 클릭해도 아무런 변화가 없습니다. 내가 찾은 모든 코드 샘플은 이것이 작동해야 함을 나타냅니다. libnotify 액션 콜백이 호출되지 않습니다.

#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, 그놈 2.82.2에 있어요. 다른 앱 (예 : firefox "다운로드 완료 됨")은 클릭 할 때 작업을 수행하는 알림을 만들 수 있습니다. 어떻게 든 제대로하지 않을뿐입니다.

답변

2

같은 문제가있었습니다. 분명히 gtk_main을 호출하거나 pause/sleep 또는 다른 non gtk 블로킹 함수를 사용하는 대신 동등한 함수 중 하나를 호출하여 GTK 루프를 사용해야 할 것이다.

관련 문제