[gnome-packagekit] Use the desktop icon when we unselect the installed application in gpk-application. Fixes fd#25098



commit 879746582e1b55fe83eeb0e4f22fc2a70efceb31
Author: Richard Hughes <richard hughsie com>
Date:   Sun Nov 15 16:01:41 2009 +0000

    Use the desktop icon when we unselect the installed application in gpk-application. Fixes fd#25098

 src/gpk-application.c |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/src/gpk-application.c b/src/gpk-application.c
index ce6a641..c84da77 100644
--- a/src/gpk-application.c
+++ b/src/gpk-application.c
@@ -285,10 +285,12 @@ gpk_application_packages_checkbox_invert (GpkApplication *application)
 	GtkTreeModel *model;
 	GtkTreeIter iter;
 	GtkTreeSelection *selection;
-	const gchar *icon;
+	const gchar *icon = NULL;
 	gboolean checkbox;
 	PkBitfield state;
 	gboolean ret;
+	gchar *package_id = NULL;
+	gchar **split;
 
 	/* get the selection and add */
 	treeview = GTK_TREE_VIEW (gtk_builder_get_object (application->priv->builder, "treeview_packages"));
@@ -299,13 +301,24 @@ gpk_application_packages_checkbox_invert (GpkApplication *application)
 		return;
 	}
 
-	gtk_tree_model_get (model, &iter, PACKAGES_COLUMN_STATE, &state, -1);
+	gtk_tree_model_get (model, &iter,
+			    PACKAGES_COLUMN_STATE, &state,
+			    PACKAGES_COLUMN_ID, &package_id,
+			    -1);
 
 	/* do something with the value */
 	pk_bitfield_invert (state, GPK_STATE_IN_LIST);
 
+	/* use the application icon if not selected */
+	if (!pk_bitfield_contain (state, GPK_STATE_IN_LIST)) {
+		split = pk_package_id_split (package_id);
+		icon = gpk_desktop_guess_icon_name (application->priv->desktop, split[PK_PACKAGE_ID_NAME]);
+		g_strfreev (split);
+	}
+
 	/* get the new icon */
-	icon = gpk_application_state_get_icon (state);
+	if (icon == NULL)
+		icon = gpk_application_state_get_icon (state);
 	checkbox = gpk_application_state_get_checkbox (state);
 
 	/* set new value */
@@ -314,6 +327,7 @@ gpk_application_packages_checkbox_invert (GpkApplication *application)
 			    PACKAGES_COLUMN_CHECKBOX, checkbox,
 			    PACKAGES_COLUMN_IMAGE, icon,
 			    -1);
+	g_free (package_id);
 }
 
 /**



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