gnome-packagekit r92 - trunk/src



Author: rhughes
Date: Mon Feb  4 07:49:03 2008
New Revision: 92
URL: http://svn.gnome.org/viewvc/gnome-packagekit?rev=92&view=rev

Log:
from git

Modified:
   trunk/src/pk-application.c
   trunk/src/pk-common-gui.c
   trunk/src/pk-common-gui.h
   trunk/src/pk-update-viewer.c

Modified: trunk/src/pk-application.c
==============================================================================
--- trunk/src/pk-application.c	(original)
+++ trunk/src/pk-application.c	Mon Feb  4 07:49:03 2008
@@ -36,6 +36,7 @@
 #include <pk-package-id.h>
 #include <pk-enum-list.h>
 #include <pk-extra.h>
+#include <pk-extra-obj.h>
 
 #include "pk-statusbar.h"
 #include "pk-common-gui.h"
@@ -420,46 +421,16 @@
 }
 
 /**
- * pk_application_icon_valid:
- *
- * Check icon actually exists and is valid in this theme
- **/
-static gboolean
-pk_application_icon_valid (PkApplication *application, const gchar *icon)
-{
-	GtkIconInfo *icon_info;
-	GtkIconTheme *icon_theme;
-	gboolean ret = TRUE;
-
-	/* no unref */
-	icon_theme = gtk_icon_theme_get_default ();
-
-	/* default to 32x32 */
-	icon_info = gtk_icon_theme_lookup_icon (icon_theme, icon, 32, GTK_ICON_LOOKUP_USE_BUILTIN);
-	if (icon_info == NULL) {
-		pk_debug ("ignoring broken icon %s", icon);
-		ret = FALSE;
-	} else {
-		/* we only used this to see if it was valid */
-		gtk_icon_info_free (icon_info);
-	}
-	return ret;
-}
-
-/**
  * pk_application_package_cb:
  **/
 static void
 pk_application_package_cb (PkClient *client, PkInfoEnum info, const gchar *package_id,
 			   const gchar *summary, PkApplication *application)
 {
-	PkPackageId *ident;
 	GtkTreeIter iter;
-	PkPackageId *pid;
-	gchar *icon = NULL;
-	gchar *comment = NULL;
+	PkExtraObj *eobj;
+	gboolean valid = FALSE;
 	gchar *text;
-	gboolean valid;
 
 	g_return_if_fail (application != NULL);
 	g_return_if_fail (PK_IS_APPLICATION (application));
@@ -471,52 +442,31 @@
 		return;
 	}
 
-	/* split by delimeter */
-	ident = pk_package_id_new_from_string (package_id);
-
-	/* get the package name */
-	pid = pk_package_id_new_from_string (package_id);
-	if (pid == NULL) {
-		pk_error ("cannot allocate package id");
-		return;
-	}
-
-	/* get from extra database */
-	pk_debug ("getting localised for %s", pid->name);
-	pk_extra_get_localised_detail (application->priv->extra, pid->name, NULL, NULL, &comment);
-	pk_extra_get_package_detail (application->priv->extra, pid->name, &icon, NULL);
-
-	pk_package_id_free (pid);
-
-	/* nothing in the localised database */
-	if (comment == NULL) {
-		comment = g_strdup (summary);
-	}
+	/* get convenience object */
+	eobj = pk_extra_obj_new_from_package_id_summary (package_id, summary);
 
 	/* check icon actually exists and is valid in this theme */
-	valid = FALSE;
-	if (icon != NULL) {
-		valid = pk_application_icon_valid (application, icon);
-	}
+	valid = pk_icon_valid (eobj->icon);
 
 	/* nothing in the detail database or invalid */
 	if (valid == FALSE) {
-		icon = g_strdup (pk_info_enum_to_icon_name (info));
+		g_free (eobj->icon);
+		eobj->icon = g_strdup (pk_info_enum_to_icon_name (info));
 	}
 
-	text = g_markup_printf_escaped ("<b>%s-%s (%s)</b>\n%s", ident->name, ident->version, ident->arch, comment);
+	text = g_markup_printf_escaped ("<b>%s-%s (%s)</b>\n%s", eobj->id->name,
+					eobj->id->version, eobj->id->arch, eobj->summary);
 
 	gtk_list_store_append (application->priv->packages_store, &iter);
 	gtk_list_store_set (application->priv->packages_store, &iter,
 			    PACKAGES_COLUMN_INSTALLED, (info == PK_INFO_ENUM_INSTALLED),
 			    PACKAGES_COLUMN_TEXT, text,
 			    PACKAGES_COLUMN_ID, package_id,
-			    PACKAGES_COLUMN_IMAGE, icon,
+			    PACKAGES_COLUMN_IMAGE, eobj->icon,
 			    -1);
-	pk_package_id_free (ident);
+
+	pk_extra_obj_free (eobj);
 	g_free (text);
-	g_free (icon);
-	g_free (comment);
 }
 
 /**
@@ -1260,6 +1210,7 @@
 	g_signal_connect (application->priv->pconnection, "connection-changed",
 			  G_CALLBACK (pk_connection_changed_cb), application);
 
+	/* single instance, so this is valid */
 	application->priv->extra = pk_extra_new ();
 	pk_extra_set_database (application->priv->extra, "/var/lib/PackageKit/extra-data.db");
 	pk_extra_set_locale (application->priv->extra, "en_GB");

Modified: trunk/src/pk-common-gui.c
==============================================================================
--- trunk/src/pk-common-gui.c	(original)
+++ trunk/src/pk-common-gui.c	Mon Feb  4 07:49:03 2008
@@ -322,6 +322,38 @@
 }
 
 /**
+ * pk_icon_valid:
+ *
+ * Check icon actually exists and is valid in this theme
+ **/
+gboolean
+pk_icon_valid (const gchar *icon)
+{
+	GtkIconInfo *icon_info;
+	GtkIconTheme *icon_theme;
+	gboolean ret = TRUE;
+
+	/* trivial case */
+	if (pk_strzero (icon) == TRUE) {
+		return FALSE;
+	}
+
+	/* no unref */
+	icon_theme = gtk_icon_theme_get_default ();
+
+	/* default to 32x32 */
+	icon_info = gtk_icon_theme_lookup_icon (icon_theme, icon, 32, GTK_ICON_LOOKUP_USE_BUILTIN);
+	if (icon_info == NULL) {
+		pk_debug ("ignoring broken icon %s", icon);
+		ret = FALSE;
+	} else {
+		/* we only used this to see if it was valid */
+		gtk_icon_info_free (icon_info);
+	}
+	return ret;
+}
+
+/**
  * pk_error_modal_dialog_cb:
  **/
 static void

Modified: trunk/src/pk-common-gui.h
==============================================================================
--- trunk/src/pk-common-gui.h	(original)
+++ trunk/src/pk-common-gui.h	Mon Feb  4 07:49:03 2008
@@ -60,6 +60,7 @@
 gchar		*pk_package_id_pretty_oneline		(const gchar	*package_id,
 							 const gchar	*summary);
 gchar		*pk_package_id_name_version		(const gchar	*package_id);
+gboolean	 pk_icon_valid				(const gchar	*icon);
 gboolean	 pk_error_modal_dialog			(const gchar	*title,
 							 const gchar	*message);
 gchar		*pk_error_format_details		(const gchar	*details);

Modified: trunk/src/pk-update-viewer.c
==============================================================================
--- trunk/src/pk-update-viewer.c	(original)
+++ trunk/src/pk-update-viewer.c	Mon Feb  4 07:49:03 2008
@@ -708,19 +708,16 @@
 }
 
 /**
- * pk_updates_set_aux_status:
+ * pk_updates_add_preview_item:
  **/
 static void
-pk_updates_set_aux_status (PkClient *client, const gchar *icon, const gchar *message)
+pk_updates_add_preview_item (PkClient *client, const gchar *icon, const gchar *message)
 {
 	GtkWidget *tree_view;
 	GtkTreeSelection *selection;
 	GtkTreeIter iter;
 	gchar *markup;
 
-	/* clear existing list */
-	gtk_list_store_clear (list_store_preview);
-
 	markup = g_strdup_printf ("<b>%s</b>", message);
 	gtk_list_store_append (list_store_preview, &iter);
 	gtk_list_store_set (list_store_preview, &iter,
@@ -813,8 +810,11 @@
 
 	length = pk_client_package_buffer_get_size (client);
 	if (length == 0) {
+		/* clear existing list */
+		gtk_list_store_clear (list_store_preview);
+
 		/* put a message in the listbox */
-		pk_updates_set_aux_status (client, "dialog-information", _("There are no updates available!"));
+		pk_updates_add_preview_item (client, "dialog-information", _("There are no updates available!"));
 
 		/* if no updates then hide apply */
 		widget = glade_xml_get_widget (glade_xml, "button_review");
@@ -851,41 +851,44 @@
 			}
 		}
 
+		/* clear existing list */
+		gtk_list_store_clear (list_store_preview);
+
 		/* add to preview box in order of priority */
 		if (num_security > 0) {
 			icon = pk_info_enum_to_icon_name (PK_INFO_ENUM_SECURITY);
 			text = pk_update_enum_to_localised_text (PK_INFO_ENUM_SECURITY, num_security);
-			pk_updates_set_aux_status (client, icon, text);
+			pk_updates_add_preview_item (client, icon, text);
 			g_free (text);
 		}
 		if (num_important > 0) {
 			icon = pk_info_enum_to_icon_name (PK_INFO_ENUM_IMPORTANT);
 			text = pk_update_enum_to_localised_text (PK_INFO_ENUM_IMPORTANT, num_important);
-			pk_updates_set_aux_status (client, icon, text);
+			pk_updates_add_preview_item (client, icon, text);
 			g_free (text);
 		}
 		if (num_bugfix > 0) {
 			icon = pk_info_enum_to_icon_name (PK_INFO_ENUM_BUGFIX);
 			text = pk_update_enum_to_localised_text (PK_INFO_ENUM_BUGFIX, num_bugfix);
-			pk_updates_set_aux_status (client, icon, text);
+			pk_updates_add_preview_item (client, icon, text);
 			g_free (text);
 		}
 		if (num_enhancement > 0) {
 			icon = pk_info_enum_to_icon_name (PK_INFO_ENUM_ENHANCEMENT);
 			text = pk_update_enum_to_localised_text (PK_INFO_ENUM_ENHANCEMENT, num_enhancement);
-			pk_updates_set_aux_status (client, icon, text);
+			pk_updates_add_preview_item (client, icon, text);
 			g_free (text);
 		}
 		if (num_low > 0) {
 			icon = pk_info_enum_to_icon_name (PK_INFO_ENUM_LOW);
 			text = pk_update_enum_to_localised_text (PK_INFO_ENUM_LOW, num_low);
-			pk_updates_set_aux_status (client, icon, text);
+			pk_updates_add_preview_item (client, icon, text);
 			g_free (text);
 		}
 		if (num_normal > 0) {
 			icon = pk_info_enum_to_icon_name (PK_INFO_ENUM_NORMAL);
 			text = pk_update_enum_to_localised_text (PK_INFO_ENUM_NORMAL, num_normal);
-			pk_updates_set_aux_status (client, icon, text);
+			pk_updates_add_preview_item (client, icon, text);
 			g_free (text);
 		}
 
@@ -943,7 +946,7 @@
 		gtk_list_store_clear (list_store_details);
 
 		/* put a message in the listbox */
-		pk_updates_set_aux_status (client, "dialog-information", _("There is an update already in progress!"));
+		pk_updates_add_preview_item (client, "dialog-information", _("There is an update already in progress!"));
 
 		/* if doing it then hide apply and refresh */
 		widget = glade_xml_get_widget (glade_xml, "button_apply");



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