[gnome-software: 16/25] gs-category: Handle size of ‘all’ subcategory specially
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 16/25] gs-category: Handle size of ‘all’ subcategory specially
- Date: Wed, 3 Feb 2021 23:15:46 +0000 (UTC)
commit d338b39d18e788b9b272089ff9c9151db625620f
Author: Philip Withnall <pwithnall endlessos org>
Date: Tue Feb 2 00:20:16 2021 +0000
gs-category: Handle size of ‘all’ subcategory specially
Rather than setting the size of all the ‘all’ subcategories in a second
pass over the categories when creating them, handle the ‘all’
subcategory specially in `gs_category_get_size()`, so that its return
value is always correct.
This will allow for elimination of the second pass in subsequent
commits.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
lib/gs-category.c | 9 +++++++--
lib/gs-plugin-loader.c | 2 --
2 files changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/lib/gs-category.c b/lib/gs-category.c
index f661dcfad..faedcbc31 100644
--- a/lib/gs-category.c
+++ b/lib/gs-category.c
@@ -77,7 +77,7 @@ gs_category_to_string (GsCategory *category)
category->icon_name);
}
g_string_append_printf (str, " size: %u\n",
- category->size);
+ gs_category_get_size (category));
g_string_append_printf (str, " desktop-groups: %u\n",
category->desktop_groups->len);
if (category->parent != NULL) {
@@ -116,6 +116,11 @@ guint
gs_category_get_size (GsCategory *category)
{
g_return_val_if_fail (GS_IS_CATEGORY (category), 0);
+
+ /* The ‘all’ subcategory is a bit special. */
+ if (category->parent != NULL && g_str_equal (category->id, "all"))
+ return gs_category_get_size (category->parent);
+
return category->size;
}
@@ -517,7 +522,7 @@ gs_category_get_property (GObject *object, guint prop_id, GValue *value, GParamS
g_value_set_object (value, self->parent);
break;
case PROP_SIZE:
- g_value_set_uint (value, self->size);
+ g_value_set_uint (value, gs_category_get_size (self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index eb8043de6..02747d128 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -1546,11 +1546,9 @@ gs_plugin_loader_fix_category_all (GsCategory *category)
GsCategory *cat_all;
guint i, j;
- /* set correct size */
cat_all = gs_category_find_child (category, "all");
if (cat_all == NULL)
return;
- gs_category_set_size (cat_all, gs_category_get_size (category));
/* add the desktop groups from all children */
children = gs_category_get_children (category);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]