[gnome-software: 5/6] gs-appstream: Add support for <supports> element
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 5/6] gs-appstream: Add support for <supports> element
- Date: Wed, 25 May 2022 13:28:45 +0000 (UTC)
commit ddf256d3d4361388fe6200ae55ba2649eac6f44e
Author: Philip Withnall <pwithnall endlessos org>
Date: Tue May 24 22:06:37 2022 +0100
gs-appstream: Add support for <supports> element
This is another element in the same family as `<requires>` and
`<recommends>`.
It has a slightly different meaning from `<recommends>`, but for now the
gnome-software code treats it as identical, as it’s new to the appstream
spec and many apps which might want to use it are probably still using
`<recommends>` instead.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
Fixes: #1774
lib/gs-app.c | 3 ++-
lib/gs-appstream.c | 7 +++++--
src/gs-app-context-bar.c | 10 ++++++++++
src/gs-hardware-support-context-dialog.c | 23 +++++++++++++++++++----
4 files changed, 36 insertions(+), 7 deletions(-)
---
diff --git a/lib/gs-app.c b/lib/gs-app.c
index ca6b6a3db..125a5e008 100644
--- a/lib/gs-app.c
+++ b/lib/gs-app.c
@@ -5892,7 +5892,8 @@ gs_app_class_init (GsAppClass *klass)
* %NULL is equivalent to an empty array. Relations of kind
* %AS_RELATION_KIND_REQUIRES are conjunctive, so each additional
* relation further restricts the set of computers which can run the
- * app. Relations of kind %AS_RELATION_KIND_RECOMMENDS are disjunctive.
+ * app. Relations of kind %AS_RELATION_KIND_RECOMMENDS and
+ * %AS_RELATION_KIND_SUPPORTS are disjunctive.
*
* Since: 41
*/
diff --git a/lib/gs-appstream.c b/lib/gs-appstream.c
index 6e275116e..45fdcb3f3 100644
--- a/lib/gs-appstream.c
+++ b/lib/gs-appstream.c
@@ -886,14 +886,14 @@ gs_appstream_refine_app_relation (GsApp *app,
as_relation_set_kind (relation, kind);
if (g_str_equal (item_kind, "control")) {
- /*
https://www.freedesktop.org/software/appstream/docs/chap-Metadata.html#tag-requires-recommends-control */
+ /*
https://www.freedesktop.org/software/appstream/docs/chap-Metadata.html#tag-relations-control */
as_relation_set_item_kind (relation, AS_RELATION_ITEM_KIND_CONTROL);
as_relation_set_value_control_kind (relation, as_control_kind_from_string
(xb_node_get_text (child)));
} else if (g_str_equal (item_kind, "display_length")) {
AsDisplayLengthKind display_length_kind;
const gchar *compare;
- /*
https://www.freedesktop.org/software/appstream/docs/chap-Metadata.html#tag-requires-recommends-display_length
*/
+ /*
https://www.freedesktop.org/software/appstream/docs/chap-Metadata.html#tag-relations-display_length */
as_relation_set_item_kind (relation, AS_RELATION_ITEM_KIND_DISPLAY_LENGTH);
compare = xb_node_get_attr (child, "compare");
@@ -929,6 +929,9 @@ gs_appstream_refine_app_relations (GsApp *app,
const gchar *element_name;
AsRelationKind relation_kind;
} relation_types[] = {
+#if AS_CHECK_VERSION(0, 15, 0)
+ { "supports", AS_RELATION_KIND_SUPPORTS },
+#endif
{ "recommends", AS_RELATION_KIND_RECOMMENDS },
{ "requires", AS_RELATION_KIND_REQUIRES },
};
diff --git a/src/gs-app-context-bar.c b/src/gs-app-context-bar.c
index 9b9cad5ca..d2ff4b95b 100644
--- a/src/gs-app-context-bar.c
+++ b/src/gs-app-context-bar.c
@@ -619,10 +619,20 @@ update_hardware_support_tile (GsAppContextBar *self)
/* Otherwise, is it adaptive? Note that %AS_RELATION_KIND_RECOMMENDS
* means more like ‘supports’ than ‘recommends’. */
+#if AS_CHECK_VERSION(0, 15, 0)
+ if (icon_name == NULL &&
+ (control_relations[AS_CONTROL_KIND_TOUCH] == AS_RELATION_KIND_RECOMMENDS ||
+ control_relations[AS_CONTROL_KIND_TOUCH] == AS_RELATION_KIND_SUPPORTS) &&
+ (control_relations[AS_CONTROL_KIND_KEYBOARD] == AS_RELATION_KIND_RECOMMENDS ||
+ control_relations[AS_CONTROL_KIND_KEYBOARD] == AS_RELATION_KIND_SUPPORTS) &&
+ (control_relations[AS_CONTROL_KIND_POINTING] == AS_RELATION_KIND_RECOMMENDS ||
+ control_relations[AS_CONTROL_KIND_POINTING] == AS_RELATION_KIND_SUPPORTS)) {
+#else
if (icon_name == NULL &&
control_relations[AS_CONTROL_KIND_TOUCH] == AS_RELATION_KIND_RECOMMENDS &&
control_relations[AS_CONTROL_KIND_KEYBOARD] == AS_RELATION_KIND_RECOMMENDS &&
control_relations[AS_CONTROL_KIND_POINTING] == AS_RELATION_KIND_RECOMMENDS) {
+#endif
icon_name = "adaptive-symbolic";
/* Translators: This is used in a context tile to indicate that
* an app works on phones, tablets *and* desktops. It should be
diff --git a/src/gs-hardware-support-context-dialog.c b/src/gs-hardware-support-context-dialog.c
index c1a4d60c5..88343d68b 100644
--- a/src/gs-hardware-support-context-dialog.c
+++ b/src/gs-hardware-support-context-dialog.c
@@ -15,8 +15,12 @@
* #GsHardwareSupportContextDialog is a dialog which shows detailed information
* about what hardware an app requires or recommends to be used when running it.
* For example, what input devices it requires, and what display sizes it
- * supports. This information is derived from the `<requires>` and
- * `<recommends>` elements in the app’s appdata.
+ * supports. This information is derived from the `<requires>`,
+ * `<recommends>` and `<supports>` elements in the app’s appdata.
+ *
+ * Currently, `<supports>` is treated as a synonym of `<recommends>` as it’s
+ * only just been introduced into the appstream standard, and many apps which
+ * should be using `<supports>` are still using `<recommends>`.
*
* It is designed to show a more detailed view of the information which the
* app’s hardware support tile in #GsAppContextBar is derived from.
@@ -127,6 +131,9 @@ add_relation_row (GtkListBox *list_box,
}
break;
case AS_RELATION_KIND_RECOMMENDS:
+#if AS_CHECK_VERSION(0, 15, 0)
+ case AS_RELATION_KIND_SUPPORTS:
+#endif
rating = GS_CONTEXT_DIALOG_ROW_IMPORTANCE_UNIMPORTANT;
icon_name = icon_name_recommends;
title = title_recommends;
@@ -205,6 +212,10 @@ max_relation_kind (AsRelationKind kind1,
return AS_RELATION_KIND_REQUIRES;
if (kind1 == AS_RELATION_KIND_RECOMMENDS || kind2 == AS_RELATION_KIND_RECOMMENDS)
return AS_RELATION_KIND_RECOMMENDS;
+#if AS_CHECK_VERSION(0, 15, 0)
+ if (kind1 == AS_RELATION_KIND_SUPPORTS || kind2 == AS_RELATION_KIND_SUPPORTS)
+ return AS_RELATION_KIND_SUPPORTS;
+#endif
return AS_RELATION_KIND_UNKNOWN;
}
@@ -328,6 +339,9 @@ gs_hardware_support_context_dialog_get_control_support (GdkDisplay *display,
control_relations[control_kind] = MAX (control_relations[control_kind], kind);
if (kind == AS_RELATION_KIND_REQUIRES ||
+#if AS_CHECK_VERSION(0, 15, 0)
+ kind == AS_RELATION_KIND_SUPPORTS ||
+#endif
kind == AS_RELATION_KIND_RECOMMENDS)
any_control_relations_set = TRUE;
}
@@ -393,8 +407,9 @@ gs_hardware_support_context_dialog_get_control_support (GdkDisplay *display,
*
* @desktop_relation_kind_out is set to the type of support the app has for
* desktop displays: whether they’re required (%AS_RELATION_KIND_REQUIRES),
- * supported but not required (%AS_RELATION_KIND_RECOMMENDS) or whether there’s
- * no information (%AS_RELATION_KIND_UNKNOWN).
+ * supported but not required (%AS_RELATION_KIND_RECOMMENDS or
+ * %AS_RELATION_KIND_SUPPORTS) or whether there’s no information
+ * (%AS_RELATION_KIND_UNKNOWN).
*
* @mobile_match_out and @mobile_relation_kind_out behave similarly, but for
* mobile displays (smaller than 768 pixels).
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]