Re: [PATCH] Rudimentary libnotify support

On 04/09/2007 07:51:54 AM, Johan Brannlund wrote:
Hi. Some time in the distant past I posted that I'd give libnotify
support a go, since I found the popup windows somewhat annoying. I now have a first version of this and I thought I could just as well post it, even though I don't expect this version to be applied. The patch can be found at

Some problems with the current version:

* If you pass "--with-libnotify=no", the code probably won't compile,

since the old code is just commented out at the moment.

* It's too chatty.

* The notification bubbles probably stay on screen too long (10

I'll try to fix these things soon. Comments on these and other issues
with the patch are welcome.

Wow, very nice! I did not have idea that so little code is needed (but apparently, more knowledge is :-). There was one misspelling in the patch (s,qg_object_unref,g_object_unref,) but otherwise it looks very much ok. I have been only wondering about using HAVE_NOTIFY vs HAVE_LIBNOTIFY and also a choice of the configure option --with-libnotify but it is of no significant importance.

I wonder whether one should not introduce another class of messages for the notifications that should be sent to libnotify if available - currently, lot of messages belong to INFO class but those probably most appropriate for libnotify like "you have got mail!" are not being sent...

---	(revision 7576)
+++	(working copy)
@@ -130,6 +130,14 @@
+        AC_HELP_STRING([--with-libnotify],
+                [Use libnotify (default=yes)]),[
+	with_libnotify=$withval
+	with_libnotify=yes
                 [Use GtkSourceView if available (default=no)]),[
@@ -568,6 +576,14 @@
+# Libnotify configuration
+if test x$with_libnotify != xno; then
+    PKG_CHECK_MODULES(NOTIFY, [ libnotify ])
+    AC_DEFINE(HAVE_NOTIFY,1,[Defined when libnotify can be used.])
+    BALSA_LIBS="$BALSA_LIBS -lnotify"
+    BALSA_AB_LIBS="$BALSA_AB_LIBS -lnotify"
 # Compface configuration
 AC_MSG_CHECKING([whether to build Compface support])
@@ -773,6 +789,7 @@
 echo "                Use SQLite: $with_sqlite"
 echo "                   Use SSL: $with_ssl"
 echo "              Use GtkSpell: $with_gtkspell"
+echo "             Use Libnotify: $with_libnotify"
 echo "         Use GtkSourceView: $with_gtksourceview"
 echo "              Use GtkPrint: $with_gtkprint"
 echo "              Use Compface: $with_compface"
Index: libbalsa/libbalsa.c
--- libbalsa/libbalsa.c	(revision 7576)
+++ libbalsa/libbalsa.c	(working copy)
@@ -48,6 +48,10 @@
 #include <gtksourceview/gtksourcetagstyle.h>
+#include <libnotify/notify.h>
 #include "libbalsa.h"
 #include "misc.h"
 #include "i18n.h"
@@ -74,6 +78,9 @@
     struct utsname utsname;
+    notify_init("Basics");
     if (!g_thread_supported()) {
Index: libbalsa/information.c
--- libbalsa/information.c	(revision 7576)
+++ libbalsa/information.c	(working copy)
@@ -22,6 +22,10 @@
 #include "config.h"
+#include <libnotify/notify.h>
 #include "information.h"
 struct information_data {
@@ -47,7 +51,11 @@
 libbalsa_information_varg(GtkWindow *parent, LibBalsaInformationType type,
                           const char *fmt, va_list ap)
+    NotifyNotification *note;
     struct information_data *data = g_new(struct information_data, 1);
+#endif /* HAVE_NOTIFY */
     g_return_if_fail(fmt != NULL);
     g_assert(libbalsa_real_information_func != NULL);
@@ -56,12 +64,20 @@
      * handler We parse the args here because by the time the idle
      * function runs we will no longer be in this stack frame. 
+    note = notify_notification_new("Balsa info",
+                                   g_strdup_vprintf(fmt,ap),NULL,NULL);
+    notify_notification_set_timeout (note, 10000); /* 10 seconds */
+    notify_notification_show (note, NULL);
+    g_object_unref(G_OBJECT(note));
     data->parent = parent;
     data->message_type = type;
     data->msg = g_strdup_vprintf(fmt, ap);
         g_object_add_weak_pointer(G_OBJECT(parent), (gpointer) &data->parent);
     g_idle_add((GSourceFunc) libbalsa_information_idle_handler, data);

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]