[virt-tools-list] [libosinfo PATCHv2 5/9] media: Add OsinfoMedia::languages property
Christophe Fergeau
cfergeau at redhat.com
Tue Dec 11 20:17:07 UTC 2012
This lists all the languages a given media can show its UI in.
---
osinfo/osinfo_media.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++-
osinfo/osinfo_media.h | 2 ++
2 files changed, 66 insertions(+), 1 deletion(-)
diff --git a/osinfo/osinfo_media.c b/osinfo/osinfo_media.c
index 7654cf7..c30afe8 100644
--- a/osinfo/osinfo_media.c
+++ b/osinfo/osinfo_media.c
@@ -153,7 +153,8 @@ enum {
PROP_INSTALLER,
PROP_LIVE,
PROP_INSTALLER_REBOOTS,
- PROP_OS
+ PROP_OS,
+ PROP_LANGUAGES,
};
static void
@@ -224,6 +225,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);
@@ -310,6 +315,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);
@@ -516,6 +525,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
@@ -1101,6 +1128,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 2a4f392..274e11c 100644
--- a/osinfo/osinfo_media.h
+++ b/osinfo/osinfo_media.h
@@ -126,6 +126,8 @@ 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);
void osinfo_media_set_os(OsinfoMedia *media, OsinfoOs *os);
+GList *osinfo_media_get_languages(OsinfoMedia *media);
+void osinfo_media_set_languages(OsinfoMedia *media, GList *languages);
gboolean osinfo_media_get_installer(OsinfoMedia *media);
gboolean osinfo_media_get_live(OsinfoMedia *media);
gint osinfo_media_get_installer_reboots(OsinfoMedia *media);
--
1.8.0.1
More information about the virt-tools-list
mailing list