[gnome-software/1895-can-t-install-a-local-rpm-package-anymore-install-button-missing] gs-details-page: Include local file as an alternative when not installed



commit 7962414c7ef62494512a93df5855249debc39415
Author: Milan Crha <mcrha redhat com>
Date:   Wed Sep 7 16:58:34 2022 +0200

    gs-details-page: Include local file as an alternative when not installed
    
    It's not enough to add the local file to the GsAppList, because it can
    contain an app with the same ID, thus the local file app won't be added
    to the list.
    
    Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1895

 src/gs-details-page.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/src/gs-details-page.c b/src/gs-details-page.c
index d35ee0a98..50b80e159 100644
--- a/src/gs-details-page.c
+++ b/src/gs-details-page.c
@@ -645,6 +645,7 @@ gs_details_page_get_alternates_cb (GObject *source_object,
        GtkWidget *select_row = NULL;
        GtkWidget *origin_row_by_packaging_format = NULL;
        gint origin_row_by_packaging_format_index = 0;
+       guint n_rows = 0;
 
        self->origin_by_packaging_format = FALSE;
        gs_widget_remove_all (self->origin_popover_list_box, (GsRemoveFunc) gtk_list_box_remove);
@@ -699,7 +700,15 @@ gs_details_page_get_alternates_cb (GObject *source_object,
        /* add the local file to the list so that we can carry it over when
         * switching between alternates */
        if (self->app_local_file != NULL) {
-               gs_app_list_add (list, self->app_local_file);
+               if (gs_app_get_state (self->app_local_file) != GS_APP_STATE_INSTALLED) {
+                       GtkWidget *row = gs_origin_popover_row_new (self->app_local_file);
+                       gtk_widget_show (row);
+                       gtk_list_box_append (GTK_LIST_BOX (self->origin_popover_list_box), row);
+                       first_row = row;
+                       select_row = row;
+                       n_rows++;
+               }
+
                /* Do not allow change of the app by the packaging format when it's a local file */
                origin_by_packaging_format = FALSE;
        }
@@ -716,6 +725,7 @@ gs_details_page_get_alternates_cb (GObject *source_object,
                GsApp *app = gs_app_list_index (list, i);
                GtkWidget *row = gs_origin_popover_row_new (app);
                gtk_widget_show (row);
+               n_rows++;
                if (first_row == NULL)
                        first_row = row;
                if (app == self->app || (
@@ -766,7 +776,7 @@ gs_details_page_get_alternates_cb (GObject *source_object,
        }
 
        /* Do not show the "selected" check when there's only one app in the list */
-       if (select_row && gs_app_list_length (list) > 1)
+       if (select_row && n_rows > 1)
                gs_origin_popover_row_set_selected (GS_ORIGIN_POPOVER_ROW (select_row), TRUE);
        else if (select_row)
                gtk_list_box_row_set_activatable (GTK_LIST_BOX_ROW (select_row), FALSE);


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