[gnome-software/wip/temp/ubuntu-xenial-rebased: 322/329] Use AS_APP_QUIRK_NOT_LAUNCHABLE to control the Launch button visibility



commit fafb8f481f04452b82f5f8da17cf2038ae7881a2
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        |    4 +---
 src/plugins/gs-appstream.c    |   19 +++++++++++++++++++
 src/plugins/gs-plugin-fwupd.c |    2 ++
 4 files changed, 27 insertions(+), 3 deletions(-)
---
diff --git a/src/gs-app.h b/src/gs-app.h
index d09dc1d..d0a4724 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 1664171..ee33676 100644
--- a/src/gs-shell-details.c
+++ b/src/gs-shell-details.c
@@ -258,9 +258,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) &&
-                    g_strcmp0 (gs_app_get_management_plugin (self->app), "snappy") != 0) {
+               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 5c04ae2..479ee5b 100644
--- a/src/plugins/gs-appstream.c
+++ b/src/plugins/gs-appstream.c
@@ -486,6 +486,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 02fe467..52c7fbc 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]