[gnome-software] extras: Fix button handling for apps in UNAVAILABLE state



commit b68366e5eb0fa3e009cd21beebd1159c0ce41459
Author: Kalev Lember <klember redhat com>
Date:   Thu Jan 31 21:55:37 2019 +0100

    extras: Fix button handling for apps in UNAVAILABLE state
    
    When we have an app in UNAVAILABLE state, it can mean two things:
    
     a) it's a "not found" app created in the extras page; in this case we
        need to handle the "Visit website" button
    
     b) it's an app that's from enabled=0 enabled_metadata=1 repo; in this
        case we are handing "Install..." button and first ask for
        confirmation whether to enable the repo as well
    
    Fixes: https://gitlab.gnome.org/GNOME/gnome-software/issues/587

 src/gs-extras-page.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
---
diff --git a/src/gs-extras-page.c b/src/gs-extras-page.c
index 737fbaa9..9885d304 100644
--- a/src/gs-extras-page.c
+++ b/src/gs-extras-page.c
@@ -262,16 +262,22 @@ static void
 app_row_button_clicked_cb (GsAppRow *app_row,
                            GsExtrasPage *self)
 {
-       GsApp *app;
-       app = gs_app_row_get_app (app_row);
-       if (gs_app_get_state (app) == AS_APP_STATE_AVAILABLE ||
-           gs_app_get_state (app) == AS_APP_STATE_AVAILABLE_LOCAL)
+       GsApp *app = gs_app_row_get_app (app_row);
+
+       if (gs_app_get_state (app) == AS_APP_STATE_UNAVAILABLE &&
+           gs_app_get_url (app, AS_URL_KIND_MISSING) != NULL) {
+               gs_shell_show_uri (self->shell,
+                                  gs_app_get_url (app, AS_URL_KIND_MISSING));
+       } else if (gs_app_get_state (app) == AS_APP_STATE_AVAILABLE ||
+                  gs_app_get_state (app) == AS_APP_STATE_AVAILABLE_LOCAL ||
+                  gs_app_get_state (app) == AS_APP_STATE_UNAVAILABLE) {
                gs_page_install_app (GS_PAGE (self), app, GS_SHELL_INTERACTION_FULL,
                                     self->search_cancellable);
-       else if (gs_app_get_state (app) == AS_APP_STATE_INSTALLED)
+       } else if (gs_app_get_state (app) == AS_APP_STATE_INSTALLED) {
                gs_page_remove_app (GS_PAGE (self), app, self->search_cancellable);
-       else
+       } else {
                g_critical ("extras: app in unexpected state %u", gs_app_get_state (app));
+       }
 }
 
 static void


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