[gnome-software/wip/ubuntu-3-24: 14/14] Ensure valid AppStream files get the fake 'Addon' group applied



commit c8ce2c8cacbaef2d26d5923dcc48eab3d7ae8214
Author: Richard Hughes <richard hughsie com>
Date:   Wed Jun 7 12:44:07 2017 +0100

    Ensure valid AppStream files get the fake 'Addon' group applied
    
    The Debian metadata extractor does not do this, and doing this "client-side"
    is the correct way to assign DE-specific icons. This way we also always show
    fonts with type=font and no categories, and we don't pollute appstream-glib
    with a gnome-software-ism.
    
    While we're breaking everything, remove the plural from the fake groups to
    better match the desktop spec. Given appstream-glib and gnome-software disagree
    on 'Fonts' and 'Font' and that both were written by the same person I think
    it's about time to make this clearer.

 plugins/core/gs-appstream.c                        |   72 +++++++++++++------
 plugins/core/gs-desktop-common.c                   |   14 ++--
 plugins/modalias/gs-self-test.c                    |    4 +-
 .../shell-extensions/gs-plugin-shell-extensions.c  |    8 +-
 plugins/shell-extensions/gs-self-test.c            |    4 +-
 src/gs-category-page.c                             |    4 +-
 6 files changed, 66 insertions(+), 40 deletions(-)
---
diff --git a/plugins/core/gs-appstream.c b/plugins/core/gs-appstream.c
index 0f093fd..f4446ac 100644
--- a/plugins/core/gs-appstream.c
+++ b/plugins/core/gs-appstream.c
@@ -1114,6 +1114,7 @@ void
 gs_appstream_add_extra_info (GsPlugin *plugin, AsApp *app)
 {
        const gchar *tmp;
+       g_autoptr(AsIcon) icon = NULL;
 
        /* add more search terms */
        switch (as_app_get_kind (app)) {
@@ -1128,35 +1129,60 @@ gs_appstream_add_extra_info (GsPlugin *plugin, AsApp *app)
                break;
        }
 
-       /* fix up these */
-       if (as_app_get_kind (app) == AS_APP_KIND_LOCALIZATION &&
-           g_str_has_prefix (as_app_get_id (app),
-                             "org.fedoraproject.LangPack-")) {
-               g_autoptr(AsIcon) icon = NULL;
-
-               /* add icon */
+       /* add the gnome-software-specific 'Addon' group and ensure they
+        * all have an icon set */
+       switch (as_app_get_kind (app)) {
+       case AS_APP_KIND_FONT:
+               as_app_add_category (app, "Addon");
+               as_app_add_category (app, "Font");
+               break;
+       case AS_APP_KIND_SHELL_EXTENSION:
+               as_app_add_category (app, "Addon");
+               as_app_add_category (app, "ShellExtension");
                icon = as_icon_new ();
                as_icon_set_kind (icon, AS_ICON_KIND_STOCK);
-               as_icon_set_name (icon, "accessories-dictionary-symbolic");
+               as_icon_set_name (icon, "application-x-addon-symbolic");
                as_app_add_icon (app, icon);
-
-               /* add categories */
-               as_app_add_category (app, "Addons");
-               as_app_add_category (app, "Localization");
-       }
-
-       /* fall back for drivers */
-       if (as_app_get_kind (app) == AS_APP_KIND_DRIVER) {
-               g_autoptr(AsIcon) icon = NULL;
+               break;
+       case AS_APP_KIND_DRIVER:
+               as_app_add_category (app, "Addon");
+               as_app_add_category (app, "Driver");
                icon = as_icon_new ();
                as_icon_set_kind (icon, AS_ICON_KIND_STOCK);
                as_icon_set_name (icon, "application-x-firmware-symbolic");
                as_app_add_icon (app, icon);
-       }
-
-       /* fix up drivers with our nonstandard groups */
-       if (as_app_get_kind (app) == AS_APP_KIND_DRIVER) {
-               as_app_add_category (app, "Addons");
-               as_app_add_category (app, "Drivers");
+               break;
+       case AS_APP_KIND_LOCALIZATION:
+               as_app_add_category (app, "Addon");
+               as_app_add_category (app, "Localization");
+               icon = as_icon_new ();
+               as_icon_set_kind (icon, AS_ICON_KIND_STOCK);
+               as_icon_set_name (icon, "accessories-dictionary-symbolic");
+               as_app_add_icon (app, icon);
+               break;
+       case AS_APP_KIND_CODEC:
+               as_app_add_category (app, "Addon");
+               as_app_add_category (app, "Codec");
+               icon = as_icon_new ();
+               as_icon_set_kind (icon, AS_ICON_KIND_STOCK);
+               as_icon_set_name (icon, "application-x-addon");
+               as_app_add_icon (app, icon);
+               break;
+       case AS_APP_KIND_INPUT_METHOD:
+               as_app_add_category (app, "Addon");
+               as_app_add_category (app, "InputSource");
+               icon = as_icon_new ();
+               as_icon_set_kind (icon, AS_ICON_KIND_STOCK);
+               as_icon_set_name (icon, "system-run-symbolic");
+               as_app_add_icon (app, icon);
+               break;
+       case AS_APP_KIND_FIRMWARE:
+               icon = as_icon_new ();
+               as_icon_set_kind (icon, AS_ICON_KIND_STOCK);
+               as_icon_set_name (icon, "system-run-symbolic");
+               as_app_add_icon (app, icon);
+               break;
+       default:
+               break;
        }
 }
diff --git a/plugins/core/gs-desktop-common.c b/plugins/core/gs-desktop-common.c
index 4ad45bb..03870ba 100644
--- a/plugins/core/gs-desktop-common.c
+++ b/plugins/core/gs-desktop-common.c
@@ -206,25 +206,25 @@ static const GsDesktopMap map_productivity[] = {
 /* Addons */
 static const GsDesktopMap map_addons[] = {
        { "fonts",              NC_("Menu of Addons", "Fonts"),
-                                       { "Addons::Fonts",
+                                       { "Addon::Font",
                                          NULL} },
        { "codecs",             NC_("Menu of Addons", "Codecs"),
-                                       { "Addons::Codecs",
+                                       { "Addon::Codec",
                                          NULL} },
        { "input-sources",      NC_("Menu of Addons", "Input Sources"),
-                                       { "Addons::InputSources",
+                                       { "Addon::InputSource",
                                          NULL} },
        { "language-packs",     NC_("Menu of Addons", "Language Packs"),
-                                       { "Addons::LanguagePacks",
+                                       { "Addon::LanguagePack",
                                          NULL} },
        { "shell-extensions",   NC_("Menu of Addons", "Shell Extensions"),
-                                       { "Addons::ShellExtensions",
+                                       { "Addon::ShellExtension",
                                          NULL} },
        { "localization",       NC_("Menu of Addons", "Localization"),
-                                       { "Addons::Localization",
+                                       { "Addon::Localization",
                                          NULL} },
        { "drivers",            NC_("Menu of Addons", "Hardware Drivers"),
-                                       { "Addons::Drivers",
+                                       { "Addon::Driver",
                                          NULL} },
        { NULL }
 };
diff --git a/plugins/modalias/gs-self-test.c b/plugins/modalias/gs-self-test.c
index 3c9adb9..00a1306 100644
--- a/plugins/modalias/gs-self-test.c
+++ b/plugins/modalias/gs-self-test.c
@@ -49,8 +49,8 @@ gs_plugins_modalias_func (GsPluginLoader *plugin_loader)
        app = gs_app_list_index (list, 0);
        g_assert_cmpstr (gs_app_get_id (app), ==, "com.hughski.ColorHug2.driver");
        g_assert_cmpint (gs_app_get_kind (app), ==, AS_APP_KIND_DRIVER);
-       g_assert (gs_app_has_category (app, "Addons"));
-       g_assert (gs_app_has_category (app, "Drivers"));
+       g_assert (gs_app_has_category (app, "Addon"));
+       g_assert (gs_app_has_category (app, "Driver"));
 }
 
 int
diff --git a/plugins/shell-extensions/gs-plugin-shell-extensions.c 
b/plugins/shell-extensions/gs-plugin-shell-extensions.c
index a9f1c6a..2d9b7be 100644
--- a/plugins/shell-extensions/gs-plugin-shell-extensions.c
+++ b/plugins/shell-extensions/gs-plugin-shell-extensions.c
@@ -215,8 +215,8 @@ gs_plugin_shell_extensions_add_app (GsPlugin *plugin,
        gs_app_add_icon (app, ic);
 
        /* add categories */
-       gs_app_add_category (app, "Addons");
-       gs_app_add_category (app, "ShellExtensions");
+       gs_app_add_category (app, "Addon");
+       gs_app_add_category (app, "ShellExtension");
 
        return TRUE;
 }
@@ -519,8 +519,8 @@ gs_plugin_shell_extensions_parse_app (GsPlugin *plugin,
        }
 
        /* required to match categories in gnome-software */
-       as_app_add_category (app, "Addons");
-       as_app_add_category (app, "ShellExtensions");
+       as_app_add_category (app, "Addon");
+       as_app_add_category (app, "ShellExtension");
 
        /* we have no data :/ */
        as_app_set_comment (app, NULL, "GNOME Shell Extension");
diff --git a/plugins/shell-extensions/gs-self-test.c b/plugins/shell-extensions/gs-self-test.c
index 0bb98e5..7022ac2 100644
--- a/plugins/shell-extensions/gs-self-test.c
+++ b/plugins/shell-extensions/gs-self-test.c
@@ -66,8 +66,8 @@ gs_plugins_shell_extensions_installed_func (GsPluginLoader *plugin_loader)
                         "enhance the user experience");
        g_assert_cmpstr (gs_app_get_license (app), ==, "GPL-2.0+");
        g_assert_cmpstr (gs_app_get_management_plugin (app), ==, "shell-extensions");
-       g_assert (gs_app_has_category (app, "Addons"));
-       g_assert (gs_app_has_category (app, "ShellExtensions"));
+       g_assert (gs_app_has_category (app, "Addon"));
+       g_assert (gs_app_has_category (app, "ShellExtension"));
        g_assert_cmpstr (gs_app_get_metadata_item (app, "shell-extensions::has-prefs"), ==, "");
        g_assert_cmpstr (gs_app_get_metadata_item (app, "shell-extensions::uuid"), ==,
                         "background-logo fedorahosted org");
diff --git a/src/gs-category-page.c b/src/gs-category-page.c
index 6f41c78..48e51d4 100644
--- a/src/gs-category-page.c
+++ b/src/gs-category-page.c
@@ -129,8 +129,8 @@ gs_category_page_reload (GsPage *page)
                 gs_category_get_id (self->subcategory));
 
        /* show the shell extensions header */
-       if (g_strcmp0 (gs_category_get_id (self->category), "Addons") == 0 &&
-           g_strcmp0 (gs_category_get_id (self->subcategory), "ShellExtensions") == 0) {
+       if (g_strcmp0 (gs_category_get_id (self->category), "Addon") == 0 &&
+           g_strcmp0 (gs_category_get_id (self->subcategory), "ShellExtension") == 0) {
                gtk_widget_set_visible (self->infobar_category_shell_extensions, TRUE);
        } else {
                gtk_widget_set_visible (self->infobar_category_shell_extensions, FALSE);


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