fixup! libmalcontent-ui: Update content rating formatting code

This commit is contained in:
Philip Withnall 2020-05-21 16:02:40 +01:00
parent 9064babe6f
commit 150d303d39
3 changed files with 26 additions and 6 deletions

View File

@ -462,11 +462,31 @@ static const gchar *content_rating_strings[GS_CONTENT_RATING_SYSTEM_LAST][7] = {
{ "3+", "7+", "12+", "16+", "18+", NULL }, /* GS_CONTENT_RATING_SYSTEM_IARC */ { "3+", "7+", "12+", "16+", "18+", NULL }, /* GS_CONTENT_RATING_SYSTEM_IARC */
}; };
const gchar * const * gchar **
gs_utils_content_rating_get_values (GsContentRatingSystem system) gs_utils_content_rating_get_values (GsContentRatingSystem system)
{ {
g_assert (system < GS_CONTENT_RATING_SYSTEM_LAST); g_return_val_if_fail ((int) system < GS_CONTENT_RATING_SYSTEM_LAST, NULL);
return content_rating_strings[system];
/* IARC is the fallback for everything */
if (system == GS_CONTENT_RATING_SYSTEM_UNKNOWN)
system = GS_CONTENT_RATING_SYSTEM_IARC;
/* ESRB is special as it requires localised suffixes */
if (system == GS_CONTENT_RATING_SYSTEM_ESRB) {
g_auto(GStrv) esrb_ages = g_new0 (gchar *, 7);
esrb_ages[0] = get_esrb_string (content_rating_strings[system][0], _("Early Childhood"));
esrb_ages[1] = get_esrb_string (content_rating_strings[system][1], _("Everyone"));
esrb_ages[2] = get_esrb_string (content_rating_strings[system][2], _("Everyone 10+"));
esrb_ages[3] = get_esrb_string (content_rating_strings[system][3], _("Teen"));
esrb_ages[4] = get_esrb_string (content_rating_strings[system][4], _("Mature"));
esrb_ages[5] = get_esrb_string (content_rating_strings[system][5], _("Adults Only"));
esrb_ages[6] = NULL;
return g_steal_pointer (&esrb_ages);
}
return g_strdupv ((gchar **) content_rating_strings[system]);
} }
static guint content_rating_ages[GS_CONTENT_RATING_SYSTEM_LAST][7] = { static guint content_rating_ages[GS_CONTENT_RATING_SYSTEM_LAST][7] = {

View File

@ -51,7 +51,7 @@ gchar *gs_utils_content_rating_age_to_str (GsContentRatingSystem system,
guint age); guint age);
GsContentRatingSystem gs_utils_content_rating_system_from_locale (const gchar *locale); GsContentRatingSystem gs_utils_content_rating_system_from_locale (const gchar *locale);
const gchar *gs_content_rating_system_to_str (GsContentRatingSystem system); const gchar *gs_content_rating_system_to_str (GsContentRatingSystem system);
const gchar * const *gs_utils_content_rating_get_values (GsContentRatingSystem system); gchar **gs_utils_content_rating_get_values (GsContentRatingSystem system);
const guint *gs_utils_content_rating_get_ages (GsContentRatingSystem system); const guint *gs_utils_content_rating_get_ages (GsContentRatingSystem system);
guint as_content_rating_id_value_to_csm_age (const gchar *id, MctAppFilterOarsValue value); guint as_content_rating_id_value_to_csm_age (const gchar *id, MctAppFilterOarsValue value);
MctAppFilterOarsValue as_content_rating_id_csm_age_to_value (const gchar *id, guint age); MctAppFilterOarsValue as_content_rating_id_csm_age_to_value (const gchar *id, guint age);

View File

@ -316,7 +316,7 @@ static void
update_categories_from_language (MctUserControls *self) update_categories_from_language (MctUserControls *self)
{ {
GsContentRatingSystem rating_system; GsContentRatingSystem rating_system;
const gchar * const * entries; g_auto(GStrv) entries = NULL;
const gchar *rating_system_str; const gchar *rating_system_str;
const guint *ages; const guint *ages;
gsize i; gsize i;
@ -680,7 +680,7 @@ on_set_age_action_activated (GSimpleAction *action,
{ {
GsContentRatingSystem rating_system; GsContentRatingSystem rating_system;
MctUserControls *self; MctUserControls *self;
const gchar * const * entries; g_auto(GStrv) entries = NULL;
const guint *ages; const guint *ages;
guint age; guint age;
guint i; guint i;