1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
|
From f7e394840ff84ae8b55f13ff9692d6b02e8e6ea5 Mon Sep 17 00:00:00 2001
Date: Wed, 20 Dec 2023 12:21:24 +0100
Subject: [PATCH 1/3] gs-appstream: Increase limit to category apps lookup
The Overview page currently checks for 100 apps in all categories.
Lookup for the same count per category.
Note: The counts are not accurate, same apps can be in multiple
sub-categories, thus the parent category count suffers of duplicity,
which the following commit will correct in a different way than
checking for id duplicity.
---
lib/gs-appstream.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/gs-appstream.c b/lib/gs-appstream.c
index f110e3c47..d600cac53 100644
--- a/lib/gs-appstream.c
+++ b/lib/gs-appstream.c
@@ -1836,7 +1836,8 @@ static guint
gs_appstream_count_component_for_groups (XbSilo *silo,
const gchar *desktop_group)
{
- guint limit = 10;
+ /* the overview page checks for 100 apps, then try to get them */
+ const guint limit = 100;
g_autofree gchar *xpath = NULL;
g_auto(GStrv) split = g_strsplit (desktop_group, "::", -1);
g_autoptr(GPtrArray) array = NULL;
@@ -1896,7 +1897,6 @@ gs_appstream_refine_category_sizes (XbSilo *silo,
}
}
}
- continue;
}
return TRUE;
}
--
GitLab
From 617af44a56f6f62e07fd3fc13ae43d688aa3b85f Mon Sep 17 00:00:00 2001
Date: Wed, 20 Dec 2023 12:24:25 +0100
Subject: [PATCH 2/3] gs-overview-page: Add debug prints about discovered
categories
For easier debugging, to see what the plugins returned.
---
src/gs-overview-page.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/gs-overview-page.c b/src/gs-overview-page.c
index 6ef5079e9..72000e257 100644
--- a/src/gs-overview-page.c
+++ b/src/gs-overview-page.c
@@ -496,6 +496,7 @@ gs_overview_page_get_categories_cb (GObject *source_object,
if (gs_category_get_icon_name (cat) != NULL) {
found_apps_cnt += gs_category_get_size (cat);
+ g_debug ("overview page found category '%s' which claims %u apps", gs_category_get_name (cat), gs_category_get_size (cat));
flowbox = GTK_FLOW_BOX (self->flowbox_categories);
} else
flowbox = GTK_FLOW_BOX (self->flowbox_iconless_categories);
@@ -524,6 +525,7 @@ out:
* See https://gitlab.gnome.org/GNOME/gnome-software/-/issues/2053 */
gtk_widget_set_visible (self->flowbox_categories, found_apps_cnt >= MIN_CATEGORIES_APPS);
+ g_debug ("overview page found %u category apps", found_apps_cnt);
if (found_apps_cnt < MIN_CATEGORIES_APPS && found_apps_cnt > 0) {
GsPluginListAppsFlags flags = GS_PLUGIN_LIST_APPS_FLAGS_INTERACTIVE;
GatherAppsData *gather_apps_data = g_new0 (GatherAppsData, 1);
--
GitLab
From 98086eca23dbd46284039722887852e8c760a0fe Mon Sep 17 00:00:00 2001
Date: Wed, 20 Dec 2023 12:32:21 +0100
Subject: [PATCH 3/3] gs-overview-page: Verify category sizes
The "list-categories" job can set inaccurate sizes for the categories,
thus check the actual category content to operate with proper numbers.
For example the appstream data can have information about apps, which
no plugin can provide due to disabled repository.
---
src/gs-overview-page.c | 176 +++++++++++++++++++++++++++++++++++------
1 file changed, 153 insertions(+), 23 deletions(-)
diff --git a/src/gs-overview-page.c b/src/gs-overview-page.c
index 72000e257..3ec689ac1 100644
--- a/src/gs-overview-page.c
+++ b/src/gs-overview-page.c
@@ -440,6 +440,7 @@ category_activated_cb (GsOverviewPage *self, GsCategoryTile *tile)
typedef struct {
GsOverviewPage *page; /* (unowned) */
GsPluginJobListCategories *job; /* (owned) */
+ guint n_pending_ops;
} GetCategoriesData;
static void
@@ -451,31 +452,18 @@ get_categories_data_free (GetCategoriesData *data)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GetCategoriesData, get_categories_data_free)
-static void
-gs_overview_page_get_categories_cb (GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
+static guint
+update_categories_sections (GsOverviewPage *self,
+ GPtrArray *list) /* (element-type GsCategory) */
{
- g_autoptr(GetCategoriesData) data = g_steal_pointer (&user_data);
- GsOverviewPage *self = GS_OVERVIEW_PAGE (data->page);
- GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (source_object);
- guint i;
GsCategory *cat;
GtkFlowBox *flowbox;
GtkWidget *tile;
guint added_cnt = 0;
guint found_apps_cnt = 0;
- g_autoptr(GError) error = NULL;
- GPtrArray *list = NULL; /* (element-type GsCategory) */
- if (!gs_plugin_loader_job_action_finish (plugin_loader, res, &error)) {
- if (!g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) &&
- !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
- g_warning ("failed to get categories: %s", error->message);
- goto out;
- }
-
- list = gs_plugin_job_list_categories_get_result_list (data->job);
+ if (g_cancellable_is_cancelled (self->cancellable))
+ return found_apps_cnt;
gs_widget_remove_all (self->flowbox_categories, (GsRemoveFunc) gtk_flow_box_remove);
gs_widget_remove_all (self->flowbox_iconless_categories, (GsRemoveFunc) gtk_flow_box_remove);
@@ -488,7 +476,7 @@ gs_overview_page_get_categories_cb (GObject *source_object,
* be visually important, and are listed near the top of the page.
* Categories without icons are listed in a separate flowbox at the
* bottom of the page. Typically they are addons. */
- for (i = 0; i < list->len; i++) {
+ for (guint i = 0; list != NULL && i < list->len; i++) {
cat = GS_CATEGORY (g_ptr_array_index (list, i));
if (gs_category_get_size (cat) == 0)
continue;
@@ -510,7 +498,6 @@ gs_overview_page_get_categories_cb (GObject *source_object,
g_object_ref (cat));
}
-out:
/* Show the heading for the iconless categories iff there are any. */
gtk_widget_set_visible (self->iconless_categories_heading,
gtk_flow_box_get_child_at_index (GTK_FLOW_BOX (self->flowbox_iconless_categories), 0) != NULL);
@@ -525,6 +512,27 @@ out:
* See https://gitlab.gnome.org/GNOME/gnome-software/-/issues/2053 */
gtk_widget_set_visible (self->flowbox_categories, found_apps_cnt >= MIN_CATEGORIES_APPS);
+ return found_apps_cnt;
+}
+
+static void
+finish_verify_category_op (GetCategoriesData *op_data)
+{
+ g_autoptr(GetCategoriesData) data = g_steal_pointer (&op_data);
+ GsOverviewPage *self = GS_OVERVIEW_PAGE (data->page);
+ guint i, found_apps_cnt;
+ GPtrArray *list; /* (element-type GsCategory) */
+
+ data->n_pending_ops--;
+ if (data->n_pending_ops > 0) {
+ /* to not be freed */
+ g_steal_pointer (&data);
+ return;
+ }
+
+ list = gs_plugin_job_list_categories_get_result_list (data->job);
+ found_apps_cnt = update_categories_sections (self, list);
+
g_debug ("overview page found %u category apps", found_apps_cnt);
if (found_apps_cnt < MIN_CATEGORIES_APPS && found_apps_cnt > 0) {
GsPluginListAppsFlags flags = GS_PLUGIN_LIST_APPS_FLAGS_INTERACTIVE;
@@ -534,10 +542,10 @@ out:
gather_apps_data->self = g_object_ref (self);
gather_apps_data->list = gs_app_list_new ();
- for (i = 0; i < list->len; i++) {
+ for (i = 0; list != NULL && i < list->len; i++) {
g_autoptr(GsPluginJob) plugin_job = NULL;
g_autoptr(GsAppQuery) query = NULL;
- GsCategory *subcat;
+ GsCategory *cat, *subcat;
cat = GS_CATEGORY (g_ptr_array_index (list, i));
if (gs_category_get_size (cat) == 0 ||
@@ -578,6 +586,128 @@ out:
gs_overview_page_decrement_action_cnt (self);
}
+typedef struct {
+ GsOverviewPage *page; /* (unowned) */
+ GetCategoriesData *op_data; /* (unowned) */
+ GsCategory *category; /* (owned) */
+} VerifyCategoryData;
+
+static void
+verify_category_data_free (VerifyCategoryData *data)
+{
+ g_clear_object (&data->category);
+ g_free (data);
+}
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (VerifyCategoryData, verify_category_data_free)
+
+static void
+gs_overview_page_verify_category_cb (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ g_autoptr(VerifyCategoryData) data = user_data;
+ GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (source_object);
+ g_autoptr(GError) local_error = NULL;
+ g_autoptr(GsAppList) list = NULL;
+
+ list = gs_plugin_loader_job_process_finish (plugin_loader, res, &local_error);
+ if (list == NULL) {
+ if (!g_error_matches (local_error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) &&
+ !g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ g_warning ("failed to get apps for category: %s", local_error->message);
+ g_debug ("Failed to get category content '%s' for overview page: %s", gs_category_get_id (data->category), local_error->message);
+ } else {
+ GsCategory *all_subcat = gs_category_find_child (data->category, "all");
+ guint size = gs_app_list_length (list);
+ g_debug ("overview page verify category '%s' size:%u~>%u subcat:'%s' size:%u~>%u",
+ gs_category_get_id (data->category), gs_category_get_size (data->category), size,
+ gs_category_get_id (all_subcat), gs_category_get_size (all_subcat), size);
+ gs_category_set_size (data->category, size);
+ gs_category_set_size (all_subcat, size);
+ }
+
+ finish_verify_category_op (data->op_data);
+}
+
+static void
+gs_overview_page_get_categories_list_cb (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ g_autoptr(GetCategoriesData) data = g_steal_pointer (&user_data);
+ GsOverviewPage *self = GS_OVERVIEW_PAGE (data->page);
+ GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (source_object);
+ g_autoptr(GError) error = NULL;
+
+ g_assert (data->n_pending_ops == 0);
+
+ data->n_pending_ops++;
+
+ /* The apps can be mentioned in the appstream data, but no plugin may provide actual app,
+ thus try to get the content as the Categories page and fine tune the numbers appropriately. */
+ if (!gs_plugin_loader_job_action_finish (plugin_loader, res, &error)) {
+ if (!g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) &&
+ !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ g_warning ("failed to get categories: %s", error->message);
+ } else {
+ g_autoptr(GPtrArray) verify_categories = NULL; /* (element-type GsCategory) */
+ GPtrArray *list = NULL; /* (element-type GsCategory) */
+ guint found_apps_cnt;
+
+ list = gs_plugin_job_list_categories_get_result_list (data->job);
+ found_apps_cnt = update_categories_sections (self, list);
+
+ if (found_apps_cnt >= MIN_CATEGORIES_APPS) {
+ verify_categories = g_ptr_array_new_full (list != NULL ? list->len : 0, g_object_unref);
+ for (guint i = 0; list != NULL && i < list->len; i++) {
+ GsCategory *category = g_ptr_array_index (list, i);
+ if (gs_category_get_size (category) > 0 &&
+ gs_category_find_child (category, "all") != NULL) {
+ g_ptr_array_add (verify_categories, g_object_ref (category));
+ }
+ }
+ }
+
+ if (verify_categories != NULL && verify_categories->len > 0 && !g_cancellable_is_cancelled (self->cancellable)) {
+ for (guint i = 0; i < verify_categories->len; i++) {
+ GsCategory *category = g_ptr_array_index (verify_categories, i);
+ GsCategory *all_subcat = gs_category_find_child (category, "all");
+ g_autoptr(GsAppQuery) query = NULL;
+ g_autoptr(GsPluginJob) plugin_job = NULL;
+ VerifyCategoryData *ver_data;
+
+ g_assert (all_subcat != NULL);
+
+ data->n_pending_ops++;
+
+ ver_data = g_new0 (VerifyCategoryData, 1);
+ ver_data->page = self;
+ ver_data->op_data = data;
+ ver_data->category = g_object_ref (category);
+
+ query = gs_app_query_new ("category", all_subcat,
+ "refine-flags", GS_PLUGIN_REFINE_FLAGS_REQUIRE_ID,
+ "dedupe-flags", GS_APP_LIST_FILTER_FLAG_KEY_ID_PROVIDES,
+ "license-type", gs_page_get_query_license_type (GS_PAGE (self)),
+ /*"developer-verified-type", gs_page_get_query_developer_verified_type (GS_PAGE (self)),*/
+ NULL);
+ plugin_job = gs_plugin_job_list_apps_new (query, GS_PLUGIN_LIST_APPS_FLAGS_NONE);
+ gs_plugin_loader_job_process_async (plugin_loader,
+ plugin_job,
+ self->cancellable,
+ gs_overview_page_verify_category_cb,
+ ver_data);
+ }
+
+ finish_verify_category_op (g_steal_pointer (&data));
+ return;
+ }
+ }
+
+ finish_verify_category_op (g_steal_pointer (&data));
+}
+
static void
third_party_destroy_cb (GtkWindow *window,
GsOverviewPage *self)
@@ -967,7 +1097,7 @@ gs_overview_page_load (GsOverviewPage *self)
data->job = g_object_ref (GS_PLUGIN_JOB_LIST_CATEGORIES (plugin_job));
gs_plugin_loader_job_process_async (self->plugin_loader, plugin_job,
- self->cancellable, gs_overview_page_get_categories_cb,
+ self->cancellable, gs_overview_page_get_categories_list_cb,
g_steal_pointer (&data));
self->action_cnt++;
}
--
GitLab
|