[gnome-packagekit/gnome-2-28] Try harder to find the correct update item in the update viewer



commit 2e8cfeeec2f81a32f324ce4ed3b31bfc59c07d2f
Author: Richard Hughes <richard hughsie com>
Date:   Thu Feb 2 17:30:53 2012 +0000

    Try harder to find the correct update item in the update viewer
    
    Try to find the exact package ID before falling back to the name in the update
    viewer. This ensures we find both versions of a package when we have installed
    multarch versions.

 src/gpk-update-viewer.c |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/src/gpk-update-viewer.c b/src/gpk-update-viewer.c
index be742f8..7ee488c 100644
--- a/src/gpk-update-viewer.c
+++ b/src/gpk-update-viewer.c
@@ -483,6 +483,30 @@ gpk_update_viewer_find_iter_model_cb (GtkTreeModel *model, GtkTreePath *path, Gt
 }
 
 /**
+ * gpk_update_viewer_find_iter_model_exact_cb:
+ **/
+static gboolean
+gpk_update_viewer_find_iter_model_exact_cb (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, const PkPackageId *id)
+{
+	gchar *id_tmp = NULL;
+	GtkTreePath **_path = NULL;
+	PkPackageId *id_new;
+	gboolean ret = FALSE;
+
+	_path = (GtkTreePath **) g_object_get_data (G_OBJECT(model), "_path");
+	gtk_tree_model_get (model, iter, GPK_UPDATES_COLUMN_ID, &id_tmp, -1);
+
+	/* only match on the name */
+	id_new = pk_package_id_new_from_string (id_tmp);
+	if (pk_package_id_equal (id_new, id)) {
+		*_path = gtk_tree_path_copy (path);
+		ret = TRUE;
+	}
+	pk_package_id_free (id_new);
+	return ret;
+}
+
+/**
  * gpk_update_viewer_model_get_path:
  **/
 static GtkTreePath *
@@ -490,7 +514,11 @@ gpk_update_viewer_model_get_path (GtkTreeModel *model, const PkPackageId *id)
 {
 	GtkTreePath *path = NULL;
 	g_object_set_data (G_OBJECT(model), "_path", (gpointer) &path);
+	gtk_tree_model_foreach (model, (GtkTreeModelForeachFunc) gpk_update_viewer_find_iter_model_exact_cb, (gpointer) id);
+	if (path != NULL)
+		goto out;
 	gtk_tree_model_foreach (model, (GtkTreeModelForeachFunc) gpk_update_viewer_find_iter_model_cb, (gpointer) id);
+out:
 	g_object_steal_data (G_OBJECT(model), "_path");
 	return path;
 }



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