gnome-packagekit r523 - in trunk: . data src



Author: rhughes
Date: Wed Mar 25 16:40:34 2009
New Revision: 523
URL: http://svn.gnome.org/viewvc/gnome-packagekit?rev=523&view=rev

Log:
from git

Modified:
   trunk/configure.ac
   trunk/data/gpk-update-icon.desktop.in
   trunk/data/gpk-update-viewer2.glade
   trunk/src/gpk-cell-renderer-info.c
   trunk/src/gpk-check-update.c
   trunk/src/gpk-enum.c
   trunk/src/gpk-smart-icon.c
   trunk/src/gpk-smart-icon.h
   trunk/src/gpk-update-viewer2.c

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac	(original)
+++ trunk/configure.ac	Wed Mar 25 16:40:34 2009
@@ -1,6 +1,6 @@
 AC_PREREQ(2.52)
 
-AC_INIT(gnome-packagekit, 0.4.6)
+AC_INIT(gnome-packagekit, 2.27.1)
 AC_CONFIG_SRCDIR(src)
 AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
 AM_CONFIG_HEADER(config.h)

Modified: trunk/data/gpk-update-icon.desktop.in
==============================================================================
--- trunk/data/gpk-update-icon.desktop.in	(original)
+++ trunk/data/gpk-update-icon.desktop.in	Wed Mar 25 16:40:34 2009
@@ -8,5 +8,5 @@
 Terminal=false
 Type=Application
 Categories=
-NotShowIn=KDE;XFCE;
+NotShowIn=KDE;
 

Modified: trunk/data/gpk-update-viewer2.glade
==============================================================================
--- trunk/data/gpk-update-viewer2.glade	(original)
+++ trunk/data/gpk-update-viewer2.glade	Wed Mar 25 16:40:34 2009
@@ -67,6 +67,7 @@
                       <widget class="GtkLabel" id="label_header_desc">
                         <property name="visible">True</property>
                         <property name="label" translatable="yes">Software updates correct errors, eliminate security vulnerabilities and provide new features.</property>
+                        <property name="wrap">True</property>
                       </widget>
                       <packing>
                         <property name="expand">False</property>
@@ -323,7 +324,7 @@
             <property name="layout_style">end</property>
             <child>
               <widget class="GtkButton" id="button_help">
-                <property name="label" translatable="yes">gtk-help</property>
+                <property name="label">gtk-help</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
@@ -337,10 +338,12 @@
               </packing>
             </child>
             <child>
-              <widget class="GtkButton" id="button_logout">
-                <property name="label" translatable="yes">Log out</property>
+              <widget class="GtkButton" id="button_cancel">
+                <property name="label">gtk-cancel</property>
+                <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
               </widget>
               <packing>
                 <property name="expand">False</property>
@@ -349,20 +352,8 @@
               </packing>
             </child>
             <child>
-              <widget class="GtkButton" id="button_shutdown">
-                <property name="label" translatable="yes">Restart computer</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-              </widget>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">2</property>
-              </packing>
-            </child>
-            <child>
               <widget class="GtkButton" id="button_close">
-                <property name="label" translatable="yes">gtk-close</property>
+                <property name="label">gtk-close</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="has_focus">True</property>
@@ -372,26 +363,12 @@
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">False</property>
-                <property name="position">3</property>
-              </packing>
-            </child>
-            <child>
-              <widget class="GtkButton" id="button_cancel">
-                <property name="label" translatable="yes">gtk-cancel</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_stock">True</property>
-              </widget>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">4</property>
+                <property name="position">2</property>
               </packing>
             </child>
             <child>
               <widget class="GtkButton" id="button_install">
-                <property name="label">_Install update(s)</property>
+                <property name="label">_Install Update(s)</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="has_focus">True</property>
@@ -401,7 +378,7 @@
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">False</property>
-                <property name="position">5</property>
+                <property name="position">3</property>
               </packing>
             </child>
           </widget>

Modified: trunk/src/gpk-cell-renderer-info.c
==============================================================================
--- trunk/src/gpk-cell-renderer-info.c	(original)
+++ trunk/src/gpk-cell-renderer-info.c	Wed Mar 25 16:40:34 2009
@@ -75,8 +75,6 @@
 		cru->priv->value = g_value_get_uint (value);
 		if (cru->priv->value == PK_INFO_ENUM_UNKNOWN) {
 			g_object_set (cru, "visible", FALSE, NULL);
-		} else if (cru->priv->value == PK_INFO_ENUM_FINISHED) {
-			/* ignore */
 		} else {
 			cru->priv->icon_name = gpk_info_enum_to_icon_name (cru->priv->value);
 			g_object_set (cru, "visible", TRUE, NULL);

Modified: trunk/src/gpk-check-update.c
==============================================================================
--- trunk/src/gpk-check-update.c	(original)
+++ trunk/src/gpk-check-update.c	Wed Mar 25 16:40:34 2009
@@ -41,6 +41,7 @@
 
 #include "egg-debug.h"
 #include "egg-string.h"
+#include "egg-dbus-monitor.h"
 
 #include "gpk-common.h"
 #include "gpk-gnome.h"
@@ -56,8 +57,8 @@
 
 /* the maximum number of lines of data on the libnotify widget */
 #define GPK_CHECK_UPDATE_MAX_NUMBER_SECURITY_ENTRIES	7
-#define ACTION_DISTRO_UPGRADE_INFO "distro-upgrade-info"
-#define ACTION_DISTRO_UPGRADE_DO_NOT_SHOW "distro-upgrade-do-not-show-available"
+#define ACTION_DISTRO_UPGRADE_INFO 			"distro-upgrade-info"
+#define ACTION_DISTRO_UPGRADE_DO_NOT_SHOW		"distro-upgrade-do-not-show-available"
 
 struct GpkCheckUpdatePrivate
 {
@@ -77,6 +78,7 @@
 	guint			 number_updates_critical_last_shown;
 	NotifyNotification	*notification_updates_available;
 	GPtrArray		*important_updates_array;
+	EggDbusMonitor		*dbus_monitor_viewer;
 };
 
 G_DEFINE_TYPE (GpkCheckUpdate, gpk_check_update, G_TYPE_OBJECT)
@@ -767,7 +769,6 @@
 	/* work out icon */
 	icon = gpk_check_update_get_best_update_icon (cupdate, list);
 	gpk_smart_icon_set_icon_name (cupdate->priv->sicon, icon);
-	gpk_smart_icon_pulse (cupdate->priv->sicon);
 
 	/* make tooltip */
 	if (status_security->len != 0)
@@ -1060,6 +1061,19 @@
 }
 
 /**
+ * gpk_cupdate_connection_changed_cb:
+ **/
+static void
+gpk_cupdate_connection_changed_cb (EggDbusMonitor *monitor, gboolean connected, GpkCheckUpdate *cupdate)
+{
+	g_return_if_fail (GPK_IS_CHECK_UPDATE (cupdate));
+	if (connected) {
+		egg_debug ("update viewer on the bus, so hiding icon");
+		gpk_smart_icon_set_icon_name (cupdate->priv->sicon, NULL);
+	}
+}
+
+/**
  * gpk_check_update_init:
  * @cupdate: This class instance
  **/
@@ -1094,6 +1108,13 @@
 				 G_CALLBACK (gpk_check_update_activate_update_cb),
 				 cupdate, 0);
 
+	cupdate->priv->dbus_monitor_viewer = egg_dbus_monitor_new ();
+	egg_dbus_monitor_assign (cupdate->priv->dbus_monitor_viewer,
+				 EGG_DBUS_MONITOR_SESSION,
+				 "org.freedesktop.PackageKit.UpdateViewer2");
+	g_signal_connect (cupdate->priv->dbus_monitor_viewer, "connection-changed",
+			  G_CALLBACK (gpk_cupdate_connection_changed_cb), cupdate);
+
 	/* install stuff using the gnome helpers */
 	cupdate->priv->gclient_refresh_cache = gpk_client_new ();
 	cupdate->priv->gclient_update_system = gpk_client_new ();
@@ -1151,6 +1172,7 @@
 	g_object_unref (cupdate->priv->gclient_update_system);
 	g_object_unref (cupdate->priv->gclient_get_updates);
 	g_object_unref (cupdate->priv->gclient_get_distro_upgrades);
+	g_object_unref (cupdate->priv->dbus_monitor_viewer);
 	if (cupdate->priv->important_updates_array != NULL) {
 		g_ptr_array_foreach (cupdate->priv->important_updates_array, (GFunc) g_free, NULL);
 		g_ptr_array_free (cupdate->priv->important_updates_array, TRUE);

Modified: trunk/src/gpk-enum.c
==============================================================================
--- trunk/src/gpk-enum.c	(original)
+++ trunk/src/gpk-enum.c	Wed Mar 25 16:40:34 2009
@@ -657,13 +657,13 @@
 		text = _("No restart is necessary");
 		break;
 	case PK_RESTART_ENUM_APPLICATION:
-		text = _("An application restart is required");
+		text = _("You will be required to restart this application");
 		break;
 	case PK_RESTART_ENUM_SESSION:
 		text = _("You will be required to log out and back in");
 		break;
 	case PK_RESTART_ENUM_SYSTEM:
-		text = _("A restart is required");
+		text = _("A restart will be required");
 		break;
 	default:
 		egg_warning ("restart unrecognised: %i", restart);

Modified: trunk/src/gpk-smart-icon.c
==============================================================================
--- trunk/src/gpk-smart-icon.c	(original)
+++ trunk/src/gpk-smart-icon.c	Wed Mar 25 16:40:34 2009
@@ -1,6 +1,6 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
  *
- * Copyright (C) 2007-2008 Richard Hughes <richard hughsie com>
+ * Copyright (C) 2007-2009 Richard Hughes <richard hughsie com>
  *
  * Licensed under the GNU General Public License Version 2
  *
@@ -52,9 +52,6 @@
 	gchar			*current;
 	gchar			*new;
 	guint			 event_source;
-	guint			 pulse_source;
-	gfloat			 icon_opacity;
-	gboolean		 going_down;
 };
 
 G_DEFINE_TYPE (GpkSmartIcon, gpk_smart_icon, GTK_TYPE_STATUS_ICON)
@@ -72,101 +69,6 @@
 }
 
 /**
- * gpk_smart_icon_set_pixmap_opacity:
- **/
-static gboolean
-gpk_smart_icon_set_pixmap_opacity (GdkPixbuf *pixbuf, gfloat adjust)
-{
-	gint width, height, rowstride, n_channels;
-	guchar *pixels, *p;
-	gint x, y;
-
-	width = gdk_pixbuf_get_width (pixbuf);
-	height = gdk_pixbuf_get_height (pixbuf);
-	rowstride = gdk_pixbuf_get_rowstride (pixbuf);
-	n_channels = gdk_pixbuf_get_n_channels (pixbuf);
-	pixels = gdk_pixbuf_get_pixels (pixbuf);
-
-	/* scale the opacity of each pixel */
-	for (y=0; y<height-1;y++) {
-		for (x=0; x<height-1;x++) {
-			p = pixels + y * rowstride + x * n_channels;
-			p[3] = (gfloat) p[3] * adjust;
-		}
-	}
-	return TRUE;
-}
-
-/**
- * gpk_smart_icon_pulse_timeout_cb:
- **/
-static gboolean
-gpk_smart_icon_pulse_timeout_cb (gpointer data)
-{
-	GpkSmartIcon *sicon = (GpkSmartIcon *) data;
-	GdkPixbuf *pixbuf;
-	GdkRectangle area;
-
-	g_return_val_if_fail (GPK_IS_SMART_ICON (sicon), FALSE);
-
-	/* debug so we can catch polling */
-	egg_debug ("polling check");
-
-	/* have we hidden the icon already? */
-	if (sicon->priv->current == NULL || sicon->priv->new == NULL) {
-		egg_debug ("not pulsing as icon cleared");
-		return FALSE;
-	}
-
-	/* get pixmap the same size as the original icon */
-	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), pixbuf);
-	g_object_unref (pixbuf);
-
-	/* dimming down */
-	if (sicon->priv->going_down) {
-		sicon->priv->icon_opacity -= 0.1;
-		if (sicon->priv->icon_opacity<0) {
-			sicon->priv->icon_opacity = 0;
-			sicon->priv->going_down = FALSE;
-		}
-		return TRUE;
-	}
-
-	/* dimming up */
-	sicon->priv->icon_opacity += 0.1;
-	if (sicon->priv->icon_opacity>1) {
-		/* restore */
-		gtk_status_icon_set_from_icon_name (GTK_STATUS_ICON (sicon), sicon->priv->current);
-		sicon->priv->pulse_source = 0;
-		return FALSE;
-	}
-	return TRUE;
-}
-
-/**
- * gpk_smart_icon_pulse:
- **/
-gboolean
-gpk_smart_icon_pulse (GpkSmartIcon *sicon)
-{
-	g_return_val_if_fail (GPK_IS_SMART_ICON (sicon), FALSE);
-
-	sicon->priv->icon_opacity = 0.9;
-	sicon->priv->going_down = TRUE;
-	if (sicon->priv->pulse_source != 0) {
-		egg_debug ("already pulsing");
-		return FALSE;
-	}
-	sicon->priv->pulse_source = g_timeout_add (20, gpk_smart_icon_pulse_timeout_cb, sicon);
-	return TRUE;
-}
-
-/**
  * gpk_smart_icon_set_icon_name_cb:
  **/
 static gboolean
@@ -174,23 +76,16 @@
 {
 	GpkSmartIcon *sicon = (GpkSmartIcon *) data;
 
-	/* debug so we can catch polling */
-	egg_debug ("polling check");
-
 	/* no point setting the same */
-	if (sicon->priv->new != NULL &&
-	    sicon->priv->current != NULL &&
-	    strcmp (sicon->priv->new, sicon->priv->current) == 0) {
-		return FALSE;
-	}
-	if (sicon->priv->new == NULL &&
-	    sicon->priv->current == NULL) {
+	if (g_strcmp0 (sicon->priv->new, sicon->priv->current) == 0) {
+		egg_debug ("setting the same: %s", sicon->priv->new);
 		return FALSE;
 	}
 
-	/* save what we have */
+	/* save new version of what we have */
 	g_free (sicon->priv->current);
 	sicon->priv->current = g_strdup (sicon->priv->new);
+	egg_debug ("setting new: %s", sicon->priv->new);
 
 	/* set the correct thing */
 	if (sicon->priv->new == NULL) {
@@ -215,6 +110,7 @@
 		g_source_remove (sicon->priv->event_source);
 		sicon->priv->event_source = 0;
 	}
+
 	/* tell us what we -want- */
 	g_free (sicon->priv->new);
 	egg_debug ("setting icon name %s", icon_name);
@@ -232,7 +128,6 @@
 gpk_smart_icon_set_priority (GpkSmartIcon *sicon, guint number)
 {
 	g_return_val_if_fail (GPK_IS_SMART_ICON (sicon), FALSE);
-
 	egg_debug ("set priority %i", number);
 	return TRUE;
 }
@@ -248,7 +143,6 @@
 	sicon->priv->new = NULL;
 	sicon->priv->current = NULL;
 	sicon->priv->event_source = 0;
-	sicon->priv->pulse_source = 0;
 	gtk_status_icon_set_visible (GTK_STATUS_ICON (sicon), FALSE);
 }
 
@@ -266,13 +160,9 @@
 	sicon = GPK_SMART_ICON (object);
 	g_return_if_fail (sicon->priv != NULL);
 
-	/* remove any timers that may be firing */
-	if (sicon->priv->event_source != 0) {
+	/* remove any timers that may be pending */
+	if (sicon->priv->event_source != 0)
 		g_source_remove (sicon->priv->event_source);
-	}
-	if (sicon->priv->pulse_source != 0) {
-		g_source_remove (sicon->priv->pulse_source);
-	}
 
 	g_free (sicon->priv->new);
 	g_free (sicon->priv->current);

Modified: trunk/src/gpk-smart-icon.h
==============================================================================
--- trunk/src/gpk-smart-icon.h	(original)
+++ trunk/src/gpk-smart-icon.h	Wed Mar 25 16:40:34 2009
@@ -1,6 +1,6 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
  *
- * Copyright (C) 2007-2008 Richard Hughes <richard hughsie com>
+ * Copyright (C) 2007-2009 Richard Hughes <richard hughsie com>
  *
  * Licensed under the GNU General Public License Version 2
  *
@@ -51,7 +51,6 @@
 
 GType		 gpk_smart_icon_get_type		(void);
 GpkSmartIcon	*gpk_smart_icon_new			(void);
-gboolean	 gpk_smart_icon_pulse			(GpkSmartIcon		*sicon);
 gboolean	 gpk_smart_icon_set_icon_name		(GpkSmartIcon		*sicon,
 							 const gchar		*icon_name);
 

Modified: trunk/src/gpk-update-viewer2.c
==============================================================================
--- trunk/src/gpk-update-viewer2.c	(original)
+++ trunk/src/gpk-update-viewer2.c	Wed Mar 25 16:40:34 2009
@@ -52,7 +52,8 @@
 #include "gpk-helper-repo-signature.h"
 #include "gpk-helper-eula.h"
 
-#define GPK_UPDATE_VIEWER_AUTO_SHUTDOWN_TIMEOUT 10 /* seconds */
+#define GPK_UPDATE_VIEWER_AUTO_CLOSE_TIMEOUT	10 /* seconds */
+#define GPK_UPDATE_VIEWER_AUTO_RESTART_TIMEOUT	60 /* seconds */
 #define GNOME_SESSION_MANAGER_SERVICE		"org.gnome.SessionManager"
 #define GNOME_SESSION_MANAGER_PATH		"/org/gnome/SessionManager"
 #define GNOME_SESSION_MANAGER_INTERFACE		"org.gnome.SessionManager"
@@ -71,6 +72,7 @@
 static EggMarkdown *markdown = NULL;
 static PkPackageId *package_id_last = NULL;
 static PkRestartEnum restart_update = PK_RESTART_ENUM_NONE;
+static gboolean running_hidden = FALSE;
 
 enum {
 	GPK_UPDATES_COLUMN_TEXT,
@@ -91,10 +93,10 @@
 static gboolean gpk_update_viewer_get_new_update_list (void);
 
 /**
- * gpk_update_viewer_button_logout_cb:
+ * gpk_update_viewer_logout:
  **/
 static void
-gpk_update_viewer_button_logout_cb (GtkWidget *widget, gpointer data)
+gpk_update_viewer_logout (void)
 {
 	DBusGConnection *connection;
 	DBusGProxy *proxy;
@@ -124,10 +126,10 @@
 }
 
 /**
- * gpk_update_viewer_button_shutdown_cb:
+ * gpk_update_viewer_shutdown:
  **/
 static void
-gpk_update_viewer_button_shutdown_cb (GtkWidget *widget, gpointer data)
+gpk_update_viewer_shutdown (void)
 {
 	EggConsoleKit *console;
 	GError *error = NULL;
@@ -206,6 +208,10 @@
 	GPtrArray *array;
 	gchar **package_ids = NULL;
 
+	/* hide the upgrade viewbox from now on */
+	widget = glade_xml_get_widget (glade_xml, "viewport_upgrade");
+	gtk_widget_hide (widget);
+
 	egg_debug ("Doing the package updates");
 	array = g_ptr_array_new ();
 
@@ -318,6 +324,41 @@
 static gboolean
 gpk_update_viewer_button_delete_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data)
 {
+	gboolean ret;
+	GError *error = NULL;
+	PkRoleEnum role;
+	PkStatusEnum status;
+
+	/* if we are in a transaction, don't quit, just hide, as we want to return
+	 * to this state if the dialog is run again */
+	ret = pk_client_get_role (client_primary, &role, NULL, &error);
+	if (!ret) {
+		egg_warning ("failed to get role: %s", error->message);
+		g_error_free (error);
+		goto out;
+	}
+	if (role == PK_ROLE_ENUM_UNKNOWN) {
+		egg_debug ("no role, so quitting");
+		goto out;
+	}
+	ret = pk_client_get_status (client_primary, &status, &error);
+	if (!ret) {
+		egg_warning ("failed to get status: %s", error->message);
+		g_error_free (error);
+		goto out;
+	}
+	if (status == PK_STATUS_ENUM_FINISHED) {
+		egg_debug ("status is finished, so quitting");
+		goto out;
+	}
+
+	/* hide window */
+	egg_debug ("hiding to preserve state");
+	running_hidden = TRUE;
+	widget = glade_xml_get_widget (glade_xml, "dialog_updates");
+	gtk_widget_hide (widget);
+	return TRUE;
+out:
 	g_main_loop_quit (loop);
 	return FALSE;
 }
@@ -450,8 +491,10 @@
 		}
 
 		gtk_tree_model_get_iter (model, &iter, path);
-		gtk_list_store_set (list_store_updates, &iter,
-				    GPK_UPDATES_COLUMN_STATUS, obj->info, -1);
+		if (obj->info != PK_INFO_ENUM_FINISHED) {
+			gtk_list_store_set (list_store_updates, &iter,
+					    GPK_UPDATES_COLUMN_STATUS, obj->info, -1);
+		}
 		gtk_tree_path_free (path);
 
 		/* set package description */
@@ -538,9 +581,10 @@
  * gpk_update_viewer_auto_shutdown:
  **/
 static gboolean
-gpk_update_viewer_auto_shutdown (void)
+gpk_update_viewer_auto_shutdown (GtkDialog *dialog)
 {
-	g_main_loop_quit (loop);
+	gtk_dialog_response (dialog, GTK_RESPONSE_CANCEL);
+	auto_shutdown_id = 0;
 	return FALSE;
 }
 
@@ -553,6 +597,7 @@
 	GtkTreeIter iter;
 	GtkWidget *widget;
 	GtkWidget *main_window;
+	GtkWidget *dialog;
 	gboolean valid;
 	gboolean selected;
 	gboolean any_selected = FALSE;
@@ -598,78 +643,42 @@
 	/* set the pluralisation of the button */
 	widget = glade_xml_get_widget (glade_xml, "button_install");
 	/* TRANSLATORS: this is the button text when we have updates */
-	title = ngettext ("_Install update", "_Install updates", number_total);
+	title = ngettext ("_Install Update", "_Install Updates", number_total);
 	gtk_button_set_label (GTK_BUTTON (widget), title);
 
 	/* no updates */
 	len = PK_OBJ_LIST(update_list)->len;
 	if (len == 0) {
-		widget = glade_xml_get_widget (glade_xml, "vpaned_updates");
-		gtk_widget_hide (widget);
-		widget = glade_xml_get_widget (glade_xml, "dialog_updates");
-		gtk_window_set_resizable (GTK_WINDOW(widget), FALSE);
-
-		/* use correct status pane */
-		widget = glade_xml_get_widget (glade_xml, "hbox_status");
+		/* hide close button */
+		widget = glade_xml_get_widget (glade_xml, "button_close");
 		gtk_widget_hide (widget);
-		widget = glade_xml_get_widget (glade_xml, "hbox_info");
-		gtk_widget_show (widget);
 
-		/* set state */
-		widget = glade_xml_get_widget (glade_xml, "image_info");
-		gtk_image_set_from_icon_name (GTK_IMAGE (widget), "dialog-information", GTK_ICON_SIZE_DIALOG);
-		gtk_widget_show (widget);
-
-		widget = glade_xml_get_widget (glade_xml, "label_info");
-		/* TRANSLATORS: there are no updates */
-		text = g_strdup_printf ("<b>%s</b>", _("There are no updates available for your computer"));
-		gtk_label_set_label (GTK_LABEL (widget), text);
-		g_free (text);
-		gtk_widget_show (widget);
-		widget = glade_xml_get_widget (glade_xml, "label_summary");
-		gtk_widget_hide (widget);
+		/* show modal dialog */
+		widget = glade_xml_get_widget (glade_xml, "dialog_updates");
+		dialog = gtk_message_dialog_new (GTK_WINDOW (widget), GTK_DIALOG_MODAL,
+						 GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE,
+						 /* TRANSLATORS: title: warn the user they are quitting with unapplied changes */
+						 "%s", _("No updates available"));
+		gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG(dialog),
+							  "%s",
+							  /* TRANSLATORS: tell the user the problem */
+							  _("There are no updates available for your computer at this time."));
+		gtk_window_set_icon_name (GTK_WINDOW(dialog), GPK_ICON_SOFTWARE_INSTALLER);
 
-		/* close button */
-		widget = glade_xml_get_widget (glade_xml, "button_close");
-		gtk_window_set_focus (GTK_WINDOW(main_window), widget);
+		/* setup a callback so we autoclose */
+		auto_shutdown_id = g_timeout_add_seconds (GPK_UPDATE_VIEWER_AUTO_RESTART_TIMEOUT, (GSourceFunc) gpk_update_viewer_auto_shutdown, dialog);
 
-		/* header */
-		widget = glade_xml_get_widget (glade_xml, "hbox_header");
-		gtk_widget_hide (widget);
+		gtk_dialog_run (GTK_DIALOG(dialog));
+		gtk_widget_destroy (dialog);
 
-		widget = glade_xml_get_widget (glade_xml, "button_help");
-		gtk_widget_hide (widget);
-		widget = glade_xml_get_widget (glade_xml, "button_install");
-		gtk_widget_hide (widget);
-		widget = glade_xml_get_widget (glade_xml, "label_status");
-		gtk_widget_hide (widget);
-		widget = glade_xml_get_widget (glade_xml, "label_package");
-		gtk_widget_hide (widget);
-
-		/* do we have to show any widgets? */
-		if (restart_update == PK_RESTART_ENUM_SYSTEM) {
-			widget = glade_xml_get_widget (glade_xml, "button_shutdown");
-			gtk_widget_show (widget);
-		} else if (restart_update == PK_RESTART_ENUM_SESSION) {
-			widget = glade_xml_get_widget (glade_xml, "button_logout");
-			gtk_widget_show (widget);
-		} else {
-			/* setup a callback so we autoclose */
-			auto_shutdown_id = g_timeout_add_seconds (GPK_UPDATE_VIEWER_AUTO_SHUTDOWN_TIMEOUT, (GSourceFunc) gpk_update_viewer_auto_shutdown, NULL);
-		}
+		/* exit the program */
+		g_main_loop_quit (loop);
 		goto out;
 	}
 
-	/* details */
-	widget = glade_xml_get_widget (glade_xml, "vpaned_updates");
-	gtk_widget_show (widget);
-	widget = glade_xml_get_widget (glade_xml, "dialog_updates");
-	gtk_window_set_resizable (GTK_WINDOW(widget), TRUE);
+	/* focus on install button */
 	widget = glade_xml_get_widget (glade_xml, "button_install");
-	gtk_widget_show (widget);
 	gtk_window_set_focus (GTK_WINDOW(main_window), widget);
-	widget = glade_xml_get_widget (glade_xml, "button_help");
-	gtk_widget_show (widget);
 
 	/* use correct status pane */
 	widget = glade_xml_get_widget (glade_xml, "hbox_status");
@@ -827,6 +836,76 @@
 }
 
 /**
+ * gpk_update_viewer_treeview_query_tooltip_cb:
+ */
+static gboolean
+gpk_update_viewer_treeview_query_tooltip_cb (GtkWidget *widget, gint x, gint y, gboolean keyboard, GtkTooltip *tooltip, gpointer user_data)
+{
+	gboolean ret;
+	GtkTreePath *path = NULL;
+	GtkTreeViewColumn *column;
+	GtkTreeIter iter;
+	GtkTreeModel *model;
+	PkInfoEnum info;
+	PkRestartEnum restart;
+	gint bin_x, bin_y, cell_x, cell_y, col_id;
+	const gchar *text = NULL;
+
+	/* get path */
+	model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget));
+	gtk_tree_view_convert_widget_to_bin_window_coords (GTK_TREE_VIEW (widget), x, y, &bin_x, &bin_y);
+	ret = gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget), bin_x, bin_y, &path, &column, &cell_x, &cell_y);
+
+	/* did not get path */
+	if (!ret || column == NULL || path == NULL)
+		goto out;
+
+	/* get iter at path */
+	gtk_tree_model_get_iter (model, &iter, path);
+
+	/* Find out what column we are over */
+	col_id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (column), "tooltip-id"));
+	switch (col_id) {
+	case GPK_UPDATES_COLUMN_INFO:
+		gtk_tree_model_get (model, &iter, GPK_UPDATES_COLUMN_INFO, &info, -1);
+		text = gpk_info_enum_to_localised_text (info);
+		break;
+	case GPK_UPDATES_COLUMN_RESTART:
+		gtk_tree_model_get (model, &iter, GPK_UPDATES_COLUMN_RESTART, &restart, -1);
+		if (restart == PK_RESTART_ENUM_NONE) {
+			ret = FALSE;
+			break;
+		}
+		text = gpk_restart_enum_to_localised_text_future (restart);
+		break;
+	case GPK_UPDATES_COLUMN_STATUS:
+		gtk_tree_model_get (model, &iter, GPK_UPDATES_COLUMN_STATUS, &info, -1);
+		if (info == PK_INFO_ENUM_UNKNOWN) {
+			ret = FALSE;
+			break;
+		}
+		text = gpk_info_enum_to_localised_past (info);
+		break;
+	default:
+		/* ignore */
+		ret = FALSE;
+		break;
+	}
+
+	/* set tooltip */
+	if (text != NULL) {
+		gtk_tooltip_set_text (tooltip, text);
+		gtk_tree_view_set_tooltip_cell (GTK_TREE_VIEW (widget), tooltip, path, column, NULL);
+	}
+out:
+	if (path != NULL)
+		gtk_tree_path_free(path);
+	return ret;
+}
+
+
+
+/**
  * gpk_update_viewer_treeview_add_columns_update:
  **/
 static void
@@ -843,6 +922,7 @@
 							   "value", GPK_UPDATES_COLUMN_RESTART, NULL);
 	gtk_tree_view_column_set_expand (GTK_TREE_VIEW_COLUMN (column), FALSE);
 	gtk_tree_view_append_column (treeview, column);
+	g_object_set_data (G_OBJECT (column), "tooltip-id", GINT_TO_POINTER (GPK_UPDATES_COLUMN_RESTART));
 
 	/* --- column for image and toggle --- */
 	column = gtk_tree_view_column_new ();
@@ -867,6 +947,7 @@
 	gtk_tree_view_column_add_attribute (column, renderer, "sensitive", GPK_UPDATES_COLUMN_SENSITIVE);
 
 	gtk_tree_view_append_column (treeview, column);
+	g_object_set_data (G_OBJECT (column), "tooltip-id", GINT_TO_POINTER (GPK_UPDATES_COLUMN_INFO));
 
 	/* column for text */
 	renderer = gtk_cell_renderer_text_new ();
@@ -902,7 +983,7 @@
 	gtk_tree_view_column_set_expand (GTK_TREE_VIEW_COLUMN (column), FALSE);
 	gtk_tree_view_column_set_sort_column_id (column, GPK_UPDATES_COLUMN_STATUS);
 
-	/* info */
+	/* status */
 	renderer = gpk_cell_renderer_info_new ();
 	g_object_set (renderer, "stock-size", GTK_ICON_SIZE_BUTTON, NULL);
 	gtk_tree_view_column_pack_start (column, renderer, FALSE);
@@ -915,6 +996,11 @@
 	gtk_tree_view_column_set_expand (GTK_TREE_VIEW_COLUMN (column), FALSE);
 
 	gtk_tree_view_append_column (treeview, column);
+	g_object_set_data (G_OBJECT (column), "tooltip-id", GINT_TO_POINTER (GPK_UPDATES_COLUMN_STATUS));
+
+	/* tooltips */
+	g_signal_connect (treeview, "query-tooltip", G_CALLBACK (gpk_update_viewer_treeview_query_tooltip_cb), NULL);
+	g_object_set (treeview, "has-tooltip", TRUE, NULL);
 }
 
 /**
@@ -1303,6 +1389,69 @@
 }
 
 /**
+ * gpk_update_viewer_check_restart:
+ **/
+static gboolean
+gpk_update_viewer_check_restart (PkRestartEnum restart)
+{
+	GtkWidget *widget;
+	GtkWidget *dialog;
+	gboolean ret = FALSE;
+	const gchar *title;
+	const gchar *message;
+	const gchar *button;
+	GtkResponseType response;
+
+	if (restart != PK_RESTART_ENUM_SYSTEM &&
+	    restart != PK_RESTART_ENUM_SESSION)
+		goto out;
+
+	/* get the text */
+	title = gpk_restart_enum_to_localised_text (restart);
+	if (restart == PK_RESTART_ENUM_SYSTEM) {
+		/* TRANSLATORS: the message text for the restart */
+		message = _("Some of the updates that were installed require the computer to be restarted before the changes will be applied.");
+		/* TRANSLATORS: the button text for the restart */
+		button = _("Restart Computer");
+	} else {
+		/* TRANSLATORS: the message text for the logout */
+		message = _("Some of the updates that were installed require you to log off and back on before the changes will be applied.");
+		/* TRANSLATORS: the button text for the logout */
+		button = _("Log Out");
+	}
+
+	/* show modal dialog */
+	widget = glade_xml_get_widget (glade_xml, "dialog_updates");
+	dialog = gtk_message_dialog_new (GTK_WINDOW (widget), GTK_DIALOG_MODAL,
+					 GTK_MESSAGE_INFO, GTK_BUTTONS_CANCEL,
+					 "%s", title);
+	gtk_dialog_add_button (GTK_DIALOG (dialog), button, GTK_RESPONSE_OK);
+	gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG(dialog), "%s", message);
+	gtk_window_set_icon_name (GTK_WINDOW(dialog), GPK_ICON_SOFTWARE_INSTALLER);
+
+	/* setup a callback so we autoclose */
+	auto_shutdown_id = g_timeout_add_seconds (GPK_UPDATE_VIEWER_AUTO_RESTART_TIMEOUT, (GSourceFunc) gpk_update_viewer_auto_shutdown, dialog);
+
+	response = gtk_dialog_run (GTK_DIALOG(dialog));
+	gtk_widget_destroy (dialog);
+
+	/* cancel */
+	if (response != GTK_RESPONSE_OK)
+		goto out;
+
+	/* doing the action, return success */
+	ret = TRUE;
+
+	/* do the action */
+	if (restart == PK_RESTART_ENUM_SYSTEM)
+		gpk_update_viewer_shutdown ();
+	else if (restart == PK_RESTART_ENUM_SESSION)
+		gpk_update_viewer_logout ();
+out:
+	return ret;
+}
+
+/**
  * gpk_update_viewer_finished_cb:
  **/
 static void
@@ -1326,6 +1475,12 @@
 	widget = glade_xml_get_widget (glade_xml, "progressbar_progress");
 	gtk_widget_hide (widget);
 
+	/* hidden window, so quit at this point */
+	if (running_hidden) {
+		egg_debug ("transaction finished whilst hidden, so exit");
+		g_main_loop_quit (loop);
+	}
+
 	/* if secondary, ignore */
 	if (client == client_primary &&
 	    (exit == PK_EXIT_ENUM_KEY_REQUIRED ||
@@ -1416,6 +1571,9 @@
 		gpk_update_viewer_check_blocked_packages (list);
 		g_object_unref (list);
 
+		/* check restart */
+		gpk_update_viewer_check_restart (restart_update);
+
 		/* refresh list */
 		gpk_update_viewer_get_new_update_list ();
 	}
@@ -1509,7 +1667,7 @@
 	gboolean valid;
 	GtkTreeIter iter;
 	GtkTreeModel *model;
-	PkStatusEnum info;
+	PkInfoEnum info;
 
 	/* get the first iter in the list */
 	model = gtk_tree_view_get_model (treeview);
@@ -1527,6 +1685,34 @@
 }
 
 /**
+ * gpk_update_viewer_detail_popup_menu_select_security:
+ **/
+static void
+gpk_update_viewer_detail_popup_menu_select_security (GtkWidget *menuitem, gpointer userdata)
+{
+	GtkTreeView *treeview = GTK_TREE_VIEW (userdata);
+	gboolean valid;
+	gboolean ret;
+	GtkTreeIter iter;
+	GtkTreeModel *model;
+	PkInfoEnum info;
+
+	/* get the first iter in the list */
+	model = gtk_tree_view_get_model (treeview);
+	valid = gtk_tree_model_get_iter_first (model, &iter);
+	while (valid) {
+		gtk_tree_model_get (model, &iter, GPK_UPDATES_COLUMN_INFO, &info, -1);
+		ret = (info == PK_INFO_ENUM_SECURITY);
+		gtk_list_store_set (GTK_LIST_STORE (model), &iter,
+				    GPK_UPDATES_COLUMN_SELECT, ret, -1);
+		valid = gtk_tree_model_iter_next (model, &iter);
+	}
+
+	/* if there are no entries selected, deselect the button */
+	gpk_update_viewer_reconsider_info (model);
+}
+
+/**
  * gpk_update_viewer_detail_popup_menu_select_none:
  **/
 static void
@@ -1620,6 +1806,12 @@
 		gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
 	}
 
+	/* TRANSLATORS: right click menu, select only security updates */
+	menuitem = gtk_menu_item_new_with_label (_("Select security updates"));
+	g_signal_connect (menuitem, "activate",
+			  G_CALLBACK (gpk_update_viewer_detail_popup_menu_select_security), treeview);
+	gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
+
 	/* TRANSLATORS: right click option, ignore this update name, not currently used */
 	menuitem = gtk_menu_item_new_with_label (_("Ignore this update"));
 	gtk_widget_set_sensitive (GTK_WIDGET (menuitem), FALSE);
@@ -1687,6 +1879,9 @@
 	GtkWidget *widget;
 	widget = glade_xml_get_widget (glade_xml, "dialog_updates");
 	gtk_window_present (GTK_WINDOW (widget));
+
+	/* not hidden anymore */
+	running_hidden = FALSE;
 }
 
 /**
@@ -2036,6 +2231,19 @@
 }
 
 /**
+ * gpk_update_viewer_vpaned_realized_cb:
+ **/
+static void
+gpk_update_viewer_vpaned_realized_cb (GtkWidget *widget, gpointer data)
+{
+	GtkRequisition req;
+	gtk_widget_size_request (widget, &req);
+	egg_debug ("req.height=%i", req.height);
+	if (req.height != 0)
+		gtk_paned_set_position (GTK_PANED (widget), 166);
+}
+
+/**
  * main:
  **/
 int
@@ -2047,7 +2255,6 @@
 	GtkWidget *main_window;
 	GtkWidget *widget;
 	GtkTreeSelection *selection;
-	GtkRequisition req;
 	PkBitfield roles;
 	gboolean ret;
 	GError *error = NULL;
@@ -2194,7 +2401,6 @@
 
 	/* updates */
 	widget = glade_xml_get_widget (glade_xml, "treeview_updates");
-	gtk_widget_set_size_request (GTK_WIDGET (widget), 750, 300);
 	gtk_tree_view_columns_autosize (GTK_TREE_VIEW (widget));
 	gtk_tree_view_set_model (GTK_TREE_VIEW (widget),
 				 GTK_TREE_MODEL (list_store_updates));
@@ -2221,16 +2427,6 @@
 	g_signal_connect (widget, "clicked",
 			  G_CALLBACK (gpk_update_viewer_button_help_cb), (gpointer) "update-viewer");
 
-	/* shutdown button */
-	widget = glade_xml_get_widget (glade_xml, "button_shutdown");
-	g_signal_connect (widget, "clicked",
-			  G_CALLBACK (gpk_update_viewer_button_shutdown_cb), NULL);
-
-	/* logout button */
-	widget = glade_xml_get_widget (glade_xml, "button_logout");
-	g_signal_connect (widget, "clicked",
-			  G_CALLBACK (gpk_update_viewer_button_logout_cb), NULL);
-
 	/* set install button insensitive */
 	widget = glade_xml_get_widget (glade_xml, "button_install");
 	gtk_widget_set_sensitive (widget, FALSE);
@@ -2260,15 +2456,14 @@
 	g_signal_connect (widget, "clicked",
 			  G_CALLBACK (gpk_update_viewer_button_upgrade_cb), NULL);
 
-	/* show window */
-	gtk_widget_show (main_window);
-
-	/* set the paned to be in the middle */
-	widget = glade_xml_get_widget (glade_xml, "vpaned_updates");
-	gtk_widget_size_request (widget, &req);
-	egg_debug ("req.height=%i", req.height);
-	if (req.height != 0)
-		gtk_paned_set_position (GTK_PANED (widget), req.height / 2);
+	/* set a size, if the screen allows */
+	ret = gpk_window_set_size_request (GTK_WINDOW (main_window), 700, 600);
+	if (!ret) {
+		egg_debug ("small form factor mode");
+		/* hide the header in SFF mode */
+		widget = glade_xml_get_widget (glade_xml, "hbox_header");
+		gtk_widget_hide (widget);
+	}
 
 	/* use correct status pane */
 	widget = glade_xml_get_widget (glade_xml, "label_status");
@@ -2276,6 +2471,14 @@
 	widget = glade_xml_get_widget (glade_xml, "label_info");
 	gtk_widget_set_size_request (widget, -1, 32);
 
+	/* show window */
+	gtk_widget_show (main_window);
+
+	/* set the paned to be in the middle */
+	widget = glade_xml_get_widget (glade_xml, "vpaned_updates");
+	g_signal_connect (widget, "realize",
+			  G_CALLBACK (gpk_update_viewer_vpaned_realized_cb), NULL);
+
 	/* coldplug */
 	gpk_update_viewer_get_new_update_list ();
 



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