From 1371e1c81911a73b65908f01ca7bd0647794ba31 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 29 Oct 2020 15:10:00 +0000 Subject: [PATCH 1/2] =?UTF-8?q?libmalcontent-ui:=20Bump=20appstream-glib?= =?UTF-8?q?=20dependency=20to=20=E2=89=A5=200.7.15?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows some (but not all) of the fallback code to be dropped. appstream-glib 0.7.17 is available on all versions of Fedora and Debian which malcontent is packaged for: • https://packages.debian.org/search?suite=bullseye&searchon=names&keywords=appstream-glib • https://src.fedoraproject.org/rpms/libappstream-glib Signed-off-by: Philip Withnall --- libmalcontent-ui/gs-content-rating.c | 45 ---------------------------- libmalcontent-ui/meson.build | 2 +- libmalcontent-ui/user-controls.c | 38 ----------------------- 3 files changed, 1 insertion(+), 84 deletions(-) diff --git a/libmalcontent-ui/gs-content-rating.c b/libmalcontent-ui/gs-content-rating.c index ced6a92..feb06af 100644 --- a/libmalcontent-ui/gs-content-rating.c +++ b/libmalcontent-ui/gs-content-rating.c @@ -577,51 +577,6 @@ static const struct { }; #endif /* appstream-glib < 0.7.18 */ -#if !AS_CHECK_VERSION(0, 7, 15) -/** - * as_content_rating_id_value_to_csm_age: - * @id: the subsection ID e.g. "violence-cartoon" - * @value: the #AsContentRatingValue, e.g. %MCT_APP_FILTER_OARS_VALUE_INTENSE - * - * Gets the Common Sense Media approved age for a specific rating level. - * - * Returns: The age in years, or 0 for no details. - * - * Since: 0.5.12 - **/ -guint -as_content_rating_id_value_to_csm_age (const gchar *id, MctAppFilterOarsValue value) -{ - if (value == AS_CONTENT_RATING_VALUE_UNKNOWN || - value == AS_CONTENT_RATING_VALUE_LAST) - return 0; - - for (gsize i = 0; i < G_N_ELEMENTS (oars_to_csm_mappings); i++) { - if (g_str_equal (id, oars_to_csm_mappings[i].id)) { - switch (value) { - case AS_CONTENT_RATING_VALUE_NONE: - return oars_to_csm_mappings[i].csm_age_none; - case AS_CONTENT_RATING_VALUE_MILD: - return oars_to_csm_mappings[i].csm_age_mild; - case AS_CONTENT_RATING_VALUE_MODERATE: - return oars_to_csm_mappings[i].csm_age_moderate; - case AS_CONTENT_RATING_VALUE_INTENSE: - return oars_to_csm_mappings[i].csm_age_intense; - case AS_CONTENT_RATING_VALUE_UNKNOWN: - case AS_CONTENT_RATING_VALUE_LAST: - default: - /* Handled above. */ - g_assert_not_reached (); - return 0; - } - } - } - - /* @id not found. */ - return 0; -} -#endif /* appstream-glib < 0.7.15 */ - #if !AS_CHECK_VERSION(0, 7, 18) /** * as_content_rating_id_csm_age_to_value: diff --git a/libmalcontent-ui/meson.build b/libmalcontent-ui/meson.build index b4e70c7..1cfa354 100644 --- a/libmalcontent-ui/meson.build +++ b/libmalcontent-ui/meson.build @@ -36,7 +36,7 @@ libmalcontent_ui_public_deps = [ libmalcontent_dep, ] libmalcontent_ui_private_deps = [ - dependency('appstream-glib'), + dependency('appstream-glib', version: '>= 0.7.15'), dependency('flatpak'), ] diff --git a/libmalcontent-ui/user-controls.c b/libmalcontent-ui/user-controls.c index 8689a78..06a7428 100644 --- a/libmalcontent-ui/user-controls.c +++ b/libmalcontent-ui/user-controls.c @@ -167,40 +167,6 @@ static const GActionEntry actions[] = { { "set-age", on_set_age_action_activated, "u", NULL, NULL, { 0, }} }; -#if !AS_CHECK_VERSION(0, 7, 15) -static const gchar * const oars_categories[] = -{ - "violence-cartoon", - "violence-fantasy", - "violence-realistic", - "violence-bloodshed", - "violence-sexual", - "violence-desecration", - "violence-slavery", - "violence-worship", - "drugs-alcohol", - "drugs-narcotics", - "drugs-tobacco", - "sex-nudity", - "sex-themes", - "sex-homosexuality", - "sex-prostitution", - "sex-adultery", - "sex-appearance", - "language-profanity", - "language-humor", - "language-discrimination", - "social-chat", - "social-info", - "social-audio", - "social-location", - "social-contacts", - "money-purchasing", - "money-gambling", - NULL -}; -#endif /* appstream-glib < 0.7.15 */ - /* Auxiliary methods */ static GsContentRatingSystem @@ -388,9 +354,7 @@ update_oars_level (MctUserControls *self) guint maximum_age; gsize i; gboolean all_categories_unset; -#if AS_CHECK_VERSION(0, 7, 15) g_autofree const gchar **oars_categories = as_content_rating_get_all_rating_ids (); -#endif g_assert (self->filter != NULL); @@ -1495,9 +1459,7 @@ mct_user_controls_build_app_filter (MctUserControls *self, { gboolean restrict_web_browsers; gsize i; -#if AS_CHECK_VERSION(0, 7, 15) g_autofree const gchar **oars_categories = as_content_rating_get_all_rating_ids (); -#endif g_return_if_fail (MCT_IS_USER_CONTROLS (self)); g_return_if_fail (builder != NULL); From fc5432205c345e81c64995a07c51990ce95cc467 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 29 Oct 2020 15:13:09 +0000 Subject: [PATCH 2/2] gs-content-rating: Backport OARS/CSM mapping changes from appstream-glib This is a backport of commit f742cc3cf2428 from appstream-glib: as-content-rating: Align the OARS/CSM mappings of sex-* Align the OARS/CSM mappings of sex-homosexuality and sex-themes, as the two are identical apart from discriminating on sexual orientation. This is a follow-up to commit 01e9ee8113a8ad. Signed-off-by: Philip Withnall Signed-off-by: Philip Withnall --- libmalcontent-ui/gs-content-rating.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmalcontent-ui/gs-content-rating.c b/libmalcontent-ui/gs-content-rating.c index feb06af..73e9e21 100644 --- a/libmalcontent-ui/gs-content-rating.c +++ b/libmalcontent-ui/gs-content-rating.c @@ -567,7 +567,7 @@ static const struct { { "social-info", OARS_1_0, 0, 0, 13, 13 }, { "social-location", OARS_1_0, 0, 13, 13, 13 }, /* v1.1 additions */ - { "sex-homosexuality", OARS_1_1, 0, 10, 13, 15 }, + { "sex-homosexuality", OARS_1_1, 0, 13, 14, 15 }, { "sex-prostitution", OARS_1_1, 0, 12, 14, 18 }, { "sex-adultery", OARS_1_1, 0, 8, 10, 18 }, { "sex-appearance", OARS_1_1, 0, 10, 10, 15 },