[gnome-software: 2/6] shell: Split the loading page




commit 5f33be4aee98583a8d4149089ee683f0da183a5a
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Fri Apr 23 08:39:41 2021 +0200

    shell: Split the loading page
    
    Move it to its own stack to simplify the main stack code.
    
    This also makes it have a unified look.
    
    The indentation is purposefully left broken here to make the actual code
    change easier to review and will be fixed in the next commit.

 src/gs-shell.c       | 11 +++++++++++
 src/gs-shell.ui      | 45 ++++++++++++++++++++++++++++++++++++---------
 src/gtk-style-hc.css |  6 ++++++
 src/gtk-style.css    |  6 ++++++
 4 files changed, 59 insertions(+), 9 deletions(-)
---
diff --git a/src/gs-shell.c b/src/gs-shell.c
index 74a01303b..04c144663 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -71,6 +71,7 @@ struct _GsShell
        GPtrArray               *modal_dialogs;
        gchar                   *events_info_uri;
        HdyLeaflet              *main_leaflet;
+       GtkStack                *stack_loading;
        GtkStack                *stack_main;
        GsPage                  *page;
        GsSidebar               *sidebar;
@@ -551,6 +552,12 @@ gs_shell_change_mode (GsShell *shell,
        GsPage *page;
 
        /* switch page */
+       if (mode == GS_SHELL_MODE_LOADING) {
+               gtk_stack_set_visible_child_name (shell->stack_loading, "loading");
+               return;
+       }
+
+       gtk_stack_set_visible_child_name (shell->stack_loading, "main");
        gtk_stack_set_visible_child_name (GTK_STACK (shell->stack_main), page_name[mode]);
 
        /* do any mode-specific actions */
@@ -2153,6 +2160,9 @@ gs_shell_get_mode (GsShell *shell)
 {
        const gchar *name;
 
+       if (g_strcmp0 (gtk_stack_get_visible_child_name (shell->stack_loading), "loading") == 0)
+               return GS_SHELL_MODE_LOADING;
+
        name = gtk_stack_get_visible_child_name (shell->stack_main);
 
        for (gsize i = 0; i < G_N_ELEMENTS (page_name); i++)
@@ -2342,6 +2352,7 @@ gs_shell_class_init (GsShellClass *klass)
        gtk_widget_class_bind_template_child (widget_class, GsShell, sidebar_box);
        gtk_widget_class_bind_template_child (widget_class, GsShell, main_header);
        gtk_widget_class_bind_template_child (widget_class, GsShell, main_leaflet);
+       gtk_widget_class_bind_template_child (widget_class, GsShell, stack_loading);
        gtk_widget_class_bind_template_child (widget_class, GsShell, stack_main);
        gtk_widget_class_bind_template_child (widget_class, GsShell, sidebar);
        gtk_widget_class_bind_template_child (widget_class, GsShell, metered_updates_bar);
diff --git a/src/gs-shell.ui b/src/gs-shell.ui
index a39c3bc4f..22bd0c1d7 100644
--- a/src/gs-shell.ui
+++ b/src/gs-shell.ui
@@ -27,6 +27,11 @@
     <signal name="key-press-event" handler="window_keypress_handler"/>
     <signal name="button-press-event" handler="window_button_press_event" after="yes"/>
 
+    <child>
+      <object class="GtkStack" id="stack_loading">
+        <property name="visible">True</property>
+        <property name="transition-type">crossfade</property>
+        <signal name="notify::visible-child" handler="stack_notify_visible_child_cb"/>
     <child>
       <object class="GtkBox">
         <property name="visible">True</property>
@@ -491,15 +496,6 @@
                             <property name="name">moderate</property>
                           </packing>
                         </child>
-                        <child>
-                          <object class="GsLoadingPage" id="loading_page">
-                            <property name="visible">True</property>
-                            <signal name="refreshed" handler="initial_refresh_done"/>
-                          </object>
-                          <packing>
-                            <property name="name">loading</property>
-                          </packing>
-                        </child>
                         <child>
                           <object class="GsSearchPage" id="search_page">
                             <property name="visible">True</property>
@@ -564,6 +560,37 @@
           </object>
         </child>
       </object>
+      <packing>
+        <property name="name">main</property>
+      </packing>
+    </child>
+        <child>
+          <object class="GtkOverlay">
+            <property name="visible">True</property>
+            <child type="overlay">
+              <object class="GtkHeaderBar">
+                <property name="visible">True</property>
+                <property name="show_close_button">True</property>
+                <property name="valign">start</property>
+              </object>
+            </child>
+            <child>
+              <object class="HdyWindowHandle">
+                <property name="visible">True</property>
+                <child>
+                  <object class="GsLoadingPage" id="loading_page">
+                    <property name="visible">True</property>
+                    <signal name="refreshed" handler="initial_refresh_done"/>
+                  </object>
+                </child>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="name">loading</property>
+          </packing>
+        </child>
+      </object>
     </child>
   </template>
 
diff --git a/src/gtk-style-hc.css b/src/gtk-style-hc.css
index 95ad283dd..03d4563c2 100644
--- a/src/gtk-style-hc.css
+++ b/src/gtk-style-hc.css
@@ -289,3 +289,9 @@ button.star, .button.star {
        border: 1px solid shade(@theme_selected_bg_color, 0.8);
        color: @theme_selected_fg_color;
 }
+
+/* the loading page headerbar */
+overlay > headerbar {
+  background: none;
+  border: none;
+}
diff --git a/src/gtk-style.css b/src/gtk-style.css
index 4b701bd0f..eb7a861b1 100644
--- a/src/gtk-style.css
+++ b/src/gtk-style.css
@@ -639,3 +639,9 @@ flowboxchild {
   font-weight: 400;
   font-size: 10pt;
 }
+
+/* the loading page headerbar */
+overlay > headerbar {
+  background: none;
+  border: none;
+}


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