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

[virt-tools-list] [libosinfo PATCHv3 5/9] media: Add OsinfoMedia::languages property



This lists all the languages a given media can show its UI in.
---
 osinfo/libosinfo.syms         |  1 +
 osinfo/osinfo_media.c         | 65 ++++++++++++++++++++++++++++++++++++++++++-
 osinfo/osinfo_media.h         |  2 ++
 osinfo/osinfo_media_private.h |  1 +
 4 files changed, 68 insertions(+), 1 deletion(-)

diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
index 4d886f6..767a1fc 100644
--- a/osinfo/libosinfo.syms
+++ b/osinfo/libosinfo.syms
@@ -397,6 +397,7 @@ LIBOSINFO_0.2.3 {
 
 	osinfo_install_script_get_config_params;
 
+	osinfo_media_get_languages;
 	osinfo_media_get_os;
 } LIBOSINFO_0.2.2;
 
diff --git a/osinfo/osinfo_media.c b/osinfo/osinfo_media.c
index d891615..abf449d 100644
--- a/osinfo/osinfo_media.c
+++ b/osinfo/osinfo_media.c
@@ -154,7 +154,8 @@ enum {
     PROP_INSTALLER,
     PROP_LIVE,
     PROP_INSTALLER_REBOOTS,
-    PROP_OS
+    PROP_OS,
+    PROP_LANGUAGES,
 };
 
 static void
@@ -225,6 +226,10 @@ osinfo_media_get_property (GObject    *object,
         g_value_take_object (value, osinfo_media_get_os (media));
         break;
 
+    case PROP_LANGUAGES:
+        g_value_set_pointer (value, osinfo_media_get_languages (media));
+        break;
+
     default:
         /* We don't have any other property... */
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -311,6 +316,10 @@ osinfo_media_set_property(GObject      *object,
         osinfo_media_set_os(media, g_value_get_object(value));
         break;
 
+    case PROP_LANGUAGES:
+        osinfo_media_set_languages(media, g_value_get_pointer(value));
+        break;
+
     default:
         /* We don't have any other property... */
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -517,6 +526,24 @@ osinfo_media_class_init (OsinfoMediaClass *klass)
                                   G_PARAM_READWRITE |
                                   G_PARAM_STATIC_STRINGS);
     g_object_class_install_property (g_klass, PROP_OS, pspec);
+
+    /*
+     * OsinfoMedia::languages:
+     *
+     * If media is an installer, this property indicates the languages that
+     * can be used during automatic installations.
+     *
+     * On media that are not installers, this property will indicate the
+     * languages that the user interface can be displayed in.
+     * Use #osinfo_media_get_installer (or OsinfoMedia::installer) to know
+     * if the media is an installer or not.
+     */
+    pspec = g_param_spec_pointer ("languages",
+                                  "Languages",
+                                  _("Supported languages"),
+                                  G_PARAM_READABLE |
+                                  G_PARAM_STATIC_STRINGS);
+    g_object_class_install_property (g_klass, PROP_LANGUAGES, pspec);
 }
 
 static void
@@ -1102,6 +1129,42 @@ void osinfo_media_set_os(OsinfoMedia *media, OsinfoOs *os)
     g_weak_ref_set(&media->priv->os, os);
     g_object_unref(os);
 }
+
+/**
+ * osinfo_media_get_languages:
+ * @media: a #OsinfoMedia instance
+ *
+ * If media is an installer, this property indicates the languages that
+ * can be used during automatic installations.
+ *
+ * On media that are not installers, this property will indicate the
+ * languages that the user interface can be displayed in.
+ * Use #osinfo_media_get_installer (or OsinfoMedia::installer) to know
+ * if the media is an installer or not.
+ *
+ * Returns: (transfer container) (element-type utf8): a #GList
+ * containing the list of supported supported languages which must be
+ * freed with g_list_free() when no longer neede, or NULL if the supported
+ * languages are unknown
+ */
+GList *osinfo_media_get_languages(OsinfoMedia *media)
+{
+    g_return_val_if_fail(OSINFO_IS_MEDIA(media), NULL);
+    return osinfo_entity_get_param_value_list(OSINFO_ENTITY(media), OSINFO_MEDIA_PROP_LANG);
+}
+
+void osinfo_media_set_languages(OsinfoMedia *media, GList *languages)
+{
+    GList *it;
+
+    g_return_if_fail(OSINFO_IS_MEDIA(media));
+
+    osinfo_entity_clear_param(OSINFO_ENTITY(media), OSINFO_MEDIA_PROP_LANG);
+    for (it = languages; it != NULL; it = it->next)
+        osinfo_entity_add_param(OSINFO_ENTITY(media),
+                                OSINFO_MEDIA_PROP_LANG,
+                                it->data);
+}
 /*
  * Local variables:
  *  indent-tabs-mode: nil
diff --git a/osinfo/osinfo_media.h b/osinfo/osinfo_media.h
index 8d34688..8c8d649 100644
--- a/osinfo/osinfo_media.h
+++ b/osinfo/osinfo_media.h
@@ -81,6 +81,7 @@ typedef struct _OsinfoMediaPrivate OsinfoMediaPrivate;
 #define OSINFO_MEDIA_PROP_LIVE           "live"
 #define OSINFO_MEDIA_PROP_INSTALLER      "installer"
 #define OSINFO_MEDIA_PROP_INSTALLER_REBOOTS "installer-reboots"
+#define OSINFO_MEDIA_PROP_LANG           "l10n-language"
 
 /* object */
 struct _OsinfoMedia
@@ -125,6 +126,7 @@ const gchar *osinfo_media_get_application_id(OsinfoMedia *media);
 const gchar *osinfo_media_get_kernel_path(OsinfoMedia *media);
 const gchar *osinfo_media_get_initrd_path(OsinfoMedia *media);
 OsinfoOs *osinfo_media_get_os(OsinfoMedia *media);
+GList *osinfo_media_get_languages(OsinfoMedia *media);
 gboolean osinfo_media_get_installer(OsinfoMedia *media);
 gboolean osinfo_media_get_live(OsinfoMedia *media);
 gint osinfo_media_get_installer_reboots(OsinfoMedia *media);
diff --git a/osinfo/osinfo_media_private.h b/osinfo/osinfo_media_private.h
index 00ae697..efaffd1 100644
--- a/osinfo/osinfo_media_private.h
+++ b/osinfo/osinfo_media_private.h
@@ -26,6 +26,7 @@
 #ifndef __OSINFO_MEDIA_PRIVATE_H__
 #define __OSINFO_MEDIA_PRIVATE_H__
 
+void osinfo_media_set_languages(OsinfoMedia *media, GList *languages);
 void osinfo_media_set_os(OsinfoMedia *media, OsinfoOs *os);
 
 #endif /* __OSINFO_MEDIA_PRIVATE_H__ */
-- 
1.8.0.1


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