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

Zeeshan Ali (Khattak) zeeshanak at gnome.org
Wed Dec 12 02:17:58 UTC 2012


On Tue, Dec 11, 2012 at 10:17 PM, Christophe Fergeau
<cfergeau at redhat.com> wrote:
> 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)

I wonder if this should be internal only?

-- 
Regards,

Zeeshan Ali (Khattak)
FSF member#5124




More information about the virt-tools-list mailing list