libnotify support.



Since it seems to be all the rage with the kids these days, I added
libnotify support to NetworkManager.

To be honest, it doesn't excite me, but I thought I would share it.

You need libnotify and the notification-daemon installed and properly
configured.

The patch doesn't actually call the new nwma_notify() because I couldn't
find a good place for it.  But you can stick it somewhere to play with.

	Robert Love

Index: configure.in
===================================================================
RCS file: /cvs/gnome/NetworkManager/configure.in,v
retrieving revision 1.84
diff -u -u -r1.84 configure.in
--- configure.in	30 Jun 2005 14:34:17 -0000	1.84
+++ configure.in	5 Jul 2005 18:22:35 -0000
@@ -169,6 +169,17 @@
 fi
 AM_CONDITIONAL(WITH_GCRYPT, test x"$ac_gcrypt" != xno)
 
+LIBNOTIFY_CFLAGS=
+LIBNOTIFY_LIBS=
+PKG_CHECK_MODULES(LIBNOTIFY, libnotify, HAVE_LIBNOTIFY="yes", HAVE_LIBNOTIFY="no")
+if test "x$HAVE_LIBNOTIFY" = "xyes"; then
+  AC_DEFINE(HAVE_LIBNOTIFY, 1, [libnotify available])
+else
+  AC_MSG_WARN([*** libnotify not found, no notifications ***])
+fi
+AC_SUBST(LIBNOTIFY_CFLAGS)
+AC_SUBST(LIBNOTIFY_LIBS)
+
 PKG_CHECK_MODULES(PANEL_APPLET, libpanelapplet-2.0)
 AC_SUBST(PANEL_APPLET_CFLAGS)
 AC_SUBST(PANEL_APPLET_LIBS)
Index: gnome/applet/Makefile.am
===================================================================
RCS file: /cvs/gnome/NetworkManager/gnome/applet/Makefile.am,v
retrieving revision 1.6
diff -u -u -r1.6 Makefile.am
--- gnome/applet/Makefile.am	23 Jun 2005 20:34:57 -0000	1.6
+++ gnome/applet/Makefile.am	5 Jul 2005 18:22:35 -0000
@@ -7,16 +7,17 @@
 libexec_PROGRAMS = nm-applet
 
 nm_applet_CPPFLAGS =							\
-	$(DBUS_CFLAGS)							\
-	$(GTHREAD_CFLAGS)						\
-	$(HAL_CFLAGS)							\
-	$(DBUS_GLIB_CFLAGS)						\
+	$(DBUS_CFLAGS)								\
+	$(GTHREAD_CFLAGS)							\
+	$(HAL_CFLAGS)								\
+	$(DBUS_GLIB_CFLAGS)							\
 	$(GLADE_CFLAGS)							\
-	$(GTK_CFLAGS)							\
+	$(GTK_CFLAGS)								\
 	$(GCONF_CFLAGS)							\
 	$(LIBGNOMEUI_CFLAGS)						\
 	$(PANEL_APPLET_CFLAGS)						\
 	$(GNOME_KEYRING_CFLAGS)						\
+	$(LIBNOTIFY_CFLAGS)							\
 	-DICONDIR=\""$(datadir)/pixmaps"\"				\
 	-DGLADEDIR=\""$(gladedir)"\"					\
 	-DBINDIR=\""$(bindir)"\"					\
@@ -71,6 +72,7 @@
 	$(GCONF_LIBS)						\
 	$(LIBGNOMEUI_LIBS)					\
 	$(GNOME_KEYRING_LIBS)				\
+	$(LIBNOTIFY_LIBS)					\
 	$(top_builddir)/utils/libnmutils.la	\
 	$(NULL)
 
Index: gnome/applet/applet.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/gnome/applet/applet.c,v
retrieving revision 1.20
diff -u -u -r1.20 applet.c
--- gnome/applet/applet.c	30 Jun 2005 20:25:50 -0000	1.20
+++ gnome/applet/applet.c	5 Jul 2005 18:22:36 -0000
@@ -59,6 +59,10 @@
 #include <glade/glade.h>
 #include <gconf/gconf-client.h>
 
+#ifdef HAVE_LIBNOTIFY
+#include <libnotify/notify.h>
+#endif
+
 #include "applet.h"
 #include "applet-dbus.h"
 #include "applet-dbus-devices.h"
@@ -990,6 +994,27 @@
 	return NULL;
 }
 
+#ifdef HAVE_LIBNOTIFY
+static void nmwa_notify (void)
+{
+	static NotifyIcon *icon = NULL;
+
+	if (!notify_is_initted ())
+		notify_init (_("NetworkManager"));
+
+	notification_msg = g_strdup_printf (_("Connected to the network!"));
+	notify_send_notification (NULL, "network", NOTIFY_URGENCY_NORMAL,
+						 notification_msg,
+						 NULL,		/* no body text */
+						 0,			/* no icon */
+						 FALSE, 0,	/* expiry, server default */
+						 NULL,		/* no user_data */
+						 0);			/* no actions */
+	g_free (notification_msg);
+}
+#else
+static inline void nmwa_notify (void) { }
+#endif
 
 /*
  * nmwa_update_state


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