[gnome-packagekit] Only select the package item after all the results have appeared. Fixes only getting on result for '
- From: Richard Hughes <rhughes src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-packagekit] Only select the package item after all the results have appeared. Fixes only getting on result for '
- Date: Tue, 5 May 2009 11:14:00 -0400 (EDT)
commit 21fae8ac43fe052c7e9e58a2359f9c6e0336277e
Author: Richard Hughes <richard hughsie com>
Date: Tue May 5 16:13:03 2009 +0100
Only select the package item after all the results have appeared. Fixes only getting on result for 'Java' using the yum backend
---
src/gpk-application.c | 64 ++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 55 insertions(+), 9 deletions(-)
diff --git a/src/gpk-application.c b/src/gpk-application.c
index c2c2feb..8fe8919 100644
--- a/src/gpk-application.c
+++ b/src/gpk-application.c
@@ -926,8 +926,6 @@ static void
gpk_application_package_cb (PkClient *client, const PkPackageObj *obj, GpkApplication *application)
{
GtkTreeIter iter;
- GtkTreeSelection *selection;
- GtkWidget *widget;
gchar *summary;
const gchar *icon = NULL;
gchar *text;
@@ -998,13 +996,6 @@ gpk_application_package_cb (PkClient *client, const PkPackageObj *obj, GpkApplic
PACKAGES_COLUMN_IMAGE, icon,
-1);
- /* if it's an exact match, select it */
- if (egg_strequal (obj->id->name, application->priv->search_text)) {
- widget = GTK_WIDGET (gtk_builder_get_object (application->priv->builder, "treeview_packages"));
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget));
- gtk_tree_selection_select_iter (selection, &iter);
- }
-
/* only process every n events else we re-order too many times */
if (package_cnt++ % 200 == 0) {
while (gtk_events_pending ())
@@ -1233,6 +1224,57 @@ gpk_application_primary_requeue (GpkApplication *application)
}
/**
+ * gpk_application_select_exact_match:
+ *
+ * NOTE: we have to do this in the finished_cb, as if we do this as we return
+ * results we cancel the search and start getting the package details.
+ **/
+static void
+gpk_application_select_exact_match (GpkApplication *application, const gchar *text)
+{
+ GtkTreeView *treeview;
+ gboolean valid;
+ GtkTreeIter iter;
+ GtkTreePath *path;
+ GtkTreeModel *model;
+ GtkTreeSelection *selection = NULL;
+ gchar *package_id;
+ PkPackageId *id;
+
+ g_return_if_fail (PK_IS_APPLICATION (application));
+
+ /* get the first iter in the list */
+ treeview = GTK_TREE_VIEW (gtk_builder_get_object (application->priv->builder, "treeview_packages"));
+ model = gtk_tree_view_get_model (treeview);
+ valid = gtk_tree_model_get_iter_first (model, &iter);
+
+ /* for all items in treeview */
+ while (valid) {
+ gtk_tree_model_get (model, &iter, PACKAGES_COLUMN_ID, &package_id, -1);
+ if (package_id != NULL) {
+
+ /* exact match, so select and scroll */
+ id = pk_package_id_new_from_string (package_id);
+ if (g_strcmp0 (id->name, text) == 0) {
+ selection = gtk_tree_view_get_selection (treeview);
+ gtk_tree_selection_select_iter (selection, &iter);
+ path = gtk_tree_model_get_path (model, &iter);
+ gtk_tree_view_scroll_to_cell (treeview, path, NULL, FALSE, 0.5f, 0.5f);
+ gtk_tree_path_free (path);
+ }
+ pk_package_id_free (id);
+
+ /* no point continuing for a second match */
+ if (selection != NULL)
+ break;
+ }
+ g_free (package_id);
+ valid = gtk_tree_model_iter_next (model, &iter);
+ }
+}
+
+
+/**
* gpk_application_finished_cb:
**/
static void
@@ -1342,11 +1384,15 @@ gpk_application_finished_cb (PkClient *client, PkExitEnum exit_enum, guint runti
role == PK_ROLE_ENUM_SEARCH_DETAILS ||
role == PK_ROLE_ENUM_SEARCH_GROUP ||
role == PK_ROLE_ENUM_GET_PACKAGES) {
+
/* were there no entries found? */
if (exit_enum == PK_EXIT_ENUM_SUCCESS && !application->priv->has_package) {
gpk_application_suggest_better_search (application);
}
+ /* if there is an exact match, select it */
+ gpk_application_select_exact_match (application, application->priv->search_text);
+
/* focus back to the text extry */
widget = GTK_WIDGET (gtk_builder_get_object (application->priv->builder, "entry_text"));
gtk_widget_grab_focus (widget);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]