Back to index

lightdm  1.3.2
Classes | Defines | Functions
language.h File Reference
#include <glib-object.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  LightDMLanguage
struct  LightDMLanguageClass

Defines

#define LIGHTDM_TYPE_LANGUAGE   (lightdm_language_get_type())
#define LIGHTDM_LANGUAGE(obj)   (G_TYPE_CHECK_INSTANCE_CAST ((obj), LIGHTDM_TYPE_LANGUAGE, LightDMLanguage));
#define LIGHTDM_LANGUAGE_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass), LIGHTDM_TYPE_LANGUAGE, LightDMLanguageClass))
#define LIGHTDM_IS_LANGUAGE(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LIGHTDM_TYPE_LANGUAGE))
#define LIGHTDM_IS_LANGUAGE_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), LIGHTDM_TYPE_LANGUAGE))
#define LIGHTDM_LANGUAGE_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), LIGHTDM_TYPE_LANGUAGE, LightDMLanguageClass))

Functions

GType lightdm_language_get_type (void)
GList * lightdm_get_languages (void)
 lightdm_get_languages:
LightDMLanguagelightdm_get_language (void)
 lightdm_get_language:
const gchar * lightdm_language_get_code (LightDMLanguage *language)
 lightdm_language_get_code: : A LightDMLanguage
const gchar * lightdm_language_get_name (LightDMLanguage *language)
 lightdm_language_get_name: : A LightDMLanguage
const gchar * lightdm_language_get_territory (LightDMLanguage *language)
 lightdm_language_get_territory: : A LightDMLanguage
gboolean lightdm_language_matches (LightDMLanguage *language, const gchar *code)

Class Documentation

struct LightDMLanguage

Definition at line 26 of file language.h.

Class Members
GObject parent_instance

Define Documentation

#define LIGHTDM_IS_LANGUAGE (   obj)    (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LIGHTDM_TYPE_LANGUAGE))

Definition at line 22 of file language.h.

#define LIGHTDM_IS_LANGUAGE_CLASS (   klass)    (G_TYPE_CHECK_CLASS_TYPE ((klass), LIGHTDM_TYPE_LANGUAGE))

Definition at line 23 of file language.h.

#define LIGHTDM_LANGUAGE (   obj)    (G_TYPE_CHECK_INSTANCE_CAST ((obj), LIGHTDM_TYPE_LANGUAGE, LightDMLanguage));

Definition at line 20 of file language.h.

#define LIGHTDM_LANGUAGE_CLASS (   klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), LIGHTDM_TYPE_LANGUAGE, LightDMLanguageClass))

Definition at line 21 of file language.h.

#define LIGHTDM_LANGUAGE_GET_CLASS (   obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), LIGHTDM_TYPE_LANGUAGE, LightDMLanguageClass))

Definition at line 24 of file language.h.

Definition at line 19 of file language.h.


Function Documentation

lightdm_get_language:

Get the current language.

Return value: (transfer none): The current language or #NULL if no language.

Definition at line 161 of file language.c.

{
    const gchar *lang;
    GList *link;

    lang = g_getenv ("LANG");
    if (!lang)
        return NULL;

    for (link = lightdm_get_languages (); link; link = link->next)
    {
        LightDMLanguage *language = link->data;
        if (lightdm_language_matches (language, lang))
            return language;
    }

    return NULL;
}

Here is the call graph for this function:

GList* lightdm_get_languages ( void  )

lightdm_get_languages:

Get a list of languages to present to the user.

Return value: (element-type LightDMLanguage) (transfer none): A list of LightDMLanguage that should be presented to the user.

Definition at line 188 of file language.c.

{
    update_languages ();
    return languages;
}

Here is the call graph for this function:

Here is the caller graph for this function:

const gchar* lightdm_language_get_code ( LightDMLanguage language)

lightdm_language_get_code: : A LightDMLanguage

Get the code of a language.

Return value: The code of the language

Definition at line 203 of file language.c.

{
    g_return_val_if_fail (LIGHTDM_IS_LANGUAGE (language), NULL);
    return GET_PRIVATE (language)->code;
}
const gchar* lightdm_language_get_name ( LightDMLanguage language)

lightdm_language_get_name: : A LightDMLanguage

Get the name of a language.

Return value: The name of the language

Definition at line 218 of file language.c.

{
    LightDMLanguagePrivate *priv;

    g_return_val_if_fail (LIGHTDM_IS_LANGUAGE (language), NULL);

    priv = GET_PRIVATE (language);

    if (!priv->name)
    {
        gchar *locale = get_locale_name (priv->code);
        if (locale)
        {
            gchar *current = setlocale (LC_ALL, NULL);
            setlocale (LC_IDENTIFICATION, locale);
            setlocale (LC_MESSAGES, "");

            gchar *language_en = nl_langinfo (_NL_IDENTIFICATION_LANGUAGE);
            if (language_en && strlen (language_en) > 0)
                priv->name = g_strdup (dgettext ("iso_639_3", language_en));

            setlocale (LC_ALL, current);
        }
        if (!priv->name)
        {
            gchar **tokens = g_strsplit_set (priv->code, "_.@", 2);
            priv->name = g_strdup (tokens[0]);
            g_strfreev (tokens);
        }
    }

    return priv->name;
}

Here is the call graph for this function:

const gchar* lightdm_language_get_territory ( LightDMLanguage language)

lightdm_language_get_territory: : A LightDMLanguage

Get the territory the language is used in.

Return value: The territory the language is used in.

Definition at line 261 of file language.c.

{
    LightDMLanguagePrivate *priv;

    g_return_val_if_fail (LIGHTDM_IS_LANGUAGE (language), NULL);

    priv = GET_PRIVATE (language);

    if (!priv->territory && strchr (priv->code, '_'))
    {
        gchar *locale = get_locale_name (priv->code);
        if (locale)
        {
            gchar *current = setlocale (LC_ALL, NULL);
            setlocale (LC_IDENTIFICATION, locale);
            setlocale (LC_MESSAGES, "");

            gchar *country_en = nl_langinfo (_NL_IDENTIFICATION_TERRITORY);
            if (country_en && strlen (country_en) > 0 && g_strcmp0 (country_en, "ISO") != 0)
                priv->territory = g_strdup (dgettext ("iso_3166", country_en));

            setlocale (LC_ALL, current);
        }
        if (!priv->territory)
        {
            gchar **tokens = g_strsplit_set (priv->code, "_.@", 3);
            priv->territory = g_strdup (tokens[1]);
            g_strfreev (tokens);
        }
    }

    return priv->territory;
}

Here is the call graph for this function:

GType lightdm_language_get_type ( void  )
gboolean lightdm_language_matches ( LightDMLanguage language,
const gchar *  code 
)

Here is the caller graph for this function: