[gnome-software/mwleeds/hardcoded-pwa-list] Allow web apps to be in UNAVAILABLE state



commit d6ec9fddbc090d7e7b1b1130198af0641308233e
Author: Phaedrus Leeds <mwleeds protonmail com>
Date:   Thu Mar 24 13:50:20 2022 -0700

    Allow web apps to be in UNAVAILABLE state
    
    After a web app is uninstalled in Software, it is only re-installable if
    it is present in the AppStream data. Otherwise the app must have been
    installed via Epiphany, and the information needed to re-install it
    (e.g. the icon) is not available. If we leave the state as
    GS_APP_STATE_UNKNOWN after the removal, the user is greeted by an ugly
    message "Unable to find org.gnome.Epiphany.WebApp_...." in place of the
    details page. So set the state to GS_APP_STATE_UNAVAILABLE instead, and
    update other parts of Software to allow that state to mean "Don't show
    any Install/Remove/Open button" when it is set on a web app.

 plugins/epiphany/gs-plugin-epiphany.c | 2 ++
 src/gs-app-row.c                      | 7 +++++--
 src/gs-details-page.c                 | 4 +++-
 3 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/plugins/epiphany/gs-plugin-epiphany.c b/plugins/epiphany/gs-plugin-epiphany.c
index 006c77646..72273bf52 100644
--- a/plugins/epiphany/gs-plugin-epiphany.c
+++ b/plugins/epiphany/gs-plugin-epiphany.c
@@ -397,6 +397,8 @@ gs_epiphany_refine_app_state (GsPlugin *plugin,
                        gs_app_set_state (app, gs_app_get_state (cached_app));
                else if (appstream_source)
                        gs_app_set_state (app, GS_APP_STATE_AVAILABLE);
+               else
+                       gs_app_set_state (app, GS_APP_STATE_UNAVAILABLE);
        }
 }
 
diff --git a/src/gs-app-row.c b/src/gs-app-row.c
index 4efd5660a..3697864be 100644
--- a/src/gs-app-row.c
+++ b/src/gs-app-row.c
@@ -135,13 +135,16 @@ gs_app_row_refresh_button (GsAppRow *app_row, gboolean missing_search_result)
        /* label */
        switch (gs_app_get_state (priv->app)) {
        case GS_APP_STATE_UNAVAILABLE:
-               gtk_widget_set_visible (priv->button, TRUE);
-               if (missing_search_result) {
+               if (gs_app_get_kind (priv->app) == AS_COMPONENT_KIND_WEB_APP) {
+                       gtk_widget_set_visible (priv->button, FALSE);
+               } else if (missing_search_result) {
+                       gtk_widget_set_visible (priv->button, TRUE);
                        /* TRANSLATORS: this is a button next to the search results that
                         * allows the application to be easily installed */
                        gs_progress_button_set_label (GS_PROGRESS_BUTTON (priv->button), _("Visit Website"));
                        gs_progress_button_set_icon_name (GS_PROGRESS_BUTTON (priv->button), NULL);
                } else {
+                       gtk_widget_set_visible (priv->button, TRUE);
                        /* TRANSLATORS: this is a button next to the search results that
                         * allows the application to be easily installed.
                         * The ellipsis indicates that further steps are required */
diff --git a/src/gs-details-page.c b/src/gs-details-page.c
index dd1591087..a6abe824a 100644
--- a/src/gs-details-page.c
+++ b/src/gs-details-page.c
@@ -842,7 +842,9 @@ gs_details_page_refresh_buttons (GsDetailsPage *self)
                }
                break;
        case GS_APP_STATE_UNAVAILABLE:
-               if (gs_app_get_url_missing (self->app) != NULL) {
+               if (gs_app_get_kind (self->app) == AS_COMPONENT_KIND_WEB_APP) {
+                       gtk_widget_set_visible (self->button_install, FALSE);
+               } else if (gs_app_get_url_missing (self->app) != NULL) {
                        gtk_widget_set_visible (self->button_install, FALSE);
                } else {
                        gtk_widget_set_visible (self->button_install, TRUE);


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