gnome-packagekit r208 - in trunk: po src



Author: rhughes
Date: Sun May 25 16:36:39 2008
New Revision: 208
URL: http://svn.gnome.org/viewvc/gnome-packagekit?rev=208&view=rev

Log:
from git

Modified:
   trunk/po/POTFILES.in
   trunk/src/Makefile.am
   trunk/src/gpk-client.c
   trunk/src/gpk-firmware.c
   trunk/src/gpk-notify.c
   trunk/src/gpk-notify.h
   trunk/src/gpk-smart-icon.c
   trunk/src/gpk-smart-icon.h
   trunk/src/gpk-update-icon.c
   trunk/src/gpk-update-viewer.c
   trunk/src/gpk-watch.c

Modified: trunk/po/POTFILES.in
==============================================================================
--- trunk/po/POTFILES.in	(original)
+++ trunk/po/POTFILES.in	Sun May 25 16:36:39 2008
@@ -32,6 +32,7 @@
 src/gpk-install-provide-file.c
 src/gpk-install-mime-type.c
 src/gpk-log.c
+src/gpk-check-update.c
 src/gpk-notify.c
 src/gpk-prefs.c
 src/gpk-repo.c

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Sun May 25 16:36:39 2008
@@ -73,6 +73,8 @@
 	gpk-client-chooser.h				\
 	gpk-smart-icon.c				\
 	gpk-smart-icon.h				\
+	gpk-notify.c					\
+	gpk-notify.h					\
 	gpk-gnome.c					\
 	gpk-gnome.h					\
 	gpk-common.c					\
@@ -131,8 +133,8 @@
 
 gpk_update_icon_SOURCES =				\
 	gpk-update-icon.c				\
-	gpk-notify.c					\
-	gpk-notify.h					\
+	gpk-check-update.c				\
+	gpk-check-update.h				\
 	gpk-auto-refresh.c				\
 	gpk-auto-refresh.h				\
 	gpk-watch.c					\

Modified: trunk/src/gpk-client.c
==============================================================================
--- trunk/src/gpk-client.c	(original)
+++ trunk/src/gpk-client.c	Sun May 25 16:36:39 2008
@@ -52,7 +52,7 @@
 #include <gpk-common.h>
 #include <gpk-gnome.h>
 #include <gpk-error.h>
-#include "gpk-smart-icon.h"
+#include "gpk-notify.h"
 #include "gpk-consolekit.h"
 #include "gpk-animated-icon.h"
 
@@ -73,7 +73,7 @@
 	PkClient		*client_action;
 	PkClient		*client_resolve;
 	PkClient		*client_secondary;
-	GpkSmartIcon		*sicon;
+	GpkNotify		*notify;
 	GladeXML		*glade_xml;
 	GConfClient		*gconf_client;
 	guint			 pulse_timer_id;
@@ -320,19 +320,19 @@
 	}
 
 	/* this will not show if specified in gconf */
-	gpk_smart_icon_notify_new (gclient->priv->sicon,
-				  _("The system update has completed"), message_text->str,
-				  "software-update-available",
-				  GPK_NOTIFY_URGENCY_LOW, GPK_NOTIFY_TIMEOUT_LONG);
+	gpk_notify_create (gclient->priv->notify,
+			   _("The system update has completed"), message_text->str,
+			   "software-update-available",
+			   GPK_NOTIFY_URGENCY_LOW, GPK_NOTIFY_TIMEOUT_LONG);
 	if (restart == PK_RESTART_ENUM_SYSTEM) {
-		gpk_smart_icon_notify_button (gclient->priv->sicon, GPK_NOTIFY_BUTTON_RESTART_COMPUTER, NULL);
-		gpk_smart_icon_notify_button (gclient->priv->sicon, GPK_NOTIFY_BUTTON_DO_NOT_SHOW_AGAIN,
+		gpk_notify_button (gclient->priv->notify, GPK_NOTIFY_BUTTON_RESTART_COMPUTER, NULL);
+		gpk_notify_button (gclient->priv->notify, GPK_NOTIFY_BUTTON_DO_NOT_SHOW_AGAIN,
 					      GPK_CONF_NOTIFY_UPDATE_COMPLETE_RESTART);
 	} else {
-		gpk_smart_icon_notify_button (gclient->priv->sicon, GPK_NOTIFY_BUTTON_DO_NOT_SHOW_AGAIN,
+		gpk_notify_button (gclient->priv->notify, GPK_NOTIFY_BUTTON_DO_NOT_SHOW_AGAIN,
 					      GPK_CONF_NOTIFY_UPDATE_COMPLETE);
 	}
-	gpk_smart_icon_notify_show (gclient->priv->sicon);
+	gpk_notify_show (gclient->priv->notify);
 	g_string_free (message_text, TRUE);
 }
 
@@ -465,6 +465,9 @@
 static void
 gpk_client_error_code_cb (PkClient *client, PkErrorCodeEnum code, const gchar *details, GpkClient *gclient)
 {
+	const gchar *title;
+	const gchar *message;
+
 	g_return_if_fail (GPK_IS_CLIENT (gclient));
 
 	/* have we handled? */
@@ -493,8 +496,21 @@
 	}
 
 	pk_debug ("code was %s", pk_error_enum_to_text (code));
-	gpk_error_dialog (gpk_error_enum_to_localised_text (code),
-			  gpk_error_enum_to_localised_message (code), details);
+
+	/* use a modal dialog if showing progress, else use libnotify */
+	title = gpk_error_enum_to_localised_text (code);
+	message = gpk_error_enum_to_localised_message (code);
+	if (gclient->priv->show_progress) {
+		gpk_error_dialog (title, message, details);
+	} else {
+		/* this will not show if specified in gconf */
+		gpk_notify_create (gclient->priv->notify, title, message, "help-browser",
+				   GPK_NOTIFY_URGENCY_LOW, GPK_NOTIFY_TIMEOUT_LONG);
+		gpk_notify_button (gclient->priv->notify,
+					      GPK_NOTIFY_BUTTON_DO_NOT_SHOW_AGAIN, GPK_CONF_NOTIFY_ERROR);
+		gpk_notify_show (gclient->priv->notify);
+	}
+
 }
 
 /**
@@ -1190,15 +1206,15 @@
 	/* if we are not showing UI, then notify the user what we are doing (just on the active terminal) */
 	if (!gclient->priv->show_progress) {
 		/* this will not show if specified in gconf */
-		gpk_smart_icon_notify_new (gclient->priv->sicon,
-					  _("Updates are being installed"),
-					  _("Updates are being automatically installed on your computer"),
-					  "software-update-urgent",
-					  GPK_NOTIFY_URGENCY_LOW, GPK_NOTIFY_TIMEOUT_LONG);
-		gpk_smart_icon_notify_button (gclient->priv->sicon, GPK_NOTIFY_BUTTON_CANCEL_UPDATE, NULL);
-		gpk_smart_icon_notify_button (gclient->priv->sicon, GPK_NOTIFY_BUTTON_DO_NOT_SHOW_AGAIN,
+		gpk_notify_create (gclient->priv->notify,
+				   _("Updates are being installed"),
+				   _("Updates are being automatically installed on your computer"),
+				   "software-update-urgent",
+				   GPK_NOTIFY_URGENCY_LOW, GPK_NOTIFY_TIMEOUT_LONG);
+		gpk_notify_button (gclient->priv->notify, GPK_NOTIFY_BUTTON_CANCEL_UPDATE, NULL);
+		gpk_notify_button (gclient->priv->notify, GPK_NOTIFY_BUTTON_DO_NOT_SHOW_AGAIN,
 					      GPK_CONF_NOTIFY_UPDATE_STARTED);
-		gpk_smart_icon_notify_show (gclient->priv->sicon);
+		gpk_notify_show (gclient->priv->notify);
 	}
 
 	/* wait for completion */
@@ -1498,11 +1514,11 @@
 }
 
 /**
- * gpk_client_smart_icon_notify_button:
+ * gpk_client_notify_button_cb:
  **/
 static void
-gpk_client_smart_icon_notify_button (GpkSmartIcon *sicon, GpkNotifyButton button,
-				     const gchar *data, GpkClient *gclient)
+gpk_client_notify_button_cb (GpkNotify *notify, GpkNotifyButton button,
+			     const gchar *data, GpkClient *gclient)
 {
 	gboolean ret;
 
@@ -1725,9 +1741,9 @@
 	g_signal_connect (gclient->priv->client_action, "eula-required",
 			  G_CALLBACK (gpk_client_eula_required_cb), gclient);
 
-	gclient->priv->sicon = gpk_smart_icon_new ();
-	g_signal_connect (gclient->priv->sicon, "notification-button",
-			  G_CALLBACK (gpk_client_smart_icon_notify_button), gclient);
+	gclient->priv->notify = gpk_notify_new ();
+	g_signal_connect (gclient->priv->notify, "notification-button",
+			  G_CALLBACK (gpk_client_notify_button_cb), gclient);
 
 	gclient->priv->client_resolve = pk_client_new ();
 	g_signal_connect (gclient->priv->client_resolve, "status-changed",
@@ -1796,7 +1812,7 @@
 	g_object_unref (gclient->priv->client_secondary);
 	g_object_unref (gclient->priv->control);
 	g_object_unref (gclient->priv->gconf_client);
-	g_object_unref (gclient->priv->sicon);
+	g_object_unref (gclient->priv->notify);
 
 	G_OBJECT_CLASS (gpk_client_parent_class)->finalize (object);
 }

Modified: trunk/src/gpk-firmware.c
==============================================================================
--- trunk/src/gpk-firmware.c	(original)
+++ trunk/src/gpk-firmware.c	Sun May 25 16:36:39 2008
@@ -44,8 +44,8 @@
 #include <gpk-client.h>
 #include <gpk-common.h>
 
+#include "gpk-notify.h"
 #include "gpk-firmware.h"
-#include "gpk-smart-icon.h"
 
 static void     gpk_firmware_class_init	(GpkFirmwareClass *klass);
 static void     gpk_firmware_init	(GpkFirmware      *firmware);
@@ -53,11 +53,11 @@
 
 #define GPK_FIRMWARE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GPK_TYPE_FIRMWARE, GpkFirmwarePrivate))
 #define GPK_FIRMWARE_STATE_FILE		"/var/run/PackageKit/udev-firmware"
-#define GPK_FIRMWARE_LOGIN_DELAY	1 /* seconds */
+#define GPK_FIRMWARE_LOGIN_DELAY	20 /* seconds */
 
 struct GpkFirmwarePrivate
 {
-	GpkSmartIcon		*sicon;
+	GpkNotify		*notify;
 	gchar			**files;
 };
 
@@ -70,11 +70,11 @@
 	GpkFirmware *firmware = (GpkFirmware *) data;
 
 	message = _("Additional firmware is required to make hardware in this computer function correctly.");
-	gpk_smart_icon_notify_new (firmware->priv->sicon, _("Additional firmware required"), message,
-				   "help-browser", GPK_NOTIFY_URGENCY_LOW, GPK_NOTIFY_TIMEOUT_NEVER);
-	gpk_smart_icon_notify_button (firmware->priv->sicon, GPK_NOTIFY_BUTTON_INSTALL_FIRMWARE, NULL);
-	gpk_smart_icon_notify_button (firmware->priv->sicon, GPK_NOTIFY_BUTTON_DO_NOT_SHOW_AGAIN, GPK_CONF_PROMPT_FIRMWARE);
-	gpk_smart_icon_notify_show (firmware->priv->sicon);
+	gpk_notify_create (firmware->priv->notify, _("Additional firmware required"), message,
+			   "help-browser", GPK_NOTIFY_URGENCY_LOW, GPK_NOTIFY_TIMEOUT_NEVER);
+	gpk_notify_button (firmware->priv->notify, GPK_NOTIFY_BUTTON_INSTALL_FIRMWARE, NULL);
+	gpk_notify_button (firmware->priv->notify, GPK_NOTIFY_BUTTON_DO_NOT_SHOW_AGAIN, GPK_CONF_PROMPT_FIRMWARE);
+	gpk_notify_show (firmware->priv->notify);
 
 	return FALSE;
 }
@@ -95,11 +95,11 @@
 }
 
 /**
- * gpk_firmware_smart_icon_notify_button:
+ * gpk_firmware_notify_button_cb:
  **/
 static void
-gpk_firmware_smart_icon_notify_button (GpkSmartIcon *sicon, GpkNotifyButton button,
-				       const gchar *data, GpkFirmware *firmware)
+gpk_firmware_notify_button_cb (GpkNotify *notify, GpkNotifyButton button,
+			       const gchar *data, GpkFirmware *firmware)
 {
 	pk_debug ("got: %i with data %s", button, data);
 	/* find the localised text */
@@ -133,9 +133,10 @@
 
 	firmware->priv = GPK_FIRMWARE_GET_PRIVATE (firmware);
 	firmware->priv->files = NULL;
-	firmware->priv->sicon = gpk_smart_icon_new ();
-	g_signal_connect (firmware->priv->sicon, "notification-button",
-			  G_CALLBACK (gpk_firmware_smart_icon_notify_button), firmware);
+
+	firmware->priv->notify = gpk_notify_new ();
+	g_signal_connect (firmware->priv->notify, "notification-button",
+			  G_CALLBACK (gpk_firmware_notify_button_cb), firmware);
 
 	/* file exists? */
 	ret = g_file_test (GPK_FIRMWARE_STATE_FILE, G_FILE_TEST_EXISTS);
@@ -180,7 +181,7 @@
 
 	g_return_if_fail (firmware->priv != NULL);
 	g_strfreev (firmware->priv->files);
-	g_object_unref (firmware->priv->sicon);
+	g_object_unref (firmware->priv->notify);
 
 	G_OBJECT_CLASS (gpk_firmware_parent_class)->finalize (object);
 }

Modified: trunk/src/gpk-notify.c
==============================================================================
--- trunk/src/gpk-notify.c	(original)
+++ trunk/src/gpk-notify.c	Sun May 25 16:36:39 2008
@@ -35,46 +35,51 @@
 #include <glib/gi18n.h>
 
 #include <gtk/gtk.h>
+#include <gtk/gtkstatusicon.h>
+#include <libnotify/notify.h>
 #include <gconf/gconf-client.h>
 
 #include <pk-debug.h>
-#include <pk-client.h>
-#include <pk-control.h>
-#include <pk-common.h>
-#include <pk-task-list.h>
-#include <pk-connection.h>
-#include <pk-package-id.h>
-#include <pk-package-ids.h>
-#include <pk-package-list.h>
-
-#include <gpk-common.h>
-#include <gpk-gnome.h>
-
-#include "gpk-smart-icon.h"
-#include "gpk-auto-refresh.h"
-#include "gpk-client.h"
+#include <pk-enum.h>
+#include "gpk-marshal.h"
+#include "gpk-common.h"
 #include "gpk-notify.h"
+#include "gpk-smart-icon.h"
 
 static void     gpk_notify_class_init	(GpkNotifyClass *klass);
 static void     gpk_notify_init		(GpkNotify      *notify);
-static void     gpk_notify_finalize	(GObject       *object);
+static void     gpk_notify_finalize	(GObject        *object);
 
 #define GPK_NOTIFY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GPK_TYPE_NOTIFY, GpkNotifyPrivate))
+#define GPK_NOTIFY_PERSIST_TIMEOUT	100
 
 struct GpkNotifyPrivate
 {
-	GpkSmartIcon		*sicon;
-	PkConnection		*pconnection;
-	PkTaskList		*tlist;
-	PkControl		*control;
-	GpkAutoRefresh		*arefresh;
-	GpkClient		*gclient;
+	NotifyNotification	*notification;
 	GConfClient		*gconf_client;
-	gboolean		 cache_okay;
-	gboolean		 cache_update_in_progress;
+	gchar			*notify_data;
+	gboolean		 has_gconf_check;
 };
 
-G_DEFINE_TYPE (GpkNotify, gpk_notify, G_TYPE_OBJECT)
+enum {
+	NOTIFICATION_BUTTON,
+	LAST_SIGNAL
+};
+
+G_DEFINE_TYPE (GpkNotify, gpk_notify, GTK_TYPE_STATUS_ICON)
+
+static guint signals [LAST_SIGNAL] = { 0 };
+
+static PkEnumMatch enum_button_ids[] = {
+	{GPK_NOTIFY_BUTTON_UNKNOWN,		"unknown"},	/* fall though value */
+	{GPK_NOTIFY_BUTTON_DO_NOT_SHOW_AGAIN,	"do-not-show-again"},
+	{GPK_NOTIFY_BUTTON_DO_NOT_WARN_AGAIN,	"do-not-warn-again"},
+	{GPK_NOTIFY_BUTTON_CANCEL_UPDATE,	"cancel-update"},
+	{GPK_NOTIFY_BUTTON_UPDATE_COMPUTER,	"update-computer"},
+	{GPK_NOTIFY_BUTTON_RESTART_COMPUTER,	"restart-computer"},
+	{GPK_NOTIFY_BUTTON_INSTALL_FIRMWARE,	"install-firmware"},
+	{0, NULL}
+};
 
 /**
  * gpk_notify_class_init:
@@ -84,873 +89,173 @@
 gpk_notify_class_init (GpkNotifyClass *klass)
 {
 	GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
 	object_class->finalize = gpk_notify_finalize;
-
 	g_type_class_add_private (klass, sizeof (GpkNotifyPrivate));
+	signals [NOTIFICATION_BUTTON] =
+		g_signal_new ("notification-button",
+			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+			      0, NULL, NULL, gpk_marshal_VOID__UINT_STRING,
+			      G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_STRING);
 }
 
 /**
- * gpk_notify_show_help_cb:
- **/
-static void
-gpk_notify_show_help_cb (GtkMenuItem *item, GpkNotify *notify)
-{
-	g_return_if_fail (GPK_IS_NOTIFY (notify));
-	gpk_gnome_help ("update-icon");
-}
-
-/**
- * gpk_notify_show_preferences_cb:
- **/
-static void
-gpk_notify_show_preferences_cb (GtkMenuItem *item, GpkNotify *notify)
-{
-	const gchar *command = "gpk-prefs";
-	if (g_spawn_command_line_async (command, NULL) == FALSE) {
-		pk_warning ("Couldn't execute command: %s", command);
-	}
-}
-
-/**
- * gpk_notify_about_dialog_url_cb:
- **/
-static void 
-gpk_notify_about_dialog_url_cb (GtkAboutDialog *about, const char *address, gpointer data)
-{
-	GError *error = NULL;
-	gboolean ret;
-	char *cmdline;
-	GdkScreen *gscreen;
-	GtkWidget *error_dialog;
-	gchar *url;
-	gchar *protocol = (gchar*) data;
-
-	if (protocol != NULL)
-		url = g_strconcat (protocol, address, NULL);
-	else
-		url = g_strdup (address);
-
-	gscreen = gtk_window_get_screen (GTK_WINDOW (about));
-
-	cmdline = g_strconcat ("xdg-open ", url, NULL);
-	ret = gdk_spawn_command_line_on_screen (gscreen, cmdline, &error);
-	g_free (cmdline);
-
-	if (ret)
-		goto out;
-
-	g_error_free (error);
-	error = NULL;
-
-	cmdline = g_strconcat ("gnome-open ", url, NULL);
-	ret = gdk_spawn_command_line_on_screen (gscreen, cmdline, &error);
-	g_free (cmdline);
-
-	if (ret == FALSE) {
-		error_dialog = gtk_message_dialog_new (GTK_WINDOW (about),
-						       GTK_DIALOG_MODAL,
-						       GTK_MESSAGE_INFO,
-						       GTK_BUTTONS_OK,
-						       _("Failed to show url"));
-		gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (error_dialog),
-							  "%s", error->message);
-		gtk_dialog_run (GTK_DIALOG (error_dialog));
-		gtk_widget_destroy (error_dialog);
-		g_error_free (error);
-	}
-
-out:
-	g_free (url);
-}
-
-/**
- * gpk_notify_show_about_cb:
+ * gpk_notify_create:
  **/
-static void
-gpk_notify_show_about_cb (GtkMenuItem *item, gpointer data)
+gboolean
+gpk_notify_create (GpkNotify *notify, const gchar *title, const gchar *message,
+		   const gchar *icon, GpkNotifyUrgency urgency, GpkNotifyTimeout timeout)
 {
-	static gboolean been_here = FALSE;
-	const char *authors[] = {
-		"Richard Hughes <richard hughsie com>",
-		NULL};
-	const char *documenters[] = {
-		"Richard Hughes <richard hughsie com>",
-		NULL};
-	const char *license[] = {
-		N_("Licensed under the GNU General Public License Version 2"),
-		N_("PackageKit is free software; you can redistribute it and/or\n"
-		   "modify it under the terms of the GNU General Public License\n"
-		   "as published by the Free Software Foundation; either version 2\n"
-		   "of the License, or (at your option) any later version."),
-		N_("PackageKit is distributed in the hope that it will be useful,\n"
-		   "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
-		   "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"
-		   "GNU General Public License for more details."),
-		N_("You should have received a copy of the GNU General Public License\n"
-		   "along with this program; if not, write to the Free Software\n"
-		   "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\n"
-		   "02110-1301, USA.")
-	};
-  	const char  *translators = _("translator-credits");
-	char	    *license_trans;
-
-	/* Translators comment: put your own name here to appear in the about dialog. */
-  	if (!strcmp (translators, "translator-credits")) {
-		translators = NULL;
-	}
-
-	license_trans = g_strconcat (_(license[0]), "\n\n", _(license[1]), "\n\n",
-				     _(license[2]), "\n\n", _(license[3]), "\n",  NULL);
-
-	/* FIXME: unnecessary with libgnomeui >= 2.16.0 */
-	if (!been_here) {
-		been_here = TRUE;
-		gtk_about_dialog_set_url_hook (gpk_notify_about_dialog_url_cb, NULL, NULL);
-		gtk_about_dialog_set_email_hook (gpk_notify_about_dialog_url_cb, "mailto:";, NULL);
-	}
+	guint timeout_val = 0;
 
-	gtk_window_set_default_icon_name ("system-software-installer");
-	gtk_show_about_dialog (NULL,
-			       "version", VERSION,
-			       "copyright", "Copyright \xc2\xa9 2007 Richard Hughes",
-			       "license", license_trans,
-			       "website-label", _("PackageKit Website"),
-			       "website", "www.packagekit.org",
-			       "comments", "PackageKit",
-			       "authors", authors,
-			       "documenters", documenters,
-			       "translator-credits", translators,
-			       "logo-icon-name", "system-software-installer",
-			       NULL);
-	g_free (license_trans);
-}
-
-/**
- * gpk_notify_popup_menu_cb:
- *
- * Display the popup menu.
- **/
-static void
-gpk_notify_popup_menu_cb (GtkStatusIcon *status_icon, guint button, guint32 timestamp, GpkNotify *icon)
-{
-	GtkMenu *menu = (GtkMenu*) gtk_menu_new ();
-	GtkWidget *item;
-	GtkWidget *image;
-
-	pk_debug ("icon right clicked");
-
-	/* Preferences */
-	item = gtk_image_menu_item_new_with_mnemonic (_("_Preferences"));
-	image = gtk_image_new_from_icon_name (GTK_STOCK_PREFERENCES, GTK_ICON_SIZE_MENU);
-	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
-	g_signal_connect (G_OBJECT (item), "activate",
-			  G_CALLBACK (gpk_notify_show_preferences_cb), icon);
-	gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-
-	/* Separator for HIG? */
-	item = gtk_separator_menu_item_new ();
-	gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-
-	/* No help yet */
-	item = gtk_image_menu_item_new_with_mnemonic (_("_Help"));
-	image = gtk_image_new_from_icon_name (GTK_STOCK_HELP, GTK_ICON_SIZE_MENU);
-	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
-	g_signal_connect (G_OBJECT (item), "activate",
-			  G_CALLBACK (gpk_notify_show_help_cb), icon);
-	gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-
-	/* About */
-	item = gtk_image_menu_item_new_with_mnemonic (_("_About"));
-	image = gtk_image_new_from_icon_name (GTK_STOCK_ABOUT, GTK_ICON_SIZE_MENU);
-	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
-	g_signal_connect (G_OBJECT (item), "activate",
-			  G_CALLBACK (gpk_notify_show_about_cb), icon);
-	gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-
-	/* show the menu */
-	gtk_widget_show_all (GTK_WIDGET (menu));
-	gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
-			gtk_status_icon_position_menu, status_icon,
-			button, timestamp);
-	if (button == 0) {
-		gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
-	}
-}
+	g_return_val_if_fail (GPK_IS_NOTIFY (notify), FALSE);
 
-static gboolean gpk_notify_check_for_updates_cb (GpkNotify *notify);
-static void gpk_notify_refresh_cache_finished_cb (PkClient *client, PkExitEnum exit_code, guint runtime, GpkNotify *notify);
-static gboolean gpk_notify_query_updates (GpkNotify *notify);
+	pk_debug ("Doing notification: %s, %s, %s", title, message, icon);
 
-/**
- * gpk_notify_update_system:
- **/
-static gboolean
-gpk_notify_update_system (GpkNotify *notify)
-{
-	gboolean ret;
-	ret = gpk_client_update_system (notify->priv->gclient, NULL);
+	/* no gconf to check */
+	notify->priv->has_gconf_check = FALSE;
 
-	/* we failed, show the icon */
-	if (!ret) {
-		gpk_smart_icon_set_icon_name (notify->priv->sicon, NULL);
-		/* we failed, so re-get the update list */
-		gpk_notify_query_updates (notify);
+	/* default values */
+	if (timeout == GPK_NOTIFY_TIMEOUT_SHORT) {
+		timeout_val = 5000;
+	} else if (timeout == GPK_NOTIFY_TIMEOUT_LONG) {
+		timeout_val = 15000;
 	}
-	return ret;
-}
 
-/**
- * gpk_notify_menuitem_update_system_cb:
- **/
-static void
-gpk_notify_menuitem_update_system_cb (GtkMenuItem *item, gpointer data)
-{
-	GpkNotify *notify = GPK_NOTIFY (data);
-	g_return_if_fail (GPK_IS_NOTIFY (notify));
-	gpk_client_show_finished (notify->priv->gclient, TRUE);
-	gpk_client_show_progress (notify->priv->gclient, TRUE);
-	gpk_notify_update_system (notify);
-}
-
-/**
- * gpk_notify_menuitem_show_updates_cb:
- **/
-static void
-gpk_notify_menuitem_show_updates_cb (GtkMenuItem *item, gpointer data)
-{
-	const gchar *command = "gpk-update-viewer";
-	if (g_spawn_command_line_async (command, NULL) == FALSE) {
-		pk_warning ("Couldn't execute command: %s", command);
+	/* TODO: use the single icon */
+	if (FALSE && gtk_status_icon_get_visible (GTK_STATUS_ICON (NULL))) {
+		notify->priv->notification = notify_notification_new_with_status_icon (title, message, icon, GTK_STATUS_ICON (NULL));
+	} else {
+		notify->priv->notification = notify_notification_new (title, message, icon, NULL);
 	}
+	notify_notification_set_timeout (notify->priv->notification, timeout_val);
+	notify_notification_set_urgency (notify->priv->notification, (NotifyUrgency) urgency);
+	return TRUE;
 }
 
 /**
- * gpk_notify_activate_update_cb:
- * @button: Which buttons are pressed
- *
- * Callback when the icon is clicked
- **/
-static void
-gpk_notify_activate_update_cb (GtkStatusIcon *status_icon,
-			      GpkNotify      *icon)
-{
-	GtkMenu *menu = (GtkMenu*) gtk_menu_new ();
-	GtkWidget *item;
-	GtkWidget *image;
-
-	pk_debug ("icon left clicked");
-
-	/* show updates */
-	item = gtk_image_menu_item_new_with_mnemonic (_("_Show Updates"));
-	image = gtk_image_new_from_icon_name ("system-software-update", GTK_ICON_SIZE_MENU);
-	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
-	g_signal_connect (G_OBJECT (item), "activate",
-			  G_CALLBACK (gpk_notify_menuitem_show_updates_cb), icon);
-	gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-
-	/* update system */
-	item = gtk_image_menu_item_new_with_mnemonic (_("_Update System Now"));
-	image = gtk_image_new_from_icon_name ("software-update-available", GTK_ICON_SIZE_MENU);
-	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
-	g_signal_connect (G_OBJECT (item), "activate",
-			  G_CALLBACK (gpk_notify_menuitem_update_system_cb), icon);
-	gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-
-	/* show the menu */
-	gtk_widget_show_all (GTK_WIDGET (menu));
-	gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
-			gtk_status_icon_position_menu, status_icon,
-			1, gtk_get_current_event_time());
-}
-
-/**
- * pk_connection_changed_cb:
- **/
-static void
-pk_connection_changed_cb (PkConnection *pconnection, gboolean connected, GpkNotify *notify)
-{
-	g_return_if_fail (GPK_IS_NOTIFY (notify));
-	pk_debug ("connected=%i", connected);
-}
-
-/**
- * gpk_notify_critical_updates_warning:
+ * gpk_notify_libnotify_cb:
  **/
 static void
-gpk_notify_critical_updates_warning (GpkNotify *notify, const gchar *details, guint number)
+gpk_notify_libnotify_cb (NotifyNotification *notification, gchar *action, GpkNotify *notify)
 {
-	const gchar *title;
-	gchar *message;
-	GString *string;
+	GpkNotifyButton button;
 
 	g_return_if_fail (GPK_IS_NOTIFY (notify));
 
-	/* format title */
-	title = ngettext ("Security update available", "Security updates available", number);
+	/* get the value */
+	button = pk_enum_find_value (enum_button_ids, action);
 
-	/* format message text */
-	string = g_string_new ("");
-	g_string_append (string, ngettext ("The following important update is available for your computer:",
-					   "The following important updates are available for your computer:", number));
-	g_string_append (string, "\n\n");
-	g_string_append (string, details);
-	message = g_string_free (string, FALSE);
-
-	/* this will not show if specified in gconf */
-	gpk_smart_icon_notify_new (notify->priv->sicon, title, message, "software-update-urgent",
-				   GPK_NOTIFY_URGENCY_CRITICAL, GPK_NOTIFY_TIMEOUT_NEVER);
-	gpk_smart_icon_notify_button (notify->priv->sicon, GPK_NOTIFY_BUTTON_UPDATE_COMPUTER, NULL);
-	gpk_smart_icon_notify_button (notify->priv->sicon, GPK_NOTIFY_BUTTON_DO_NOT_WARN_AGAIN, GPK_CONF_NOTIFY_CRITICAL);
-	gpk_smart_icon_notify_show (notify->priv->sicon);
-
-	g_free (message);
+	/* send a signal with the type and data */
+	pk_debug ("emit: %s with data %s", action, notify->priv->notify_data);
+	g_signal_emit (notify, signals [NOTIFICATION_BUTTON], 0, button, notify->priv->notify_data);
 }
 
 /**
- * gpk_notify_client_info_to_enums:
+ * gpk_notify_button:
  **/
-static PkInfoEnum
-gpk_notify_client_info_to_enums (GpkNotify *notify, PkClient *client)
+gboolean
+gpk_notify_button (GpkNotify *notify, GpkNotifyButton button, const gchar *data)
 {
-	guint i;
-	guint length;
-	PkInfoEnum infos = 0;
-	PkPackageItem *item;
-
-	g_return_val_if_fail (GPK_IS_NOTIFY (notify), PK_INFO_ENUM_UNKNOWN);
-
-	/* shortcut */
-	length = pk_client_package_buffer_get_size (client);
-	if (length == 0) {
-		return PK_INFO_ENUM_UNKNOWN;
-	}
-
-	/* add each status to a list */
-	for (i=0; i<length; i++) {
-		item = pk_client_package_buffer_get_item (client, i);
-		if (item == NULL) {
-			pk_warning ("not found item %i", i);
-			break;
-		}
-		pk_debug ("%s %s", item->package_id, pk_info_enum_to_text (item->info));
-		pk_enums_add (infos, item->info);
-	}
-	return infos;
-}
-
-/**
- * gpk_notify_get_best_update_icon:
- **/
-static const gchar *
-gpk_notify_get_best_update_icon (GpkNotify *notify, PkClient *client)
-{
-	gint value;
-	PkInfoEnum infos;
-	const gchar *icon;
-
-	g_return_val_if_fail (GPK_IS_NOTIFY (notify), NULL);
-
-	/* get an enumerated list with all the update types */
-	infos = gpk_notify_client_info_to_enums (notify, client);
-
-	/* get the most important icon */
-	value = pk_enums_contain_priority (infos,
-					   PK_INFO_ENUM_SECURITY,
-					   PK_INFO_ENUM_IMPORTANT,
-					   PK_INFO_ENUM_BUGFIX,
-					   PK_INFO_ENUM_NORMAL,
-					   PK_INFO_ENUM_ENHANCEMENT,
-					   PK_INFO_ENUM_LOW, -1);
-	if (value == -1) {
-		pk_warning ("should not be possible!");
-		value = PK_INFO_ENUM_LOW;
-	}
-
-	/* get the icon */
-	icon = gpk_info_enum_to_icon_name (value);
-	return icon;
-}
-
-/**
- * gpk_notify_check_on_battery:
- **/
-static gboolean
-gpk_notify_check_on_battery (GpkNotify *notify)
-{
-	gboolean ret;
-
-	g_return_val_if_fail (GPK_IS_NOTIFY (notify), FALSE);
-
-	ret = gconf_client_get_bool (notify->priv->gconf_client, GPK_CONF_UPDATE_BATTERY, NULL);
-	if (ret) {
-		pk_debug ("okay to update due to policy");
-		return TRUE;
-	}
-
-	ret = gpk_auto_refresh_get_on_battery (notify->priv->arefresh);
-	if (!ret) {
-		pk_debug ("okay to update as on AC");
-		return TRUE;
-	}
-
-	/* this will not show if specified in gconf */
-	gpk_smart_icon_notify_new (notify->priv->sicon,
-				  _("Will not install updates"),
-				  _("Automatic updates are not being installed as the computer is on battery power"),
-				  "dialog-information",
-				  GPK_NOTIFY_URGENCY_LOW, GPK_NOTIFY_TIMEOUT_LONG);
-	gpk_smart_icon_notify_button (notify->priv->sicon,
-				      GPK_NOTIFY_BUTTON_DO_NOT_SHOW_AGAIN,
-				      GPK_CONF_NOTIFY_UPDATE_NOT_BATTERY);
-	gpk_smart_icon_notify_show (notify->priv->sicon);
-	return FALSE;
-}
-
-/**
- * gpk_notify_get_update_policy:
- **/
-static PkUpdateEnum
-gpk_notify_get_update_policy (GpkNotify *notify)
-{
-	PkUpdateEnum update;
-	gchar *updates;
+	const gchar *text = NULL;
+	const gchar *id = NULL;
 
 	g_return_val_if_fail (GPK_IS_NOTIFY (notify), FALSE);
 
-	updates = gconf_client_get_string (notify->priv->gconf_client, GPK_CONF_AUTO_UPDATE, NULL);
-	if (updates == NULL) {
-		pk_warning ("'%s' gconf key is null!", GPK_CONF_AUTO_UPDATE);
-		return PK_UPDATE_ENUM_UNKNOWN;
-	}
-	update = pk_update_enum_from_text (updates);
-	g_free (updates);
-	return update;
-}
-
-/**
- * gpk_notify_query_updates_finished_cb:
- **/
-static void
-gpk_notify_query_updates_finished_cb (PkClient *client, PkExitEnum exit, guint runtime, GpkNotify *notify)
-{
-	PkPackageItem *item;
-	guint length;
-	guint i;
-	gboolean ret;
-	GString *status_security;
-	GString *status_tooltip;
-	PkUpdateEnum update;
-	PkPackageId *ident;
-	GPtrArray *security_array;
-	const gchar *icon;
-
-	g_return_if_fail (GPK_IS_NOTIFY (notify));
-
-	status_security = g_string_new ("");
-	status_tooltip = g_string_new ("");
-	security_array = g_ptr_array_new ();
-
-	/* find packages */
-	length = pk_client_package_buffer_get_size (client);
-	pk_debug ("length=%i", length);
-
-	/* we have no updates */
-	if (length == 0) {
-		pk_debug ("no updates");
-		gpk_smart_icon_set_icon_name (notify->priv->sicon, NULL);
-		goto out;
-	}
-
-	/* find the security updates */
-	for (i=0; i<length; i++) {
-		item = pk_client_package_buffer_get_item (client, i);
-		pk_debug ("%s, %s, %s", pk_info_enum_to_text (item->info),
-			  item->package_id, item->summary);
-		ident = pk_package_id_new_from_string (item->package_id);
-		if (item->info == PK_INFO_ENUM_SECURITY) {
-			/* add to array */
-			g_ptr_array_add (security_array, g_strdup (item->package_id));
-			g_string_append_printf (status_security, "<b>%s</b> - %s\n",
-						ident->name, item->summary);
-		}
-		pk_package_id_free (ident);
-	}
-
-	/* we are done querying this */
-	g_object_unref (client);
-
-	/* do we do the automatic updates? */
-	update = gpk_notify_get_update_policy (notify);
-	if (update == PK_UPDATE_ENUM_UNKNOWN) {
-		pk_warning ("policy unknown");
-		goto out;
-	}
-
-	/* work out icon */
-	icon = gpk_notify_get_best_update_icon (notify, client);
-	gpk_smart_icon_set_icon_name (notify->priv->sicon, icon);
-	gpk_smart_icon_pulse (notify->priv->sicon);
-
-	/* make tooltip */
-	if (status_security->len != 0) {
-		g_string_set_size (status_security, status_security->len-1);
-	}
-	g_string_append_printf (status_tooltip, ngettext ("There is %d update pending",
-							  "There are %d updates pending", length), length);
-	gpk_smart_icon_set_tooltip (notify->priv->sicon, status_tooltip->str);
-
-	/* is policy none? */
-	if (update == PK_UPDATE_ENUM_NONE) {
-		pk_debug ("not updating as policy NONE");
-
-		/* do we warn the user? */
-		if (security_array->len > 0) {
-			gpk_notify_critical_updates_warning (notify, status_security->str, length);
-		}
-		goto out;
-	}
-
-	/* are we on battery and configured to skip the action */
-	ret = gpk_notify_check_on_battery (notify);
-	if (!ret) {
-		pk_debug ("on battery so not doing update");
-		/* do we warn the user? */
-		if (security_array->len > 0) {
-			gpk_notify_critical_updates_warning (notify, status_security->str, length);
-		}
-		goto out;
-	}
-
-	/* just do security updates */
-	if (update == PK_UPDATE_ENUM_SECURITY) {
-		gchar **package_ids;
-		gboolean ret;
-		GError *error = NULL;
-
-		if (security_array->len == 0) {
-			pk_debug ("policy security, but none available");
-			goto out;
-		}
-
-		/* convert */
-		package_ids = pk_package_ids_from_array (security_array);
-		gpk_client_show_finished (notify->priv->gclient, FALSE);
-		gpk_client_show_progress (notify->priv->gclient, FALSE);
-		ret = gpk_client_update_packages (notify->priv->gclient, package_ids, &error);
-		if (!ret) {
-			pk_warning ("Individual updates failed: %s", error->message);
-			g_error_free (error);
+	/* get the id */
+	id = pk_enum_find_string (enum_button_ids, button);
 
-			/* we failed, so re-get the update list */
-			gpk_notify_query_updates (notify);
-		}
-		g_strfreev (package_ids);
-		goto out;
-	}
-
-	/* just do everything */
-	if (update == PK_UPDATE_ENUM_ALL) {
-		pk_debug ("we should do the update automatically!");
-		gpk_client_show_finished (notify->priv->gclient, FALSE);
-		gpk_client_show_progress (notify->priv->gclient, FALSE);
-		g_idle_add ((GSourceFunc) gpk_notify_update_system, notify);
-		goto out;
+	/* find the localised text */
+	if (button == GPK_NOTIFY_BUTTON_DO_NOT_SHOW_AGAIN) {
+		text = _("Do not show this notification again");
+		notify->priv->has_gconf_check = TRUE;
+	} else if (button == GPK_NOTIFY_BUTTON_DO_NOT_WARN_AGAIN) {
+		text = _("Do not warn me again");
+		notify->priv->has_gconf_check = TRUE;
+	} else if (button == GPK_NOTIFY_BUTTON_CANCEL_UPDATE) {
+		text = _("Cancel system update");
+	} else if (button == GPK_NOTIFY_BUTTON_UPDATE_COMPUTER) {
+		text = _("Update computer now");
+	} else if (button == GPK_NOTIFY_BUTTON_RESTART_COMPUTER) {
+		text = _("Restart computer now");
+	} else if (button == GPK_NOTIFY_BUTTON_INSTALL_FIRMWARE) {
+		text = _("Install firmware");
 	}
 
-	/* shouldn't happen */
-	pk_warning ("unknown update mode");
-out:
-	g_string_free (status_security, TRUE);
-	g_string_free (status_tooltip, TRUE);
-
-	/* get rid of the array, and free the contents */
-	g_ptr_array_free (security_array, TRUE);
-}
-
-/**
- * gpk_notify_error_code_cb:
- **/
-static void
-gpk_notify_error_code_cb (PkClient *client, PkErrorCodeEnum error_code, const gchar *details, GpkNotify *notify)
-{
-	const gchar *title;
-
-	g_return_if_fail (GPK_IS_NOTIFY (notify));
-
-	title = gpk_error_enum_to_localised_text (error_code);
-
-	/* ignore some errors */
-	if (error_code == PK_ERROR_ENUM_PROCESS_KILL ||
-	    error_code == PK_ERROR_ENUM_TRANSACTION_CANCELLED) {
-		pk_debug ("error ignored %s\n%s", title, details);
-		return;
-	}
+	/* save data privately, TODO: this really needs to be in a hashtable */
+	notify->priv->notify_data = g_strdup (data);
 
-	/* this will not show if specified in gconf */
-	gpk_smart_icon_notify_new (notify->priv->sicon, title, details, "help-browser",
-				  GPK_NOTIFY_URGENCY_LOW, GPK_NOTIFY_TIMEOUT_LONG);
-	gpk_smart_icon_notify_button (notify->priv->sicon,
-				      GPK_NOTIFY_BUTTON_DO_NOT_SHOW_AGAIN, GPK_CONF_NOTIFY_ERROR);
-	gpk_smart_icon_notify_show (notify->priv->sicon);
+	/* add a button to the UI */
+	notify_notification_add_action (notify->priv->notification, id, text, (NotifyActionCallback) gpk_notify_libnotify_cb, notify, NULL);
+	return FALSE;
 }
 
 /**
- * gpk_notify_query_updates:
+ * gpk_notify_show:
+ * Return value: if the notification is being displayed
+ *
+ * This will show the notification previously setup with gpk_notify_create() and
+ * gpk_notify_button().
+ *
+ * If you set a key using %GPK_NOTIFY_BUTTON_DO_NOT_SHOW_AGAIN or
+ * %GPK_NOTIFY_BUTTON_DO_NOT_WARN_AGAIN then this key will be checked before the notification is
+ * shown.
  **/
-static gboolean
-gpk_notify_query_updates (GpkNotify *notify)
+gboolean
+gpk_notify_show (GpkNotify *notify)
 {
-	gboolean ret;
 	GError *error = NULL;
-	PkClient *client;
+	gboolean value;
 
 	g_return_val_if_fail (GPK_IS_NOTIFY (notify), FALSE);
+	g_return_val_if_fail (notify->priv->notification != NULL, FALSE);
 
-	if (pk_task_list_contains_role (notify->priv->tlist, PK_ROLE_ENUM_UPDATE_SYSTEM)) {
-		pk_debug ("Not checking for updates as already in progress");
-		return FALSE;
+	/* check the gconf key isn't set to ignore */
+	if (notify->priv->has_gconf_check) {
+		pk_debug ("key is %s", notify->priv->notify_data);
+		/* are we accepting notifications */
+		value = gconf_client_get_bool (notify->priv->gconf_client, notify->priv->notify_data, NULL);
+		if (!value) {
+			pk_debug ("not showing notification as prevented in gconf with %s", notify->priv->notify_data);
+			return FALSE;
+		}
 	}
 
-	client = pk_client_new ();
-	g_signal_connect (client, "finished",
-			  G_CALLBACK (gpk_notify_query_updates_finished_cb), notify);
-	g_signal_connect (client, "error-code",
-			  G_CALLBACK (gpk_notify_error_code_cb), notify);
-	pk_client_set_use_buffer (client, TRUE, NULL);
-
-	/* get updates */
-	ret = pk_client_get_updates (client, PK_FILTER_ENUM_NONE, &error);
-	if (!ret) {
-		pk_warning ("failed to get updates: %s", error->message);
+	notify_notification_close (notify->priv->notification, NULL);
+	notify_notification_show (notify->priv->notification, &error);
+	if (error != NULL) {
+		pk_warning ("error: %s", error->message);
 		g_error_free (error);
-	}
-	return ret;
-}
-
-/**
- * gpk_notify_refresh_cache_finished_cb:
- **/
-static void
-gpk_notify_refresh_cache_finished_cb (PkClient *client, PkExitEnum exit_code, guint runtime, GpkNotify *notify)
-{
-	g_return_if_fail (GPK_IS_NOTIFY (notify));
-
-	pk_debug ("finished refreshing cache :%s", pk_exit_enum_to_text (exit_code));
-	if (exit_code != PK_EXIT_ENUM_SUCCESS) {
-		/* we failed to get the cache */
-		notify->priv->cache_okay = FALSE;
-	} else {
-		/* stop the polling */
-		notify->priv->cache_okay = TRUE;
-
-		/* now try to get updates */
-		pk_debug ("get updates");
-		gpk_notify_query_updates (notify);
-	}
-	notify->priv->cache_update_in_progress = FALSE;
-	g_object_unref (client);
-}
-
-/**
- * gpk_notify_check_for_updates_cb:
- **/
-static gboolean
-gpk_notify_check_for_updates_cb (GpkNotify *notify)
-{
-	gboolean ret;
-	PkClient *client;
-	pk_debug ("refresh cache");
-
-	g_return_val_if_fail (GPK_IS_NOTIFY (notify), FALSE);
-
-	/* got a cache, no need to poll */
-	if (notify->priv->cache_okay) {
 		return FALSE;
 	}
-
-	/* already in progress, but not yet certified okay */
-	if (notify->priv->cache_update_in_progress) {
-		return TRUE;
-	}
-
-	notify->priv->cache_update_in_progress = TRUE;
-	notify->priv->cache_okay = TRUE;
-	client = pk_client_new ();
-	g_signal_connect (client, "finished",
-			  G_CALLBACK (gpk_notify_refresh_cache_finished_cb), notify);
-	g_signal_connect (client, "error-code",
-			  G_CALLBACK (gpk_notify_error_code_cb), notify);
-	ret = pk_client_refresh_cache (client, TRUE, NULL);
-	if (ret == FALSE) {
-		g_object_unref (client);
-		pk_warning ("failed to refresh cache");
-		/* try again in a few minutes */
-	}
 	return TRUE;
 }
 
 /**
- * gpk_notify_updates_changed_cb:
+ * gpk_notify_close:
  **/
-static void
-gpk_notify_updates_changed_cb (PkClient *client, GpkNotify *notify)
+gboolean
+gpk_notify_close (GpkNotify *notify)
 {
-	g_return_if_fail (GPK_IS_NOTIFY (notify));
-
-	/* now try to get newest update list */
-	pk_debug ("get updates");
-	gpk_notify_query_updates (notify);
-}
-
-/**
- * gpk_notify_restart_schedule_cb:
- **/
-static void
-gpk_notify_restart_schedule_cb (PkClient *client, GpkNotify *notify)
-{
-	gboolean ret;
-	GError *error = NULL;
-	const gchar *file;
-
-	g_return_if_fail (GPK_IS_NOTIFY (notify));
-
-	/* wait for the daemon to quit */
-	g_usleep (2*G_USEC_PER_SEC);
-
-	file = BINDIR "/gpk-update-icon";
-	pk_debug ("trying to spawn: %s", file);
-	ret = g_spawn_command_line_async (file, &error);
-	if (!ret) {
-		pk_warning ("failed to spawn new instance: %s", error->message);
-		g_error_free (error);
-	}
-}
-
-/**
- * gpk_notify_task_list_changed_cb:
- **/
-static void
-gpk_notify_task_list_changed_cb (PkTaskList *tlist, GpkNotify *notify)
-{
-	g_return_if_fail (GPK_IS_NOTIFY (notify));
-	/* hide icon if we are updating */
-	if (pk_task_list_contains_role (tlist, PK_ROLE_ENUM_UPDATE_SYSTEM) ||
-	    pk_task_list_contains_role (tlist, PK_ROLE_ENUM_UPDATE_PACKAGES)) {
-		gpk_smart_icon_set_icon_name (notify->priv->sicon, NULL);
-	}
-}
-
-/**
- * gpk_notify_auto_refresh_cache_cb:
- **/
-static void
-gpk_notify_auto_refresh_cache_cb (GpkAutoRefresh *arefresh, GpkNotify *notify)
-{
-	g_return_if_fail (GPK_IS_NOTIFY (notify));
-
-	/* schedule another update */
-	gpk_notify_check_for_updates_cb (notify);
-}
-
-/**
- * gpk_notify_auto_get_updates_cb:
- **/
-static void
-gpk_notify_auto_get_updates_cb (GpkAutoRefresh *arefresh, GpkNotify *notify)
-{
-	g_return_if_fail (GPK_IS_NOTIFY (notify));
-
-	/* show the icon at login time
-	 * hopefully it just needs a quick network access, else we may have to
-	 * make it a gconf variable */
-	gpk_notify_query_updates (notify);
-}
-
-/**
- * gpk_notify_smart_icon_notify_button:
- **/
-static void
-gpk_notify_smart_icon_notify_button (GpkSmartIcon *sicon, GpkNotifyButton button,
-				     const gchar *data, GpkNotify *notify)
-{
-	g_return_if_fail (GPK_IS_NOTIFY (notify));
-
-	pk_debug ("got: %i with data %s", button, data);
-	/* find the localised text */
-	if (button == GPK_NOTIFY_BUTTON_DO_NOT_SHOW_AGAIN ||
-	    button == GPK_NOTIFY_BUTTON_DO_NOT_WARN_AGAIN) {
-		if (data == NULL) {
-			pk_warning ("data NULL");
-		} else {
-			pk_debug ("setting %s to FALSE", data);
-			gconf_client_set_bool (notify->priv->gconf_client, data, FALSE, NULL);
-		}
-	} else if (button == GPK_NOTIFY_BUTTON_CANCEL_UPDATE) {
-		pk_warning ("unable to cancel!");
-	} else if (button == GPK_NOTIFY_BUTTON_UPDATE_COMPUTER) {
-		gpk_notify_update_system (notify);
-	}
+	g_return_val_if_fail (GPK_IS_NOTIFY (notify), FALSE);
+	notify_notification_close (notify->priv->notification, NULL);
+	return TRUE;
 }
 
 /**
  * gpk_notify_init:
- * @notify: This class instance
+ * @smart_icon: This class instance
  **/
 static void
 gpk_notify_init (GpkNotify *notify)
 {
-	GtkStatusIcon *status_icon;
 	notify->priv = GPK_NOTIFY_GET_PRIVATE (notify);
-
-	notify->priv->sicon = gpk_smart_icon_new ();
-	g_signal_connect (notify->priv->sicon, "notification-button",
-			  G_CALLBACK (gpk_notify_smart_icon_notify_button), notify);
-
+	notify->priv->notification = NULL;
+	notify->priv->notify_data = NULL;
+	notify->priv->has_gconf_check = FALSE;
 	notify->priv->gconf_client = gconf_client_get_default ();
-	notify->priv->arefresh = gpk_auto_refresh_new ();
-	g_signal_connect (notify->priv->arefresh, "refresh-cache",
-			  G_CALLBACK (gpk_notify_auto_refresh_cache_cb), notify);
-	g_signal_connect (notify->priv->arefresh, "get-updates",
-			  G_CALLBACK (gpk_notify_auto_get_updates_cb), notify);
-
-	/* right click actions are common */
-	status_icon = gpk_smart_icon_get_status_icon (notify->priv->sicon);
-	g_signal_connect_object (G_OBJECT (status_icon),
-				 "popup_menu",
-				 G_CALLBACK (gpk_notify_popup_menu_cb),
-				 notify, 0);
-	g_signal_connect_object (G_OBJECT (status_icon),
-				 "activate",
-				 G_CALLBACK (gpk_notify_activate_update_cb),
-				 notify, 0);
-
-	/* install stuff using the gnome helpers */
-	notify->priv->gclient = gpk_client_new ();
-	gpk_client_show_finished (notify->priv->gclient, TRUE);
-	gpk_client_show_progress (notify->priv->gclient, TRUE);
-
-	notify->priv->pconnection = pk_connection_new ();
-	g_signal_connect (notify->priv->pconnection, "connection-changed",
-			  G_CALLBACK (pk_connection_changed_cb), notify);
-	if (pk_connection_valid (notify->priv->pconnection)) {
-		pk_connection_changed_cb (notify->priv->pconnection, TRUE, notify);
-	}
 
-	notify->priv->control = pk_control_new ();
-	g_signal_connect (notify->priv->control, "updates-changed",
-			  G_CALLBACK (gpk_notify_updates_changed_cb), notify);
-	g_signal_connect (notify->priv->control, "restart-schedule",
-			  G_CALLBACK (gpk_notify_restart_schedule_cb), notify);
-
-	/* we need the task list so we can hide the update icon when we are doing the update */
-	notify->priv->tlist = pk_task_list_new ();
-	g_signal_connect (notify->priv->tlist, "changed",
-			  G_CALLBACK (gpk_notify_task_list_changed_cb), notify);
-
-	/* refresh the cache, and poll until we get a good refresh */
-	notify->priv->cache_okay = FALSE;
-	notify->priv->cache_update_in_progress = FALSE;
+	/* signal we are here... */
+	notify_init ("packagekit");
 }
 
 /**
@@ -965,16 +270,17 @@
 	g_return_if_fail (GPK_IS_NOTIFY (object));
 
 	notify = GPK_NOTIFY (object);
-
 	g_return_if_fail (notify->priv != NULL);
 
-	g_object_unref (notify->priv->sicon);
-	g_object_unref (notify->priv->pconnection);
-	g_object_unref (notify->priv->tlist);
-	g_object_unref (notify->priv->arefresh);
 	g_object_unref (notify->priv->gconf_client);
-	g_object_unref (notify->priv->control);
-	g_object_unref (notify->priv->gclient);
+
+	if (notify->priv->notification != NULL) {
+		notify_notification_close (notify->priv->notification, NULL);
+		g_object_unref (notify->priv->notification);
+	}
+	if (notify->priv->notify_data != NULL) {
+		g_free (notify->priv->notify_data);
+	}
 
 	G_OBJECT_CLASS (gpk_notify_parent_class)->finalize (object);
 }

Modified: trunk/src/gpk-notify.h
==============================================================================
--- trunk/src/gpk-notify.h	(original)
+++ trunk/src/gpk-notify.h	Sun May 25 16:36:39 2008
@@ -1,6 +1,6 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
  *
- * Copyright (C) 2007 Richard Hughes <richard hughsie com>
+ * Copyright (C) 2007-2008 Richard Hughes <richard hughsie com>
  *
  * Licensed under the GNU General Public License Version 2
  *
@@ -39,17 +39,54 @@
 
 typedef struct
 {
-	 GObject		 parent;
+	 GtkStatusIcon		 parent;
 	 GpkNotifyPrivate	*priv;
 } GpkNotify;
 
 typedef struct
 {
-	GObjectClass	parent_class;
+	GtkStatusIconClass	 parent_class;
 } GpkNotifyClass;
 
-GType		 gpk_notify_get_type		  	(void) G_GNUC_CONST;
+typedef enum
+{
+	GPK_NOTIFY_URGENCY_LOW,
+	GPK_NOTIFY_URGENCY_NORMAL,
+	GPK_NOTIFY_URGENCY_CRITICAL
+} GpkNotifyUrgency;
+
+typedef enum
+{
+	GPK_NOTIFY_TIMEOUT_SHORT,
+	GPK_NOTIFY_TIMEOUT_LONG,
+	GPK_NOTIFY_TIMEOUT_NEVER
+} GpkNotifyTimeout;
+
+typedef enum
+{
+	GPK_NOTIFY_BUTTON_DO_NOT_SHOW_AGAIN,
+	GPK_NOTIFY_BUTTON_DO_NOT_WARN_AGAIN,
+	GPK_NOTIFY_BUTTON_CANCEL_UPDATE,
+	GPK_NOTIFY_BUTTON_UPDATE_COMPUTER,
+	GPK_NOTIFY_BUTTON_RESTART_COMPUTER,
+	GPK_NOTIFY_BUTTON_INSTALL_FIRMWARE,
+	GPK_NOTIFY_BUTTON_UNKNOWN
+} GpkNotifyButton;
+
+GType		 gpk_notify_get_type			(void) G_GNUC_CONST;
 GpkNotify	*gpk_notify_new				(void);
+gboolean	 gpk_notify_create			(GpkNotify		*notify,
+							 const gchar		*title,
+							 const gchar		*message,
+							 const gchar		*icon,
+							 GpkNotifyUrgency	 urgency,
+							 GpkNotifyTimeout	 timeout);
+gboolean	 gpk_notify_button			(GpkNotify		*notify,
+							 GpkNotifyButton	 button,
+							 const gchar		*data);
+gboolean	 gpk_notify_show			(GpkNotify		*notify);
+gboolean	 gpk_notify_close			(GpkNotify		*notify);
+
 
 G_END_DECLS
 

Modified: trunk/src/gpk-smart-icon.c
==============================================================================
--- trunk/src/gpk-smart-icon.c	(original)
+++ trunk/src/gpk-smart-icon.c	Sun May 25 16:36:39 2008
@@ -35,10 +35,7 @@
 #include <glib/gi18n.h>
 
 #include <gtk/gtk.h>
-#include <libnotify/notify.h>
 #include <gtk/gtkstatusicon.h>
-#include <libnotify/notify.h>
-#include <gconf/gconf-client.h>
 
 #include <pk-debug.h>
 #include <pk-enum.h>
@@ -48,45 +45,22 @@
 
 static void     gpk_smart_icon_class_init	(GpkSmartIconClass *klass);
 static void     gpk_smart_icon_init		(GpkSmartIcon      *sicon);
-static void     gpk_smart_icon_finalize		(GObject       *object);
+static void     gpk_smart_icon_finalize		(GObject           *object);
 
 #define GPK_SMART_ICON_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GPK_TYPE_SMART_ICON, GpkSmartIconPrivate))
 #define GPK_SMART_ICON_PERSIST_TIMEOUT	100
 
 struct GpkSmartIconPrivate
 {
-	GtkStatusIcon		*status_icon;
-	NotifyNotification	*dialog;
-	GConfClient		*gconf_client;
 	gchar			*current;
 	gchar			*new;
-	gchar			*notify_data;
 	guint			 event_source;
 	guint			 pulse_source;
-	gboolean		 has_gconf_check;
 	gfloat			 icon_opacity;
 	gboolean		 going_down;
 };
 
-enum {
-	NOTIFICATION_BUTTON,
-	LAST_SIGNAL
-};
-
-G_DEFINE_TYPE (GpkSmartIcon, gpk_smart_icon, G_TYPE_OBJECT)
-
-static guint signals [LAST_SIGNAL] = { 0 };
-
-static PkEnumMatch enum_button_ids[] = {
-	{GPK_NOTIFY_BUTTON_UNKNOWN,		"unknown"},	/* fall though value */
-	{GPK_NOTIFY_BUTTON_DO_NOT_SHOW_AGAIN,	"do-not-show-again"},
-	{GPK_NOTIFY_BUTTON_DO_NOT_WARN_AGAIN,	"do-not-warn-again"},
-	{GPK_NOTIFY_BUTTON_CANCEL_UPDATE,	"cancel-update"},
-	{GPK_NOTIFY_BUTTON_UPDATE_COMPUTER,	"update-computer"},
-	{GPK_NOTIFY_BUTTON_RESTART_COMPUTER,	"restart-computer"},
-	{GPK_NOTIFY_BUTTON_INSTALL_FIRMWARE,	"install-firmware"},
-	{0, NULL}
-};
+G_DEFINE_TYPE (GpkSmartIcon, gpk_smart_icon, GTK_TYPE_STATUS_ICON)
 
 /**
  * gpk_smart_icon_class_init:
@@ -98,11 +72,6 @@
 	GObjectClass *object_class = G_OBJECT_CLASS (klass);
 	object_class->finalize = gpk_smart_icon_finalize;
 	g_type_class_add_private (klass, sizeof (GpkSmartIconPrivate));
-	signals [NOTIFICATION_BUTTON] =
-		g_signal_new ("notification-button",
-			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
-			      0, NULL, NULL, gpk_marshal_VOID__UINT_STRING,
-			      G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_STRING);
 }
 
 /**
@@ -150,12 +119,12 @@
 	}
 
 	/* get pixmap the same size as the original icon */
-	gtk_status_icon_get_geometry (GTK_STATUS_ICON (sicon->priv->status_icon), NULL, &area, NULL);
+	gtk_status_icon_get_geometry (GTK_STATUS_ICON (sicon), NULL, &area, NULL);
 	pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), sicon->priv->current, area.width, 0, NULL);
 
 	/* set the new pixmap with the correct opacity */
 	gpk_smart_icon_set_pixmap_opacity (pixbuf, sicon->priv->icon_opacity);
-	gtk_status_icon_set_from_pixbuf (GTK_STATUS_ICON (sicon->priv->status_icon), pixbuf);
+	gtk_status_icon_set_from_pixbuf (GTK_STATUS_ICON (sicon), pixbuf);
 	g_object_unref (pixbuf);
 
 	/* dimming down */
@@ -172,7 +141,7 @@
 	sicon->priv->icon_opacity += 0.1;
 	if (sicon->priv->icon_opacity>1) {
 		/* restore */
-		gtk_status_icon_set_from_icon_name (GTK_STATUS_ICON (sicon->priv->status_icon), sicon->priv->current);
+		gtk_status_icon_set_from_icon_name (GTK_STATUS_ICON (sicon), sicon->priv->current);
 		sicon->priv->pulse_source = 0;
 		return FALSE;
 	}
@@ -190,7 +159,7 @@
 	sicon->priv->icon_opacity = 0.9;
 	sicon->priv->going_down = TRUE;
 	if (sicon->priv->pulse_source != 0) {
-		pk_warning ("already pulsing");
+		pk_debug ("already pulsing");
 		return FALSE;
 	}
 	sicon->priv->pulse_source = g_timeout_add (20, gpk_smart_icon_pulse_timeout_cb, sicon);
@@ -222,10 +191,10 @@
 
 	/* set the correct thing */
 	if (sicon->priv->new == NULL) {
-		gtk_status_icon_set_visible (GTK_STATUS_ICON (sicon->priv->status_icon), FALSE);
+		gtk_status_icon_set_visible (GTK_STATUS_ICON (sicon), FALSE);
 	} else {
-		gtk_status_icon_set_from_icon_name (GTK_STATUS_ICON (sicon->priv->status_icon), sicon->priv->new);
-		gtk_status_icon_set_visible (GTK_STATUS_ICON (sicon->priv->status_icon), TRUE);
+		gtk_status_icon_set_from_icon_name (GTK_STATUS_ICON (sicon), sicon->priv->new);
+		gtk_status_icon_set_visible (GTK_STATUS_ICON (sicon), TRUE);
 	}
 	return FALSE;
 }
@@ -254,189 +223,14 @@
 }
 
 /**
- * gpk_smart_icon_sync:
- **/
-gboolean
-gpk_smart_icon_sync (GpkSmartIcon *sicon)
-{
-	g_return_val_if_fail (GPK_IS_SMART_ICON (sicon), FALSE);
-
-	/* if we have a request pending, then cancel it in preference to this one */
-	if (sicon->priv->event_source != 0) {
-		g_source_remove (sicon->priv->event_source);
-		sicon->priv->event_source = 0;
-	}
-
-	/* sync the icon now */
-	gpk_smart_icon_set_icon_name_cb (sicon);
-
-	/* wait until we are in the panel.
-	 * We should probably use gtk_status_icon_is_embedded if it worked... */
-	g_usleep (50000);
-
-	return TRUE;
-}
-
-/**
- * gpk_smart_icon_get_status_icon:
- **/
-GtkStatusIcon *
-gpk_smart_icon_get_status_icon (GpkSmartIcon *sicon)
-{
-	g_return_val_if_fail (GPK_IS_SMART_ICON (sicon), NULL);
-	return sicon->priv->status_icon;
-}
-
-/**
- * gpk_smart_icon_set_tooltip:
- **/
-gboolean
-gpk_smart_icon_set_tooltip (GpkSmartIcon *sicon, const gchar *tooltip)
-{
-	g_return_val_if_fail (GPK_IS_SMART_ICON (sicon), FALSE);
-	gtk_status_icon_set_tooltip (GTK_STATUS_ICON (sicon->priv->status_icon), tooltip);
-	return TRUE;
-}
-
-/**
- * gpk_smart_icon_notify:
+ * gpk_smart_icon_set_priority:
  **/
 gboolean
-gpk_smart_icon_notify_new (GpkSmartIcon *sicon, const gchar *title, const gchar *message,
-			   const gchar *icon, GpkNotifyUrgency urgency, GpkNotifyTimeout timeout)
+gpk_smart_icon_set_priority (GpkSmartIcon *sicon, guint number)
 {
-	guint timeout_val = 0;
-
 	g_return_val_if_fail (GPK_IS_SMART_ICON (sicon), FALSE);
 
-	pk_debug ("Doing notification: %s, %s, %s", title, message, icon);
-
-	/* no gconf to check */
-	sicon->priv->has_gconf_check = FALSE;
-
-	/* default values */
-	if (timeout == GPK_NOTIFY_TIMEOUT_SHORT) {
-		timeout_val = 5000;
-	} else if (timeout == GPK_NOTIFY_TIMEOUT_LONG) {
-		timeout_val = 15000;
-	}
-
-	if (gtk_status_icon_get_visible (sicon->priv->status_icon)) {
-		sicon->priv->dialog = notify_notification_new_with_status_icon (title, message, icon, sicon->priv->status_icon);
-	} else {
-		sicon->priv->dialog = notify_notification_new (title, message, icon, NULL);
-	}
-	notify_notification_set_timeout (sicon->priv->dialog, timeout_val);
-	notify_notification_set_urgency (sicon->priv->dialog, (NotifyUrgency) urgency);
-	return TRUE;
-}
-
-/**
- * gpk_smart_icon_libnotify_cb:
- **/
-static void
-gpk_smart_icon_libnotify_cb (NotifyNotification *dialog, gchar *action, GpkSmartIcon *sicon)
-{
-	GpkNotifyButton button;
-
-	g_return_if_fail (GPK_IS_SMART_ICON (sicon));
-
-	/* get the value */
-	button = pk_enum_find_value (enum_button_ids, action);
-
-	/* send a signal with the type and data */
-	pk_debug ("emit: %s with data %s", action, sicon->priv->notify_data);
-	g_signal_emit (sicon, signals [NOTIFICATION_BUTTON], 0, button, sicon->priv->notify_data);
-}
-
-/**
- * gpk_smart_icon_notify_button:
- **/
-gboolean
-gpk_smart_icon_notify_button (GpkSmartIcon *sicon, GpkNotifyButton button, const gchar *data)
-{
-	const gchar *text = NULL;
-	const gchar *id = NULL;
-
-	g_return_val_if_fail (GPK_IS_SMART_ICON (sicon), FALSE);
-
-	/* get the id */
-	id = pk_enum_find_string (enum_button_ids, button);
-
-	/* find the localised text */
-	if (button == GPK_NOTIFY_BUTTON_DO_NOT_SHOW_AGAIN) {
-		text = _("Do not show this notification again");
-		sicon->priv->has_gconf_check = TRUE;
-	} else if (button == GPK_NOTIFY_BUTTON_DO_NOT_WARN_AGAIN) {
-		text = _("Do not warn me again");
-		sicon->priv->has_gconf_check = TRUE;
-	} else if (button == GPK_NOTIFY_BUTTON_CANCEL_UPDATE) {
-		text = _("Cancel system update");
-	} else if (button == GPK_NOTIFY_BUTTON_UPDATE_COMPUTER) {
-		text = _("Update computer now");
-	} else if (button == GPK_NOTIFY_BUTTON_RESTART_COMPUTER) {
-		text = _("Restart computer now");
-	} else if (button == GPK_NOTIFY_BUTTON_INSTALL_FIRMWARE) {
-		text = _("Install firmware");
-	}
-
-	/* save data privately, TODO: this really needs to be in a hashtable */
-	sicon->priv->notify_data = g_strdup (data);
-
-	/* add a button to the UI */
-	notify_notification_add_action (sicon->priv->dialog, id, text, (NotifyActionCallback) gpk_smart_icon_libnotify_cb, sicon, NULL);
-	return FALSE;
-}
-
-/**
- * gpk_smart_icon_notify_show:
- * Return value: if the notification is being displayed
- *
- * This will show the notification previously setup with gpk_smart_icon_notify_new() and
- * gpk_smart_icon_notify_button().
- *
- * If you set a key using %GPK_NOTIFY_BUTTON_DO_NOT_SHOW_AGAIN or
- * %GPK_NOTIFY_BUTTON_DO_NOT_WARN_AGAIN then this key will be checked before the notification is
- * shown.
- **/
-gboolean
-gpk_smart_icon_notify_show (GpkSmartIcon *sicon)
-{
-	GError *error = NULL;
-	gboolean value;
-
-	g_return_val_if_fail (GPK_IS_SMART_ICON (sicon), FALSE);
-	g_return_val_if_fail (sicon->priv->dialog != NULL, FALSE);
-
-	/* check the gconf key isn't set to ignore */
-	if (sicon->priv->has_gconf_check) {
-		pk_debug ("key is %s", sicon->priv->notify_data);
-		/* are we accepting notifications */
-		value = gconf_client_get_bool (sicon->priv->gconf_client, sicon->priv->notify_data, NULL);
-		if (!value) {
-			pk_debug ("not showing notification as prevented in gconf with %s", sicon->priv->notify_data);
-			return FALSE;
-		}
-	}
-
-	notify_notification_close (sicon->priv->dialog, NULL);
-	notify_notification_show (sicon->priv->dialog, &error);
-	if (error != NULL) {
-		pk_warning ("error: %s", error->message);
-		g_error_free (error);
-		return FALSE;
-	}
-	return TRUE;
-}
-
-/**
- * gpk_smart_icon_notify_close:
- **/
-gboolean
-gpk_smart_icon_notify_close (GpkSmartIcon *sicon)
-{
-	g_return_val_if_fail (GPK_IS_SMART_ICON (sicon), FALSE);
-	notify_notification_close (sicon->priv->dialog, NULL);
+	pk_debug ("set priority %i", number);
 	return TRUE;
 }
 
@@ -448,20 +242,11 @@
 gpk_smart_icon_init (GpkSmartIcon *sicon)
 {
 	sicon->priv = GPK_SMART_ICON_GET_PRIVATE (sicon);
-	sicon->priv->status_icon = gtk_status_icon_new ();
 	sicon->priv->new = NULL;
 	sicon->priv->current = NULL;
-	sicon->priv->dialog = NULL;
-	sicon->priv->notify_data = NULL;
 	sicon->priv->event_source = 0;
 	sicon->priv->pulse_source = 0;
-	sicon->priv->has_gconf_check = FALSE;
-	sicon->priv->gconf_client = gconf_client_get_default ();
-
-	/* signal we are here... */
-	notify_init ("packagekit");
-
-	gtk_status_icon_set_visible (GTK_STATUS_ICON (sicon->priv->status_icon), FALSE);
+	gtk_status_icon_set_visible (GTK_STATUS_ICON (sicon), FALSE);
 }
 
 /**
@@ -488,16 +273,6 @@
 
 	g_free (sicon->priv->new);
 	g_free (sicon->priv->current);
-	g_object_unref (sicon->priv->gconf_client);
-
-	g_object_unref (sicon->priv->status_icon);
-	if (sicon->priv->dialog != NULL) {
-		notify_notification_close (sicon->priv->dialog, NULL);
-		g_object_unref (sicon->priv->dialog);
-	}
-	if (sicon->priv->notify_data != NULL) {
-		g_free (sicon->priv->notify_data);
-	}
 
 	G_OBJECT_CLASS (gpk_smart_icon_parent_class)->finalize (object);
 }

Modified: trunk/src/gpk-smart-icon.h
==============================================================================
--- trunk/src/gpk-smart-icon.h	(original)
+++ trunk/src/gpk-smart-icon.h	Sun May 25 16:36:39 2008
@@ -23,6 +23,7 @@
 #define __GPK_SMART_ICON_H
 
 #include <glib-object.h>
+#include <gtk/gtkstatusicon.h>
 
 G_BEGIN_DECLS
 
@@ -39,61 +40,22 @@
 
 typedef struct
 {
-	 GObject		 parent;
+	 GtkStatusIcon		 parent;
 	 GpkSmartIconPrivate	*priv;
 } GpkSmartIcon;
 
 typedef struct
 {
-	GObjectClass	parent_class;
+	GtkStatusIconClass	 parent_class;
 } GpkSmartIconClass;
 
-typedef enum
-{
-	GPK_NOTIFY_URGENCY_LOW,
-	GPK_NOTIFY_URGENCY_NORMAL,
-	GPK_NOTIFY_URGENCY_CRITICAL
-} GpkNotifyUrgency;
-
-typedef enum
-{
-	GPK_NOTIFY_TIMEOUT_SHORT,
-	GPK_NOTIFY_TIMEOUT_LONG,
-	GPK_NOTIFY_TIMEOUT_NEVER
-} GpkNotifyTimeout;
-
-typedef enum
-{
-	GPK_NOTIFY_BUTTON_DO_NOT_SHOW_AGAIN,
-	GPK_NOTIFY_BUTTON_DO_NOT_WARN_AGAIN,
-	GPK_NOTIFY_BUTTON_CANCEL_UPDATE,
-	GPK_NOTIFY_BUTTON_UPDATE_COMPUTER,
-	GPK_NOTIFY_BUTTON_RESTART_COMPUTER,
-	GPK_NOTIFY_BUTTON_INSTALL_FIRMWARE,
-	GPK_NOTIFY_BUTTON_UNKNOWN
-} GpkNotifyButton;
-
 GType		 gpk_smart_icon_get_type		(void) G_GNUC_CONST;
 GpkSmartIcon	*gpk_smart_icon_new			(void);
-GtkStatusIcon	*gpk_smart_icon_get_status_icon		(GpkSmartIcon	*sicon);
-gboolean	 gpk_smart_icon_sync			(GpkSmartIcon	*sicon);
-gboolean	 gpk_smart_icon_pulse			(GpkSmartIcon	*sicon);
-gboolean	 gpk_smart_icon_set_icon_name		(GpkSmartIcon	*sicon,
-							 const gchar	*icon_name);
-gboolean	 gpk_smart_icon_set_tooltip		(GpkSmartIcon	*sicon,
-							 const gchar	*tooltip);
-gboolean	 gpk_smart_icon_notify_new		(GpkSmartIcon	*sicon,
-							 const gchar	*title,
-							 const gchar	*message,
-							 const gchar	*icon,
-							 GpkNotifyUrgency urgency,
-							 GpkNotifyTimeout timeout);
-gboolean	 gpk_smart_icon_notify_button		(GpkSmartIcon	*sicon,
-							 GpkNotifyButton	 button,
-							 const gchar	*data);
-gboolean	 gpk_smart_icon_notify_show		(GpkSmartIcon	*sicon);
-gboolean	 gpk_smart_icon_notify_close		(GpkSmartIcon	*sicon);
-
+gboolean	 gpk_smart_icon_pulse			(GpkSmartIcon		*sicon);
+gboolean	 gpk_smart_icon_set_priority		(GpkSmartIcon		*sicon,
+							 guint			 number);
+gboolean	 gpk_smart_icon_set_icon_name		(GpkSmartIcon		*sicon,
+							 const gchar		*icon_name);
 
 G_END_DECLS
 

Modified: trunk/src/gpk-update-icon.c
==============================================================================
--- trunk/src/gpk-update-icon.c	(original)
+++ trunk/src/gpk-update-icon.c	Sun May 25 16:36:39 2008
@@ -36,7 +36,7 @@
 #include <pk-debug.h>
 #include <pk-common.h>
 
-#include "gpk-notify.h"
+#include "gpk-check-update.h"
 #include "gpk-watch.h"
 #include "gpk-firmware.h"
 #include "gpk-dbus.h"
@@ -110,7 +110,7 @@
 {
 	gboolean verbose = FALSE;
 	gboolean program_version = FALSE;
-	GpkNotify *notify = NULL;
+	GpkCheckUpdate *cupdate = NULL;
 	GpkWatch *watch = NULL;
 	GpkDbus *dbus = NULL;
 	GpkFirmware *firmware = NULL;
@@ -167,7 +167,7 @@
 
 	/* create new objects */
 	dbus = gpk_dbus_new ();
-	notify = gpk_notify_new ();
+	cupdate = gpk_check_update_new ();
 	watch = gpk_watch_new ();
 	firmware = gpk_firmware_new ();
 
@@ -197,7 +197,7 @@
 
 out:
 	g_object_unref (dbus);
-	g_object_unref (notify);
+	g_object_unref (cupdate);
 	g_object_unref (watch);
 	g_object_unref (firmware);
 	g_object_unref (libgbus);

Modified: trunk/src/gpk-update-viewer.c
==============================================================================
--- trunk/src/gpk-update-viewer.c	(original)
+++ trunk/src/gpk-update-viewer.c	Sun May 25 16:36:39 2008
@@ -667,7 +667,14 @@
 
 	urls = g_strsplit (url_string, ";", 0);
 	length = g_strv_length (urls);
-	for (i = 0; urls[i]; i += 2) {
+
+	/* could we have malformed descriptions with ';' in them? */
+	if (length % 2 != 0) {
+		pk_warning ("length not correct, correcting");
+		length--;
+	}
+
+	for (i=0; i<length; i+=2) {
 		uri = urls[i];
 		text = urls[i+1];
 		if (pk_strzero (text)) {
@@ -753,8 +760,14 @@
 	pk_package_id_free (ident);
 
 	if (!pk_strzero (update_text)) {
+		gchar *first;
+		gchar *second;
+		first = pk_strreplace (update_text, "\n- ", "\nâ ");
+		second = pk_strreplace (first, "\n* ", "\nâ ");
 		/* translators: this is the package description */
-		pk_update_viewer_add_description_item (_("Description"), update_text, NULL);
+		pk_update_viewer_add_description_item (_("Description"), second, NULL);
+		g_free (first);
+		g_free (second);
 	}
 
 	/* add all the links */

Modified: trunk/src/gpk-watch.c
==============================================================================
--- trunk/src/gpk-watch.c	(original)
+++ trunk/src/gpk-watch.c	Sun May 25 16:36:39 2008
@@ -49,6 +49,7 @@
 #include <pk-package-id.h>
 
 #include "gpk-common.h"
+#include "gpk-notify.h"
 #include "gpk-watch.h"
 #include "gpk-client.h"
 #include "gpk-inhibit.h"
@@ -70,7 +71,9 @@
 	PkControl		*control;
 	GpkSmartIcon		*sicon;
 	GpkSmartIcon		*sicon_restart;
+	GpkNotify		*notify;
 	GpkInhibit		*inhibit;
+	GpkClient		*gclient;
 	PkConnection		*pconnection;
 	PkTaskList		*tlist;
 	GConfClient		*gconf_client;
@@ -111,7 +114,7 @@
 	length = pk_task_list_get_size (watch->priv->tlist);
 	pk_debug ("refresh tooltip %i", length);
 	if (length == 0) {
-		gpk_smart_icon_set_tooltip (watch->priv->sicon, "Doing nothing...");
+		gtk_status_icon_set_tooltip (GTK_STATUS_ICON (watch->priv->sicon), "Doing nothing...");
 		return TRUE;
 	}
 	status = g_string_new ("");
@@ -146,7 +149,7 @@
 	} else {
 		g_string_set_size (status, status->len-1);
 	}
-	gpk_smart_icon_set_tooltip (watch->priv->sicon, status->str);
+	gtk_status_icon_set_tooltip (GTK_STATUS_ICON (watch->priv->sicon), status->str);
 	g_string_free (status, TRUE);
 	return TRUE;
 }
@@ -291,7 +294,7 @@
 		    restart == PK_RESTART_ENUM_SESSION) {
 			restart_message = gpk_restart_enum_to_localised_text (restart);
 			icon_name = gpk_restart_enum_to_icon_name (restart);
-			gpk_smart_icon_set_tooltip (watch->priv->sicon_restart, restart_message);
+			gtk_status_icon_set_tooltip (GTK_STATUS_ICON (watch->priv->sicon_restart), restart_message);
 			gpk_smart_icon_set_icon_name (watch->priv->sicon_restart, icon_name);
 		}
 	}
@@ -345,10 +348,10 @@
 	}
 
 	/* libnotify dialog */
-	gpk_smart_icon_notify_new (watch->priv->sicon, _("Task completed"), message,
-				  "help-browser", GPK_NOTIFY_URGENCY_LOW, GPK_NOTIFY_TIMEOUT_SHORT);
-	gpk_smart_icon_notify_button (watch->priv->sicon, GPK_NOTIFY_BUTTON_DO_NOT_SHOW_AGAIN, GPK_CONF_NOTIFY_COMPLETED);
-	gpk_smart_icon_notify_show (watch->priv->sicon);
+	gpk_notify_create (watch->priv->notify, _("Task completed"), message,
+			   "help-browser", GPK_NOTIFY_URGENCY_LOW, GPK_NOTIFY_TIMEOUT_SHORT);
+	gpk_notify_button (watch->priv->notify, GPK_NOTIFY_BUTTON_DO_NOT_SHOW_AGAIN, GPK_CONF_NOTIFY_COMPLETED);
+	gpk_notify_show (watch->priv->notify);
 	g_free (message);
 	g_free (package_id);
 }
@@ -396,10 +399,10 @@
 	/* we need to format this */
 	escaped_details = g_markup_escape_text (details, -1);
 
-	gpk_smart_icon_notify_new (watch->priv->sicon, title, escaped_details, "help-browser",
-				  GPK_NOTIFY_URGENCY_LOW, GPK_NOTIFY_TIMEOUT_LONG);
-	gpk_smart_icon_notify_button (watch->priv->sicon, GPK_NOTIFY_BUTTON_DO_NOT_SHOW_AGAIN, GPK_CONF_NOTIFY_ERROR);
-	gpk_smart_icon_notify_show (watch->priv->sicon);
+	gpk_notify_create (watch->priv->notify, title, escaped_details, "help-browser",
+			   GPK_NOTIFY_URGENCY_LOW, GPK_NOTIFY_TIMEOUT_LONG);
+	gpk_notify_button (watch->priv->notify, GPK_NOTIFY_BUTTON_DO_NOT_SHOW_AGAIN, GPK_CONF_NOTIFY_ERROR);
+	gpk_notify_show (watch->priv->notify);
 	g_free (escaped_details);
 }
 
@@ -429,10 +432,10 @@
 	/* we need to format this */
 	escaped_details = g_markup_escape_text (details, -1);
 
-	gpk_smart_icon_notify_new (watch->priv->sicon, title, escaped_details, filename,
-				  GPK_NOTIFY_URGENCY_LOW, GPK_NOTIFY_TIMEOUT_NEVER);
-	gpk_smart_icon_notify_button (watch->priv->sicon, GPK_NOTIFY_BUTTON_DO_NOT_SHOW_AGAIN, GPK_CONF_NOTIFY_MESSAGE);
-	gpk_smart_icon_notify_show (watch->priv->sicon);
+	gpk_notify_create (watch->priv->notify, title, escaped_details, filename,
+			   GPK_NOTIFY_URGENCY_LOW, GPK_NOTIFY_TIMEOUT_NEVER);
+	gpk_notify_button (watch->priv->notify, GPK_NOTIFY_BUTTON_DO_NOT_SHOW_AGAIN, GPK_CONF_NOTIFY_MESSAGE);
+	gpk_notify_show (watch->priv->notify);
 	g_free (escaped_details);
 }
 
@@ -581,17 +584,6 @@
 }
 
 /**
- * gpk_watch_refresh_cache_finished_cb:
- **/
-static void
-gpk_watch_refresh_cache_finished_cb (PkClient *client, PkExitEnum exit_code, guint runtime, GpkWatch *watch)
-{
-	g_return_if_fail (GPK_IS_WATCH (watch));
-	pk_debug ("unreffing client %p", client);
-	g_object_unref (client);
-}
-
-/**
  * gpk_watch_restart_cb:
  **/
 static void
@@ -608,27 +600,23 @@
 {
 	gboolean ret;
 	GpkWatch *watch = GPK_WATCH (data);
-	PkClient *client;
 	GError *error = NULL;
 	gchar *message;
 
 	g_return_if_fail (GPK_IS_WATCH (watch));
 
 	pk_debug ("refresh cache");
-	client = pk_client_new ();
-	g_signal_connect (client, "finished",
-			  G_CALLBACK (gpk_watch_refresh_cache_finished_cb), watch);
-
-	ret = pk_client_refresh_cache (client, TRUE, NULL);
+	gpk_client_show_finished (watch->priv->gclient, FALSE);
+	gpk_client_show_progress (watch->priv->gclient, FALSE);
+	ret = gpk_client_refresh_cache (watch->priv->gclient, &error);
 	if (!ret) {
-		g_object_unref (client);
 		message = g_strdup_printf (_("The error was: %s"), error->message);
 		pk_warning ("%s", message);
 		g_error_free (error);
-		gpk_smart_icon_notify_new (watch->priv->sicon, _("Failed to refresh cache"), message,
-				      "process-stop", GPK_NOTIFY_URGENCY_LOW, GPK_NOTIFY_TIMEOUT_SHORT);
+		gpk_notify_create (watch->priv->notify, _("Failed to refresh cache"), message,
+				   "process-stop", GPK_NOTIFY_URGENCY_LOW, GPK_NOTIFY_TIMEOUT_SHORT);
 		g_free (message);
-		gpk_smart_icon_notify_show (watch->priv->sicon);
+		gpk_notify_show (watch->priv->notify);
 	}
 }
 
@@ -1045,10 +1033,18 @@
 
 	watch->priv->show_refresh_in_menu = TRUE;
 	watch->priv->gconf_client = gconf_client_get_default ();
+
 	watch->priv->sicon = gpk_smart_icon_new ();
+	gpk_smart_icon_set_priority (watch->priv->sicon, 1);
+
 	watch->priv->sicon_restart = gpk_smart_icon_new ();
+	gpk_smart_icon_set_priority (watch->priv->sicon_restart, 3);
+
 	watch->priv->set_proxy_timeout = 0;
 
+	watch->priv->notify = gpk_notify_new ();
+	watch->priv->gclient = gpk_client_new ();
+
 	/* we need to get ::locked */
 	watch->priv->control = pk_control_new ();
 	g_signal_connect (watch->priv->control, "locked",
@@ -1058,14 +1054,14 @@
 	watch->priv->inhibit = gpk_inhibit_new ();
 
 	/* right click actions are common */
-	status_icon = gpk_smart_icon_get_status_icon (watch->priv->sicon);
+	status_icon = GTK_STATUS_ICON (watch->priv->sicon);
 	g_signal_connect_object (G_OBJECT (status_icon),
 				 "popup_menu", G_CALLBACK (gpk_watch_popup_menu_cb), watch, 0);
 	g_signal_connect_object (G_OBJECT (status_icon),
 				 "activate", G_CALLBACK (gpk_watch_activate_status_cb), watch, 0);
 
 	/* provide the user with a way to restart */
-	status_icon = gpk_smart_icon_get_status_icon (watch->priv->sicon_restart);
+	status_icon = GTK_STATUS_ICON (watch->priv->sicon_restart);
 	g_signal_connect_object (G_OBJECT (status_icon),
 				 "activate", G_CALLBACK (gpk_watch_activate_status_restart_cb), watch, 0);
 
@@ -1091,10 +1087,8 @@
 	pk_action = polkit_action_new ();
 	polkit_action_set_action_id (pk_action, "org.freedesktop.consolekit.system.restart");
 
-	restart_action = polkit_gnome_action_new_default ("restart-system",
-							  pk_action,
-							  _("_Restart computer"),
-							  NULL);
+	restart_action = polkit_gnome_action_new_default ("restart-system", pk_action,
+							  _("_Restart computer"), NULL);
 	g_object_set (restart_action,
 		      "no-icon-name", "gnome-shutdown",
 		      "auth-icon-name", "gnome-shutdown",
@@ -1140,10 +1134,12 @@
 		g_source_remove (watch->priv->set_proxy_timeout);
 	}
 
+	g_object_unref (watch->priv->notify);
 	g_object_unref (watch->priv->sicon);
 	g_object_unref (watch->priv->inhibit);
 	g_object_unref (watch->priv->tlist);
 	g_object_unref (watch->priv->control);
+	g_object_unref (watch->priv->gclient);
 	g_object_unref (watch->priv->pconnection);
 	g_object_unref (watch->priv->gconf_client);
 	g_object_unref (watch->priv->restart_action);



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