[gnome-software] trivial: Move the location of appstream_app_get_locale_value()



commit 3411a21ccc01d287b8b30b7a52d3b70cf211e807
Author: Richard Hughes <richard hughsie com>
Date:   Sat Oct 5 19:57:40 2013 +0100

    trivial: Move the location of appstream_app_get_locale_value()
    
    We need this for AppData too.

 src/plugins/appstream-app.c    |   35 ++++-------------------------------
 src/plugins/appstream-common.c |   28 ++++++++++++++++++++++++++++
 src/plugins/appstream-common.h |    1 +
 3 files changed, 33 insertions(+), 31 deletions(-)
---
diff --git a/src/plugins/appstream-app.c b/src/plugins/appstream-app.c
index 6c28c1a..47f2449 100644
--- a/src/plugins/appstream-app.c
+++ b/src/plugins/appstream-app.c
@@ -21,10 +21,8 @@
 
 #include "config.h"
 
-#define _GNU_SOURCE
-#include <string.h>
-
 #include "appstream-app.h"
+#include "appstream-common.h"
 
 struct AppstreamApp
 {
@@ -48,31 +46,6 @@ struct AppstreamApp
 };
 
 /**
- * appstream_app_get_locale_value:
- *
- * Returns a metric on how good a match the locale is, with 0 being an
- * exact match and higher numbers meaning further away from perfect.
- */
-static guint
-appstream_app_get_locale_value (const gchar *lang)
-{
-       const gchar * const *locales;
-       guint i;
-
-       /* shortcut as C will always match */
-       if (lang == NULL || strcmp (lang, "C") == 0)
-               return G_MAXUINT - 1;
-
-       locales = g_get_language_names ();
-       for (i = 0; locales[i] != NULL; i++) {
-               if (g_ascii_strcasecmp (locales[i], lang) == 0)
-                       return i;
-       }
-
-       return G_MAXUINT;
-}
-
-/**
  * appstream_app_free:
  */
 void
@@ -270,7 +243,7 @@ appstream_app_set_name (AppstreamApp *app,
 {
        guint new_value;
 
-       new_value = appstream_app_get_locale_value (lang);
+       new_value = appstream_get_locale_value (lang);
        if (new_value < app->name_value) {
                g_free (app->name);
                app->name = g_strndup (name, length);
@@ -289,7 +262,7 @@ appstream_app_set_summary (AppstreamApp *app,
 {
        guint new_value;
 
-       new_value = appstream_app_get_locale_value (lang);
+       new_value = appstream_get_locale_value (lang);
        if (new_value < app->summary_value) {
                g_free (app->summary);
                app->summary = g_strndup (summary, length);
@@ -330,7 +303,7 @@ appstream_app_set_description (AppstreamApp *app,
 {
        guint new_value;
 
-       new_value = appstream_app_get_locale_value (lang);
+       new_value = appstream_get_locale_value (lang);
        if (new_value < app->description_value) {
                g_free (app->description);
                app->description = g_strndup (description, length);
diff --git a/src/plugins/appstream-common.c b/src/plugins/appstream-common.c
index 77d0f8a..3140473 100644
--- a/src/plugins/appstream-common.c
+++ b/src/plugins/appstream-common.c
@@ -21,6 +21,9 @@
 
 #include "config.h"
 
+#define _GNU_SOURCE
+#include <string.h>
+
 #include "appstream-common.h"
 
 /**
@@ -116,3 +119,28 @@ appstream_tag_to_string (AppstreamTag tag)
                return "image";
        return NULL;
 }
+
+/**
+ * appstream_get_locale_value:
+ *
+ * Returns a metric on how good a match the locale is, with 0 being an
+ * exact match and higher numbers meaning further away from perfect.
+ */
+guint
+appstream_get_locale_value (const gchar *lang)
+{
+       const gchar * const *locales;
+       guint i;
+
+       /* shortcut as C will always match */
+       if (lang == NULL || strcmp (lang, "C") == 0)
+               return G_MAXUINT - 1;
+
+       locales = g_get_language_names ();
+       for (i = 0; locales[i] != NULL; i++) {
+               if (g_ascii_strcasecmp (locales[i], lang) == 0)
+                       return i;
+       }
+
+       return G_MAXUINT;
+}
diff --git a/src/plugins/appstream-common.h b/src/plugins/appstream-common.h
index fc4d3c7..a9e1107 100644
--- a/src/plugins/appstream-common.h
+++ b/src/plugins/appstream-common.h
@@ -52,6 +52,7 @@ typedef enum {
 
 AppstreamTag    appstream_tag_from_string      (const gchar    *element_name);
 const gchar    *appstream_tag_to_string        (AppstreamTag    tag);
+guint           appstream_get_locale_value     (const gchar    *lang);
 
 G_END_DECLS
 


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