[gnome-software] Fix selecting the first subcategory
- From: Joaquim Manuel Pereira Rocha <jrocha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Fix selecting the first subcategory
- Date: Tue, 7 Jun 2016 07:42:58 +0000 (UTC)
commit 7340133ffba9130ddb27559ba0ff958e1a53ec81
Author: Joaquim Rocha <jrocha endlessm com>
Date: Mon Jun 6 16:57:16 2016 +0200
Fix selecting the first subcategory
When no "favorites" subcategory exists, then should select the first
subcategory in the list but this was failing due to the difference
between the subcategories list and the ones that actually get inserted
in there (because e.g. empty subcategories are not inserted).
src/gs-shell-category.c | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/src/gs-shell-category.c b/src/gs-shell-category.c
index 8b6c280..f017701 100644
--- a/src/gs-shell-category.c
+++ b/src/gs-shell-category.c
@@ -196,6 +196,13 @@ gs_shell_category_create_filter_list (GsShellCategory *self,
g_object_set (row, "xalign", 0.0, "margin", 10, NULL);
gtk_widget_show (row);
gtk_list_box_insert (GTK_LIST_BOX (self->listbox_filter), row, -1);
+
+ /* if no subcategory was passed, then set it to the first one
+ * that gets inserted in the list in order for the first
+ * row/subcategory to be selected */
+ if (!subcategory)
+ subcategory = s;
+
if (subcategory == s)
gtk_list_box_select_row (GTK_LIST_BOX (self->listbox_filter), GTK_LIST_BOX_ROW
(gtk_widget_get_parent (row)));
}
@@ -217,7 +224,8 @@ gs_shell_category_set_category (GsShellCategory *self, GsCategory *category)
g_clear_object (&self->category);
self->category = g_object_ref (category);
- /* select favourites by default */
+ /* select favourites by default, otherwise the first subcategory in the
+ * list will be selected */
children = gs_category_get_children (category);
for (i = 0; i < children->len; i++) {
sub = GS_CATEGORY (g_ptr_array_index (children, i));
@@ -227,10 +235,6 @@ gs_shell_category_set_category (GsShellCategory *self, GsCategory *category)
}
}
- /* okay, no favourites, so just select the first entry */
- if (selected == NULL && children->len > 0)
- selected = GS_CATEGORY (g_ptr_array_index (children, 0));
-
/* find apps in this group */
gs_shell_category_create_filter_list (self, category, selected);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]