[gnome-software] Use AS_APP_QUIRK_NOT_LAUNCHABLE to control the Launch button visibility



commit ae409951a113317816f75713e7e1c35fe2769595
Author: Richard Hughes <richard hughsie com>
Date:   Tue Apr 26 20:09:31 2016 +0100

    Use AS_APP_QUIRK_NOT_LAUNCHABLE to control the Launch button visibility

 src/gs-app.h                  |    1 +
 src/gs-shell-details.c        |    3 +--
 src/plugins/gs-appstream.c    |   19 +++++++++++++++++++
 src/plugins/gs-plugin-fwupd.c |    1 +
 4 files changed, 22 insertions(+), 2 deletions(-)
---
diff --git a/src/gs-app.h b/src/gs-app.h
index 0e476d7..5584eba 100644
--- a/src/gs-app.h
+++ b/src/gs-app.h
@@ -84,6 +84,7 @@ typedef enum {
 
 #if !AS_CHECK_VERSION(0,5,15)
 #define AS_APP_QUIRK_HAS_SHORTCUT              (1 << 6)
+#define AS_APP_QUIRK_NOT_LAUNCHABLE            (1 << 7)
 #endif
 
 GQuark          gs_app_error_quark             (void);
diff --git a/src/gs-shell-details.c b/src/gs-shell-details.c
index 6969862..945982f 100644
--- a/src/gs-shell-details.c
+++ b/src/gs-shell-details.c
@@ -312,8 +312,7 @@ gs_shell_details_switch_to (GsPage *page, gboolean scroll_up)
        case AS_APP_STATE_INSTALLED:
        case AS_APP_STATE_UPDATABLE:
        case AS_APP_STATE_UPDATABLE_LIVE:
-               if (gs_app_get_kind (self->app) == AS_APP_KIND_DESKTOP ||
-                   gs_app_get_kind (self->app) == AS_APP_KIND_WEB_APP) {
+               if (!gs_app_has_quirk (self->app, AS_APP_QUIRK_NOT_LAUNCHABLE)) {
                        gtk_widget_set_visible (self->button_details_launch, TRUE);
                } else {
                        gtk_widget_set_visible (self->button_details_launch, FALSE);
diff --git a/src/plugins/gs-appstream.c b/src/plugins/gs-appstream.c
index 4bc8c9d..8101f6f 100644
--- a/src/plugins/gs-appstream.c
+++ b/src/plugins/gs-appstream.c
@@ -460,6 +460,25 @@ gs_appstream_refine_app (GsPlugin *plugin,
                }
        }
 
+       /* types we can never launch */
+       switch (gs_app_get_kind (app)) {
+       case AS_APP_KIND_ADDON:
+       case AS_APP_KIND_CODEC:
+       case AS_APP_KIND_FIRMWARE:
+       case AS_APP_KIND_FONT:
+       case AS_APP_KIND_GENERIC:
+       case AS_APP_KIND_INPUT_METHOD:
+       case AS_APP_KIND_LOCALIZATION:
+       case AS_APP_KIND_OS_UPDATE:
+       case AS_APP_KIND_OS_UPGRADE:
+       case AS_APP_KIND_RUNTIME:
+       case AS_APP_KIND_SOURCE:
+               gs_app_add_quirk (app, AS_APP_QUIRK_NOT_LAUNCHABLE);
+               break;
+       default:
+               break;
+       }
+
        /* set management plugin automatically */
        gs_refine_item_management_plugin (app, item);
 
diff --git a/src/plugins/gs-plugin-fwupd.c b/src/plugins/gs-plugin-fwupd.c
index 1268060..0802cf5 100644
--- a/src/plugins/gs-plugin-fwupd.c
+++ b/src/plugins/gs-plugin-fwupd.c
@@ -196,6 +196,7 @@ gs_plugin_fwupd_new_app_from_results (FwupdResult *res)
        /* default stuff */
        app = gs_app_new (fwupd_result_get_update_id (res));
        gs_app_set_kind (app, AS_APP_KIND_FIRMWARE);
+       gs_app_add_quirk (app, AS_APP_QUIRK_NOT_LAUNCHABLE);
        gs_app_set_management_plugin (app, "fwupd");
        gs_app_add_category (app, "System");
        gs_app_set_metadata (app, "fwupd::DeviceID",


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