[gnome-software/wip/rancell/ubuntu-3-20-3: 16/55] Use AS_APP_QUIRK_NOT_LAUNCHABLE to control the Launch button visibility



commit b571f182c20d1a6cce4259f49cb8cb7341658a24
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                  |    5 +++++
 src/gs-shell-details.c        |    3 +--
 src/plugins/gs-appstream.c    |   19 +++++++++++++++++++
 src/plugins/gs-plugin-fwupd.c |    2 ++
 4 files changed, 27 insertions(+), 2 deletions(-)
---
diff --git a/src/gs-app.h b/src/gs-app.h
index b8f9c35..5e3d03f 100644
--- a/src/gs-app.h
+++ b/src/gs-app.h
@@ -82,6 +82,11 @@ typedef enum {
 #define AS_APP_QUIRK_NOT_REVIEWABLE            (1 << 5)
 #endif
 
+#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);
 
 GsApp          *gs_app_new                     (const gchar    *id);
diff --git a/src/gs-shell-details.c b/src/gs-shell-details.c
index 57e0aa9..437f619 100644
--- a/src/gs-shell-details.c
+++ b/src/gs-shell-details.c
@@ -256,8 +256,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 5d85e16..b62050b 100644
--- a/src/plugins/gs-appstream.c
+++ b/src/plugins/gs-appstream.c
@@ -488,6 +488,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 abf1f16..4e1b65a 100644
--- a/src/plugins/gs-plugin-fwupd.c
+++ b/src/plugins/gs-plugin-fwupd.c
@@ -207,6 +207,8 @@ gs_plugin_fwupd_set_app_from_kv (GsApp *app, const gchar *key, GVariant *val)
 {
        g_debug ("key %s", key);
 
+       gs_app_add_quirk (app, AS_APP_QUIRK_NOT_LAUNCHABLE);
+
        if (g_strcmp0 (key, "AppstreamId") == 0) {
                gs_app_set_id (app, g_variant_get_string (val, NULL));
                return;


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