aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2006-04-05 06:11:59 +0000
committerChristian Grothoff <christian@grothoff.org>2006-04-05 06:11:59 +0000
commit3cf77a9cb18163d402cc01df527faf32245668c4 (patch)
treedc5f461b3c270e7d5bd178fc5fb83454d9249640
parentb6f4c5d502bfa20aa8b0c1da81da326027dcf0a9 (diff)
downloadgnunet-gtk-3cf77a9cb18163d402cc01df527faf32245668c4.tar.gz
gnunet-gtk-3cf77a9cb18163d402cc01df527faf32245668c4.zip
Hi again.
Soo, adding libnotify support to gnunet-gtk :) Im guessing its not so cleanly done(depending on how you wish to structure it, but ill leave that up to the GNUnet developers ;)), but its rather small so you shouldn't have any trouble deciding if it should go in SVN or not) Im unsure about the configure-ac.diff, if it is the "right thing(TM)" (it works here with and without libnotify) would be nice to be able to disable it altogether. (i can't find a good autotool tutorial online) the small diffs are included in the attached file(three-diffs-libnotify.tar.gz). anyways, im of to bed, good night. /Nicklas Larsson
-rw-r--r--AUTHORS1
-rw-r--r--configure.ac12
-rw-r--r--pixmaps/gnunet-gtk-notify.pngbin0 -> 3685 bytes
-rw-r--r--src/common/Makefile.am7
-rw-r--r--src/common/helper.c50
-rw-r--r--src/include/gnunetgtk_common.h7
-rw-r--r--src/plugins/fs/fs.c4
7 files changed, 78 insertions, 3 deletions
diff --git a/AUTHORS b/AUTHORS
index 9c2732ab..ce438c70 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -3,6 +3,7 @@ Christian Grothoff <christian@grothoff.org>
3 3
4Code contributions also came from: 4Code contributions also came from:
5Igor Wronsky <iwronsky@users.sourceforge.net> 5Igor Wronsky <iwronsky@users.sourceforge.net>
6Nicklas Larsson <whybill@gmail.com>
6Nils Durner <durner@gnunet.org> 7Nils Durner <durner@gnunet.org>
7Milan <nalimilan@club-internet.fr> 8Milan <nalimilan@club-internet.fr>
8 9
diff --git a/configure.ac b/configure.ac
index f18a8c0d..291636b6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -228,6 +228,18 @@ then
228 AC_MSG_ERROR([gnunet-gtk requires libextractor headers]) 228 AC_MSG_ERROR([gnunet-gtk requires libextractor headers])
229fi 229fi
230 230
231# libnotify
232LIBNOTIFY_REQUIRED=0.3.2
233PKG_CHECK_MODULES([LIBNOTIFY], [libnotify >= $LIBNOTIFY_REQUIRED], libnotify=yes, libnotify=no)
234AC_SUBST([LIBNOTIFY_CFLAGS])
235AC_SUBST([LIBNOTIFY_LIBS])
236AM_CONDITIONAL([ENABLE_LIBNOTIFY],[test "x$libnotify" = "xyes"])
237if test "x$libnotify" != "xyes"; then
238 AC_MSG_WARN([Library requirements (libnotify >= $LIBNOTIFY_REQUIRED) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them.])
239else
240 AC_MSG_NOTICE([** libnotify integration enabled])
241 AC_DEFINE(WITH_LIBNOTIFY, 1, [Define if libnotify is enabled])
242fi
231 243
232# We define the paths here, because MinGW/GCC expands paths 244# We define the paths here, because MinGW/GCC expands paths
233# passed through the command line ("-DDATADIR=..."). This would 245# passed through the command line ("-DDATADIR=..."). This would
diff --git a/pixmaps/gnunet-gtk-notify.png b/pixmaps/gnunet-gtk-notify.png
new file mode 100644
index 00000000..8c1446a0
--- /dev/null
+++ b/pixmaps/gnunet-gtk-notify.png
Binary files differ
diff --git a/src/common/Makefile.am b/src/common/Makefile.am
index 19b1a6d0..ed844e9f 100644
--- a/src/common/Makefile.am
+++ b/src/common/Makefile.am
@@ -2,7 +2,8 @@ INCLUDES = \
2 -I$(top_srcdir)/intl \ 2 -I$(top_srcdir)/intl \
3 -I$(top_srcdir)/src/include \ 3 -I$(top_srcdir)/src/include \
4 @GTK_CFLAGS@ \ 4 @GTK_CFLAGS@ \
5 @GNUNETGTK_CFLAGS@ 5 @GNUNETGTK_CFLAGS@ \
6 $(LIBNOTIFY_CFLAGS)
6 7
7lib_LTLIBRARIES = \ 8lib_LTLIBRARIES = \
8 libgnunetgtk_common.la 9 libgnunetgtk_common.la
@@ -19,6 +20,6 @@ libgnunetgtk_common_la_LIBADD = \
19 @GNUNETGTK_LIBS@ \ 20 @GNUNETGTK_LIBS@ \
20 $(INTLLIBS) \ 21 $(INTLLIBS) \
21 -lgnunetutil \ 22 -lgnunetutil \
22 -lgthread-2.0 23 -lgthread-2.0 \
23 24 $(LIBNOTIFY_LIBS)
24 25
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 */
diff --git a/src/include/gnunetgtk_common.h b/src/include/gnunetgtk_common.h
index 091b43cb..54a0e625 100644
--- a/src/include/gnunetgtk_common.h
+++ b/src/include/gnunetgtk_common.h
@@ -97,4 +97,11 @@ void run_with_save_calls(PThreadMain cb,
97 */ 97 */
98void connectGladeWithPlugins(GladeXML * xml); 98void connectGladeWithPlugins(GladeXML * xml);
99 99
100/**
101 * Sends a message to libnotify
102 *
103 *
104 */
105void gnunetgtk_notify(const char * message, int type);
106
100#endif 107#endif
diff --git a/src/plugins/fs/fs.c b/src/plugins/fs/fs.c
index 6087312c..8733efc1 100644
--- a/src/plugins/fs/fs.c
+++ b/src/plugins/fs/fs.c
@@ -62,6 +62,7 @@ static void saveEventProcessor(void * arg) {
62 case FSUI_download_complete: 62 case FSUI_download_complete:
63 displayDownloadComplete(event->data.DownloadProgress.uri, 63 displayDownloadComplete(event->data.DownloadProgress.uri,
64 event->data.DownloadProgress.filename); 64 event->data.DownloadProgress.filename);
65 addLogEntry(_("Download `%s' complete"), event->data.DownloadProgress.filename); /* here or in download.c ? or call notify directly ? */
65 break; 66 break;
66 case FSUI_download_error: 67 case FSUI_download_error:
67 BREAK(); 68 BREAK();
@@ -83,11 +84,13 @@ static void saveEventProcessor(void * arg) {
83 displayUploadComplete(event->data.UploadComplete.main_filename, 84 displayUploadComplete(event->data.UploadComplete.main_filename,
84 event->data.UploadComplete.filename, 85 event->data.UploadComplete.filename,
85 event->data.UploadComplete.uri); 86 event->data.UploadComplete.uri);
87 addLogEntry(_("Upload `%s' complete"), event->data.UploadComplete.main_filename); /* here or in upload.c ? or call notify directly ? */
86 break; 88 break;
87 case FSUI_upload_error: 89 case FSUI_upload_error:
88 LOG(LOG_ERROR, 90 LOG(LOG_ERROR,
89 _("Error while uploading: %s\n"), 91 _("Error while uploading: %s\n"),
90 event->data.message); 92 event->data.message);
93 addLogEntry(_("Error while uploading `%s'"), event->data.message); /* here or in upload.c ? */
91 break; 94 break;
92 case FSUI_gnunetd_connected: 95 case FSUI_gnunetd_connected:
93 LOG(LOG_MESSAGE, 96 LOG(LOG_MESSAGE,
@@ -96,6 +99,7 @@ static void saveEventProcessor(void * arg) {
96 case FSUI_gnunetd_disconnected: 99 case FSUI_gnunetd_disconnected:
97 LOG(LOG_MESSAGE, 100 LOG(LOG_MESSAGE,
98 _("Disconnected from gnunetd.\n")); 101 _("Disconnected from gnunetd.\n"));
102 addLogEntry(_("Disconnected from gnunetd.\n")); /* here or ? or call notify directly ? */
99 break; 103 break;
100 default: 104 default:
101 BREAK(); 105 BREAK();