aboutsummaryrefslogtreecommitdiff
path: root/src/common/helper.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/helper.c')
-rw-r--r--src/common/helper.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/common/helper.c b/src/common/helper.c
index f323658e..1307401a 100644
--- a/src/common/helper.c
+++ b/src/common/helper.c
@@ -29,6 +29,10 @@
29 29
30#define HELPER_DEBUG NO 30#define HELPER_DEBUG NO
31 31
32#ifdef WITH_LIBNOTIFY
33#include <libnotify/notify.h>
34#endif
35
32typedef struct { 36typedef struct {
33 Semaphore * sem; 37 Semaphore * sem;
34 void * args; 38 void * args;
@@ -205,6 +209,9 @@ void infoMessage(int doPopup,
205 info.note = g_strdup_vprintf(format, args); 209 info.note = g_strdup_vprintf(format, args);
206 va_end(args); 210 va_end(args);
207 info.doPopup = doPopup; 211 info.doPopup = doPopup;
212
213 gnunetgtk_notify(info.note, 1);
214
208 gtkSaveCall(&doInfoMessage, 215 gtkSaveCall(&doInfoMessage,
209 &info); 216 &info);
210 g_free(info.note); 217 g_free(info.note);
@@ -500,4 +507,47 @@ void run_with_save_calls(PThreadMain cb,
500 SEMAPHORE_FREE(cls.sig); 507 SEMAPHORE_FREE(cls.sig);
501} 508}
502 509
510/**
511 * Simple glue to libnotify, and others?
512 *
513 */
514void gnunetgtk_notify(const char *message, int type) {
515
516 GtkWidget * root;
517
518#ifdef WITH_LIBNOTIFY
519 NotifyNotification *libnotify;
520 NotifyUrgency libnotify_urgency = NOTIFY_URGENCY_NORMAL;
521 long libnotify_expire_timeout = NOTIFY_EXPIRES_DEFAULT;
522
523 if (!notify_is_initted()){
524 if (!notify_init ("gnunet-gtk")){
525 LOG(LOG_DEBUG,_("Could not init libnotify\n"));
526 return;
527 }
528 }
529
530 root = glade_xml_get_widget(getMainXML(),"mainWindow");
531 if(gtk_window_is_active(GTK_WINDOW(root)) == FALSE){
532 if( type == 0)
533 libnotify_urgency = NOTIFY_URGENCY_LOW;
534 else if( type == 1)
535 libnotify_urgency = NOTIFY_URGENCY_NORMAL;
536 else
537 libnotify_urgency = NOTIFY_URGENCY_CRITICAL;
538 libnotify = notify_notification_new("GNUnet: gnunet-gtk",
539 message,
540 PACKAGE_DATA_DIR"/gnunet-gtk-notify.png",
541 NULL);
542 notify_notification_set_timeout(libnotify, libnotify_expire_timeout);
543 notify_notification_set_urgency(libnotify, libnotify_urgency);
544 if (!notify_notification_show (libnotify, NULL))
545 LOG(LOG_DEBUG,_("Could not send notification\n"));
546 g_object_unref(G_OBJECT(libnotify));
547 notify_uninit();
548 }
549#endif
550
551}
552
503/* end of helper.c */ 553/* end of helper.c */