diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/common/helper.c | 46 | ||||
-rw-r--r-- | src/include/gnunetgtk_common.h | 8 | ||||
-rw-r--r-- | src/plugins/fs/fs.c | 17 |
3 files changed, 52 insertions, 19 deletions
diff --git a/src/common/helper.c b/src/common/helper.c index b89597e6..581106a9 100644 --- a/src/common/helper.c +++ b/src/common/helper.c | |||
@@ -184,9 +184,6 @@ void infoMessage(int doPopup, | |||
184 | info.note = g_strdup_vprintf(format, args); | 184 | info.note = g_strdup_vprintf(format, args); |
185 | va_end(args); | 185 | va_end(args); |
186 | info.doPopup = doPopup; | 186 | info.doPopup = doPopup; |
187 | |||
188 | gnunetgtk_notify(info.note, 1); | ||
189 | |||
190 | gtkSaveCall(&doInfoMessage, | 187 | gtkSaveCall(&doInfoMessage, |
191 | &info); | 188 | &info); |
192 | g_free(info.note); | 189 | g_free(info.note); |
@@ -500,36 +497,57 @@ void run_with_save_calls(PThreadMain cb, | |||
500 | * Simple glue to libnotify, and others? | 497 | * Simple glue to libnotify, and others? |
501 | * | 498 | * |
502 | */ | 499 | */ |
503 | void gnunetgtk_notify(const char *message, int type) { | 500 | void gnunetgtk_notify(int type, |
501 | const char *message, | ||
502 | ...) { | ||
504 | #ifdef WITH_LIBNOTIFY | 503 | #ifdef WITH_LIBNOTIFY |
504 | static int once; | ||
505 | char * msg; | ||
506 | size_t size; | ||
507 | va_list arg; | ||
505 | GtkWidget * root; | 508 | GtkWidget * root; |
506 | NotifyNotification *libnotify; | 509 | NotifyNotification *libnotify; |
507 | NotifyUrgency libnotify_urgency = NOTIFY_URGENCY_NORMAL; | 510 | NotifyUrgency libnotify_urgency = NOTIFY_URGENCY_NORMAL; |
508 | long libnotify_expire_timeout = NOTIFY_EXPIRES_DEFAULT; | 511 | long libnotify_expire_timeout = NOTIFY_EXPIRES_DEFAULT; |
509 | 512 | ||
510 | if (!notify_is_initted()){ | 513 | if (! notify_is_initted()){ |
511 | if (!notify_init ("gnunet-gtk")){ | 514 | if (once == 1) |
512 | LOG(LOG_DEBUG,_("Could not init libnotify\n")); | 515 | return; |
516 | if (! notify_init ("gnunet-gtk")) { | ||
517 | once = 1; | ||
518 | LOG(LOG_WARNING, | ||
519 | _("Could not initialize libnotify\n")); | ||
513 | return; | 520 | return; |
514 | } | 521 | } |
515 | } | 522 | } |
516 | 523 | ||
517 | root = glade_xml_get_widget(getMainXML(),"mainWindow"); | 524 | root = glade_xml_get_widget(getMainXML(),"mainWindow"); |
518 | if(gtk_window_is_active(GTK_WINDOW(root)) == FALSE){ | 525 | if (gtk_window_is_active(GTK_WINDOW(root)) == FALSE) { |
519 | if( type == 0) | 526 | if (type == NOTIFY_LOW) |
520 | libnotify_urgency = NOTIFY_URGENCY_LOW; | 527 | libnotify_urgency = NOTIFY_URGENCY_LOW; |
521 | else if( type == 1) | 528 | else if( type == NOTIFY_NORMAL) |
522 | libnotify_urgency = NOTIFY_URGENCY_NORMAL; | 529 | libnotify_urgency = NOTIFY_URGENCY_NORMAL; |
523 | else | 530 | else |
524 | libnotify_urgency = NOTIFY_URGENCY_CRITICAL; | 531 | libnotify_urgency = NOTIFY_URGENCY_CRITICAL; |
532 | va_start(arg, message); | ||
533 | size = vsnprintf(NULL, 0, message, arg); | ||
534 | va_end(arg); | ||
535 | msg = MALLOC(size+1); | ||
536 | va_start(arg, message); | ||
537 | vsnprintf(msg, size, message, arg); | ||
538 | va_end(arg); | ||
525 | libnotify = notify_notification_new("GNUnet: gnunet-gtk", | 539 | libnotify = notify_notification_new("GNUnet: gnunet-gtk", |
526 | message, | 540 | msg, |
527 | PACKAGE_DATA_DIR"/gnunet-gtk-notify.png", | 541 | PACKAGE_DATA_DIR"/gnunet-gtk-notify.png", |
528 | NULL); | 542 | NULL); |
543 | FREE(msg); | ||
529 | notify_notification_set_timeout(libnotify, libnotify_expire_timeout); | 544 | notify_notification_set_timeout(libnotify, libnotify_expire_timeout); |
530 | notify_notification_set_urgency(libnotify, libnotify_urgency); | 545 | notify_notification_set_urgency(libnotify, libnotify_urgency); |
531 | if (!notify_notification_show (libnotify, NULL)) | 546 | if (! notify_notification_show (libnotify, NULL)) { |
532 | LOG(LOG_DEBUG,_("Could not send notification\n")); | 547 | once = 1; |
548 | LOG(LOG_WARNING, | ||
549 | _("Could not send notification via libnotify\n")); | ||
550 | } | ||
533 | g_object_unref(G_OBJECT(libnotify)); | 551 | g_object_unref(G_OBJECT(libnotify)); |
534 | notify_uninit(); | 552 | notify_uninit(); |
535 | } | 553 | } |
diff --git a/src/include/gnunetgtk_common.h b/src/include/gnunetgtk_common.h index 1f0992c5..5abb24db 100644 --- a/src/include/gnunetgtk_common.h +++ b/src/include/gnunetgtk_common.h | |||
@@ -103,10 +103,16 @@ void run_with_save_calls(PThreadMain cb, | |||
103 | */ | 103 | */ |
104 | void connectGladeWithPlugins(GladeXML * xml); | 104 | void connectGladeWithPlugins(GladeXML * xml); |
105 | 105 | ||
106 | #define NOTIFY_LOW 0 | ||
107 | #define NOTIFY_NORMAL 1 | ||
108 | #define NOTIFY_CRITICAL 2 | ||
109 | |||
106 | /** | 110 | /** |
107 | * Sends a message to libnotify | 111 | * Sends a message to libnotify |
108 | */ | 112 | */ |
109 | void gnunetgtk_notify(const char * message, int type); | 113 | void gnunetgtk_notify(int type, |
114 | const char * message, | ||
115 | ...); | ||
110 | 116 | ||
111 | /** | 117 | /** |
112 | * Validate that a string is a Utf-8 string. | 118 | * Validate that a string is a Utf-8 string. |
diff --git a/src/plugins/fs/fs.c b/src/plugins/fs/fs.c index 5bfa5f8d..3b53784b 100644 --- a/src/plugins/fs/fs.c +++ b/src/plugins/fs/fs.c | |||
@@ -64,7 +64,10 @@ static void saveEventProcessor(void * arg) { | |||
64 | displayDownloadComplete(event->data.DownloadProgress.uri, | 64 | displayDownloadComplete(event->data.DownloadProgress.uri, |
65 | event->data.DownloadProgress.filename); | 65 | event->data.DownloadProgress.filename); |
66 | addLogEntry(_("Download `%s' complete"), | 66 | addLogEntry(_("Download `%s' complete"), |
67 | event->data.DownloadProgress.filename); /* here or in download.c ? or call notify directly ? */ | 67 | event->data.DownloadProgress.filename); |
68 | gnunetgtk_notify(NOTIFY_NORMAL, | ||
69 | _("Download `%s' complete"), | ||
70 | event->data.DownloadProgress.filename); | ||
68 | break; | 71 | break; |
69 | case FSUI_download_error: | 72 | case FSUI_download_error: |
70 | BREAK(); | 73 | BREAK(); |
@@ -86,13 +89,19 @@ static void saveEventProcessor(void * arg) { | |||
86 | displayUploadComplete(event->data.UploadComplete.main_filename, | 89 | displayUploadComplete(event->data.UploadComplete.main_filename, |
87 | event->data.UploadComplete.filename, | 90 | event->data.UploadComplete.filename, |
88 | event->data.UploadComplete.uri); | 91 | event->data.UploadComplete.uri); |
89 | addLogEntry(_("Upload `%s' complete"), event->data.UploadComplete.filename); /* here or in upload.c ? or call notify directly ? */ | 92 | addLogEntry(_("Upload `%s' complete"), |
93 | event->data.UploadComplete.filename); | ||
94 | gnunetgtk_notify(NOTIFY_NORMAL, | ||
95 | _("Upload `%s' complete"), | ||
96 | event->data.UploadComplete.filename); | ||
90 | break; | 97 | break; |
91 | case FSUI_upload_error: | 98 | case FSUI_upload_error: |
92 | LOG(LOG_ERROR, | 99 | LOG(LOG_ERROR, |
93 | _("Error while uploading: %s\n"), | 100 | _("Error while uploading: %s\n"), |
94 | event->data.message); | 101 | event->data.message); |
95 | addLogEntry(_("Error while uploading `%s'"), event->data.message); /* here or in upload.c ? */ | 102 | gnunetgtk_notify(NOTIFY_NORMAL, |
103 | _("Error while uploading `%s'"), | ||
104 | event->data.message); | ||
96 | break; | 105 | break; |
97 | case FSUI_gnunetd_connected: | 106 | case FSUI_gnunetd_connected: |
98 | LOG(LOG_MESSAGE, | 107 | LOG(LOG_MESSAGE, |
@@ -101,7 +110,7 @@ static void saveEventProcessor(void * arg) { | |||
101 | case FSUI_gnunetd_disconnected: | 110 | case FSUI_gnunetd_disconnected: |
102 | LOG(LOG_MESSAGE, | 111 | LOG(LOG_MESSAGE, |
103 | _("Disconnected from gnunetd.\n")); | 112 | _("Disconnected from gnunetd.\n")); |
104 | addLogEntry(_("Disconnected from gnunetd.\n")); /* here or ? or call notify directly ? */ | 113 | addLogEntry(_("Disconnected from gnunetd.\n")); |
105 | break; | 114 | break; |
106 | default: | 115 | default: |
107 | BREAK(); | 116 | BREAK(); |