[gnome-packagekit] Make libnotify an optional dependency as it relies on gtk-2.0
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-packagekit] Make libnotify an optional dependency as it relies on gtk-2.0
- Date: Fri, 18 Jun 2010 09:41:25 +0000 (UTC)
commit c5dee37d7c169b35e407739c20fc8164a679c280
Author: Richard Hughes <richard hughsie com>
Date: Fri Jun 18 10:41:08 2010 +0100
Make libnotify an optional dependency as it relies on gtk-2.0
configure.ac | 20 +++++++++++++-------
src/gpk-check-update.c | 7 +++++++
src/gpk-common.h | 19 +++++++++++++++++++
src/gpk-dbus-service.c | 3 +++
src/gpk-dbus-task.c | 4 ++++
src/gpk-firmware.c | 12 +++++++++---
src/gpk-hardware.c | 5 ++++-
src/gpk-update-icon.c | 2 ++
src/gpk-watch.c | 4 ++++
9 files changed, 65 insertions(+), 11 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index e03b854..69589f0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -115,8 +115,6 @@ PKG_CHECK_MODULES(DBUS, \
gthread-2.0)
PKG_CHECK_MODULES(GTK, \
gtk+-3.0 >= 2.90.3 gdk-3.0 fontconfig)
-PKG_CHECK_MODULES(LIBNOTIFY, \
- libnotify >= 0.4.3)
PKG_CHECK_MODULES(GNOME_MENUS, \
libgnome-menu >= 2.24.1)
PKG_CHECK_MODULES(UPOWER, [
@@ -124,23 +122,30 @@ PKG_CHECK_MODULES(UPOWER, [
PKG_CHECK_MODULES(CANBERRA, libcanberra-gtk3 >= 0.10)
PKG_CHECK_MODULES(X11, x11)
+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 - GUdev integration (default enabled)
dnl ---------------------------------------------------------------------------
AC_ARG_ENABLE(gudev, AS_HELP_STRING([--disable-gudev],[Disable GUdev support]), enable_gudev=$enableval)
if test x$enable_gudev != xno; then
- PKG_CHECK_MODULES(GUDEV, gudev-1.0, GPK_BUILD_GUDEV="yes", GPK_BUILD_GUDEV="no")
- if test "x$GPK_BUILD_GUDEV" = "xyes"; then
- AC_DEFINE(GPK_BUILD_GUDEV, 1, [define if GUdev is available])
+ PKG_CHECK_MODULES(GUDEV, gudev-1.0, HAVE_GUDEV="yes", HAVE_GUDEV="no")
+ if test "x$HAVE_GUDEV" = "xyes"; then
+ AC_DEFINE(HAVE_GUDEV, 1, [define if GUdev is available])
else
if test x$enable_gudev = xyes; then
AC_MSG_ERROR([GUdev enabled but not found])
fi
fi
else
- GPK_BUILD_GUDEV=no
+ HAVE_GUDEV=no
fi
-AM_CONDITIONAL(GPK_BUILD_GUDEV, test x$GPK_BUILD_GUDEV = xyes)
+AM_CONDITIONAL(HAVE_GUDEV, test x$HAVE_GUDEV = xyes)
dnl ---------------------------------------------------------------------------
dnl - Enable small form factor code
@@ -237,5 +242,6 @@ echo "
compiler: ${CC}
cflags: ${CFLAGS}
cppflags: ${CPPFLAGS}
+ libnotify support: ${has_libnotify}
"
diff --git a/src/gpk-check-update.c b/src/gpk-check-update.c
index 14ae481..ee4dc71 100644
--- a/src/gpk-check-update.c
+++ b/src/gpk-check-update.c
@@ -35,7 +35,9 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
+#ifdef HAVE_LIBNOTIFY
#include <libnotify/notify.h>
+#endif
#include <packagekit-glib2/packagekit.h>
#include <canberra-gtk.h>
#include <gio/gio.h>
@@ -53,7 +55,10 @@
#include "gpk-task.h"
static void gpk_check_update_finalize (GObject *object);
+
+#ifdef HAVE_LIBNOTIFY
static void gpk_check_update_libnotify_cb (NotifyNotification *notification, gchar *action, gpointer data);
+#endif
#define GPK_CHECK_UPDATE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GPK_TYPE_CHECK_UPDATE, GpkCheckUpdatePrivate))
@@ -554,6 +559,7 @@ gpk_check_update_activate_update_cb (GtkStatusIcon *status_icon, GpkCheckUpdate
}
}
+#ifdef HAVE_LIBNOTIFY
/**
* gpk_check_update_libnotify_cb:
**/
@@ -614,6 +620,7 @@ gpk_check_update_libnotify_cb (NotifyNotification *notification, gchar *action,
}
return;
}
+#endif
/**
* gpk_check_update_critical_updates_warning:
diff --git a/src/gpk-common.h b/src/gpk-common.h
index 19cf7df..da363f1 100644
--- a/src/gpk-common.h
+++ b/src/gpk-common.h
@@ -93,6 +93,25 @@ G_BEGIN_DECLS
/* any status that is slower than this will not be shown in the UI */
#define GPK_UI_STATUS_SHOW_DELAY 250 /* ms */
+/* 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
+
void gpk_common_test (gpointer data);
void gtk_text_buffer_insert_markup (GtkTextBuffer *buffer,
GtkTextIter *iter,
diff --git a/src/gpk-dbus-service.c b/src/gpk-dbus-service.c
index e3953ed..129327f 100644
--- a/src/gpk-dbus-service.c
+++ b/src/gpk-dbus-service.c
@@ -25,12 +25,15 @@
#include <dbus/dbus-glib.h>
#include <gtk/gtk.h>
#include <locale.h>
+#ifdef HAVE_LIBNOTIFY
#include <libnotify/notify.h>
+#endif
#include <packagekit-glib2/packagekit.h>
#include "egg-debug.h"
#include "egg-dbus-monitor.h"
+#include "gpk-common.h"
#include "gpk-dbus.h"
#include "org.freedesktop.PackageKit.h"
diff --git a/src/gpk-dbus-task.c b/src/gpk-dbus-task.c
index 29ac679..2aed0d7 100644
--- a/src/gpk-dbus-task.c
+++ b/src/gpk-dbus-task.c
@@ -30,7 +30,9 @@
#include <fontconfig/fontconfig.h>
#include <gtk/gtk.h>
+#ifdef HAVE_LIBNOTIFY
#include <libnotify/notify.h>
+#endif
#include <packagekit-glib2/packagekit.h>
#include "egg-debug.h"
@@ -259,6 +261,7 @@ out:
return;
}
+#ifdef HAVE_LIBNOTIFY
/**
* gpk_dbus_task_libnotify_cb:
**/
@@ -281,6 +284,7 @@ gpk_dbus_task_libnotify_cb (NotifyNotification *notification, gchar *action, gpo
egg_warning ("unknown action id: %s", action);
}
}
+#endif
/**
* gpk_dbus_task_error_msg:
diff --git a/src/gpk-firmware.c b/src/gpk-firmware.c
index 073bf09..6f58a37 100644
--- a/src/gpk-firmware.c
+++ b/src/gpk-firmware.c
@@ -36,9 +36,11 @@
#include <glib/gi18n.h>
#include <gio/gio.h>
#include <gtk/gtk.h>
+#ifdef HAVE_LIBNOTIFY
#include <libnotify/notify.h>
+#endif
#include <packagekit-glib2/packagekit.h>
-#ifdef GPK_BUILD_GUDEV
+#ifdef HAVE_GUDEV
#include <gudev/gudev.h>
#endif
@@ -88,6 +90,7 @@ typedef struct {
G_DEFINE_TYPE (GpkFirmware, gpk_firmware, G_TYPE_OBJECT)
+#ifdef HAVE_LIBNOTIFY
static void gpk_firmware_install_file (GpkFirmware *firmware);
static void gpk_firmware_ignore_devices (GpkFirmware *firmware);
@@ -101,6 +104,7 @@ gpk_firmware_subsystem_can_replug (GpkFirmwareSubsystem subsystem)
return TRUE;
return FALSE;
}
+#endif
/**
* gpk_firmware_request_new:
@@ -109,7 +113,7 @@ static GpkFirmwareRequest *
gpk_firmware_request_new (const gchar *filename, const gchar *sysfs_path)
{
GpkFirmwareRequest *req;
-#ifdef GPK_BUILD_GUDEV
+#ifdef HAVE_GUDEV
GUdevDevice *device;
GUdevClient *client;
const gchar *subsystem;
@@ -122,7 +126,7 @@ gpk_firmware_request_new (const gchar *filename, const gchar *sysfs_path)
req->filename = g_strdup (filename);
req->sysfs_path = g_strdup (sysfs_path);
req->subsystem = GPK_FIRMWARE_SUBSYSTEM_UNKNOWN;
-#ifdef GPK_BUILD_GUDEV
+#ifdef HAVE_GUDEV
/* get all subsystems */
client = g_udev_client_new (NULL);
@@ -173,6 +177,7 @@ gpk_firmware_request_free (GpkFirmwareRequest *req)
}
+#ifdef HAVE_LIBNOTIFY
/**
* gpk_firmware_rebind:
**/
@@ -471,6 +476,7 @@ gpk_firmware_ignore_devices (GpkFirmware *firmware)
if (string != NULL)
g_string_free (string, TRUE);
}
+#endif
/**
* gpk_firmware_check_available:
diff --git a/src/gpk-hardware.c b/src/gpk-hardware.c
index b1fb451..2d29fce 100644
--- a/src/gpk-hardware.c
+++ b/src/gpk-hardware.c
@@ -34,7 +34,9 @@
#endif /* HAVE_UNISTD_H */
#include <glib/gi18n.h>
#include <gtk/gtk.h>
+#ifdef HAVE_LIBNOTIFY
#include <libnotify/notify.h>
+#endif
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
#include <dbus/dbus.h>
@@ -67,7 +69,7 @@ struct GpkHardwarePrivate
G_DEFINE_TYPE (GpkHardware, gpk_hardware, G_TYPE_OBJECT)
-
+#ifdef HAVE_LIBNOTIFY
/**
* gpk_hardware_install_packages_cb:
**/
@@ -118,6 +120,7 @@ gpk_hardware_libnotify_cb (NotifyNotification *notification, gchar *action, gpoi
egg_warning ("unknown action id: %s", action);
}
}
+#endif
/**
* gpk_hardware_what_provides_cb:
diff --git a/src/gpk-update-icon.c b/src/gpk-update-icon.c
index 0dce1f9..1efa287 100644
--- a/src/gpk-update-icon.c
+++ b/src/gpk-update-icon.c
@@ -30,7 +30,9 @@
#include <dbus/dbus-glib.h>
#include <gtk/gtk.h>
#include <locale.h>
+#ifdef HAVE_LIBNOTIFY
#include <libnotify/notify.h>
+#endif
#include <packagekit-glib2/packagekit.h>
#include "egg-debug.h"
diff --git a/src/gpk-watch.c b/src/gpk-watch.c
index ee4dffa..f046482 100644
--- a/src/gpk-watch.c
+++ b/src/gpk-watch.c
@@ -35,7 +35,9 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
+#ifdef HAVE_LIBNOTIFY
#include <libnotify/notify.h>
+#endif
#include <packagekit-glib2/packagekit.h>
#include "egg-debug.h"
@@ -378,6 +380,7 @@ out:
return TRUE;
}
+#ifdef HAVE_LIBNOTIFY
/**
* gpk_watch_libnotify_cb:
**/
@@ -398,6 +401,7 @@ gpk_watch_libnotify_cb (NotifyNotification *notification, gchar *action, gpointe
egg_warning ("unknown action id: %s", action);
}
}
+#endif
/**
* gpk_watch_about_dialog_url_cb:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]