[gnome-software/154-gs-details-page-lack-of-information-when-flatpak-app-data-is-being-loaded] gs-details-page: Lack of information when flatpak app data is being loaded




commit 4bbc489d9738851b3902929f07c4f66c679f8946
Author: Milan Crha <mcrha redhat com>
Date:   Thu Oct 22 18:25:03 2020 +0200

    gs-details-page: Lack of information when flatpak app data is being loaded
    
    Show a text about loading the application details when populating the page,
    thus there's a hint what it does when it takes long time.
    
    Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/154
    Closes https://gitlab.gnome.org/GNOME/gnome-software/-/merge_requests/529

 src/gs-details-page.c  | 27 ++++++++++++++++++---------
 src/gs-details-page.ui |  9 +++++++++
 2 files changed, 27 insertions(+), 9 deletions(-)
---
diff --git a/src/gs-details-page.c b/src/gs-details-page.c
index 210724ce..5c5057cd 100644
--- a/src/gs-details-page.c
+++ b/src/gs-details-page.c
@@ -261,11 +261,21 @@ app_has_pending_action (GsApp *app)
               (gs_app_get_state (app) == AS_APP_STATE_QUEUED_FOR_INSTALL);
 }
 
+static void
+gs_details_page_set_header_label (GsDetailsPage *self,
+                                 const gchar *text)
+{
+       GtkWidget *widget;
+
+       widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "application_details_header"));
+       gtk_label_set_label (GTK_LABEL (widget), text ? text : "");
+       gtk_widget_set_visible (widget, text != NULL);
+}
+
 static void
 gs_details_page_switch_to (GsPage *page, gboolean scroll_up)
 {
        GsDetailsPage *self = GS_DETAILS_PAGE (page);
-       GtkWidget *widget;
        GtkAdjustment *adj;
 
        if (gs_shell_get_mode (self->shell) != GS_SHELL_MODE_DETAILS) {
@@ -274,14 +284,12 @@ gs_details_page_switch_to (GsPage *page, gboolean scroll_up)
                return;
        }
 
-       widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "application_details_header"));
-       gtk_label_set_label (GTK_LABEL (widget), "");
-       gtk_widget_show (widget);
-
        /* not set, perhaps file-to-app */
        if (self->app == NULL)
                return;
 
+       gs_details_page_set_header_label (self, gs_app_get_name (self->app));
+
        adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (self->scrolledwindow_details));
        gtk_adjustment_set_value (adj, gtk_adjustment_get_lower (adj));
 
@@ -1127,7 +1135,6 @@ gs_details_page_refresh_all (GsDetailsPage *self)
        GsAppList *history;
        GdkPixbuf *pixbuf = NULL;
        GList *addons;
-       GtkWidget *widget;
        const gchar *tmp;
        gboolean ret;
        gchar **menu_path;
@@ -1139,14 +1146,12 @@ gs_details_page_refresh_all (GsDetailsPage *self)
 
        /* change widgets */
        tmp = gs_app_get_name (self->app);
-       widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "application_details_header"));
+       gs_details_page_set_header_label (self, tmp);
        if (tmp != NULL && tmp[0] != '\0') {
                gtk_label_set_label (GTK_LABEL (self->application_details_title), tmp);
-               gtk_label_set_label (GTK_LABEL (widget), tmp);
                gtk_widget_set_visible (self->application_details_title, TRUE);
        } else {
                gtk_widget_set_visible (self->application_details_title, FALSE);
-               gtk_label_set_label (GTK_LABEL (widget), "");
        }
        tmp = gs_app_get_summary (self->app);
        if (tmp != NULL && tmp[0] != '\0') {
@@ -1968,6 +1973,8 @@ gs_details_page_set_local_file (GsDetailsPage *self, GFile *file)
        g_autoptr(GsPluginJob) plugin_job = NULL;
        gs_details_page_set_state (self, GS_DETAILS_PAGE_STATE_LOADING);
        g_clear_object (&self->app_local_file);
+       g_clear_object (&self->app);
+       gs_details_page_set_header_label (self, _("Loading…"));
        plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_FILE_TO_APP,
                                         "file", file,
                                         "refine-flags", GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON |
@@ -2001,6 +2008,8 @@ gs_details_page_set_url (GsDetailsPage *self, const gchar *url)
        g_autoptr(GsPluginJob) plugin_job = NULL;
        gs_details_page_set_state (self, GS_DETAILS_PAGE_STATE_LOADING);
        g_clear_object (&self->app_local_file);
+       g_clear_object (&self->app);
+       gs_details_page_set_header_label (self, _("Loading…"));
        plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_URL_TO_APP,
                                         "search", url,
                                         "refine-flags", GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON |
diff --git a/src/gs-details-page.ui b/src/gs-details-page.ui
index f86674fe..06d108cd 100644
--- a/src/gs-details-page.ui
+++ b/src/gs-details-page.ui
@@ -33,6 +33,15 @@
                 <property name="vexpand">True</property>
               </object>
             </child>
+            <child>
+              <object class="GtkLabel" id="loading_label">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">Loading Application Details…</property>
+                <attributes>
+                  <attribute name="scale" value="1.4"/>
+                </attributes>
+              </object>
+            </child>
           </object>
           <packing>
             <property name="name">spinner</property>


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