[gnome-power-manager] Make libnotify an optional dependency as it relies on gtk-2.0



commit 3b1b0427777af4c19bfce56a4b44ddd5a445ec10
Author: Richard Hughes <richard hughsie com>
Date:   Fri Jun 18 10:38:20 2010 +0100

    Make libnotify an optional dependency as it relies on gtk-2.0

 configure.ac      |    8 +++++++-
 src/gpm-common.h  |   19 +++++++++++++++++++
 src/gpm-manager.c |    2 ++
 3 files changed, 28 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 8bef374..8c30f3a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -137,9 +137,15 @@ PKG_CHECK_EXISTS(
  [xrandr >= 1.3],
  [AC_DEFINE(HAVE_XRANDR_13, 1, [xrandr 1.3 available])])
 
-PKG_CHECK_MODULES(LIBNOTIFY, libnotify >= 0.4.3)
 PKG_CHECK_MODULES(UPOWER, upower-glib >= 0.9.1)
 
+dnl **** Check for LIBNOTIFY ****
+PKG_CHECK_MODULES(LIBNOTIFY, libnotify3 >= 0.4.3, has_libnotify=yes, has_libnotify=no)
+AM_CONDITIONAL(HAVE_LIBNOTIFY, test x$libnotify = xyes)
+if test x$has_libnotify = xyes; then
+	AC_DEFINE(HAVE_LIBNOTIFY,1,[Use session notifications])
+fi
+
 dnl ---------------------------------------------------------------------------
 dnl - Check XF86XK_Keys
 dnl ---------------------------------------------------------------------------
diff --git a/src/gpm-common.h b/src/gpm-common.h
index b57ae70..f891037 100644
--- a/src/gpm-common.h
+++ b/src/gpm-common.h
@@ -138,6 +138,25 @@ G_BEGIN_DECLS
 #define GS_CONF_DIR					"/apps/gnome-screensaver"
 #define GS_CONF_PREF_LOCK_ENABLED			GS_CONF_DIR "/lock_enabled"
 
+/* libnotify dummy code */
+#ifndef HAVE_LIBNOTIFY
+#define	notify_init(f1)						/* nothing */
+#define	notify_is_initted(f1)					FALSE
+#define	notify_notification_close(f1,f2)			TRUE
+#define	notify_notification_show(f1,f2)				TRUE
+#define	notify_notification_set_timeout(f1,f2)			/* nothing */
+#define	notify_notification_set_urgency(f1,f2)			/* nothing */
+#define	notify_notification_add_action(f1,f2,f3,f4,f5,f6)	/* nothing */
+#define NotifyNotification					GtkWidget
+#define	NotifyUrgency						guint
+#define	notify_notification_new(f1,f2,f3,f4)			gtk_fixed_new()
+#define	notify_notification_new_with_status_icon(f1,f2,f3,f4)	gtk_fixed_new()
+#define NOTIFY_URGENCY_LOW					0
+#define NOTIFY_URGENCY_NORMAL					1
+#define NOTIFY_URGENCY_CRITICAL					2
+#define NOTIFY_EXPIRES_NEVER					0
+#endif
+
 typedef enum {
 	GPM_ICON_POLICY_PRESENT,
 	GPM_ICON_POLICY_CHARGE,
diff --git a/src/gpm-manager.c b/src/gpm-manager.c
index ee112ea..858093a 100644
--- a/src/gpm-manager.c
+++ b/src/gpm-manager.c
@@ -40,7 +40,9 @@
 #include <dbus/dbus-glib-lowlevel.h>
 #include <canberra-gtk.h>
 #include <libupower-glib/upower.h>
+#ifdef HAVE_LIBNOTIFY
 #include <libnotify/notify.h>
+#endif
 
 #include "egg-debug.h"
 #include "egg-console-kit.h"



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