[gnome-software] gs-content-rating: Expose list of all OARS categories



commit 46b988ede900d648ba65f478742f49d81f549997
Author: Philip Withnall <withnall endlessm com>
Date:   Tue Nov 12 13:46:58 2019 +0000

    gs-content-rating: Expose list of all OARS categories
    
    This is equivalent to `as_content_rating_get_all_rating_ids()`, but we
    can use it without bumping our appstream-glib dependency. It could
    eventually be dropped once we depend on appstream-glib ≥ 0.7.15.
    
    Signed-off-by: Philip Withnall <withnall endlessm com>

 src/gs-content-rating.c | 13 +++++++++++++
 src/gs-content-rating.h |  1 +
 2 files changed, 14 insertions(+)
---
diff --git a/src/gs-content-rating.c b/src/gs-content-rating.c
index d9fc8ca9..8984983b 100644
--- a/src/gs-content-rating.c
+++ b/src/gs-content-rating.c
@@ -383,6 +383,19 @@ gs_content_rating_key_value_to_str (const gchar *id, AsContentRatingValue value)
        return NULL;
 }
 
+/* Equivalent to as_content_rating_get_all_rating_ids() */
+const gchar **
+gs_content_rating_get_all_rating_ids (void)
+{
+       g_autoptr(GPtrArray) ids = g_ptr_array_new_with_free_func (NULL);
+
+       for (gsize i = 0; i < G_N_ELEMENTS (oars_descriptions); i++)
+               g_ptr_array_add (ids, (gpointer) oars_descriptions[i].id);
+       g_ptr_array_add (ids, NULL);
+
+       return (const gchar **) g_ptr_array_free (g_steal_pointer (&ids), FALSE);
+}
+
 static char *
 get_esrb_string (gchar *source, gchar *translate)
 {
diff --git a/src/gs-content-rating.h b/src/gs-content-rating.h
index a69873f4..5494f2b5 100644
--- a/src/gs-content-rating.h
+++ b/src/gs-content-rating.h
@@ -38,6 +38,7 @@ gchar *gs_utils_content_rating_age_to_str (GsContentRatingSystem system,
 GsContentRatingSystem gs_utils_content_rating_system_from_locale (const gchar *locale);
 const gchar *gs_content_rating_key_value_to_str (const gchar *id,
                                                 AsContentRatingValue value);
+const gchar **gs_content_rating_get_all_rating_ids (void);
 const gchar *gs_content_rating_system_to_str (GsContentRatingSystem system);
 
 G_END_DECLS


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]