Merge lp:~vikoadi/switchboard-plug-locale/new-ui into lp:~elementary-apps/switchboard-plug-locale/trunk
- new-ui
- Merge into trunk
Status: | Rejected |
---|---|
Rejected by: | Marvin Beckers |
Proposed branch: | lp:~vikoadi/switchboard-plug-locale/new-ui |
Merge into: | lp:~elementary-apps/switchboard-plug-locale/trunk |
Diff against target: |
1890 lines (+521/-1030) 16 files modified
cmake/ValaPrecompile.cmake (+0/-1) src/CMakeLists.txt (+4/-4) src/Installer/UbuntuInstaller.vala (+19/-17) src/Installer/aptd-client.vala (+2/-2) src/LocaleManager.vala (+17/-18) src/Plug.vala (+132/-126) src/Widgets/BaseEntry.vala (+0/-54) src/Widgets/InstallEntry.vala (+0/-94) src/Widgets/InstallInfoBar.vala (+1/-1) src/Widgets/InstallPopover.vala (+2/-2) src/Widgets/LanguageEntry.vala (+0/-362) src/Widgets/LanguageList.vala (+0/-349) src/Widgets/LanguageListBox.vala (+49/-0) src/Widgets/LocaleSetting.vala (+249/-0) src/Widgets/Preview.vala (+41/-0) vapi/monetary.vapi (+5/-0) |
To merge this branch: | bzr merge lp:~vikoadi/switchboard-plug-locale/new-ui |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PerfectCarl (community) | Needs Fixing | ||
Review via email: mp+245190@code.launchpad.net |
Commit message
Description of the change
new ui
Cody Garver (codygarver) wrote : | # |
- 71. By Viko Adi Rahmawan
-
add monetary.vapi
Viko Adi Rahmawan (vikoadi) wrote : | # |
add monetary.vapi
- 72. By Viko Adi Rahmawan
-
allow removing language
- 73. By Viko Adi Rahmawan
-
allow removing language
PerfectCarl (name-is-carl) wrote : | # |
Could you remove the --save-temps from cmake/PreCompil
warning: --save-temps has no effect when -C or --ccode is set
PerfectCarl (name-is-carl) wrote : | # |
1) the regions are not sorted it seems
http://
2) Some language are not capitalized in the add dialog. Is it on purpose?
http://
3) Chinese apprears multiple times
http://
PerfectCarl (name-is-carl) wrote : | # |
About 3) same for English.
4) In the add language dialog, Deutsch is listed and also German, Low (Germany). What is the reason behind it
5) In the add language dialog, some languages are displayed with an additional label in parenthesis, some aren't. What is the reason behind it?
6) In the add language dialog, what is the sorting order?
http://
PerfectCarl (name-is-carl) wrote : | # |
7) In the add language dialog, there is a string named 'Unspecified'. What does it do?
PerfectCarl (name-is-carl) wrote : | # |
8) When I add a language (francais on top of the existing English) the language is not displayed in the left list.
Could we add the language so the user can see that their changes are taken into account (and so he got a chance to change the formats before the reboot)
PerfectCarl (name-is-carl) wrote : | # |
About 8) after having log out/log it and even reboot the computer, the language that I added (francais) is not displayed in the left list (nor has it been used as the system language)
Corentin Noël (tintou) wrote : | # |
About 2) This is normal as the language appear in the right locale, for example in french « français » is correct whereas « Français » is incorrect.
About 3) it's a bug that all variants of each languages are shown in this list because it's something that will be selected afterward, but it's not a merge blocker as it's already wrong in trunk.
Corentin Noël (tintou) wrote : | # |
3) 4) 5) are the same problem, here all variants are listed when it should only show the name of the language (for example it should only show English that would install English (UK), English (US), …)
Corentin Noël (tintou) wrote : | # |
You also need to show the thousand separator in the example.
Shawn McTear (syst3mfailur3) wrote : | # |
About 1) Looks like its sorted based on the language code, not the string displayed. "English (United Kindom)" would have the language code of en_GB, which is be correcly between en_CA and en_NZ.
Note: Didn't try this branch or look at code, just an observation based on the screenshot PerfectCarl provided.
PerfectCarl (name-is-carl) wrote : | # |
@tintou
> About 2) This is normal as the language appear in the right locale, for example in french « français » is correct whereas « Français » is incorrect.
I thought about something along those lines.
But text is usually capitalized in comboboxes (see the power plug for an example).
I guess because each line is considered as a new sentence.
So the rule for the language does not feel consistent.
Maybe a ux guy could get us a confirmation
- 74. By Viko Adi Rahmawan
-
enable grouping for number
- 75. By Viko Adi Rahmawan
-
remove --save-temps
Danielle Foré (danrabbit) wrote : | # |
Yes let's please capitalize in the comboboxes and add list since in this case we're talking about a title and not just the word in the middle of a sentence.
Also, if there is only one item in a combobox, we should probably make the box insensitive.
- 76. By Viko Adi Rahmawan
-
trying sort
- 77. By Viko Adi Rahmawan
-
more preview strftime format
- 78. By Viko Adi Rahmawan
-
sort format
Viko Adi Rahmawan (vikoadi) wrote : | # |
@Carl :
* remove --save-temps - DONE
1. region now sorted - DONE
2, 3, 4, 5, 6, 7, I'm not changing anything related to Add Dialog Popover, I'll take a look in another branch
8. It's actually an installation error which dont give any message dialog, I'll try to look at apt-daemon dbus to see how error is handled.
@Corentin:
* thousand separator - DONE
any idea from where /usr/lib/
@Daniel:
* Insensitive Combobox - DONE
* Capitalize - Related to add dialog i mention above.
Viko Adi Rahmawan (vikoadi) wrote : | # |
> About 1) Looks like its sorted based on the language code, not the string
> displayed. "English (United Kindom)" would have the language code of en_GB,
> which is be correcly between en_CA and en_NZ.
>
> Note: Didn't try this branch or look at code, just an observation based on the
> screenshot PerfectCarl provided.
You're right,
Now sorted
- 79. By Viko Adi Rahmawan
-
hide combobox if only have one item
- 80. By Viko Adi Rahmawan
-
show Message Dialog on installation error
- 81. By Viko Adi Rahmawan
-
gettexting
- 82. By Viko Adi Rahmawan
-
no need to simulate
- 83. By Viko Adi Rahmawan
-
dont use translated string for display (but still searchable)
Unmerged revisions
- 83. By Viko Adi Rahmawan
-
dont use translated string for display (but still searchable)
- 82. By Viko Adi Rahmawan
-
no need to simulate
- 81. By Viko Adi Rahmawan
-
gettexting
- 80. By Viko Adi Rahmawan
-
show Message Dialog on installation error
- 79. By Viko Adi Rahmawan
-
hide combobox if only have one item
- 78. By Viko Adi Rahmawan
-
sort format
- 77. By Viko Adi Rahmawan
-
more preview strftime format
- 76. By Viko Adi Rahmawan
-
trying sort
- 75. By Viko Adi Rahmawan
-
remove --save-temps
- 74. By Viko Adi Rahmawan
-
enable grouping for number
Preview Diff
1 | === modified file 'cmake/ValaPrecompile.cmake' |
2 | --- cmake/ValaPrecompile.cmake 2014-06-09 19:13:14 +0000 |
3 | +++ cmake/ValaPrecompile.cmake 2015-01-16 04:39:50 +0000 |
4 | @@ -229,7 +229,6 @@ |
5 | ${vala_pkg_opts} |
6 | ${ARGS_OPTIONS} |
7 | "-g" |
8 | - "--save-temps" |
9 | ${in_files} |
10 | ${custom_vapi_arguments} |
11 | COMMAND |
12 | |
13 | === modified file 'src/CMakeLists.txt' |
14 | --- src/CMakeLists.txt 2014-12-13 17:17:47 +0000 |
15 | +++ src/CMakeLists.txt 2015-01-16 04:39:50 +0000 |
16 | @@ -18,12 +18,11 @@ |
17 | LocaleManager.vala |
18 | Installer/UbuntuInstaller.vala |
19 | Installer/aptd-client.vala |
20 | - Widgets/BaseEntry.vala |
21 | - Widgets/LanguageList.vala |
22 | - Widgets/LanguageEntry.vala |
23 | - Widgets/InstallEntry.vala |
24 | + Widgets/LocaleSetting.vala |
25 | + Widgets/LanguageListBox.vala |
26 | Widgets/InstallPopover.vala |
27 | Widgets/InstallInfoBar.vala |
28 | + Widgets/Preview.vala |
29 | ${CMAKE_CURRENT_BINARY_DIR}/config.vala |
30 | PACKAGES |
31 | gtk+-3.0 |
32 | @@ -34,6 +33,7 @@ |
33 | posix |
34 | ibus-1.0 |
35 | polkit-gobject-1 |
36 | + monetary |
37 | OPTIONS |
38 | --vapidir=${CMAKE_CURRENT_SOURCE_DIR}/../vapi/ |
39 | --thread |
40 | |
41 | === modified file 'src/Installer/UbuntuInstaller.vala' |
42 | --- src/Installer/UbuntuInstaller.vala 2014-12-13 17:32:18 +0000 |
43 | +++ src/Installer/UbuntuInstaller.vala 2015-01-16 04:39:50 +0000 |
44 | @@ -93,14 +93,10 @@ |
45 | |
46 | public void check_missing_languages () { |
47 | Utils.get_missing_languages.begin ((obj, res) => { |
48 | - try { |
49 | - missing_packages = Utils.get_missing_languages.end (res); |
50 | + missing_packages = Utils.get_missing_languages.end (res); |
51 | |
52 | - if (missing_packages != null) |
53 | - check_missing_finished (missing_packages); |
54 | - } catch (Error e) { |
55 | - warning ("cant parse missing language:%s", e.message); |
56 | - } |
57 | + if (missing_packages != null) |
58 | + check_missing_finished (missing_packages); |
59 | }); |
60 | |
61 | } |
62 | @@ -118,7 +114,6 @@ |
63 | |
64 | var installed = get_to_remove_packages_for_language (languagecode); |
65 | |
66 | - |
67 | aptd.remove_packages.begin (installed, (obj, res) => { |
68 | |
69 | try { |
70 | @@ -147,8 +142,22 @@ |
71 | void run_transaction (string transaction_id) { |
72 | |
73 | proxy = new AptdTransactionProxy (); |
74 | - proxy.finished.connect (() => { |
75 | - on_apt_finshed (transaction_id, true); |
76 | + proxy.finished.connect ((id, exit_state) => { |
77 | + if (exit_state == "exit-success") { |
78 | + on_apt_finshed (id, true); |
79 | + } else { |
80 | + on_apt_finshed (id, false); |
81 | + if (exit_state != "exit-cancelled") { |
82 | + var msg = new Gtk.MessageDialog (null, |
83 | + Gtk.DialogFlags.MODAL, |
84 | + Gtk.MessageType.WARNING, |
85 | + Gtk.ButtonsType.OK, |
86 | + _("Transaction Error with exit state: %s").printf (exit_state)); |
87 | + msg.response.connect ( ()=> {msg.destroy ();}); |
88 | + msg.run (); |
89 | + } |
90 | + } |
91 | + |
92 | }); |
93 | |
94 | proxy.property_changed.connect ((prop, val) => { |
95 | @@ -160,8 +169,6 @@ |
96 | |
97 | try { |
98 | proxy.connect_to_aptd (transaction_id); |
99 | - proxy.simulate (); |
100 | - |
101 | proxy.run (); |
102 | } catch (Error e) { |
103 | on_apt_finshed (transaction_id, false); |
104 | @@ -172,11 +179,6 @@ |
105 | |
106 | |
107 | void on_apt_finshed (string id, bool success) { |
108 | - if (!success) { |
109 | - transactions.unset (id); |
110 | - return; |
111 | - } |
112 | - |
113 | if (!transactions.has_key (id)) { //transaction already removed |
114 | return; |
115 | } |
116 | |
117 | === modified file 'src/Installer/aptd-client.vala' |
118 | --- src/Installer/aptd-client.vala 2014-12-13 17:17:47 +0000 |
119 | +++ src/Installer/aptd-client.vala 2015-01-16 04:39:50 +0000 |
120 | @@ -69,7 +69,7 @@ |
121 | |
122 | public class AptdTransactionProxy: GLib.Object |
123 | { |
124 | - public signal void finished (string transaction_id); |
125 | + public signal void finished (string transaction_id, string exit_state); |
126 | public signal void property_changed (string property, Variant variant); |
127 | |
128 | public void connect_to_aptd (string transaction_id) throws IOError |
129 | @@ -78,7 +78,7 @@ |
130 | _aptd_service.finished.connect ((exit_state) => |
131 | { |
132 | debug ("aptd transaction finished: %s\n", exit_state); |
133 | - finished (transaction_id); |
134 | + finished (transaction_id, exit_state); |
135 | }); |
136 | _aptd_service.property_changed.connect ((prop, variant) => { |
137 | property_changed (prop, variant); |
138 | |
139 | === modified file 'src/LocaleManager.vala' |
140 | --- src/LocaleManager.vala 2014-05-07 12:25:29 +0000 |
141 | +++ src/LocaleManager.vala 2015-01-16 04:39:50 +0000 |
142 | @@ -8,9 +8,9 @@ |
143 | MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
144 | PURPOSE. See the GNU General Public License for more details. |
145 | You should have received a copy of the GNU General Public License along |
146 | - with this program. If not, see |
147 | + with this program. If not, see |
148 | ***/ |
149 | - |
150 | + |
151 | /*[DBus (name = "org.freedesktop.locale1")] |
152 | public interface LocaleProxy: GLib.Object |
153 | { |
154 | @@ -53,7 +53,7 @@ |
155 | Gnome.XkbInfo xkbinfo; |
156 | |
157 | public signal void loaded_user (string language, string format, Gee.HashMap<string, string> inputs); |
158 | - |
159 | + |
160 | public signal void connected (); |
161 | |
162 | bool is_connected = false; |
163 | @@ -77,7 +77,7 @@ |
164 | (obj, res) => { |
165 | try { |
166 | locale_proxy = Bus.get_proxy.end (res); |
167 | - |
168 | + |
169 | if (account_proxy != null && locale_proxy != null) { |
170 | is_connected = true; |
171 | connected (); |
172 | @@ -97,7 +97,7 @@ |
173 | (obj, res) => { |
174 | try { |
175 | account_proxy = Bus.get_proxy.end (res); |
176 | - |
177 | + |
178 | if (account_proxy != null && locale1_proxy != null) { |
179 | is_connected = true; |
180 | connected (); |
181 | @@ -107,7 +107,7 @@ |
182 | } catch (Error e) { |
183 | warning ("Could not connect to user account"); |
184 | } |
185 | - |
186 | + |
187 | }); |
188 | |
189 | DBusProxy.create_for_bus.begin (BusType.SYSTEM, |
190 | @@ -120,12 +120,12 @@ |
191 | (obj, res) => { |
192 | try { |
193 | locale1_proxy = DBusProxy.create_for_bus.end (res); |
194 | - |
195 | + |
196 | if (account_proxy != null && locale1_proxy != null) { |
197 | is_connected = true; |
198 | connected (); |
199 | } |
200 | - |
201 | + |
202 | } catch (Error e) { |
203 | warning ("Could not connect to locale1 dbus"); |
204 | } |
205 | @@ -150,10 +150,10 @@ |
206 | while (iter.next ("(ss)", &k, &value)) { |
207 | map.@set (k, value); |
208 | } |
209 | - |
210 | + |
211 | |
212 | loaded_user (language, format, map); |
213 | - |
214 | + |
215 | } |
216 | |
217 | void on_settings_changed (string key) { |
218 | @@ -186,7 +186,7 @@ |
219 | |
220 | /* // leading to segfault, would be my preferred way instead of using raw dbus |
221 | void set_system_language (string language, string? format) { |
222 | - |
223 | + |
224 | var list = new Gee.ArrayList<string> (); |
225 | |
226 | list.add ("LANG=%s".printf (language)); |
227 | @@ -207,7 +207,7 @@ |
228 | |
229 | void set_system_language_direct (string language, string? format) { |
230 | |
231 | - VariantBuilder builder = new VariantBuilder (new VariantType ("as") ); |
232 | + VariantBuilder builder = new VariantBuilder (new VariantType ("as") ); |
233 | builder.add ("s", "LANG=%s".printf (language)); |
234 | if (format != null) { |
235 | builder.add ("s", "LC_TIME=%s".printf (format)); |
236 | @@ -215,11 +215,10 @@ |
237 | builder.add ("s", "LC_MONETARY=%s".printf (format)); |
238 | builder.add ("s", "LC_MEASUREMENT=%s".printf (format)); |
239 | } |
240 | - |
241 | + |
242 | var variant = new Variant ("(asb)", builder, true); |
243 | locale1_proxy.call.begin ("SetLocale", variant, DBusCallFlags.NONE, -1, null); |
244 | - |
245 | - |
246 | + |
247 | } |
248 | |
249 | void set_system_input_direct () { |
250 | @@ -263,7 +262,7 @@ |
251 | debug("Setting user language to %s", language); |
252 | |
253 | try { |
254 | - account_proxy.set_language (language); |
255 | + account_proxy.set_language (language); |
256 | } catch (Error e) { |
257 | critical (e.message); |
258 | } |
259 | @@ -277,7 +276,7 @@ |
260 | debug("Setting user format to %s", language); |
261 | |
262 | try { |
263 | - account_proxy.set_formats_locale (language); |
264 | + account_proxy.set_formats_locale (language); |
265 | } catch (Error e) { |
266 | critical (e.message); |
267 | } |
268 | @@ -344,4 +343,4 @@ |
269 | } |
270 | return instance; |
271 | } |
272 | -} |
273 | \ No newline at end of file |
274 | +} |
275 | |
276 | === modified file 'src/Plug.vala' |
277 | --- src/Plug.vala 2014-12-13 17:32:18 +0000 |
278 | +++ src/Plug.vala 2015-01-16 04:39:50 +0000 |
279 | @@ -8,7 +8,7 @@ |
280 | MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
281 | PURPOSE. See the GNU General Public License for more details. |
282 | You should have received a copy of the GNU General Public License along |
283 | - with this program. If not, see |
284 | + with this program. If not, see |
285 | ***/ |
286 | |
287 | namespace LC { |
288 | @@ -27,14 +27,17 @@ |
289 | |
290 | public class Locale.Plug : Switchboard.Plug { |
291 | |
292 | - LanguageList language_list; |
293 | + LanguageListBox list_box; |
294 | + LocaleSetting locale_setting; |
295 | |
296 | + UbuntuInstaller installer; |
297 | LocaleManager lm; |
298 | |
299 | Gtk.InfoBar infobar; |
300 | + InstallInfoBar install_infobar; |
301 | Gtk.InfoBar missing_lang_infobar; |
302 | Gtk.Grid grid; |
303 | - Gtk.Box top_box; |
304 | + Gtk.Box locale_box; |
305 | |
306 | public Plug () { |
307 | |
308 | @@ -43,39 +46,74 @@ |
309 | display_name: _("Region & Language"), |
310 | description: _("Change your region and language settings"), |
311 | icon: "preferences-desktop-locale"); |
312 | - |
313 | + |
314 | } |
315 | |
316 | public override Gtk.Widget get_widget () { |
317 | if (grid == null) { |
318 | grid = new Gtk.Grid (); |
319 | |
320 | + setup_ui (); |
321 | + setup_info (); |
322 | + |
323 | } |
324 | return grid; |
325 | } |
326 | |
327 | + void reload () { |
328 | + var langs = Utils.get_installed_languages (); |
329 | + var locales = Utils.get_installed_locales (); |
330 | + |
331 | + list_box.reload_languages (langs); |
332 | + locale_setting.reload_languages (langs, locales.to_array ()); |
333 | + installer.check_missing_languages (); |
334 | + } |
335 | void setup_info () { |
336 | lm = LocaleManager.get_default (); |
337 | |
338 | lm.connected.connect (() => { |
339 | - language_list.reload_languages(); |
340 | + reload (); |
341 | + |
342 | + infobar.no_show_all = true; |
343 | + infobar.hide (); |
344 | + }); |
345 | + |
346 | + installer = new UbuntuInstaller (); |
347 | + installer.install_finished.connect ((langcode) => { |
348 | + reload (); |
349 | + make_sensitive (true); |
350 | + }); |
351 | + installer.remove_finished.connect ((langcode) => { |
352 | + reload (); |
353 | + make_sensitive (true); |
354 | + }); |
355 | + installer.check_missing_finished.connect ((missing) => { |
356 | + if (missing.length > 0) { |
357 | + missing_lang_infobar.show (); |
358 | + missing_lang_infobar.show_all (); |
359 | + } else { |
360 | + missing_lang_infobar.hide (); |
361 | + } |
362 | + }); |
363 | + installer.progress_changed.connect ((progress) => { |
364 | + install_infobar.set_progress (progress); |
365 | + install_infobar.set_cancellable (installer.install_cancellable); |
366 | + install_infobar.set_transaction_mode (installer.transaction_mode); |
367 | }); |
368 | |
369 | } |
370 | - |
371 | + |
372 | public override void shown () { |
373 | - setup_ui (); |
374 | - setup_info (); |
375 | } |
376 | - |
377 | + |
378 | public override void hidden () { |
379 | - |
380 | + |
381 | } |
382 | - |
383 | + |
384 | public override void search_callback (string location) { |
385 | - |
386 | + |
387 | } |
388 | - |
389 | + |
390 | // 'search' returns results like ("Keyboard → Behavior → Duration", "keyboard<sep>behavior") |
391 | public override async Gee.TreeMap<string, string> search (string search) { |
392 | return new Gee.TreeMap<string, string> (null, null); |
393 | @@ -85,75 +123,19 @@ |
394 | |
395 | // Wires up and configures initial UI |
396 | private void setup_ui () { |
397 | - |
398 | - try { |
399 | - var provider = new Gtk.CssProvider(); |
400 | - provider.load_from_data (" |
401 | - .rounded-corners { |
402 | - border-radius: 5px; |
403 | - } |
404 | - |
405 | - .insensitve { |
406 | - color: #ccc; |
407 | - } |
408 | - |
409 | - .bg1 {background-color: #444;} |
410 | - .bg2 {background-color: #666;} |
411 | - .bg3 {background-color: #888;} |
412 | - .bg4 {background-color: #aaa;} |
413 | - ", 400); |
414 | - |
415 | - Gtk.StyleContext.add_provider_for_screen (grid.get_style_context ().get_screen (), provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); |
416 | - } catch (Error e) { |
417 | - warning ("Could not set styles"); |
418 | - } |
419 | - |
420 | - var sw = new Gtk.ScrolledWindow (null, null); |
421 | - |
422 | - grid.column_homogeneous = true; |
423 | - grid.row_spacing = 5; |
424 | - |
425 | - language_list = new LanguageList (); |
426 | - language_list.valign = Gtk.Align.START; |
427 | - sw.add (language_list); |
428 | - |
429 | - var header_entry = new BaseEntry (); |
430 | - header_entry.hexpand = true; |
431 | - header_entry.margin_left = 24; |
432 | - header_entry.margin_right = 24; |
433 | - |
434 | - var choose_language_hint = new Gtk.Label (_("Choose your language:")); |
435 | - choose_language_hint.hexpand = true; |
436 | - var choose_format_hint = new Gtk.Label (_("Numbers and dates:")); |
437 | - var choose_input_hint = new Gtk.Label (_("Keyboard input:")); |
438 | - |
439 | - choose_language_hint.halign = Gtk.Align.START; |
440 | - choose_format_hint.halign = Gtk.Align.START; |
441 | - choose_input_hint.halign = Gtk.Align.START; |
442 | - |
443 | - header_entry.left_grid.attach (choose_language_hint, 0, 0, 1, 1); |
444 | - header_entry.right_grid.attach (choose_format_hint, 0, 0, 1, 1); |
445 | - header_entry.right_grid.attach (choose_input_hint, 1, 0, 1, 1); |
446 | - var spacer = new Gtk.Image.from_icon_name ("edit-delete-symbolic", Gtk.IconSize.MENU); |
447 | - spacer.set_opacity (0); |
448 | - header_entry.settings_grid.add (spacer); |
449 | |
450 | infobar = new Gtk.InfoBar (); |
451 | infobar.message_type = Gtk.MessageType.INFO; |
452 | infobar.no_show_all = true; |
453 | + infobar.hide (); |
454 | var content = infobar.get_content_area () as Gtk.Container; |
455 | var label = new Gtk.Label (_("Some changes will not take effect until you log out")); |
456 | content.add (label); |
457 | |
458 | - language_list.settings_changed.connect (() => { |
459 | - infobar.no_show_all = false; |
460 | - infobar.show_all (); |
461 | - }); |
462 | - |
463 | - var install_infobar = new InstallInfoBar (); |
464 | - install_infobar.hide (); |
465 | + install_infobar = new InstallInfoBar (); |
466 | + install_infobar.no_show_all = true; |
467 | install_infobar.cancel_clicked.connect (() => { |
468 | - language_list.cancel_install (); |
469 | + installer.cancel_install (); |
470 | }); |
471 | |
472 | missing_lang_infobar = new Gtk.InfoBar (); |
473 | @@ -167,69 +149,93 @@ |
474 | install_missing.clicked.connect (() => { |
475 | missing_lang_infobar.hide (); |
476 | |
477 | - language_list.install_missing_languages (); |
478 | - }); |
479 | - language_list.check_missing_finished.connect ((missing) => { |
480 | - if (missing.length > 0) { |
481 | - missing_lang_infobar.show (); |
482 | - missing_lang_infobar.show_all (); |
483 | - } else { |
484 | - missing_lang_infobar.hide (); |
485 | - } |
486 | + installer.install_missing_languages (); |
487 | }); |
488 | |
489 | missing_content.pack_start (missing_label, false); |
490 | missing_content.pack_end (install_missing, false); |
491 | |
492 | - language_list.settings_changed.connect (() => { |
493 | + list_box = new LanguageListBox (); |
494 | + |
495 | + locale_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); |
496 | + var scroll = new Gtk.ScrolledWindow (null, null); |
497 | + scroll.shadow_type = Gtk.ShadowType.IN; |
498 | + scroll.add (list_box); |
499 | + scroll.expand = true; |
500 | + locale_box.pack_start (scroll, true, true); |
501 | + |
502 | + var add_button = new Gtk.ToolButton (null, "add"); |
503 | + add_button.set_icon_name ("list-add-symbolic"); |
504 | + add_button.set_tooltip_text (_("Add…")); |
505 | + add_button.clicked.connect (() => { |
506 | + var popover = new InstallPopover (add_button); |
507 | + popover.show_all (); |
508 | + popover.language_selected.connect (on_install_language); |
509 | + }); |
510 | + |
511 | + |
512 | + var remove_button = new Gtk.ToolButton (null, "remove"); |
513 | + remove_button.set_icon_name ("list-remove-symbolic"); |
514 | + remove_button.set_tooltip_text (_("Remove")); |
515 | + remove_button.clicked.connect (() => { |
516 | + make_sensitive (false); |
517 | + installer.remove (list_box.get_selected_language_code ()); |
518 | + }); |
519 | + |
520 | + var tbar = new Gtk.Toolbar (); |
521 | + tbar.set_style (Gtk.ToolbarStyle.ICONS); |
522 | + tbar.set_icon_size (Gtk.IconSize.SMALL_TOOLBAR); |
523 | + tbar.set_show_arrow (false); |
524 | + tbar.hexpand = true; |
525 | + tbar.insert (add_button, -1); |
526 | + tbar.insert (remove_button, -1); |
527 | + |
528 | + scroll.get_style_context().set_junction_sides(Gtk.JunctionSides.BOTTOM); |
529 | + tbar.get_style_context().add_class(Gtk.STYLE_CLASS_INLINE_TOOLBAR); |
530 | + tbar.get_style_context().set_junction_sides(Gtk.JunctionSides.TOP); |
531 | + |
532 | + locale_setting = new LocaleSetting (); |
533 | + locale_setting.margin_top = 50; |
534 | + locale_setting.hexpand = true; |
535 | + locale_setting.settings_changed.connect (() => { |
536 | infobar.no_show_all = false; |
537 | infobar.show_all (); |
538 | }); |
539 | - language_list.progress_changed.connect((progress) => { |
540 | - install_infobar.set_progress (progress); |
541 | - install_infobar.set_cancellable (language_list.install_cancellable); |
542 | - install_infobar.set_transaction_mode (language_list.get_transaction_mode ()); |
543 | + |
544 | + locale_box.pack_start (tbar, false, false); |
545 | + |
546 | + var keyboard_link = new Gtk.LinkButton.with_label ("", _("Keyboard layout settings…")); |
547 | + keyboard_link.margin = 10; |
548 | + keyboard_link.halign = Gtk.Align.END; |
549 | + keyboard_link.valign = Gtk.Align.END; |
550 | + keyboard_link.activate_link.connect (() => { |
551 | + var command = new Granite.Services.SimpleCommand ( |
552 | + Environment.get_home_dir (), |
553 | + "/usr/bin/switchboard -o hardware-pantheon-keyboard"); |
554 | + command.run (); |
555 | + return true; |
556 | }); |
557 | |
558 | - try { |
559 | - |
560 | - var permission = new Polkit.Permission.sync ("org.freedesktop.locale1.set-locale", Polkit.UnixProcess.new (Posix.getpid ())); |
561 | - var apply_button = new Gtk.LockButton (permission); |
562 | - |
563 | - apply_button.label = _("Apply for login screen, guest account and new users"); |
564 | - apply_button.halign = Gtk.Align.CENTER; |
565 | - apply_button.margin = 12; |
566 | - grid.attach (apply_button, 0, 6, 4, 1); |
567 | - |
568 | - permission.notify["allowed"].connect (() => { |
569 | - if (permission.allowed) { |
570 | - on_applied_to_system(); |
571 | - permission.impl_update (false, true, true); |
572 | - } |
573 | - }); |
574 | - |
575 | - } catch (Error e) { |
576 | - critical (e.message); |
577 | - } |
578 | - |
579 | - |
580 | - sw.show (); |
581 | - header_entry.show_all (); |
582 | - |
583 | - grid.attach (infobar, 0, 0, 4, 1); |
584 | - grid.attach (missing_lang_infobar, 0, 1, 4, 1); |
585 | - grid.attach (install_infobar, 0, 2, 4, 1); |
586 | - grid.attach (header_entry, 0, 3, 4, 1); |
587 | - grid.attach (top_box, 0, 4, 4, 1); |
588 | - grid.attach (sw, 0, 5, 4, 1); |
589 | - grid.show (); |
590 | - |
591 | - } |
592 | - |
593 | - void on_applied_to_system () { |
594 | - lm.apply_user_to_system (); |
595 | - infobar.no_show_all = false; |
596 | - infobar.show_all (); |
597 | + grid.attach (infobar, 0, 0, 3, 1); |
598 | + grid.attach (missing_lang_infobar, 0, 1, 3, 1); |
599 | + grid.attach (install_infobar, 0, 2, 3, 1); |
600 | + grid.attach (locale_box, 0, 3, 1, 2); |
601 | + grid.attach (locale_setting, 1, 3, 2, 1); |
602 | + grid.attach (keyboard_link, 2, 4, 1, 1); |
603 | + |
604 | + locale_box.show_all (); |
605 | + grid.show_all (); |
606 | + missing_lang_infobar.hide (); |
607 | + } |
608 | + |
609 | + void on_install_language (string language) { |
610 | + make_sensitive (false); |
611 | + installer.install (language); |
612 | + } |
613 | + |
614 | + void make_sensitive (bool sensitive ) { |
615 | + locale_box.set_sensitive (sensitive); |
616 | + locale_setting.set_sensitive (sensitive); |
617 | } |
618 | } |
619 | |
620 | |
621 | === removed file 'src/Widgets/BaseEntry.vala' |
622 | --- src/Widgets/BaseEntry.vala 2014-11-15 20:22:28 +0000 |
623 | +++ src/Widgets/BaseEntry.vala 1970-01-01 00:00:00 +0000 |
624 | @@ -1,54 +0,0 @@ |
625 | -/*** |
626 | - Copyright (C) 2011-2012 Switchboard Locale Plug Developers |
627 | - This program is free software: you can redistribute it and/or modify it |
628 | - under the terms of the GNU Lesser General Public License version 3, as published |
629 | - by the Free Software Foundation. |
630 | - This program is distributed in the hope that it will be useful, but |
631 | - WITHOUT ANY WARRANTY; without even the implied warranties of |
632 | - MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
633 | - PURPOSE. See the GNU General Public License for more details. |
634 | - You should have received a copy of the GNU General Public License along |
635 | - with this program. If not, see |
636 | -***/ |
637 | - |
638 | -public class BaseEntry : Gtk.ListBoxRow { |
639 | - |
640 | - public bool selected = false; |
641 | - public string locale {get; set;} |
642 | - public string region = ""; |
643 | - public string country = ""; |
644 | - |
645 | - public Gtk.Grid left_grid; |
646 | - public Gtk.Grid right_grid; |
647 | - public Gtk.Box settings_grid; |
648 | - |
649 | - public BaseEntry () { |
650 | - |
651 | - var box = new Gtk.Grid (); |
652 | - //box.column_homogeneous = true; |
653 | - box.margin = 10; |
654 | - box.column_spacing = 5; |
655 | - |
656 | - var inner_grid = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 10); |
657 | - inner_grid.homogeneous = true; |
658 | - |
659 | - left_grid = new Gtk.Grid (); |
660 | - inner_grid.pack_start (left_grid, true, true); |
661 | - |
662 | - right_grid = new Gtk.Grid (); |
663 | - right_grid.column_homogeneous = true; |
664 | - right_grid.column_spacing = 5; |
665 | - inner_grid.pack_start (right_grid, true, true); |
666 | - |
667 | - box.attach (inner_grid, 0, 0, 1, 1); |
668 | - |
669 | - settings_grid = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 5); |
670 | - settings_grid.halign = Gtk.Align.END; |
671 | - |
672 | - box.attach (settings_grid, 1, 0, 1, 1); |
673 | - add (box); |
674 | - |
675 | - box.show_all (); |
676 | - |
677 | - } |
678 | -} |
679 | |
680 | === removed file 'src/Widgets/InstallEntry.vala' |
681 | --- src/Widgets/InstallEntry.vala 2014-12-13 18:42:10 +0000 |
682 | +++ src/Widgets/InstallEntry.vala 1970-01-01 00:00:00 +0000 |
683 | @@ -1,94 +0,0 @@ |
684 | -/*** |
685 | - Copyright (C) 2011-2012 Switchboard Locale Plug Developers |
686 | - This program is free software: you can redistribute it and/or modify it |
687 | - under the terms of the GNU Lesser General Public License version 3, as published |
688 | - by the Free Software Foundation. |
689 | - This program is distributed in the hope that it will be useful, but |
690 | - WITHOUT ANY WARRANTY; without even the implied warranties of |
691 | - MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
692 | - PURPOSE. See the GNU General Public License for more details. |
693 | - You should have received a copy of the GNU General Public License along |
694 | - with this program. If not, see |
695 | -***/ |
696 | - |
697 | -public class InstallEntry : BaseEntry { |
698 | - |
699 | - |
700 | - public Gtk.Label label; |
701 | - |
702 | - Gtk.Spinner spinner; |
703 | - Gtk.Image image; |
704 | - |
705 | - private const string STYLE = """ |
706 | - |
707 | - GtkListBoxRow.list-row { |
708 | - background-image: none; |
709 | - background-color: #fff; |
710 | - border-radius: 5px; |
711 | - border: 1px solid #ccc; |
712 | - } |
713 | - |
714 | - """; |
715 | - |
716 | - public InstallEntry () { |
717 | - |
718 | - var css_provider = new Gtk.CssProvider (); |
719 | - try { |
720 | - css_provider.load_from_data (STYLE, STYLE.length); |
721 | - } catch (Error e) { |
722 | - warning ("loading css: %s", e.message); |
723 | - } |
724 | - get_style_context ().add_provider (css_provider, -1); |
725 | - |
726 | - locale = "zz_ZZ"; |
727 | - region = "zz"; |
728 | - country = "ZZ"; |
729 | - |
730 | - spinner = new Gtk.Spinner (); |
731 | - spinner.margin_end = 3; |
732 | - |
733 | - image = new Gtk.Image.from_icon_name ("browser-download", Gtk.IconSize.BUTTON); |
734 | - image.halign = Gtk.Align.START; |
735 | - image.valign = Gtk.Align.START; |
736 | - image.margin_end = 3; |
737 | - left_grid.attach (spinner, 0, 0, 1, 1); |
738 | - left_grid.attach (image, 0, 0, 1, 1); |
739 | - |
740 | - label = new Gtk.Label (_("Install more languages…")); |
741 | - label.halign = Gtk.Align.START; |
742 | - |
743 | - left_grid.attach (label, 1, 0, 2, 1); |
744 | - |
745 | - show_all (); |
746 | - spinner.hide (); |
747 | - } |
748 | - |
749 | - public void install_started () { |
750 | - |
751 | - start_spinner (); |
752 | - } |
753 | - |
754 | - |
755 | - public void install_complete () { |
756 | - |
757 | - stop_spinner (); |
758 | - } |
759 | - |
760 | - |
761 | - void start_spinner () { |
762 | - |
763 | - spinner.show (); |
764 | - image.hide (); |
765 | - spinner.start (); |
766 | - |
767 | - } |
768 | - |
769 | - void stop_spinner () { |
770 | - |
771 | - spinner.stop (); |
772 | - image.show (); |
773 | - spinner.hide (); |
774 | - |
775 | - } |
776 | - |
777 | -} |
778 | |
779 | === modified file 'src/Widgets/InstallInfoBar.vala' |
780 | --- src/Widgets/InstallInfoBar.vala 2014-12-14 05:11:57 +0000 |
781 | +++ src/Widgets/InstallInfoBar.vala 2015-01-16 04:39:50 +0000 |
782 | @@ -44,7 +44,7 @@ |
783 | box.pack_end (cancel_button, false); |
784 | box.pack_end (progress, false); |
785 | |
786 | - show_all (); |
787 | + box.show_all (); |
788 | } |
789 | |
790 | public void set_transaction_mode (UbuntuInstaller.TransactionMode transaction_mode) { |
791 | |
792 | === modified file 'src/Widgets/InstallPopover.vala' |
793 | --- src/Widgets/InstallPopover.vala 2014-11-15 18:07:42 +0000 |
794 | +++ src/Widgets/InstallPopover.vala 2015-01-16 04:39:50 +0000 |
795 | @@ -126,8 +126,8 @@ |
796 | language_label = new Gtk.Label (language); |
797 | language_label.halign = Gtk.Align.START; |
798 | language_label.margin = 5; |
799 | - language_label.set_markup ("<b>%s</b>".printf(translated_lang)); |
800 | - //warning ("Language: %s Translated: %s", language, ); |
801 | + language_label.set_markup ("<b>%s</b>".printf(language)); |
802 | + //warning ("Language: %s Translated: %s", language, translated_lang); |
803 | add (language_label); |
804 | } |
805 | } |
806 | |
807 | === removed file 'src/Widgets/LanguageEntry.vala' |
808 | --- src/Widgets/LanguageEntry.vala 2014-12-13 18:42:10 +0000 |
809 | +++ src/Widgets/LanguageEntry.vala 1970-01-01 00:00:00 +0000 |
810 | @@ -1,362 +0,0 @@ |
811 | -/*** |
812 | - Copyright (C) 2011-2012 Switchboard Locale Plug Developers |
813 | - This program is free software: you can redistribute it and/or modify it |
814 | - under the terms of the GNU Lesser General Public License version 3, as published |
815 | - by the Free Software Foundation. |
816 | - This program is distributed in the hope that it will be useful, but |
817 | - WITHOUT ANY WARRANTY; without even the implied warranties of |
818 | - MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
819 | - PURPOSE. See the GNU General Public License for more details. |
820 | - You should have received a copy of the GNU General Public License along |
821 | - with this program. If not, see |
822 | -***/ |
823 | - |
824 | -public enum UpdateType { |
825 | - LANGUAGE, |
826 | - FORMAT, |
827 | - INPUT; |
828 | -} |
829 | - |
830 | -public class LanguageEntry : BaseEntry { |
831 | - |
832 | - public Gtk.Button delete_button; |
833 | - |
834 | - public signal void set_region (string region); |
835 | - |
836 | - public signal void language_changed (UpdateType type, string locale); |
837 | - public signal void input_changed (string langcode, string region, bool added); |
838 | - public signal void deletion_requested (string region); |
839 | - |
840 | - // language selecetion |
841 | - public Gtk.RadioButton check_button; |
842 | - Gtk.Label region_label; |
843 | - Gtk.ComboBox country_combobox; |
844 | - |
845 | - // region selection |
846 | - public Gtk.RadioButton format_checkbutton; |
847 | - Gtk.ComboBox format_combobox; |
848 | - Gtk.ListStore format_store; |
849 | - |
850 | - // input selection |
851 | - public Gtk.CheckButton input_checkbutton; |
852 | - Gtk.ComboBox input_combobox; |
853 | - Gtk.ListStore input_store; |
854 | - |
855 | - Gtk.Image delete_image; |
856 | - |
857 | - Gtk.ListStore list_store; |
858 | - |
859 | - bool update_lock = false; |
860 | - |
861 | - Gtk.TreeIter iter; |
862 | - |
863 | - Gee.HashMap<string, int> regionbox_map = new Gee.HashMap<string, int> (); |
864 | - Gee.HashMap<string, int> formatbox_map = new Gee.HashMap<string, int> (); |
865 | - Gee.HashMap<string, int> inputbox_map = new Gee.HashMap<string, int> (); |
866 | - |
867 | - public string langcode; |
868 | - |
869 | - private const string STYLE = """ |
870 | - |
871 | - GtkListBoxRow.list-row { |
872 | - background-image: none; |
873 | - background-color: #fff; |
874 | - border-radius: 5px; |
875 | - border: 1px solid #ccc; |
876 | - } |
877 | - |
878 | - """; |
879 | - |
880 | - public LanguageEntry (string _locale, LanguageList? list = null) { |
881 | - |
882 | - var css_provider = new Gtk.CssProvider (); |
883 | - try { |
884 | - css_provider.load_from_data (STYLE, STYLE.length); |
885 | - } catch (Error e) { |
886 | - warning ("loading css: %s", e.message); |
887 | - } |
888 | - get_style_context ().add_provider (css_provider, -1); |
889 | - margin_bottom = 5; |
890 | - |
891 | - locale = _locale; |
892 | - langcode = locale.substring (0, 2); |
893 | - |
894 | - country = Gnome.Languages.get_country_from_locale (locale, null); |
895 | - region = Gnome.Languages.get_language_from_code (langcode, null); |
896 | - |
897 | - format_store = new Gtk.ListStore (2, typeof (string), typeof (string)); |
898 | - input_store = new Gtk.ListStore (2, typeof (string), typeof (string)); |
899 | - list_store = new Gtk.ListStore (2, typeof (string), typeof (string)); |
900 | - |
901 | - Gtk.CellRendererText value_renderer = new Gtk.CellRendererText (); |
902 | - value_renderer.ellipsize = Pango.EllipsizeMode.END; |
903 | - value_renderer.max_width_chars = 25; |
904 | - |
905 | - reload_input (); |
906 | - |
907 | - /* |
908 | - * Language (translation) |
909 | - */ |
910 | - |
911 | - check_button = new Gtk.RadioButton.from_widget (list.language_button); |
912 | - check_button.toggled.connect (on_language_activated); |
913 | - check_button.set_active (false); |
914 | - |
915 | - region_label = new Gtk.Label (region); |
916 | - region_label.halign = Gtk.Align.START; |
917 | - region_label.set_markup ("<b>%s</b>".printf(region_label.label)); |
918 | - |
919 | - country_combobox = new Gtk.ComboBox.with_model (list_store); |
920 | - country_combobox.changed.connect (on_language_changed); |
921 | - country_combobox.width_request = 50; |
922 | - country_combobox.halign = Gtk.Align.END; |
923 | - country_combobox.hexpand = true; |
924 | - country_combobox.pack_start (value_renderer, true); |
925 | - country_combobox.add_attribute (value_renderer, "text", 0); |
926 | - |
927 | - /* |
928 | - * Regional format (date, currency, …) |
929 | - */ |
930 | - |
931 | - format_checkbutton = new Gtk.RadioButton.from_widget (list.format_button); |
932 | - format_checkbutton.toggled.connect (on_format_activated); |
933 | - |
934 | - format_combobox = new Gtk.ComboBox.with_model (format_store); |
935 | - format_combobox.changed.connect (on_format_changed); |
936 | - format_combobox.pack_start (value_renderer, true); |
937 | - format_combobox.add_attribute (value_renderer, "text", 0); |
938 | - |
939 | - var format_grid = new Gtk.Grid (); |
940 | - format_grid.attach (format_checkbutton, 0, 0, 1, 1); |
941 | - format_grid.attach (format_combobox, 1, 0, 1, 1); |
942 | - |
943 | - /* |
944 | - * Input language (Keyboard layout) |
945 | - */ |
946 | - |
947 | - input_checkbutton = new Gtk.CheckButton (); |
948 | - input_checkbutton.toggled.connect (() => { |
949 | - on_input_changed (); |
950 | - }); |
951 | - |
952 | - input_combobox = new Gtk.ComboBox.with_model (input_store); |
953 | - input_combobox.changed.connect (on_input_changed); |
954 | - input_combobox.pack_start (value_renderer, true); |
955 | - input_combobox.add_attribute (value_renderer, "text", 0); |
956 | - input_combobox.hexpand = true; |
957 | - |
958 | - var input_grid = new Gtk.Grid (); |
959 | - input_grid.attach (input_checkbutton, 0, 0, 1, 1); |
960 | - input_grid.attach (input_combobox, 1, 0, 1, 1); |
961 | - |
962 | - |
963 | - //left_grid.attach (country_grid, 0, 0, 1, 1); |
964 | - left_grid.attach (check_button, 0, 0, 1, 1); |
965 | - left_grid.attach (region_label, 1, 0, 1, 1); |
966 | - left_grid.attach (country_combobox, 2, 0, 1, 1); |
967 | - |
968 | - right_grid.attach (format_grid, 0, 0, 1, 1); |
969 | - right_grid.attach (input_grid, 1, 0, 1, 1); |
970 | - |
971 | - delete_image = new Gtk.Image.from_icon_name ("edit-delete-symbolic", Gtk.IconSize.MENU); |
972 | - |
973 | - delete_button = new Gtk.ToggleButton(); |
974 | - delete_button.set_image (delete_image); |
975 | - delete_button.sensitive = true; |
976 | - delete_button.clicked.connect (() => { |
977 | - deletion_requested (locale); |
978 | - }); |
979 | - |
980 | - settings_grid.pack_start (delete_button); |
981 | - |
982 | - add_language (locale); |
983 | - |
984 | - show_all (); |
985 | - } |
986 | - |
987 | - void reload_input () { |
988 | - var xkb = new Gnome.XkbInfo (); |
989 | - var input_sources = xkb.get_layouts_for_language (langcode); |
990 | - |
991 | - foreach (var input in input_sources) { |
992 | - string display_name; |
993 | - string short_name; |
994 | - string xkb_layout; |
995 | - string xkb_variant; |
996 | - |
997 | - xkb.get_layout_info (input, out display_name, out short_name, out xkb_layout, out xkb_variant); |
998 | - |
999 | - if (xkb_layout == "us" && langcode != "en") { |
1000 | - // skip english international |
1001 | - continue; |
1002 | - } |
1003 | - |
1004 | - var xkb_string = xkb_layout; |
1005 | - if (xkb_variant != "") |
1006 | - xkb_string += "+"+xkb_variant; |
1007 | - |
1008 | - input_store.append (out iter); |
1009 | - input_store.set (iter, 0, display_name, 1, xkb_string); |
1010 | - |
1011 | - inputbox_map.@set (xkb_string, inputbox_map.size); |
1012 | - } |
1013 | - } |
1014 | - |
1015 | - public void set_display_region (string locale) { |
1016 | - |
1017 | - update_lock = true; |
1018 | - |
1019 | - if (regionbox_map.has_key (locale)) { |
1020 | - country_combobox.active = regionbox_map.@get (locale); |
1021 | - check_button.active = true; |
1022 | - } |
1023 | - |
1024 | - update_lock = false; |
1025 | - |
1026 | - } |
1027 | - |
1028 | - public void set_display_format (string locale) { |
1029 | - |
1030 | - update_lock = true; |
1031 | - |
1032 | - format_combobox.active = formatbox_map.@get (locale); |
1033 | - format_checkbutton.active = true; |
1034 | - |
1035 | - update_lock = false; |
1036 | - |
1037 | - } |
1038 | - |
1039 | - public void set_display_input (string input) { |
1040 | - |
1041 | - update_lock = true; |
1042 | - |
1043 | - if (inputbox_map.has_key (input)) { |
1044 | - var number = inputbox_map.@get (input); |
1045 | - input_combobox.active = number; |
1046 | - input_checkbutton.active = true; |
1047 | - } |
1048 | - |
1049 | - update_lock = false; |
1050 | - |
1051 | - } |
1052 | - |
1053 | - void on_language_activated () { |
1054 | - |
1055 | - if (update_lock) |
1056 | - return; |
1057 | - |
1058 | - Value lang; |
1059 | - |
1060 | - country_combobox.get_active_iter (out iter); |
1061 | - |
1062 | - list_store.get_value (iter, 1, out lang); |
1063 | - |
1064 | - language_changed (UpdateType.LANGUAGE, lang.get_string ()); |
1065 | - |
1066 | - } |
1067 | - |
1068 | - void on_format_activated () { |
1069 | - |
1070 | - if (update_lock) |
1071 | - return; |
1072 | - |
1073 | - Value format; |
1074 | - |
1075 | - format_combobox.get_active_iter (out iter); |
1076 | - format_store.get_value (iter, 1, out format); |
1077 | - message ("%s", format.get_string ()); |
1078 | - language_changed (UpdateType.FORMAT, format.get_string ()); |
1079 | - |
1080 | - } |
1081 | - |
1082 | - void on_input_activated (bool? changed = false) { |
1083 | - if (update_lock) |
1084 | - return; |
1085 | - |
1086 | - Value xkb_string; |
1087 | - |
1088 | - input_combobox.get_active_iter (out iter); |
1089 | - input_store.get_value (iter, 1, out xkb_string); |
1090 | - |
1091 | - input_changed (langcode, xkb_string.get_string (), changed); |
1092 | - |
1093 | - } |
1094 | - |
1095 | - void on_language_changed () { |
1096 | - if (!check_button.active) |
1097 | - return; |
1098 | - |
1099 | - on_language_activated (); |
1100 | - |
1101 | - } |
1102 | - |
1103 | - void on_format_changed () { |
1104 | - if (!format_checkbutton.active) |
1105 | - return; |
1106 | - |
1107 | - on_format_activated (); |
1108 | - } |
1109 | - |
1110 | - void on_input_changed () { |
1111 | - if (!input_checkbutton.active) { |
1112 | - on_input_activated (false); |
1113 | - return; |
1114 | - } |
1115 | - |
1116 | - on_input_activated (true); |
1117 | - } |
1118 | - |
1119 | - |
1120 | - public void add_language (string locale) { |
1121 | - |
1122 | - string language = ""; |
1123 | - string country = ""; |
1124 | - |
1125 | - if (locale.length == 2) {// only lancode |
1126 | - language = Gnome.Languages.get_language_from_code (locale, null); |
1127 | - country = Gnome.Languages.get_country_from_code (locale, null); |
1128 | - } else if (locale.length == 5) {// full locale |
1129 | - language = Gnome.Languages.get_language_from_locale (locale, null); |
1130 | - country = Gnome.Languages.get_country_from_locale (locale, null); |
1131 | - } |
1132 | - |
1133 | - if (country == null) |
1134 | - country = language; |
1135 | - |
1136 | - |
1137 | - list_store.append (out iter); |
1138 | - regionbox_map.@set (locale, regionbox_map.size); |
1139 | - list_store.set (iter, 0, country, 1, locale); |
1140 | - |
1141 | - |
1142 | - country_combobox.active = 0; |
1143 | - input_combobox.active = 0; |
1144 | - } |
1145 | - |
1146 | - public void add_locale (string locale) { |
1147 | - var country = Gnome.Languages.get_country_from_locale (locale, null); |
1148 | - |
1149 | - var country_short = country.replace ("(%s)".printf (region), ""); |
1150 | - if (country != null) { |
1151 | - format_store.append (out iter); |
1152 | - formatbox_map.@set (locale, formatbox_map.size); |
1153 | - format_store.set (iter, 0, country_short, 1, locale); |
1154 | - |
1155 | - format_combobox.show (); |
1156 | - format_checkbutton.show (); |
1157 | - } |
1158 | - |
1159 | - format_combobox.active = 0; |
1160 | - } |
1161 | - |
1162 | - public void hide_delete () { |
1163 | - |
1164 | - delete_image.set_opacity (0); |
1165 | - |
1166 | - } |
1167 | - |
1168 | - public void show_delete () { |
1169 | - |
1170 | - delete_image.set_opacity (1); |
1171 | - } |
1172 | -} |
1173 | |
1174 | === removed file 'src/Widgets/LanguageList.vala' |
1175 | --- src/Widgets/LanguageList.vala 2014-12-16 17:40:58 +0000 |
1176 | +++ src/Widgets/LanguageList.vala 1970-01-01 00:00:00 +0000 |
1177 | @@ -1,349 +0,0 @@ |
1178 | -/*** |
1179 | - Copyright (C) 2011-2012 Switchboard Locale Plug Developers |
1180 | - This program is free software: you can redistribute it and/or modify it |
1181 | - under the terms of the GNU Lesser General Public License version 3, as published |
1182 | - by the Free Software Foundation. |
1183 | - This program is distributed in the hope that it will be useful, but |
1184 | - WITHOUT ANY WARRANTY; without even the implied warranties of |
1185 | - MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
1186 | - PURPOSE. See the GNU General Public License for more details. |
1187 | - You should have received a copy of the GNU General Public License along |
1188 | - with this program. If not, see |
1189 | -***/ |
1190 | - |
1191 | -public class LanguageList : Gtk.ListBox { |
1192 | - |
1193 | - public signal void settings_changed (); |
1194 | - public signal void check_missing_finished (string [] missing); |
1195 | - public signal void progress_changed (int progress); |
1196 | - |
1197 | - InstallPopover language_popover; |
1198 | - InstallEntry install_entry; |
1199 | - |
1200 | - UbuntuInstaller li; |
1201 | - |
1202 | - public bool install_cancellable { |
1203 | - get {return li.install_cancellable;} |
1204 | - } |
1205 | - |
1206 | - public Gtk.RadioButton language_button = new Gtk.RadioButton (null); |
1207 | - public Gtk.RadioButton format_button = new Gtk.RadioButton (null); |
1208 | - |
1209 | - LocaleManager lm; |
1210 | - |
1211 | - Gee.HashMap<string, LanguageEntry> languages; |
1212 | - Gee.HashMap<string, string?> input_sources; |
1213 | - |
1214 | - private const string STYLE = """ |
1215 | - |
1216 | - GtkListBox { |
1217 | - background-color: transparent; |
1218 | - } |
1219 | - |
1220 | - """; |
1221 | - |
1222 | - public LanguageList () { |
1223 | - |
1224 | - var css_provider = new Gtk.CssProvider (); |
1225 | - try { |
1226 | - css_provider.load_from_data (STYLE, STYLE.length); |
1227 | - } catch (Error e) { |
1228 | - warning ("loading css: %s", e.message); |
1229 | - } |
1230 | - get_style_context ().add_provider (css_provider, -1); |
1231 | - |
1232 | - valign = Gtk.Align.START; |
1233 | - vexpand = true; |
1234 | - hexpand = true; |
1235 | - margin_start = 24; |
1236 | - margin_end = 24; |
1237 | - |
1238 | - set_activate_on_single_click(true); |
1239 | - set_sort_func (sort_func); |
1240 | - set_selection_mode (Gtk.SelectionMode.NONE); |
1241 | - //set_header_func (header_func); |
1242 | - set_filter_func (filter_func); |
1243 | - |
1244 | - languages = new Gee.HashMap<string, LanguageEntry> (); |
1245 | - input_sources = new Gee.HashMap<string, string?> (); |
1246 | - |
1247 | - li = new UbuntuInstaller (); |
1248 | - li.install_finished.connect (on_install_finished); |
1249 | - li.remove_finished.connect (on_remove_finished); |
1250 | - li.check_missing_languages (); |
1251 | - li.check_missing_finished.connect (on_check_missing_finished); |
1252 | - li.progress_changed.connect ((progress) => { |
1253 | - progress_changed (progress); |
1254 | - }); |
1255 | - |
1256 | - lm = LocaleManager.get_default (); |
1257 | - |
1258 | - install_entry = new InstallEntry(); |
1259 | - language_popover = new InstallPopover (install_entry.label); |
1260 | - language_popover.language_selected.connect (on_install_language); |
1261 | - |
1262 | - add (install_entry); |
1263 | - |
1264 | - show (); |
1265 | - |
1266 | - } |
1267 | - |
1268 | - bool update_lock = true; |
1269 | - |
1270 | - public void reload_languages () { |
1271 | - |
1272 | - var langs = Utils.get_installed_languages (); |
1273 | - foreach (var lang in langs) { |
1274 | - add_language (lang); |
1275 | - } |
1276 | - |
1277 | - var locales = Utils.get_installed_locales (); |
1278 | - foreach (var locale in locales) { |
1279 | - add_locale (locale); |
1280 | - } |
1281 | - |
1282 | - li.check_missing_languages (); |
1283 | - |
1284 | - requery_display (); |
1285 | - |
1286 | - } |
1287 | - |
1288 | - void requery_display () { |
1289 | - |
1290 | - var lang = lm.get_user_language (); |
1291 | - var region = lm.get_user_format (); |
1292 | - var inputs = lm.get_user_inputmaps (); |
1293 | - |
1294 | - update_lock = true; |
1295 | - |
1296 | - select_language (lang); |
1297 | - select_format (region); |
1298 | - select_inputs (inputs); |
1299 | - |
1300 | - update_lock = false; |
1301 | - |
1302 | - } |
1303 | - |
1304 | - /* |
1305 | - * update selections |
1306 | - */ |
1307 | - |
1308 | - void select_language (string language) { |
1309 | - |
1310 | - var lang = languages.get (language[0:2]); |
1311 | - lang.set_display_region (language); |
1312 | - |
1313 | - } |
1314 | - |
1315 | - void select_format (string locale) { |
1316 | - |
1317 | - var lang = languages.get (locale[0:2]); |
1318 | - lang.set_display_format(locale[0:5]); |
1319 | - |
1320 | - } |
1321 | - |
1322 | - void select_inputs (Gee.HashMap<string, string> map) { |
1323 | - |
1324 | - map.@foreach ((entry) => { |
1325 | - input_sources.@set (entry.key, entry.value); |
1326 | - var lang = languages.get (entry.key); |
1327 | - lang.set_display_input (entry.value); |
1328 | - return true; |
1329 | - }); |
1330 | - |
1331 | - } |
1332 | - |
1333 | - void on_install_language (string lang) { |
1334 | - |
1335 | - li.install (lang); |
1336 | - install_entry.install_started (); |
1337 | - |
1338 | - } |
1339 | - |
1340 | - void on_install_finished (string language) { |
1341 | - |
1342 | - reload_languages (); |
1343 | - install_entry.install_complete (); |
1344 | - |
1345 | - li.check_missing_languages (); |
1346 | - |
1347 | - } |
1348 | - |
1349 | - void on_deletion_requested (string locale) { |
1350 | - |
1351 | - li.remove (locale); |
1352 | - |
1353 | - } |
1354 | - |
1355 | - void on_remove_finished (string langcode) { |
1356 | - |
1357 | - var widget = languages.@get (langcode); |
1358 | - remove (widget); |
1359 | - languages.unset (langcode); |
1360 | - |
1361 | - if (languages.size == 1) { |
1362 | - languages.@foreach ((entry) => { |
1363 | - entry.value.hide_delete (); |
1364 | - return true; |
1365 | - }); |
1366 | - } |
1367 | - |
1368 | - } |
1369 | - |
1370 | - void on_check_missing_finished (string [] missing) { |
1371 | - this.set_sensitive (true); |
1372 | - check_missing_finished (missing); |
1373 | - } |
1374 | - |
1375 | - public void cancel_install () { |
1376 | - li.cancel_install (); |
1377 | - check_missing_languages (); |
1378 | - } |
1379 | - |
1380 | - public UbuntuInstaller.TransactionMode get_transaction_mode () { |
1381 | - return li.transaction_mode; |
1382 | - } |
1383 | - |
1384 | - public void add_language(string locale) { |
1385 | - |
1386 | - var langcode = locale.substring (0, 2); |
1387 | - |
1388 | - if (languages.has_key (langcode)) { |
1389 | - var entry = languages.@get (langcode); |
1390 | - entry.add_language (locale); |
1391 | - |
1392 | - return; |
1393 | - } |
1394 | - |
1395 | - var l_entry = new LanguageEntry(locale, this); |
1396 | - |
1397 | - languages.@set (langcode, l_entry); |
1398 | - |
1399 | - l_entry.language_changed.connect (on_language_changed); |
1400 | - l_entry.input_changed.connect (on_input_changed); |
1401 | - l_entry.deletion_requested.connect (on_deletion_requested); |
1402 | - |
1403 | - add (l_entry); |
1404 | - l_entry.show (); |
1405 | - |
1406 | - |
1407 | - // update visibility of delete button |
1408 | - if (languages.size == 1) { |
1409 | - languages.@foreach ((entry) => { |
1410 | - entry.value.hide_delete (); |
1411 | - return true; |
1412 | - }); |
1413 | - } else { |
1414 | - languages.@foreach ((entry) => { |
1415 | - entry.value.show_delete (); |
1416 | - return true; |
1417 | - }); |
1418 | - } |
1419 | - |
1420 | - } |
1421 | - |
1422 | - public void add_locale (string locale) { |
1423 | - var langcode = locale.substring (0, 2); |
1424 | - |
1425 | - if (languages.has_key (langcode)) { |
1426 | - var entry = languages.@get (langcode); |
1427 | - entry.add_locale (locale); |
1428 | - |
1429 | - return; |
1430 | - } else { |
1431 | - warning ("Found locale without corresponding language pack"); |
1432 | - } |
1433 | - } |
1434 | - |
1435 | - public void check_missing_languages () { |
1436 | - li.check_missing_languages (); |
1437 | - } |
1438 | - |
1439 | - public void install_missing_languages (){ |
1440 | - this.set_sensitive (false); |
1441 | - li.install_missing_languages (); |
1442 | - } |
1443 | - |
1444 | - void on_language_changed (UpdateType type, string lang) { |
1445 | - if (update_lock) |
1446 | - return; |
1447 | - |
1448 | - switch (type) { |
1449 | - case UpdateType.LANGUAGE: |
1450 | - lm.set_user_language (lang); |
1451 | - break; |
1452 | - case UpdateType.FORMAT: |
1453 | - lm.set_user_format (lang+".UTF-8"); |
1454 | - break; |
1455 | - } |
1456 | - |
1457 | - settings_changed (); |
1458 | - |
1459 | - } |
1460 | - |
1461 | - |
1462 | - void on_input_changed (string langcode, string inputcode, bool added) { |
1463 | - |
1464 | - if (update_lock) |
1465 | - return; |
1466 | - |
1467 | - if (!added) { |
1468 | - input_sources.@unset (langcode); |
1469 | - } else { |
1470 | - input_sources.@set (langcode, inputcode); |
1471 | - } |
1472 | - |
1473 | - VariantBuilder builder2 = new VariantBuilder (new VariantType ("a(ss)") ); |
1474 | - VariantBuilder builder = new VariantBuilder (new VariantType ("a(ss)") ); |
1475 | - input_sources.@foreach((entry) => { |
1476 | - message ("('%s', '%s')", "xkb", entry.value); |
1477 | - builder2.add ("(ss)", entry.key, entry.value); |
1478 | - builder.add ("(ss)", "xkb", entry.value); |
1479 | - return true; |
1480 | - }); |
1481 | - |
1482 | - lm.set_input_language (builder.end (), builder2.end ()); |
1483 | - |
1484 | - } |
1485 | - |
1486 | - /* |
1487 | - * Gtk.ListBox functions |
1488 | - */ |
1489 | - |
1490 | - public override void row_activated (Gtk.ListBoxRow row) { |
1491 | - |
1492 | - if (row is InstallEntry) { |
1493 | - language_popover.show_all (); |
1494 | - } else { |
1495 | - var locale = row as LanguageEntry; |
1496 | - locale.check_button.set_active (true); |
1497 | - } |
1498 | - |
1499 | - } |
1500 | - |
1501 | - int sort_func (Gtk.ListBoxRow row1, Gtk.ListBoxRow row2) { |
1502 | - |
1503 | - var first = row1 as BaseEntry; |
1504 | - var second = row2 as BaseEntry; |
1505 | - |
1506 | - var string1 = first.region + " " + first.country; |
1507 | - var string2 = second.region + " " + second.country; |
1508 | - var diff = (int) (string1.collate (string2) ); |
1509 | - return diff; |
1510 | - |
1511 | - } |
1512 | - |
1513 | - /*void header_func (Gtk.ListBoxRow? row, Gtk.ListBoxRow? before) { |
1514 | - |
1515 | - if (before != null) { |
1516 | - row.set_header (new Gtk.Separator (Gtk.Orientation.HORIZONTAL)); |
1517 | - } |
1518 | - |
1519 | - }*/ |
1520 | - |
1521 | - bool filter_func (Gtk.ListBoxRow row) { |
1522 | - |
1523 | - return true; |
1524 | - |
1525 | - } |
1526 | -} |
1527 | |
1528 | === added file 'src/Widgets/LanguageListBox.vala' |
1529 | --- src/Widgets/LanguageListBox.vala 1970-01-01 00:00:00 +0000 |
1530 | +++ src/Widgets/LanguageListBox.vala 2015-01-16 04:39:50 +0000 |
1531 | @@ -0,0 +1,49 @@ |
1532 | +public class LanguageListBox : Gtk.ListBox { |
1533 | + Gee.HashMap <string, LanguageRow> languages; |
1534 | + public LanguageListBox () { |
1535 | + languages = new Gee.HashMap <string, LanguageRow> (); |
1536 | + } |
1537 | + public void reload_languages (string[] langs) { |
1538 | + //clear hashmap and this listbox |
1539 | + languages.clear (); |
1540 | + this.foreach ((item) => { |
1541 | + this.remove (item); |
1542 | + }); |
1543 | + |
1544 | + foreach (var lang in langs) { |
1545 | + add_language (lang); |
1546 | + } |
1547 | + |
1548 | + var first_row = get_row_at_index (0); |
1549 | + select_row (first_row); |
1550 | + |
1551 | + show_all (); |
1552 | + } |
1553 | + void add_language (string locale) { |
1554 | + var code = locale.substring (0, 2); |
1555 | + if (!languages.has_key (code)) { |
1556 | + var country = Gnome.Languages.get_language_from_code (locale, null); |
1557 | + var label = new LanguageRow (code, country); |
1558 | + languages.set (code, label); |
1559 | + add (label); |
1560 | + } |
1561 | + } |
1562 | + public string? get_selected_language_code () { |
1563 | + var selected_row = get_selected_row () as LanguageRow; |
1564 | + if (selected_row != null) |
1565 | + return selected_row.code; |
1566 | + else |
1567 | + return null; |
1568 | + } |
1569 | + private class LanguageRow : Gtk.ListBoxRow { |
1570 | + public string code; |
1571 | + Gtk.Label label; |
1572 | + public LanguageRow (string code, string text) { |
1573 | + this.code = code; |
1574 | + label = new Gtk.Label (text); |
1575 | + label.halign = Gtk.Align.START; |
1576 | + label.margin = 10; |
1577 | + this.add (label); |
1578 | + } |
1579 | + } |
1580 | +} |
1581 | |
1582 | === added file 'src/Widgets/LocaleSetting.vala' |
1583 | --- src/Widgets/LocaleSetting.vala 1970-01-01 00:00:00 +0000 |
1584 | +++ src/Widgets/LocaleSetting.vala 2015-01-16 04:39:50 +0000 |
1585 | @@ -0,0 +1,249 @@ |
1586 | +/*** |
1587 | + Copyright (C) 2011-2012 Switchboard Locale Plug Developers |
1588 | + This program is free software: you can redistribute it and/or modify it |
1589 | + under the terms of the GNU Lesser General Public License version 3, as published |
1590 | + by the Free Software Foundation. |
1591 | + This program is distributed in the hope that it will be useful, but |
1592 | + WITHOUT ANY WARRANTY; without even the implied warranties of |
1593 | + MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
1594 | + PURPOSE. See the GNU General Public License for more details. |
1595 | + You should have received a copy of the GNU General Public License along |
1596 | + with this program. If not, see |
1597 | +***/ |
1598 | + |
1599 | +public class LocaleSetting : Gtk.Grid { |
1600 | + Gtk.ComboBox language_combobox; |
1601 | + Gtk.ComboBox region_combobox; |
1602 | + Gtk.ComboBox format_combobox; |
1603 | + |
1604 | + Gtk.ListStore language_store; |
1605 | + Gtk.ListStore region_store; |
1606 | + Gtk.ListStore format_store; |
1607 | + |
1608 | + LocaleManager lm; |
1609 | + Preview preview; |
1610 | + |
1611 | + string[] langs; |
1612 | + string[] locales; |
1613 | + |
1614 | + public signal void settings_changed (); |
1615 | + |
1616 | + public LocaleSetting () { |
1617 | + this.column_homogeneous = false; |
1618 | + this.margin = 20; |
1619 | + this.row_spacing = 10; |
1620 | + this.column_spacing = 10; |
1621 | + this.halign = Gtk.Align.CENTER; |
1622 | + |
1623 | + lm = LocaleManager.get_default (); |
1624 | + |
1625 | + language_store = new Gtk.ListStore (2, typeof (string), typeof (string)); |
1626 | + region_store = new Gtk.ListStore (2, typeof (string), typeof (string)); |
1627 | + format_store = new Gtk.ListStore (2, typeof (string), typeof (string)); |
1628 | + |
1629 | + region_store.set_sort_column_id (0, Gtk.SortType.ASCENDING); |
1630 | + format_store.set_sort_column_id (0, Gtk.SortType.ASCENDING); |
1631 | + format_store.set_sort_func (0, format_compare_func); |
1632 | + |
1633 | + language_combobox = new Gtk.ComboBox.with_model (language_store); |
1634 | + region_combobox = new Gtk.ComboBox.with_model (region_store); |
1635 | + format_combobox = new Gtk.ComboBox.with_model (format_store); |
1636 | + |
1637 | + Gtk.CellRendererText renderer = new Gtk.CellRendererText (); |
1638 | + |
1639 | + language_combobox.pack_start (renderer, true); |
1640 | + language_combobox.add_attribute (renderer, "text", 0); |
1641 | + language_combobox.changed.connect (on_language_changed); |
1642 | + language_combobox.active = 0; |
1643 | + |
1644 | + region_combobox.pack_start (renderer, true); |
1645 | + region_combobox.add_attribute (renderer, "text", 0); |
1646 | + region_combobox.changed.connect (on_region_changed); |
1647 | + region_combobox.active = 0; |
1648 | + |
1649 | + format_combobox.pack_start (renderer, true); |
1650 | + format_combobox.add_attribute (renderer, "text", 0); |
1651 | + format_combobox.changed.connect (on_format_changed); |
1652 | + format_combobox.active = 0; |
1653 | + |
1654 | + preview = new Preview (); |
1655 | + |
1656 | + attach (create_end_label (_("Language: ")), 0, 0, 1, 1); |
1657 | + attach (language_combobox,1, 0, 1, 1); |
1658 | + attach (create_end_label (_("Region: ")), 0, 2, 1, 1); |
1659 | + attach (region_combobox, 1, 2, 1, 1); |
1660 | + attach (create_end_label (_("Formats: ")), 0, 3, 1, 1); |
1661 | + attach (format_combobox, 1, 3, 1, 1); |
1662 | + attach (preview, 0, 4, 2, 1); |
1663 | + |
1664 | + |
1665 | + try { |
1666 | + var permission = new Polkit.Permission.sync ("org.freedesktop.locale1.set-locale", Polkit.UnixProcess.new (Posix.getpid ())); |
1667 | + |
1668 | + var apply_button = new Gtk.LockButton (permission); |
1669 | + apply_button.label = _("Apply to entire system"); |
1670 | + apply_button.tooltip_lock = _("Apply for login screen, guest account and new users"); |
1671 | + apply_button.tooltip_unlock = _("Apply for login screen, guest account and new users"); |
1672 | + apply_button.halign = Gtk.Align.START; |
1673 | + attach (apply_button, 1, 5, 1, 1); |
1674 | + |
1675 | + permission.notify["allowed"].connect (() => { |
1676 | + if (permission.allowed) { |
1677 | + on_applied_to_system(); |
1678 | + permission.impl_update (false, true, true); |
1679 | + } |
1680 | + }); |
1681 | + |
1682 | + } catch (Error e) { |
1683 | + critical (e.message); |
1684 | + } |
1685 | + |
1686 | + this.show_all (); |
1687 | + } |
1688 | + |
1689 | + void on_language_changed () { |
1690 | + // populate region |
1691 | + region_store.clear (); |
1692 | + Gtk.TreeIter iter; |
1693 | + |
1694 | + var user_language = lm.get_user_language (); |
1695 | + int selected_language = 0; |
1696 | + string lang_code; |
1697 | + |
1698 | + if (!language_combobox.get_active_iter (out iter)) |
1699 | + return; |
1700 | + language_store.get (iter, 1, out lang_code); |
1701 | + |
1702 | + var i = 0; |
1703 | + foreach (string lang in this.langs) { |
1704 | + if (lang.has_prefix (lang_code)) { |
1705 | + var language = Gnome.Languages.get_language_from_locale (lang, null); |
1706 | + |
1707 | + if (language == "") |
1708 | + break; |
1709 | + |
1710 | + region_store.append (out iter); |
1711 | + region_store.set (iter, 0, language, 1, lang); |
1712 | + |
1713 | + if (user_language == lang) |
1714 | + selected_language = i; |
1715 | + i++; |
1716 | + } |
1717 | + } |
1718 | + |
1719 | + region_combobox.sensitive = i != 1; // set to unsensitive if only have one item |
1720 | + region_combobox.active = selected_language; |
1721 | + } |
1722 | + void on_region_changed () { |
1723 | + Gtk.TreeIter iter; |
1724 | + string region; |
1725 | + |
1726 | + if (!region_combobox.get_active_iter (out iter)) |
1727 | + return; |
1728 | + region_store.get (iter, 1, out region); |
1729 | + |
1730 | + if (lm.get_user_language () != region) |
1731 | + settings_changed (); |
1732 | + |
1733 | + warning ("set language :%s ", region); |
1734 | + lm.set_user_language (region); |
1735 | + } |
1736 | + void on_format_changed () { |
1737 | + Gtk.TreeIter iter; |
1738 | + string format; |
1739 | + |
1740 | + if (!format_combobox.get_active_iter (out iter)) |
1741 | + return; |
1742 | + format_store.get (iter, 1, out format); |
1743 | + |
1744 | + if (lm.get_user_format () != format) |
1745 | + settings_changed (); |
1746 | + |
1747 | + warning ("set format :%s ", format); |
1748 | + lm.set_user_format (format); |
1749 | + |
1750 | + preview.reload_languages (format); |
1751 | + } |
1752 | + |
1753 | + Gtk.Label create_end_label (string text) { |
1754 | + var label = new Gtk.Label (text); |
1755 | + label.halign = Gtk.Align.END; |
1756 | + return label; |
1757 | + } |
1758 | + |
1759 | + public void reload_languages (string[] langs, string[] locales) { |
1760 | + this.langs = langs; |
1761 | + this.locales = locales; |
1762 | + |
1763 | + int i; |
1764 | + int selected_format = 0; |
1765 | + int selected_language = 0; |
1766 | + |
1767 | + var user_format = lm.get_user_format (); |
1768 | + var user_language = lm.get_user_language (); |
1769 | + |
1770 | + warning ("current format"+user_format); |
1771 | + warning ("current language"+user_language); |
1772 | + |
1773 | + language_store.clear (); |
1774 | + region_store.clear (); |
1775 | + format_store.clear (); |
1776 | + |
1777 | + i = 0; |
1778 | + foreach (var lang in this.langs) { |
1779 | + string language = null; |
1780 | + |
1781 | + if (lang.length == 2) |
1782 | + language = Gnome.Languages.get_language_from_code (lang, null); |
1783 | + |
1784 | + if (language != null) { |
1785 | + var iter = Gtk.TreeIter (); |
1786 | + language_store.append (out iter); |
1787 | + language_store.set (iter, 0, language, 1, lang); |
1788 | + |
1789 | + if (user_language.has_prefix (lang)) |
1790 | + selected_language = i; |
1791 | + i++; |
1792 | + } |
1793 | + } |
1794 | + language_combobox.sensitive = i != 1; // set to unsensitive if only have one item |
1795 | + language_combobox.active = selected_language; |
1796 | + |
1797 | + i = 0; |
1798 | + foreach (var locale in this.locales) { |
1799 | + var country = Gnome.Languages.get_country_from_locale (locale, null); |
1800 | + |
1801 | + if (country != null) { |
1802 | + locale += ".UTF-8"; |
1803 | + var iter = Gtk.TreeIter (); |
1804 | + format_store.append (out iter); |
1805 | + format_store.set (iter, 0, country, 1, locale); |
1806 | + |
1807 | + if (locale == user_format) |
1808 | + selected_format = i; |
1809 | + i++; |
1810 | + } |
1811 | + } |
1812 | + format_combobox.sensitive = i != 1; // set to unsensitive if only have one item |
1813 | + format_combobox.active = selected_format; |
1814 | + } |
1815 | + |
1816 | + void on_applied_to_system () { |
1817 | + lm.apply_user_to_system (); |
1818 | + settings_changed (); |
1819 | + } |
1820 | + int format_compare_func (Gtk.TreeModel model, Gtk.TreeIter a, Gtk.TreeIter b){ |
1821 | + string a_lang, a_code, b_lang, b_code; |
1822 | + |
1823 | + model.get (a, 1, out a_code); |
1824 | + model.get (b, 1, out b_code); |
1825 | + |
1826 | + if (a_code.substring (0, 2) != b_code.substring (0, 2)) |
1827 | + return a_code.ascii_casecmp (b_code); |
1828 | + |
1829 | + model.get (a, 0, out a_lang); |
1830 | + model.get (b, 0, out b_lang); |
1831 | + |
1832 | + return a_lang.ascii_casecmp (b_lang); |
1833 | + } |
1834 | +} |
1835 | |
1836 | === added file 'src/Widgets/Preview.vala' |
1837 | --- src/Widgets/Preview.vala 1970-01-01 00:00:00 +0000 |
1838 | +++ src/Widgets/Preview.vala 2015-01-16 04:39:50 +0000 |
1839 | @@ -0,0 +1,41 @@ |
1840 | +public class Preview : Gtk.Grid { |
1841 | + LocaleManager lm; |
1842 | + Gtk.Label first_line; |
1843 | + Gtk.Label second_line; |
1844 | + |
1845 | + public Preview () { |
1846 | + this.row_spacing = 10; |
1847 | + this.margin_top = 10; |
1848 | + this.margin_bottom = 20; |
1849 | + |
1850 | + lm = LocaleManager.get_default (); |
1851 | + |
1852 | + first_line = new Gtk.Label (""); |
1853 | + second_line = new Gtk.Label (""); |
1854 | + |
1855 | + first_line.set_sensitive (false); |
1856 | + second_line.set_sensitive (false); |
1857 | + |
1858 | + attach (first_line, 0, 0, 1, 1); |
1859 | + attach (second_line, 0, 1, 1, 1); |
1860 | + |
1861 | + this.show_all (); |
1862 | + } |
1863 | + |
1864 | + public void reload_languages (string format) { |
1865 | + Intl.setlocale (LocaleCategory.ALL, format); |
1866 | + |
1867 | + var date = new DateTime.now_local (); |
1868 | + first_line.set_label ("%s".printf ( |
1869 | + date.format ("%c") |
1870 | + )); |
1871 | + |
1872 | + char currency[20]; |
1873 | + Monetary.strfmon (currency, "%5.2n", 1234.56); |
1874 | + |
1875 | + second_line.set_label ("%s %s %'.2f ".printf ( |
1876 | + date.format("%x %X"), |
1877 | + (string) currency, |
1878 | + 1234.56)); |
1879 | + } |
1880 | +} |
1881 | |
1882 | === added file 'vapi/monetary.vapi' |
1883 | --- vapi/monetary.vapi 1970-01-01 00:00:00 +0000 |
1884 | +++ vapi/monetary.vapi 2015-01-16 04:39:50 +0000 |
1885 | @@ -0,0 +1,5 @@ |
1886 | +[CCode (cheader_filename = "monetary.h")] |
1887 | +public class Monetary { |
1888 | + [CCode(cname = "strfmon")] |
1889 | + public static ssize_t strfmon(char[] s, string format, double data); |
1890 | +} |
error: Package `monetary' not found in specified Vala API directories or GObject- Introspection GIR directories
Vala 0.26.1