[gnome-software/gnome-3-30] shell: Avoid the "reload" signal interrupting the loading page



commit e5f68196f5abd075b3cb6790ac77d87f517aadfe
Author: Kalev Lember <klember redhat com>
Date:   Mon Nov 26 13:31:20 2018 +0100

    shell: Avoid the "reload" signal interrupting the loading page
    
    When we do the initial metadata download, packagekit downloads appstream
    metadata that the appstream plugin detects and then emits "reload".
    
    This however messes up the loading page as then all other pages ask for
    data and the packagekit initial refresh transaction gets interrupted and
    we end up inadvertently switching to the main page.
    
    To fix this, this commit connects up the "reload" signal handler only
    when the initial refresh is done.

 src/gs-shell.c | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)
---
diff --git a/src/gs-shell.c b/src/gs-shell.c
index 8f066ba5..b6afa83e 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -545,6 +545,17 @@ gs_shell_back_button_cb (GtkWidget *widget, GsShell *shell)
        gs_shell_go_back (shell);
 }
 
+static void
+gs_shell_reload_cb (GsPluginLoader *plugin_loader, GsShell *shell)
+{
+       GsShellPrivate *priv = gs_shell_get_instance_private (shell);
+       g_autoptr(GList) keys = g_hash_table_get_keys (priv->pages);
+       for (GList *l = keys; l != NULL; l = l->next) {
+               GsPage *page = GS_PAGE (g_hash_table_lookup (priv->pages, l->data));
+               gs_page_reload (page);
+       }
+}
+
 static void
 initial_refresh_done (GsLoadingPage *loading_page, gpointer data)
 {
@@ -564,6 +575,10 @@ initial_refresh_done (GsLoadingPage *loading_page, gpointer data)
        /* go to OVERVIEW, unless the "loading" callbacks changed mode already */
        if (priv->mode == GS_SHELL_MODE_LOADING)
                gs_shell_change_mode (shell, GS_SHELL_MODE_OVERVIEW, NULL, TRUE);
+
+       /* now that we're finished with the loading page, connect the reload signal handler */
+       g_signal_connect (priv->plugin_loader, "reload",
+                         G_CALLBACK (gs_shell_reload_cb), shell);
 }
 
 static gboolean
@@ -835,17 +850,6 @@ main_window_closed_cb (GtkWidget *dialog, GdkEvent *event, gpointer user_data)
        return TRUE;
 }
 
-static void
-gs_shell_reload_cb (GsPluginLoader *plugin_loader, GsShell *shell)
-{
-       GsShellPrivate *priv = gs_shell_get_instance_private (shell);
-       g_autoptr(GList) keys = g_hash_table_get_keys (priv->pages);
-       for (GList *l = keys; l != NULL; l = l->next) {
-               GsPage *page = GS_PAGE (g_hash_table_lookup (priv->pages, l->data));
-               gs_page_reload (page);
-       }
-}
-
 static void
 gs_shell_main_window_mapped_cb (GtkWidget *widget, GsShell *shell)
 {
@@ -1995,8 +1999,6 @@ gs_shell_setup (GsShell *shell, GsPluginLoader *plugin_loader, GCancellable *can
        g_return_if_fail (GS_IS_SHELL (shell));
 
        priv->plugin_loader = g_object_ref (plugin_loader);
-       g_signal_connect (priv->plugin_loader, "reload",
-                         G_CALLBACK (gs_shell_reload_cb), shell);
        g_signal_connect_object (priv->plugin_loader, "notify::events",
                                 G_CALLBACK (gs_shell_events_notify_cb),
                                 shell, 0);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]