gnome-software/0002-shell-setup-order.patch

135 lines
4.3 KiB
Diff

diff --git a/lib/gs-appstream.c b/lib/gs-appstream.c
index 38cc31bb5..c73adce6d 100644
--- a/lib/gs-appstream.c
+++ b/lib/gs-appstream.c
@@ -1626,12 +1626,12 @@ gs_appstream_add_categories (XbSilo *silo,
for (guint k = 0; k < groups->len; k++) {
const gchar *group = g_ptr_array_index (groups, k);
guint cnt = gs_appstream_count_component_for_groups (silo, group);
- for (guint l = 0; l < cnt; l++) {
- gs_category_increment_size (parent);
+ if (cnt > 0) {
+ gs_category_increment_size (parent, cnt);
if (children->len > 1) {
/* Parent category has multiple groups, so increment
* each group's size too */
- gs_category_increment_size (cat);
+ gs_category_increment_size (cat, cnt);
}
}
}
diff --git a/lib/gs-category.c b/lib/gs-category.c
index b311c4941..4baede3bc 100644
--- a/lib/gs-category.c
+++ b/lib/gs-category.c
@@ -147,17 +147,19 @@ gs_category_set_size (GsCategory *category, guint size)
/**
* gs_category_increment_size:
* @category: a #GsCategory
+ * @value: how many to add
*
- * Adds one to the size count if an application is available
+ * Adds @value to the size count.
*
* Since: 3.22
**/
void
-gs_category_increment_size (GsCategory *category)
+gs_category_increment_size (GsCategory *category,
+ guint value)
{
g_return_if_fail (GS_IS_CATEGORY (category));
- category->size++;
+ category->size += value;
g_object_notify_by_pspec (G_OBJECT (category), obj_props[PROP_SIZE]);
}
diff --git a/lib/gs-category.h b/lib/gs-category.h
index ecd2e1e23..1e82591aa 100644
--- a/lib/gs-category.h
+++ b/lib/gs-category.h
@@ -39,6 +39,7 @@ GsCategory *gs_category_find_child (GsCategory *category,
GPtrArray *gs_category_get_children (GsCategory *category);
guint gs_category_get_size (GsCategory *category);
-void gs_category_increment_size (GsCategory *category);
+void gs_category_increment_size (GsCategory *category,
+ guint value);
G_END_DECLS
diff --git a/src/gs-shell.c b/src/gs-shell.c
index db449a9b0..796d7b05a 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -107,6 +107,7 @@ struct _GsShell
GtkWidget *primary_menu;
GtkWidget *sub_page_header_title;
+ gboolean active_after_setup;
gboolean is_narrow;
guint allocation_changed_cb_id;
@@ -165,6 +166,12 @@ gs_shell_modal_dialog_present (GsShell *shell, GtkWindow *window)
void
gs_shell_activate (GsShell *shell)
{
+ /* Waiting for plugin loader to setup first */
+ if (shell->plugin_loader == NULL) {
+ shell->active_after_setup = TRUE;
+ return;
+ }
+
gtk_widget_show (GTK_WIDGET (shell));
gtk_window_present (GTK_WINDOW (shell));
}
@@ -2237,6 +2244,11 @@ gs_shell_setup (GsShell *shell, GsPluginLoader *plugin_loader, GCancellable *can
if (g_settings_get_boolean (shell->settings, "first-run"))
g_settings_set_boolean (shell->settings, "first-run", FALSE);
}
+
+ if (shell->active_after_setup) {
+ shell->active_after_setup = FALSE;
+ gs_shell_activate (shell);
+ }
}
void
diff --git a/src/gs-application.c b/src/gs-application.c
index e3f5f55c7..bdadd5c34 100644
--- a/src/gs-application.c
+++ b/src/gs-application.c
@@ -968,12 +968,9 @@ gs_application_startup (GApplication *application)
G_CALLBACK (gs_application_shell_loaded_cb),
app);
- gs_shell_setup (app->shell, app->plugin_loader, app->cancellable);
app->main_window = GTK_WINDOW (app->shell);
gtk_application_add_window (GTK_APPLICATION (app), app->main_window);
- app->update_monitor = gs_update_monitor_new (app, app->plugin_loader);
-
gs_application_update_software_sources_presence (application);
/* Set up the plugins. */
@@ -990,6 +987,7 @@ startup_cb (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
{
+ GsApplication *app = GS_APPLICATION (user_data);
GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (source_object);
g_autoptr(GError) local_error = NULL;
@@ -1002,6 +1000,11 @@ startup_cb (GObject *source_object,
/* show the priority of each plugin */
gs_plugin_loader_dump_state (plugin_loader);
+
+ /* Setup the shell only after the plugin loader finished its setup,
+ thus all plugins are loaded and ready for the jobs. */
+ gs_shell_setup (app->shell, app->plugin_loader, app->cancellable);
+ app->update_monitor = gs_update_monitor_new (app, app->plugin_loader);
}
static void