summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrobert.ancell@canonical.com <>2011-02-12 13:09:07 +1100
committerrobert.ancell@canonical.com <>2011-02-12 13:09:07 +1100
commitd0928b89bbd232ef6d46986064b34cf0fddb00c5 (patch)
treef3d4db6557b4c8001e5618a321f4ccf1163a0c81
parent1e08c9f3908769bceba221bed108b32beffc9429 (diff)
downloadlightdm-d0928b89bbd232ef6d46986064b34cf0fddb00c5.tar.gz
Correctly pass LANG and LANGUAGE through to the session
-rw-r--r--NEWS1
-rw-r--r--doc/lightdm-gobject-0-sections.txt1
-rw-r--r--doc/tmpl/language.sgml10
-rw-r--r--greeters/lightdm-gtk-greeter.c2
-rw-r--r--liblightdm-gobject/greeter.c10
-rw-r--r--liblightdm-gobject/language.c30
-rw-r--r--liblightdm-gobject/language.h2
-rw-r--r--liblightdm-qt/ldmgreeter.cpp14
-rw-r--r--src/display.c10
-rw-r--r--src/display.h2
-rw-r--r--src/display.xml1
11 files changed, 65 insertions, 18 deletions
diff --git a/NEWS b/NEWS
index a8e9a9e7..2f7c3ba3 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ Overview of changes in lightdm 0.2.4
* Generate metadata for QT libraries
* Move Webkit greeter into separate module
* Rename ldm-gtk-greeter to lightdm-gtk-greeter
+ * Correctly pass LANG and LANGUAGE through to the session
Overview of changes in lightdm 0.2.3
diff --git a/doc/lightdm-gobject-0-sections.txt b/doc/lightdm-gobject-0-sections.txt
index 20261d07..caf90b3b 100644
--- a/doc/lightdm-gobject-0-sections.txt
+++ b/doc/lightdm-gobject-0-sections.txt
@@ -7,6 +7,7 @@ LdmLanguage
ldm_language_get_code
ldm_language_get_name
ldm_language_get_territory
+ldm_language_matches
<SUBSECTION Standard>
LDM_IS_LANGUAGE
LDM_IS_LANGUAGE_CLASS
diff --git a/doc/tmpl/language.sgml b/doc/tmpl/language.sgml
index 27b44666..b87efab3 100644
--- a/doc/tmpl/language.sgml
+++ b/doc/tmpl/language.sgml
@@ -68,3 +68,13 @@ Information about an available language
@Returns:
+<!-- ##### FUNCTION ldm_language_matches ##### -->
+<para>
+
+</para>
+
+@language:
+@code:
+@Returns:
+
+
diff --git a/greeters/lightdm-gtk-greeter.c b/greeters/lightdm-gtk-greeter.c
index a5fb147e..ab32bb6d 100644
--- a/greeters/lightdm-gtk-greeter.c
+++ b/greeters/lightdm-gtk-greeter.c
@@ -637,7 +637,7 @@ main(int argc, char **argv)
language_radio_list = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_item));
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
- if (g_str_equal (ldm_language_get_code (language), ldm_greeter_get_default_language (greeter)))
+ if (ldm_language_matches (language, ldm_greeter_get_default_language (greeter)))
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item), TRUE);
g_object_set_data (G_OBJECT (menu_item), "language", g_strdup (ldm_language_get_code (language)));
diff --git a/liblightdm-gobject/greeter.c b/liblightdm-gobject/greeter.c
index ae15874a..9a18705d 100644
--- a/liblightdm-gobject/greeter.c
+++ b/liblightdm-gobject/greeter.c
@@ -70,7 +70,6 @@ struct _LdmGreeterPrivate
gboolean have_users;
GList *users;
- gchar *default_language;
gboolean have_languages;
GList *languages;
@@ -187,7 +186,6 @@ ldm_greeter_connect (LdmGreeter *greeter)
result = dbus_g_proxy_call (greeter->priv->display_proxy, "Connect", &error,
G_TYPE_INVALID,
G_TYPE_STRING, &greeter->priv->theme,
- G_TYPE_STRING, &greeter->priv->default_language,
G_TYPE_STRING, &greeter->priv->default_layout,
G_TYPE_STRING, &greeter->priv->default_session,
G_TYPE_STRING, &greeter->priv->timed_user,
@@ -195,9 +193,9 @@ ldm_greeter_connect (LdmGreeter *greeter)
G_TYPE_INVALID);
if (result)
- g_debug ("Connected theme=%s default-language=%s default-layout=%s default-session=%s timed-user=%s login-delay=%d",
+ g_debug ("Connected theme=%s default-layout=%s default-session=%s timed-user=%s login-delay=%d",
greeter->priv->theme,
- greeter->priv->default_language, greeter->priv->default_layout, greeter->priv->default_session,
+ greeter->priv->default_layout, greeter->priv->default_session,
greeter->priv->timed_user, greeter->priv->login_delay);
else
g_warning ("Failed to connect to display manager: %s", error->message);
@@ -480,7 +478,7 @@ const gchar *
ldm_greeter_get_default_language (LdmGreeter *greeter)
{
g_return_val_if_fail (greeter != NULL, NULL);
- return greeter->priv->default_language;
+ return getenv ("LANG");
}
/**
@@ -1192,6 +1190,8 @@ static void
ldm_greeter_init (LdmGreeter *greeter)
{
greeter->priv = G_TYPE_INSTANCE_GET_PRIVATE (greeter, LDM_TYPE_GREETER, LdmGreeterPrivate);
+
+ g_debug ("default-language=%s", ldm_greeter_get_default_language (greeter));
}
static void
diff --git a/liblightdm-gobject/language.c b/liblightdm-gobject/language.c
index b3e9373b..1375c254 100644
--- a/liblightdm-gobject/language.c
+++ b/liblightdm-gobject/language.c
@@ -102,6 +102,36 @@ ldm_language_get_territory (LdmLanguage *language)
return language->priv->territory;
}
+static gboolean
+is_utf8 (const gchar *code)
+{
+ return g_str_has_suffix (code, ".utf8") || g_str_has_suffix (code, ".UTF-8");
+}
+
+/**
+ * ldm_language_matches:
+ * @language: A #LdmLanguage
+ * @code: A language code
+ *
+ * Check if a language code matches this language.
+ *
+ * Return value: TRUE if the code matches this language.
+ **/
+gboolean
+ldm_language_matches (LdmLanguage *language, const gchar *code)
+{
+ /* Handle the fact the UTF-8 is specified both as '.utf8' and '.UTF-8' */
+ if (is_utf8 (language->priv->code) && is_utf8 (code))
+ {
+ /* Match the characters before the '.' */
+ int i;
+ for (i = 0; language->priv->code[i] && code[i] && language->priv->code[i] == code[i] && code[i] != '.' ; i++);
+ return language->priv->code[i] == '.' && code[i] == '.';
+ }
+
+ return g_str_equal (language->priv->code, code);
+}
+
static void
ldm_language_init (LdmLanguage *language)
{
diff --git a/liblightdm-gobject/language.h b/liblightdm-gobject/language.h
index a67289ac..ac189b99 100644
--- a/liblightdm-gobject/language.h
+++ b/liblightdm-gobject/language.h
@@ -48,6 +48,8 @@ const gchar *ldm_language_get_name (LdmLanguage *language);
const gchar *ldm_language_get_territory (LdmLanguage *language);
+gboolean ldm_language_matches (LdmLanguage *language, const gchar *code);
+
G_END_DECLS
#endif /* _LDM_LANGUAGE_H_ */
diff --git a/liblightdm-qt/ldmgreeter.cpp b/liblightdm-qt/ldmgreeter.cpp
index 569220bf..607294c2 100644
--- a/liblightdm-qt/ldmgreeter.cpp
+++ b/liblightdm-qt/ldmgreeter.cpp
@@ -17,7 +17,6 @@
class LdmGreeterPrivate
{
public:
- QString language;
QString layout;
QString session;
QString username;
@@ -60,7 +59,7 @@ LdmGreeter::LdmGreeter() :
d->userManager = new UserManagerInterface("org.lightdm.LightDisplayManager", "/org/lightdm/LightDisplayManager/Users", busType, this);
d->consoleKit = new ConsoleKitInterface("org.freedesktop.ConsoleKit","/org/freedesktop/ConsoleKit/Manager", QDBusConnection::systemBus(), this );
- QDBusPendingReply<QString, QString, QString, QString, QString, int> connectResult = d->display->Connect();
+ QDBusPendingReply<QString, QString, QString, QString, int> connectResult = d->display->Connect();
connectResult.waitForFinished();
if(!connectResult.isValid())
{
@@ -69,11 +68,10 @@ LdmGreeter::LdmGreeter() :
else
{
d->themeName = connectResult.argumentAt<0>();
- d->language = connectResult.argumentAt<1>();
- d->layout = connectResult.argumentAt<2>();
- d->session = connectResult.argumentAt<3>();
- d->username = connectResult.argumentAt<4>();
- d->delay = connectResult.argumentAt<5>();
+ d->layout = connectResult.argumentAt<1>();
+ d->session = connectResult.argumentAt<2>();
+ d->username = connectResult.argumentAt<3>();
+ d->delay = connectResult.argumentAt<4>();
}
connect(d->display, SIGNAL(QuitGreeter()), SLOT(close()));
@@ -94,7 +92,7 @@ QString LdmGreeter::hostname()
QString LdmGreeter::defaultLanguage()
{
- return d->language;
+ return getenv("LANG");
}
QString LdmGreeter::defaultLayout()
diff --git a/src/display.c b/src/display.c
index 54f882f2..09aababa 100644
--- a/src/display.c
+++ b/src/display.c
@@ -431,7 +431,10 @@ start_user_session (Display *display, const gchar *session, const gchar *languag
/* Update the .dmrc with changed settings */
g_key_file_set_string (dmrc_file, "Desktop", "Session", session);
if (language)
+ {
g_key_file_set_string (dmrc_file, "Desktop", "Language", language);
+ g_key_file_set_string (dmrc_file, "Desktop", "Langlist", language);
+ }
if (!g_key_file_has_key (dmrc_file, "Desktop", "Layout", NULL))
g_key_file_set_string (dmrc_file, "Desktop", "Layout", display->priv->default_layout);
@@ -645,6 +648,10 @@ start_greeter (Display *display)
g_signal_connect (G_OBJECT (display->priv->greeter_session), "exited", G_CALLBACK (greeter_session_exited_cb), display);
g_signal_connect (G_OBJECT (display->priv->greeter_session), "killed", G_CALLBACK (greeter_session_killed_cb), display);
session_set_env (display->priv->greeter_session, "DISPLAY", xserver_get_address (display->priv->xserver));
+ if (getenv ("LANG"))
+ session_set_env (display->priv->greeter_session, "LANG", getenv ("LANG"));
+ if (getenv ("LANGUAGE"))
+ session_set_env (display->priv->greeter_session, "LANGUAGE", getenv ("LANGUAGE"));
if (display->priv->greeter_ck_session)
session_set_env (display->priv->greeter_session, "XDG_SESSION_COOKIE", ck_connector_get_cookie (display->priv->greeter_ck_session));
set_env_from_pam_session (display->priv->greeter_session, display->priv->greeter_pam_session);
@@ -716,7 +723,7 @@ session_started_cb (PAMSession *session, Display *display)
gboolean
display_connect (Display *display,
const gchar **theme,
- const gchar **language, const gchar **layout, const gchar **session,
+ const gchar **layout, const gchar **session,
const gchar **username, gint *delay, GError *error)
{
if (!display->priv->greeter_connected)
@@ -726,7 +733,6 @@ display_connect (Display *display,
}
*theme = g_build_filename (THEME_DIR, display->priv->greeter_theme, "index.theme", NULL);
- *language = g_strdup (getenv ("LANG") ? getenv ("LANG") : "C");
*layout = g_strdup (display->priv->default_layout);
*session = g_strdup (display->priv->default_session);
*username = g_strdup (display->priv->default_user);
diff --git a/src/display.h b/src/display.h
index 2333d913..3befa1e7 100644
--- a/src/display.h
+++ b/src/display.h
@@ -95,7 +95,7 @@ gboolean display_start (Display *display);
// FIXME: Make greeter its own object?
-gboolean display_connect (Display *display, const gchar **theme, const gchar **language, const gchar **layout, const gchar **session, const gchar **username, gint *delay, GError *error);
+gboolean display_connect (Display *display, const gchar **theme, const gchar **layout, const gchar **session, const gchar **username, gint *delay, GError *error);
gboolean display_start_authentication (Display *display, const gchar *username, DBusGMethodInvocation *context);
diff --git a/src/display.xml b/src/display.xml
index c9877747..4e21ec16 100644
--- a/src/display.xml
+++ b/src/display.xml
@@ -5,7 +5,6 @@
<!-- Method for greeter to connect to display manager -->
<method name="Connect">
<arg name="theme" direction="out" type="s"/>
- <arg name="language" direction="out" type="s"/>
<arg name="layout" direction="out" type="s"/>
<arg name="session" direction="out" type="s"/>
<arg name="username" direction="out" type="s"/>