gnome-packagekit r91 - trunk/src



Author: rhughes
Date: Sat Feb  2 09:01:53 2008
New Revision: 91
URL: http://svn.gnome.org/viewvc/gnome-packagekit?rev=91&view=rev

Log:
from git

Modified:
   trunk/src/pk-application.c

Modified: trunk/src/pk-application.c
==============================================================================
--- trunk/src/pk-application.c	(original)
+++ trunk/src/pk-application.c	Sat Feb  2 09:01:53 2008
@@ -35,6 +35,7 @@
 #include <pk-connection.h>
 #include <pk-package-id.h>
 #include <pk-enum-list.h>
+#include <pk-extra.h>
 
 #include "pk-statusbar.h"
 #include "pk-common-gui.h"
@@ -57,6 +58,7 @@
 	PkClient		*client_files;
 	PkConnection		*pconnection;
 	PkStatusbar		*statusbar;
+	PkExtra			*extra;
 	gchar			*package;
 	gchar			*url;
 	PkEnumList		*role_list;
@@ -416,6 +418,34 @@
 		pk_application_set_text_buffer (widget, _("No files"));
 	}
 }
+
+/**
+ * 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:
  **/
@@ -423,10 +453,13 @@
 pk_application_package_cb (PkClient *client, PkInfoEnum info, const gchar *package_id,
 			   const gchar *summary, PkApplication *application)
 {
-	const gchar *icon_name;
 	PkPackageId *ident;
 	GtkTreeIter iter;
+	PkPackageId *pid;
+	gchar *icon = NULL;
+	gchar *comment = NULL;
 	gchar *text;
+	gboolean valid;
 
 	g_return_if_fail (application != NULL);
 	g_return_if_fail (PK_IS_APPLICATION (application));
@@ -441,18 +474,49 @@
 	/* split by delimeter */
 	ident = pk_package_id_new_from_string (package_id);
 
-	text = g_markup_printf_escaped ("<b>%s-%s (%s)</b>\n%s", ident->name, ident->version, ident->arch, summary);
-	icon_name = pk_info_enum_to_icon_name (info);
+	/* 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);
+	}
+
+	/* check icon actually exists and is valid in this theme */
+	valid = FALSE;
+	if (icon != NULL) {
+		valid = pk_application_icon_valid (application, icon);
+	}
+
+	/* nothing in the detail database or invalid */
+	if (valid == FALSE) {
+		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);
 
 	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_name,
+			    PACKAGES_COLUMN_IMAGE, icon,
 			    -1);
 	pk_package_id_free (ident);
 	g_free (text);
+	g_free (icon);
+	g_free (comment);
 }
 
 /**
@@ -613,12 +677,15 @@
 
 	if (application->priv->search_depth == 0) {
 		pk_client_reset (application->priv->client_search);
+		pk_client_set_name_filter (application->priv->client_search, TRUE);
 		ret = pk_client_search_name (application->priv->client_search, filter_all, package);
 	} else if (application->priv->search_depth == 1) {
 		pk_client_reset (application->priv->client_search);
+		pk_client_set_name_filter (application->priv->client_search, TRUE);
 		ret = pk_client_search_details (application->priv->client_search, filter_all, package);
 	} else {
 		pk_client_reset (application->priv->client_search);
+		pk_client_set_name_filter (application->priv->client_search, TRUE);
 		ret = pk_client_search_file (application->priv->client_search, filter_all, package);
 	}
 
@@ -705,7 +772,7 @@
 	/* column for installed toggles */
 	column = gtk_tree_view_column_new ();
 	renderer = gtk_cell_renderer_pixbuf_new ();
-	g_object_set (renderer, "stock-size", GTK_ICON_SIZE_LARGE_TOOLBAR, NULL);
+	g_object_set (renderer, "stock-size", GTK_ICON_SIZE_DIALOG, NULL);
 	gtk_tree_view_column_pack_start (column, renderer, FALSE);
 	gtk_tree_view_column_add_attribute (column, renderer, "icon-name", PACKAGES_COLUMN_IMAGE);
 	gtk_tree_view_append_column (treeview, column);
@@ -1193,6 +1260,10 @@
 	g_signal_connect (application->priv->pconnection, "connection-changed",
 			  G_CALLBACK (pk_connection_changed_cb), application);
 
+	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");
+
 	application->priv->glade_xml = glade_xml_new (PK_DATA "/pk-application.glade", NULL, NULL);
 	main_window = glade_xml_get_widget (application->priv->glade_xml, "window_manager");
 
@@ -1447,6 +1518,8 @@
 	g_object_unref (application->priv->role_list);
 	g_object_unref (application->priv->current_filter);
 	g_object_unref (application->priv->statusbar);
+	g_object_unref (application->priv->extra);
+
 	g_free (application->priv->url);
 	g_free (application->priv->package);
 



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