From faa0b9a3eb90b455b5fe2ba9c322c2c9fee5895d Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Fri, 20 Mar 2020 14:55:36 +0000 Subject: [PATCH] app-filter: Factor out a helper function This introduces no functional changes, but will make an upcoming change a little simpler. Signed-off-by: Philip Withnall --- libmalcontent/app-filter.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/libmalcontent/app-filter.c b/libmalcontent/app-filter.c index a9d9683..9340caf 100644 --- a/libmalcontent/app-filter.c +++ b/libmalcontent/app-filter.c @@ -108,6 +108,21 @@ mct_app_filter_get_user_id (MctAppFilter *filter) return filter->user_id; } +static MctAppFilterOarsValue +oars_str_to_enum (const gchar *value_str) +{ + if (g_str_equal (value_str, "none")) + return MCT_APP_FILTER_OARS_VALUE_NONE; + else if (g_str_equal (value_str, "mild")) + return MCT_APP_FILTER_OARS_VALUE_MILD; + else if (g_str_equal (value_str, "moderate")) + return MCT_APP_FILTER_OARS_VALUE_MODERATE; + else if (g_str_equal (value_str, "intense")) + return MCT_APP_FILTER_OARS_VALUE_INTENSE; + else + return MCT_APP_FILTER_OARS_VALUE_UNKNOWN; +} + /** * mct_app_filter_is_path_allowed: * @filter: an #MctAppFilter @@ -477,16 +492,7 @@ mct_app_filter_get_oars_value (MctAppFilter *filter, if (!g_variant_lookup (filter->oars_ratings, oars_section, "&s", &value_str)) return MCT_APP_FILTER_OARS_VALUE_UNKNOWN; - if (g_str_equal (value_str, "none")) - return MCT_APP_FILTER_OARS_VALUE_NONE; - else if (g_str_equal (value_str, "mild")) - return MCT_APP_FILTER_OARS_VALUE_MILD; - else if (g_str_equal (value_str, "moderate")) - return MCT_APP_FILTER_OARS_VALUE_MODERATE; - else if (g_str_equal (value_str, "intense")) - return MCT_APP_FILTER_OARS_VALUE_INTENSE; - else - return MCT_APP_FILTER_OARS_VALUE_UNKNOWN; + return oars_str_to_enum (value_str); } /**