[gnome-software] Ensure valid AppStream files get the fake 'Addon' group applied
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Ensure valid AppStream files get the fake 'Addon' group applied
- Date: Wed, 7 Jun 2017 12:48:07 +0000 (UTC)
commit f0942644284b33f1e4291377e9760069353b6472
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 d8f6557..c18e176 100644
--- a/plugins/core/gs-appstream.c
+++ b/plugins/core/gs-appstream.c
@@ -1179,6 +1179,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)) {
@@ -1193,35 +1194,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 81358f7..bd7262f 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 32e4366..a7baf27 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 1d92a21..b9b0187 100644
--- a/plugins/shell-extensions/gs-self-test.c
+++ b/plugins/shell-extensions/gs-self-test.c
@@ -65,8 +65,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 9a3e7b8..1ba8ab5 100644
--- a/src/gs-category-page.c
+++ b/src/gs-category-page.c
@@ -130,8 +130,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]