[gnome-software] Go to the overview mode by default before activation



commit 95b75e9227db979c0fb323041ec3e7e9d0f0b51a
Author: Joaquim Rocha <jrocha endlessm com>
Date:   Tue Oct 17 12:58:30 2017 +0200

    Go to the overview mode by default before activation
    
    The overview mode is the default one but was only being set when the
    user opens GNOME Software (even if it was already running). This patch
    sets that mode right after the loading is finished on start up, as a
    consequence, the start up is a bit slower, but the user sees the
    overview right away which makes it looks faster.

 src/gs-application.c |   27 +++++++++------------------
 1 files changed, 9 insertions(+), 18 deletions(-)
---
diff --git a/src/gs-application.c b/src/gs-application.c
index 7902906..9072eb4 100644
--- a/src/gs-application.c
+++ b/src/gs-application.c
@@ -66,8 +66,8 @@ struct _GsApplication {
 #endif
        GsShellSearchProvider *search_provider;
        GSettings       *settings;
-       gboolean         loading_done;
        GSimpleActionGroup      *action_map;
+       guint            shell_loaded_handler_id;
 };
 
 G_DEFINE_TYPE (GsApplication, gs_application, GTK_TYPE_APPLICATION);
@@ -248,9 +248,10 @@ theme_changed (GtkSettings *settings, GParamSpec *pspec, GsApplication *app)
 }
 
 static void
-initial_shell_loaded_cb (GsApplication *app)
+gs_application_shell_loaded_cb (GsShell *shell, GsApplication *app)
 {
-       app->loading_done = TRUE;
+       gs_shell_set_mode (app->shell, GS_SHELL_MODE_OVERVIEW);
+       app->shell_loaded_handler_id = 0;
 }
 
 static void
@@ -286,9 +287,9 @@ gs_application_initialize_ui (GsApplication *app)
        gs_shell_setup (app->shell, app->plugin_loader, app->cancellable);
        gtk_application_add_window (GTK_APPLICATION (app), gs_shell_get_window (app->shell));
 
-       g_signal_connect_swapped (app->shell, "loaded",
-                                 G_CALLBACK (initial_shell_loaded_cb),
-                                 app);
+        app->shell_loaded_handler_id = g_signal_connect (app->shell, "loaded",
+                                                         G_CALLBACK (gs_application_shell_loaded_cb),
+                                                         app);
 
        /* it's very important to set the loading as the first mode because it will
         * make the plugins load all their needed initial catalogs/information */
@@ -832,7 +833,7 @@ wrapper_action_activated_cb (GSimpleAction *action,
                                                                       G_SIMPLE_ACTION (real_action),
                                                                       g_variant_ref (parameter));
 
-               g_signal_handlers_disconnect (app->shell, app->shell_loaded_handler_id);
+               g_signal_handler_disconnect (app->shell, app->shell_loaded_handler_id);
                app->shell_loaded_handler_id = 0;
 
                g_signal_connect_swapped (app->shell, "loaded",
@@ -909,22 +910,12 @@ gs_application_startup (GApplication *application)
 }
 
 static void
-gs_application_shell_loaded_cb (GsShell *shell, GsApplication *app)
-{
-       gs_shell_set_mode (app->shell, GS_SHELL_MODE_OVERVIEW);
-}
-
-static void
 gs_application_activate (GApplication *application)
 {
        GsApplication *app = GS_APPLICATION (application);
 
-       if (app->loading_done)
+       if (app->shell_loaded_handler_id == 0)
                gs_shell_set_mode (app->shell, GS_SHELL_MODE_OVERVIEW);
-       else
-               g_signal_connect (app->shell, "loaded",
-                                 G_CALLBACK (gs_application_shell_loaded_cb),
-                                 app);
 
        gs_shell_activate (GS_APPLICATION (application)->shell);
 


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