Merge lp:~gber/lightdm/lightdm-language-selection into lp:lightdm

Proposed by Guido Berhoerster
Status: Merged
Approved by: Robert Ancell
Approved revision: 1647
Merged at revision: 1654
Proposed branch: lp:~gber/lightdm/lightdm-language-selection
Merge into: lp:lightdm
Diff against target: 158 lines (+51/-34)
4 files modified
liblightdm-gobject/user.c (+1/-7)
src/accounts.c (+40/-26)
src/accounts.h (+1/-1)
src/display.c (+9/-0)
To merge this branch: bzr merge lp:~gber/lightdm/lightdm-language-selection
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Robert Ancell Approve
Review via email: mp+159095@code.launchpad.net

Description of the change

Fix the two bugs which prevent the language selection from working

To post a comment you must log in.
Revision history for this message
Robert Ancell (robert-ancell) wrote :

What is the #if 0 code doing there? No dead code please.

review: Needs Fixing
1647. By Guido Berhoerster

Remove dead code and clarify comment

Revision history for this message
Guido Berhoerster (gber) wrote :

> What is the #if 0 code doing there? No dead code please.

Removed and clarified comment.

Revision history for this message
Robert Ancell (robert-ancell) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'liblightdm-gobject/user.c'
2--- liblightdm-gobject/user.c 2013-01-31 20:56:09 +0000
3+++ liblightdm-gobject/user.c 2013-04-19 09:45:32 +0000
4@@ -1132,16 +1132,10 @@
5
6 // FIXME: Watch for changes
7
8- /* The Language field is actually a locale, strip the codeset off it to get the language */
9+ /* The Language field contains the locale */
10 if (priv->language)
11 g_free (priv->language);
12 priv->language = g_key_file_get_string (priv->dmrc_file, "Desktop", "Language", NULL);
13- if (priv->language)
14- {
15- gchar *codeset = strchr (priv->language, '.');
16- if (codeset)
17- *codeset = '\0';
18- }
19
20 if (priv->layouts)
21 {
22
23=== modified file 'src/accounts.c'
24--- src/accounts.c 2012-01-13 13:05:33 +0000
25+++ src/accounts.c 2013-04-19 09:45:32 +0000
26@@ -44,9 +44,6 @@
27 /* Language */
28 gchar *language;
29
30- /* Locale */
31- gchar *locale;
32-
33 /* X session */
34 gchar *xsession;
35 };
36@@ -332,36 +329,52 @@
37 return user->priv->shell;
38 }
39
40-const gchar *
41-user_get_locale (User *user)
42-{
43- g_return_val_if_fail (user != NULL, NULL);
44-
45- g_free (user->priv->locale);
46- if (user->priv->proxy)
47- user->priv->locale = NULL;
48- else
49- user->priv->locale = get_string_from_dmrc (user->priv->name, "Desktop", "Language");
50-
51- /* Treat a blank locale as unset */
52- if (g_strcmp0 (user->priv->locale, "") == 0)
53- {
54- g_free (user->priv->locale);
55- user->priv->locale = NULL;
56- }
57-
58- return user->priv->locale;
59-}
60-
61 void
62 user_set_language (User *user, const gchar *language)
63 {
64 g_return_if_fail (user != NULL);
65
66+ call_method (user->priv->proxy, "SetLanguage", g_variant_new ("(s)", language), "()", NULL);
67+ save_string_to_dmrc (user->priv->name, "Desktop", "Language", language);
68+}
69+
70+const gchar *
71+user_get_language (User *user)
72+{
73+ GVariant *variant, *inner;
74+ gboolean success;
75+
76+ g_return_val_if_fail (user != NULL, NULL);
77+
78+ g_free (user->priv->language);
79 if (user->priv->proxy)
80- call_method (user->priv->proxy, "SetLanguage", g_variant_new ("(s)", language), "()", NULL);
81+ {
82+ /* the "Language" property cannot be retrieved with get_property () here since it
83+ * uses g_dbus_proxy_get_cached_property () which would return the previous (cached) value
84+ * of the "Language" property
85+ */
86+ success = call_method (user->priv->proxy, "org.freedesktop.DBus.Properties.Get", g_variant_new ("(ss)", g_dbus_proxy_get_interface_name(user->priv->proxy), "Language"), "(v)", &variant);
87+ if (success)
88+ {
89+ g_variant_get (variant, "(v)", &inner);
90+ user->priv->language = g_variant_dup_string (inner, NULL);
91+ g_variant_unref (inner);
92+ g_variant_unref (variant);
93+ }
94+ else
95+ user->priv->language = NULL;
96+ }
97 else
98- save_string_to_dmrc (user->priv->name, "Desktop", "Language", language);
99+ user->priv->language = get_string_from_dmrc (user->priv->name, "Desktop", "Language");
100+
101+ /* Treat a blank language as unset */
102+ if (g_strcmp0 (user->priv->language, "") == 0)
103+ {
104+ g_free (user->priv->language);
105+ user->priv->language = NULL;
106+ }
107+
108+ return user->priv->language;
109 }
110
111 void
112@@ -436,6 +449,7 @@
113 g_free (self->priv->gecos);
114 g_free (self->priv->home_directory);
115 g_free (self->priv->shell);
116+ g_free (self->priv->language);
117
118 G_OBJECT_CLASS (user_parent_class)->finalize (object);
119 }
120
121=== modified file 'src/accounts.h'
122--- src/accounts.h 2011-11-29 04:42:03 +0000
123+++ src/accounts.h 2013-04-19 09:45:32 +0000
124@@ -58,7 +58,7 @@
125
126 void user_set_xsession (User *user, const gchar *session);
127
128-const gchar *user_get_locale (User *user);
129+const gchar *user_get_language (User *user);
130
131 void user_set_language (User *user, const gchar *language);
132
133
134=== modified file 'src/display.c'
135--- src/display.c 2013-03-26 22:22:49 +0000
136+++ src/display.c 2013-04-19 09:45:32 +0000
137@@ -702,6 +702,7 @@
138 {
139 User *user;
140 gchar *filename, *sessions_dir, *path;
141+ const gchar *language;
142 gchar **argv;
143
144 user = session_get_user (display->priv->session);
145@@ -725,6 +726,14 @@
146 if (!argv)
147 return TRUE;
148
149+ /* Retrieve language setting */
150+ language = user_get_language (user);
151+ if (language != NULL && language != '\0')
152+ {
153+ session_set_env (display->priv->session, "LANG", language);
154+ session_set_env (display->priv->session, "GDM_LANG", language);
155+ }
156+
157 session_set_env (display->priv->session, "DESKTOP_SESSION", display->priv->user_session); // FIXME: Apparently deprecated?
158 session_set_env (display->priv->session, "GDMSESSION", display->priv->user_session); // FIXME: Not cross-desktop
159

Subscribers

People subscribed via source and target branches