[gnome-packagekit] Port to libnotify 0.7.0



commit 1efccf17638b2b7e658c54351a5e8492729bfad5
Author: William Jon McCann <jmccann redhat com>
Date:   Mon Oct 18 16:47:42 2010 +0100

    Port to libnotify 0.7.0
    
    Signed-off-by: Richard Hughes <richard hughsie com>

 configure.ac                     |    9 ++-------
 contrib/gnome-packagekit.spec.in |    2 +-
 src/gpk-check-update.c           |   29 +++++++++--------------------
 src/gpk-common.h                 |   19 -------------------
 src/gpk-dbus-service.c           |    2 --
 src/gpk-dbus-task.c              |   10 +++-------
 src/gpk-firmware.c               |   14 ++++----------
 src/gpk-hardware.c               |    6 +-----
 src/gpk-update-icon.c            |    2 --
 src/gpk-watch.c                  |   22 +++++++---------------
 10 files changed, 27 insertions(+), 88 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 954e03e..eb91b8d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -128,12 +128,8 @@ PKG_CHECK_MODULES(CONTROL_CENTER, [
 PANELS_DIR="${libdir}/control-center-1/panels"
 AC_SUBST(PANELS_DIR)
 
-dnl **** Check for NOTIFY ****
-PKG_CHECK_MODULES(NOTIFY, libnotify >= 0.5.0, has_libnotify=yes, has_libnotify=no)
-AM_CONDITIONAL(HAVE_NOTIFY, test x$libnotify = xyes)
-if test x$has_libnotify = xyes; then
-	AC_DEFINE(HAVE_NOTIFY,1,[Use session notifications])
-fi
+dnl **** Check for libnotify ****
+PKG_CHECK_MODULES(NOTIFY, libnotify >= 0.7.0)
 
 dnl ---------------------------------------------------------------------------
 dnl - GUdev integration (default enabled)
@@ -248,6 +244,5 @@ echo "
         compiler:                  ${CC}
         cflags:                    ${CFLAGS}
         cppflags:                  ${CPPFLAGS}
-        libnotify support:         ${has_libnotify}
 "
 
diff --git a/contrib/gnome-packagekit.spec.in b/contrib/gnome-packagekit.spec.in
index 42b0756..ae1c73b 100644
--- a/contrib/gnome-packagekit.spec.in
+++ b/contrib/gnome-packagekit.spec.in
@@ -32,7 +32,7 @@ BuildRequires: gtk2-devel >= 2.18.1
 BuildRequires: libwnck-devel
 BuildRequires: dbus-devel
 BuildRequires: dbus-glib-devel
-BuildRequires: libnotify-devel >= 0.5.0
+BuildRequires: libnotify-devel >= 0.7.0
 BuildRequires: gnome-panel-devel
 BuildRequires: scrollkeeper
 BuildRequires: gnome-doc-utils >= 0.3.2
diff --git a/src/gpk-check-update.c b/src/gpk-check-update.c
index 7c7237d..1322c04 100644
--- a/src/gpk-check-update.c
+++ b/src/gpk-check-update.c
@@ -35,9 +35,7 @@
 #include <glib/gi18n.h>
 
 #include <gtk/gtk.h>
-#ifdef HAVE_NOTIFY
 #include <libnotify/notify.h>
-#endif
 #include <packagekit-glib2/packagekit.h>
 #include <canberra-gtk.h>
 #include <gio/gio.h>
@@ -56,9 +54,7 @@
 
 static void     gpk_check_update_finalize	(GObject	     *object);
 
-#ifdef HAVE_NOTIFY
 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))
 
@@ -398,18 +394,14 @@ gpk_check_update_finished_notify (GpkCheckUpdate *cupdate, PkResults *results)
 	}
 
 	/* TRANSLATORS: title: system update completed all okay */
-	notification = notify_notification_new_with_status_icon (_("The system update has completed"),
-								 message_text->str, "help-browser",
-								 cupdate->priv->status_icon);
+	notification = notify_notification_new (_("The system update has completed"),
+						 message_text->str, NULL);
 	notify_notification_set_timeout (notification, 15000);
 	notify_notification_set_urgency (notification, NOTIFY_URGENCY_LOW);
 	if (restart == PK_RESTART_ENUM_SYSTEM) {
 		notify_notification_add_action (notification, "restart",
 						/* TRANSLATORS: restart computer as system packages need update */
 						_("Restart computer now"), gpk_check_update_libnotify_cb, cupdate, NULL);
-//		notify_notification_add_action (notification, "do-not-show-complete-restart",
-//						/* TRANSLATORS: don't show this option again (for restart) */
-//						_("Do not show this again"), gpk_check_update_libnotify_cb, cupdate, NULL);
 	} else {
 		notify_notification_add_action (notification, "do-not-show-complete",
 						/* TRANSLATORS: don't show this option again (when finished)  */
@@ -466,7 +458,7 @@ gpk_check_update_show_error (GpkCheckUpdate *cupdate, PkError *error_code)
 
 	/* do the bubble */
 	egg_debug ("title=%s, message=%s", title, message);
-	notification = notify_notification_new_with_status_icon (title, message, "help-browser", cupdate->priv->status_icon);
+	notification = notify_notification_new (title, message, NULL);
 	if (notification == NULL) {
 		egg_warning ("failed to get bubble");
 		goto out;
@@ -562,7 +554,6 @@ gpk_check_update_activate_update_cb (GtkStatusIcon *status_icon, GpkCheckUpdate
 	}
 }
 
-#ifdef HAVE_NOTIFY
 /**
  * gpk_check_update_libnotify_cb:
  **/
@@ -623,7 +614,6 @@ gpk_check_update_libnotify_cb (NotifyNotification *notification, gchar *action,
 	}
 	return;
 }
-#endif
 
 /**
  * gpk_check_update_critical_updates_warning:
@@ -671,7 +661,7 @@ gpk_check_update_critical_updates_warning (GpkCheckUpdate *cupdate, GPtrArray *a
 
 	/* do the bubble */
 	egg_debug ("title=%s, message=%s", title, message);
-	notification = notify_notification_new_with_status_icon (title, message, "help-browser", cupdate->priv->status_icon);
+	notification = notify_notification_new (title, message, NULL);
 	if (notification == NULL) {
 		egg_warning ("failed to get bubble");
 		return;
@@ -763,9 +753,8 @@ gpk_check_update_check_on_battery (GpkCheckUpdate *cupdate)
 	/* TRANSLATORS: policy says update, but we are on battery and so prompt */
 	message = _("Automatic updates are not being installed as the computer is running on battery power");
 	/* TRANSLATORS: informs user will not install by default */
-	notification = notify_notification_new_with_status_icon (_("Updates not installed"),
-								 message, "help-browser",
-								 cupdate->priv->status_icon);
+	notification = notify_notification_new (_("Updates not installed"),
+						message, NULL);
 	notify_notification_set_timeout (notification, 15000);
 	notify_notification_set_urgency (notification, NOTIFY_URGENCY_LOW);
 //	notify_notification_add_action (notification, "do-not-show-update-not-battery",
@@ -799,10 +788,10 @@ gpk_check_update_notify_doing_updates (GpkCheckUpdate *cupdate)
 		goto out;
 
 	/* TRANSLATORS: title: notification when we scheduled an automatic update */
-	notification = notify_notification_new_with_status_icon (_("Updates are being installed"),
+	notification = notify_notification_new (_("Updates are being installed"),
 						/* TRANSLATORS: tell the user why the hard disk is grinding... */
 						_("Updates are being automatically installed on your computer"),
-						"software-update-urgent", cupdate->priv->status_icon);
+						"software-update-urgent");
 	notify_notification_set_timeout (notification, 15000);
 	notify_notification_set_urgency (notification, NOTIFY_URGENCY_LOW);
 	/* TRANSLATORS: button: cancel the update system */
@@ -1293,7 +1282,7 @@ gpk_check_update_get_distro_upgrades_finished_cb (GObject *object, GAsyncResult
 
 	/* TRANSLATORS: a distro update is available, e.g. Fedora 8 to Fedora 9 */
 	title = _("Distribution upgrades available");
-	notification = notify_notification_new_with_status_icon (title, string->str, "help-browser", cupdate->priv->status_icon);
+	notification = notify_notification_new (title, string->str, NULL);
 	if (notification == NULL) {
 		egg_warning ("failed to make bubble");
 		goto out;
diff --git a/src/gpk-common.h b/src/gpk-common.h
index 174469c..723f936 100644
--- a/src/gpk-common.h
+++ b/src/gpk-common.h
@@ -92,25 +92,6 @@ 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_NOTIFY
-#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 f13a273..05f558d 100644
--- a/src/gpk-dbus-service.c
+++ b/src/gpk-dbus-service.c
@@ -25,9 +25,7 @@
 #include <dbus/dbus-glib.h>
 #include <gtk/gtk.h>
 #include <locale.h>
-#ifdef HAVE_NOTIFY
 #include <libnotify/notify.h>
-#endif
 #include <packagekit-glib2/packagekit.h>
 
 #include "egg-debug.h"
diff --git a/src/gpk-dbus-task.c b/src/gpk-dbus-task.c
index 70ff92c..d3142db 100644
--- a/src/gpk-dbus-task.c
+++ b/src/gpk-dbus-task.c
@@ -30,9 +30,7 @@
 
 #include <fontconfig/fontconfig.h>
 #include <gtk/gtk.h>
-#ifdef HAVE_NOTIFY
 #include <libnotify/notify.h>
-#endif
 #include <packagekit-glib2/packagekit.h>
 
 #include "egg-debug.h"
@@ -261,7 +259,6 @@ out:
 	return;
 }
 
-#ifdef HAVE_NOTIFY
 /**
  * gpk_dbus_task_libnotify_cb:
  **/
@@ -284,7 +281,6 @@ gpk_dbus_task_libnotify_cb (NotifyNotification *notification, gchar *action, gpo
 		egg_warning ("unknown action id: %s", action);
 	}
 }
-#endif
 
 /**
  * gpk_dbus_task_error_msg:
@@ -380,7 +376,7 @@ gpk_dbus_task_handle_error (GpkDbusTask *dtask, PkError *error_code)
 	dtask->priv->cached_error_code = g_object_ref (error_code);
 
 	/* do the bubble */
-	notification = notify_notification_new (title, message, "help-browser", NULL);
+	notification = notify_notification_new (title, message, NULL);
 	notify_notification_set_timeout (notification, 15000);
 	notify_notification_set_urgency (notification, NOTIFY_URGENCY_LOW);
 	notify_notification_add_action (notification, "show-error-details",
@@ -1135,8 +1131,8 @@ gpk_dbus_task_install_package_names_resolve_cb (PkTask *task, GAsyncResult *res,
 			/* TRANSLATORS: title: package is already installed */
 			gpk_modal_dialog_set_title (dtask->priv->dialog,
 						    ngettext ("The package is already installed",
-							      "The packages are already installed"),
-							      g_strv_length (dtask->priv->package_ids));
+							      "The packages are already installed",
+							      g_strv_length (dtask->priv->package_ids)));
 			/* TRANSLATORS: message: package is already installed */
 			gpk_modal_dialog_set_message (dtask->priv->dialog, _("Nothing to do."));
 			gpk_modal_dialog_present (dtask->priv->dialog);
diff --git a/src/gpk-firmware.c b/src/gpk-firmware.c
index d6ba537..a60e5f8 100644
--- a/src/gpk-firmware.c
+++ b/src/gpk-firmware.c
@@ -36,9 +36,7 @@
 #include <glib/gi18n.h>
 #include <gio/gio.h>
 #include <gtk/gtk.h>
-#ifdef HAVE_NOTIFY
 #include <libnotify/notify.h>
-#endif
 #include <packagekit-glib2/packagekit.h>
 #ifdef HAVE_GUDEV
 #include <gudev/gudev.h>
@@ -90,7 +88,6 @@ typedef struct {
 
 G_DEFINE_TYPE (GpkFirmware, gpk_firmware, G_TYPE_OBJECT)
 
-#ifdef HAVE_NOTIFY
 static void gpk_firmware_install_file (GpkFirmware *firmware);
 static void gpk_firmware_ignore_devices (GpkFirmware *firmware);
 
@@ -104,7 +101,6 @@ gpk_firmware_subsystem_can_replug (GpkFirmwareSubsystem subsystem)
 		return TRUE;
 	return FALSE;
 }
-#endif
 
 /**
  * gpk_firmware_request_new:
@@ -177,7 +173,6 @@ gpk_firmware_request_free (GpkFirmwareRequest *req)
 }
 
 
-#ifdef HAVE_NOTIFY
 /**
  * gpk_firmware_rebind:
  **/
@@ -272,7 +267,7 @@ gpk_firmware_require_restart (GpkFirmware *firmware)
 	message = _("You will need to restart this computer before the hardware will work correctly.");
 
 	/* TRANSLATORS: title of libnotify bubble */
-	notification = notify_notification_new (_("Additional software was installed"), message, "help-browser", NULL);
+	notification = notify_notification_new (_("Additional software was installed"), message, NULL);
 	notify_notification_set_timeout (notification, NOTIFY_EXPIRES_NEVER);
 	notify_notification_set_urgency (notification, NOTIFY_URGENCY_LOW);
 
@@ -307,7 +302,7 @@ gpk_firmware_require_replug (GpkFirmware *firmware)
 	message = _("You will need to remove and then reinsert the hardware before it will work correctly.");
 
 	/* TRANSLATORS: title of libnotify bubble */
-	notification = notify_notification_new (_("Additional software was installed"), message, "help-browser", NULL);
+	notification = notify_notification_new (_("Additional software was installed"), message, NULL);
 	notify_notification_set_timeout (notification, NOTIFY_EXPIRES_NEVER);
 	notify_notification_set_urgency (notification, NOTIFY_URGENCY_LOW);
 
@@ -334,7 +329,7 @@ gpk_firmware_require_nothing (GpkFirmware *firmware)
 	message = _("Your hardware has been set up and is now ready to use.");
 
 	/* TRANSLATORS: title of libnotify bubble */
-	notification = notify_notification_new (_("Additional software was installed"), message, "help-browser", NULL);
+	notification = notify_notification_new (_("Additional software was installed"), message, NULL);
 	notify_notification_set_timeout (notification, NOTIFY_EXPIRES_NEVER);
 	notify_notification_set_urgency (notification, NOTIFY_URGENCY_LOW);
 
@@ -476,7 +471,6 @@ gpk_firmware_ignore_devices (GpkFirmware *firmware)
 	if (string != NULL)
 		g_string_free (string, TRUE);
 }
-#endif
 
 /**
  * gpk_firmware_check_available:
@@ -617,7 +611,7 @@ gpk_firmware_timeout_cb (gpointer data)
 	}
 
 	/* TRANSLATORS: title of libnotify bubble */
-	notification = notify_notification_new (_("Additional firmware required"), string->str, "help-browser", NULL);
+	notification = notify_notification_new (_("Additional firmware required"), string->str, NULL);
 	notify_notification_set_timeout (notification, NOTIFY_EXPIRES_NEVER);
 	notify_notification_set_urgency (notification, NOTIFY_URGENCY_LOW);
 	notify_notification_add_action (notification, "install-firmware",
diff --git a/src/gpk-hardware.c b/src/gpk-hardware.c
index 6fe7932..d8d7996 100644
--- a/src/gpk-hardware.c
+++ b/src/gpk-hardware.c
@@ -34,9 +34,7 @@
 #endif /* HAVE_UNISTD_H */
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
-#ifdef HAVE_NOTIFY
 #include <libnotify/notify.h>
-#endif
 #include <dbus/dbus-glib.h>
 #include <dbus/dbus-glib-lowlevel.h>
 #include <dbus/dbus.h>
@@ -69,7 +67,6 @@ struct GpkHardwarePrivate
 
 G_DEFINE_TYPE (GpkHardware, gpk_hardware, G_TYPE_OBJECT)
 
-#ifdef HAVE_NOTIFY
 /**
  * gpk_hardware_install_packages_cb:
  **/
@@ -120,7 +117,6 @@ gpk_hardware_libnotify_cb (NotifyNotification *notification, gchar *action, gpoi
 		egg_warning ("unknown action id: %s", action);
 	}
 }
-#endif
 
 /**
  * gpk_hardware_what_provides_cb:
@@ -185,7 +181,7 @@ gpk_hardware_what_provides_cb (GObject *object, GAsyncResult *res, GpkHardware *
 	message = g_strdup_printf ("%s\n\t%s", _("Additional packages can be installed to support this hardware"), package);
 	/* TRANSLATORS: a new bit of hardware has been plugged in */
 	body = g_strdup_printf ("%s", _("New hardware attached"));
-	notification = notify_notification_new (body, message, "help-browser", NULL);
+	notification = notify_notification_new (body, message, NULL);
 	notify_notification_set_timeout (notification, NOTIFY_EXPIRES_NEVER);
 	notify_notification_set_urgency (notification, NOTIFY_URGENCY_LOW);
 	notify_notification_add_action (notification, GPK_HARDWARE_INSTALL_ACTION,
diff --git a/src/gpk-update-icon.c b/src/gpk-update-icon.c
index 603bd34..6e025ff 100644
--- a/src/gpk-update-icon.c
+++ b/src/gpk-update-icon.c
@@ -30,9 +30,7 @@
 #include <dbus/dbus-glib.h>
 #include <gtk/gtk.h>
 #include <locale.h>
-#ifdef HAVE_NOTIFY
 #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 d40fe62..977282b 100644
--- a/src/gpk-watch.c
+++ b/src/gpk-watch.c
@@ -35,9 +35,7 @@
 #include <glib/gi18n.h>
 
 #include <gtk/gtk.h>
-#ifdef HAVE_NOTIFY
 #include <libnotify/notify.h>
-#endif
 #include <packagekit-glib2/packagekit.h>
 
 #include "egg-debug.h"
@@ -92,7 +90,6 @@ gpk_watch_class_init (GpkWatchClass *klass)
 	g_type_class_add_private (klass, sizeof (GpkWatchPrivate));
 }
 
-#ifdef HAVE_NOTIFY
 /**
  * gpk_watch_libnotify_cb:
  **/
@@ -130,7 +127,6 @@ gpk_watch_libnotify_cb (NotifyNotification *notification, gchar *action, gpointe
 		egg_warning ("unknown action id: %s", action);
 	}
 }
-#endif
 
 /**
  * gpk_watch_lookup_progress_from_transaction_id:
@@ -535,10 +531,9 @@ gpk_watch_process_messages_cb (PkMessage *item, GpkWatch *watch)
 	}
 
 	/* do the bubble */
-	notification = notify_notification_new_with_status_icon (gpk_message_enum_to_localised_text (type),
-								 details,
-								 "emblem-important",
-								 watch->priv->status_icon);
+	notification = notify_notification_new (gpk_message_enum_to_localised_text (type),
+						details,
+						"emblem-important");
 	notify_notification_set_timeout (notification, NOTIFY_EXPIRES_NEVER);
 	notify_notification_set_urgency (notification, NOTIFY_URGENCY_LOW);
 	ret = notify_notification_show (notification, &error);
@@ -598,8 +593,7 @@ gpk_watch_process_error_code (GpkWatch *watch, PkError *error_code)
 	title_prefix = g_strdup_printf ("%s: %s", _("Package Manager"), title);
 
 	/* do the bubble */
-	notification = notify_notification_new_with_status_icon (title_prefix, message, "help-browser",
-								 watch->priv->status_icon);
+	notification = notify_notification_new (title_prefix, message, NULL);
 	notify_notification_set_timeout (notification, 15000);
 	notify_notification_set_urgency (notification, NOTIFY_URGENCY_LOW);
 	notify_notification_add_action (notification, "show-error-details",
@@ -688,8 +682,7 @@ gpk_watch_process_require_restart_cb (PkRequireRestart *item, GpkWatch *watch)
 	}
 
 	/* do the bubble */
-	notification = notify_notification_new_with_status_icon (title, message,
-								 icon, watch->priv->status_icon);
+	notification = notify_notification_new (title, message, icon);
 	notify_notification_set_timeout (notification, 15000);
 	notify_notification_set_urgency (notification, NOTIFY_URGENCY_LOW);
 	if (restart == PK_RESTART_ENUM_APPLICATION ||
@@ -821,9 +814,8 @@ gpk_watch_adopt_cb (PkClient *client, GAsyncResult *res, GpkWatch *watch)
 		goto out;
 
 	/* TRANSLATORS: title: an action has finished, and we are showing the libnotify bubble */
-	notification = notify_notification_new_with_status_icon (_("Task completed"),
-								 message, "help-browser",
-								 watch->priv->status_icon);
+	notification = notify_notification_new (_("Task completed"),
+						message, NULL);
 	notify_notification_set_timeout (notification, 5000);
 	notify_notification_set_urgency (notification, NOTIFY_URGENCY_LOW);
 	notify_notification_add_action (notification, "do-not-show-notify-complete",



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