[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r2857 - in gnunet-gtk/src: common include plugins/fs
From: |
grothoff |
Subject: |
[GNUnet-SVN] r2857 - in gnunet-gtk/src: common include plugins/fs |
Date: |
Sat, 20 May 2006 03:03:58 -0700 (PDT) |
Author: grothoff
Date: 2006-05-20 03:03:38 -0700 (Sat, 20 May 2006)
New Revision: 2857
Modified:
gnunet-gtk/src/common/helper.c
gnunet-gtk/src/include/gnunetgtk_common.h
gnunet-gtk/src/plugins/fs/fs.c
Log:
mantis 1098
Modified: gnunet-gtk/src/common/helper.c
===================================================================
--- gnunet-gtk/src/common/helper.c 2006-05-20 09:50:40 UTC (rev 2856)
+++ gnunet-gtk/src/common/helper.c 2006-05-20 10:03:38 UTC (rev 2857)
@@ -184,9 +184,6 @@
info.note = g_strdup_vprintf(format, args);
va_end(args);
info.doPopup = doPopup;
-
- gnunetgtk_notify(info.note, 1);
-
gtkSaveCall(&doInfoMessage,
&info);
g_free(info.note);
@@ -500,36 +497,57 @@
* Simple glue to libnotify, and others?
*
*/
-void gnunetgtk_notify(const char *message, int type) {
+void gnunetgtk_notify(int type,
+ const char *message,
+ ...) {
#ifdef WITH_LIBNOTIFY
+ static int once;
+ char * msg;
+ size_t size;
+ va_list arg;
GtkWidget * root;
NotifyNotification *libnotify;
NotifyUrgency libnotify_urgency = NOTIFY_URGENCY_NORMAL;
long libnotify_expire_timeout = NOTIFY_EXPIRES_DEFAULT;
- if (!notify_is_initted()){
- if (!notify_init ("gnunet-gtk")){
- LOG(LOG_DEBUG,_("Could not init libnotify\n"));
+ if (! notify_is_initted()){
+ if (once == 1)
+ return;
+ if (! notify_init ("gnunet-gtk")) {
+ once = 1;
+ LOG(LOG_WARNING,
+ _("Could not initialize libnotify\n"));
return;
}
}
-
+
root = glade_xml_get_widget(getMainXML(),"mainWindow");
- if(gtk_window_is_active(GTK_WINDOW(root)) == FALSE){
- if( type == 0)
+ if (gtk_window_is_active(GTK_WINDOW(root)) == FALSE) {
+ if (type == NOTIFY_LOW)
libnotify_urgency = NOTIFY_URGENCY_LOW;
- else if( type == 1)
+ else if( type == NOTIFY_NORMAL)
libnotify_urgency = NOTIFY_URGENCY_NORMAL;
else
libnotify_urgency = NOTIFY_URGENCY_CRITICAL;
+ va_start(arg, message);
+ size = vsnprintf(NULL, 0, message, arg);
+ va_end(arg);
+ msg = MALLOC(size+1);
+ va_start(arg, message);
+ vsnprintf(msg, size, message, arg);
+ va_end(arg);
libnotify = notify_notification_new("GNUnet: gnunet-gtk",
- message,
+ msg,
PACKAGE_DATA_DIR"/gnunet-gtk-notify.png",
NULL);
+ FREE(msg);
notify_notification_set_timeout(libnotify, libnotify_expire_timeout);
notify_notification_set_urgency(libnotify, libnotify_urgency);
- if (!notify_notification_show (libnotify, NULL))
- LOG(LOG_DEBUG,_("Could not send notification\n"));
+ if (! notify_notification_show (libnotify, NULL)) {
+ once = 1;
+ LOG(LOG_WARNING,
+ _("Could not send notification via libnotify\n"));
+ }
g_object_unref(G_OBJECT(libnotify));
notify_uninit();
}
Modified: gnunet-gtk/src/include/gnunetgtk_common.h
===================================================================
--- gnunet-gtk/src/include/gnunetgtk_common.h 2006-05-20 09:50:40 UTC (rev
2856)
+++ gnunet-gtk/src/include/gnunetgtk_common.h 2006-05-20 10:03:38 UTC (rev
2857)
@@ -103,10 +103,16 @@
*/
void connectGladeWithPlugins(GladeXML * xml);
+#define NOTIFY_LOW 0
+#define NOTIFY_NORMAL 1
+#define NOTIFY_CRITICAL 2
+
/**
* Sends a message to libnotify
*/
-void gnunetgtk_notify(const char * message, int type);
+void gnunetgtk_notify(int type,
+ const char * message,
+ ...);
/**
* Validate that a string is a Utf-8 string.
Modified: gnunet-gtk/src/plugins/fs/fs.c
===================================================================
--- gnunet-gtk/src/plugins/fs/fs.c 2006-05-20 09:50:40 UTC (rev 2856)
+++ gnunet-gtk/src/plugins/fs/fs.c 2006-05-20 10:03:38 UTC (rev 2857)
@@ -64,7 +64,10 @@
displayDownloadComplete(event->data.DownloadProgress.uri,
event->data.DownloadProgress.filename);
addLogEntry(_("Download `%s' complete"),
- event->data.DownloadProgress.filename); /* here or in
download.c ? or call notify directly ? */
+ event->data.DownloadProgress.filename);
+ gnunetgtk_notify(NOTIFY_NORMAL,
+ _("Download `%s' complete"),
+ event->data.DownloadProgress.filename);
break;
case FSUI_download_error:
BREAK();
@@ -86,13 +89,19 @@
displayUploadComplete(event->data.UploadComplete.main_filename,
event->data.UploadComplete.filename,
event->data.UploadComplete.uri);
- addLogEntry(_("Upload `%s' complete"),
event->data.UploadComplete.filename); /* here or in upload.c ? or call notify
directly ? */
+ addLogEntry(_("Upload `%s' complete"),
+ event->data.UploadComplete.filename);
+ gnunetgtk_notify(NOTIFY_NORMAL,
+ _("Upload `%s' complete"),
+ event->data.UploadComplete.filename);
break;
case FSUI_upload_error:
LOG(LOG_ERROR,
_("Error while uploading: %s\n"),
event->data.message);
- addLogEntry(_("Error while uploading `%s'"), event->data.message); /* here
or in upload.c ? */
+ gnunetgtk_notify(NOTIFY_NORMAL,
+ _("Error while uploading `%s'"),
+ event->data.message);
break;
case FSUI_gnunetd_connected:
LOG(LOG_MESSAGE,
@@ -101,7 +110,7 @@
case FSUI_gnunetd_disconnected:
LOG(LOG_MESSAGE,
_("Disconnected from gnunetd.\n"));
- addLogEntry(_("Disconnected from gnunetd.\n")); /* here or ? or call
notify directly ? */
+ addLogEntry(_("Disconnected from gnunetd.\n"));
break;
default:
BREAK();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r2857 - in gnunet-gtk/src: common include plugins/fs,
grothoff <=