[gnome-software/1413-missing-source-label-after-41-redesign] gs-details-page: Always show the application source



commit cb41190b8dee23a6ffe8a72f824e6982025b0099
Author: Milan Crha <mcrha redhat com>
Date:   Wed Sep 8 10:05:34 2021 +0200

    gs-details-page: Always show the application source
    
    Since the new redesign the source had been hidden under the context
    tiles. Show it also on the header bar, for better visibility.
    
    Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1413

 src/gs-details-page.c | 38 ++++++++++++++++++++++++--------------
 1 file changed, 24 insertions(+), 14 deletions(-)
---
diff --git a/src/gs-details-page.c b/src/gs-details-page.c
index 2bfd57b92..65a9cf70a 100644
--- a/src/gs-details-page.c
+++ b/src/gs-details-page.c
@@ -282,6 +282,28 @@ app_has_pending_action (GsApp *app)
               (gs_app_get_state (app) == GS_APP_STATE_QUEUED_FOR_INSTALL);
 }
 
+static void
+gs_details_page_update_origin_button (GsDetailsPage *self,
+                                     gboolean sensitive)
+{
+       g_autofree gchar *origin_ui = NULL;
+
+       if (self->app == NULL ||
+           gs_shell_get_mode (self->shell) != GS_SHELL_MODE_DETAILS) {
+               gtk_widget_hide (self->origin_box);
+               return;
+       }
+
+       origin_ui = gs_app_get_origin_ui (self->app);
+       if (origin_ui != NULL)
+               gtk_label_set_text (GTK_LABEL (self->origin_button_label), origin_ui);
+       else
+               gtk_label_set_text (GTK_LABEL (self->origin_button_label), "");
+
+       gtk_widget_set_sensitive (self->origin_box, sensitive);
+       gtk_widget_show (self->origin_box);
+}
+
 static void
 gs_details_page_switch_to (GsPage *page)
 {
@@ -609,7 +631,6 @@ gs_details_page_get_alternates_cb (GObject *source_object,
        GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (source_object);
        g_autoptr(GError) error = NULL;
        g_autoptr(GsAppList) list = NULL;
-       g_autofree gchar *origin_ui = NULL;
        gboolean instance_changed = FALSE;
        gboolean origin_by_packaging_format = self->origin_by_packaging_format;
        GtkWidget *first_row = NULL;
@@ -674,12 +695,6 @@ gs_details_page_get_alternates_cb (GObject *source_object,
                origin_by_packaging_format = FALSE;
        }
 
-       /* no alternates to show */
-       if (gs_app_list_length (list) < 2) {
-               gtk_widget_hide (self->origin_box);
-               return;
-       }
-
        /* Do not allow change of the app by the packaging format when it's installed */
        origin_by_packaging_format = origin_by_packaging_format &&
                self->app != NULL && gs_app_get_state (self->app) != GS_APP_STATE_INSTALLED;
@@ -746,13 +761,7 @@ gs_details_page_get_alternates_cb (GObject *source_object,
        if (select_row)
                gs_origin_popover_row_set_selected (GS_ORIGIN_POPOVER_ROW (select_row), TRUE);
 
-       origin_ui = gs_app_get_origin_ui (self->app);
-       if (origin_ui != NULL)
-               gtk_label_set_text (GTK_LABEL (self->origin_button_label), origin_ui);
-       else
-               gtk_label_set_text (GTK_LABEL (self->origin_button_label), "");
-
-       gtk_widget_show (self->origin_box);
+       gs_details_page_update_origin_button (self, gs_app_list_length (list) > 1);
 
        if (instance_changed)
                gs_details_page_refresh_all (self);
@@ -1502,6 +1511,7 @@ gs_details_page_load_stage2 (GsDetailsPage *self)
        gs_details_page_refresh_addons (self);
        gs_details_page_refresh_reviews (self);
        gs_details_page_refresh_all (self);
+       gs_details_page_update_origin_button (self, FALSE);
 
        /* if these tasks fail (e.g. because we have no networking) then it's
         * of no huge importance if we don't get the required data */


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