[gnome-software: 17/18] gs-app-context-bar: Use short forms of content ratings where possible
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 17/18] gs-app-context-bar: Use short forms of content ratings where possible
- Date: Tue, 29 Jun 2021 14:17:07 +0000 (UTC)
commit d17038a7ac581dc436b2b133d5e26e93566e6868
Author: Philip Withnall <pwithnall endlessos org>
Date: Fri Jun 25 18:18:45 2021 +0100
gs-app-context-bar: Use short forms of content ratings where possible
Where an official acronym/short form of a content rating is defined, use
it, to try and minimise the size of the age rating lozenge.
See discussion at https://gitlab.gnome.org/GNOME/gnome-software/-/merge_requests/770#note_1186442
Signed-off-by: Philip Withnall <pwithnall endlessos org>
Helps: #1111
src/gs-app-context-bar.c | 30 +++++++++++++++++++++++++++++-
1 file changed, 29 insertions(+), 1 deletion(-)
---
diff --git a/src/gs-app-context-bar.c b/src/gs-app-context-bar.c
index a218334b8..cd40aaea1 100644
--- a/src/gs-app-context-bar.c
+++ b/src/gs-app-context-bar.c
@@ -484,6 +484,34 @@ build_age_rating_description (AsContentRating *content_rating)
return g_strjoinv (_("; "), (gchar **) descriptions->pdata);
}
+/* Wrapper around as_content_rating_system_format_age() which returns the short
+ * form of the content rating. This doesn’t make a difference for most ratings
+ * systems, but it does for ESRB which normally produces quite long strings.
+ *
+ * FIXME: This should probably be upstreamed into libappstream once it’s been in
+ * the GNOME 41 release and stabilised. */
+static gchar *
+content_rating_system_format_age_short (AsContentRatingSystem system,
+ guint age)
+{
+ if (system == AS_CONTENT_RATING_SYSTEM_ESRB) {
+ if (age >= 18)
+ return g_strdup ("AO");
+ if (age >= 17)
+ return g_strdup ("M");
+ if (age >= 13)
+ return g_strdup ("T");
+ if (age >= 10)
+ return g_strdup ("E10+");
+ if (age >= 6)
+ return g_strdup ("E");
+
+ return g_strdup ("EC");
+ }
+
+ return as_content_rating_system_format_age (system, age);
+}
+
static void
update_age_rating_tile (GsAppContextBar *self)
{
@@ -517,7 +545,7 @@ update_age_rating_tile (GsAppContextBar *self)
age = as_content_rating_get_minimum_age (content_rating);
if (age != G_MAXUINT)
- age_text = as_content_rating_system_format_age (system, age);
+ age_text = content_rating_system_format_age_short (system, age);
/* Some ratings systems (PEGI) don’t start at age 0 */
if (content_rating != NULL && age_text == NULL && age == 0)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]