Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: chrome/browser/views/options/languages_page_view.cc

Issue 174043: Gtk languages options page part 1: accept-languages configuration. (Closed)
Patch Set: rebase Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/language_order_table_model.cc ('k') | chrome/chrome.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 #include <windows.h> 4 #include <windows.h>
5 #include <shlobj.h> 5 #include <shlobj.h>
6 #include <vsstyle.h> 6 #include <vsstyle.h>
7 #include <vssym32.h> 7 #include <vssym32.h>
8 8
9 #include "chrome/browser/views/options/languages_page_view.h" 9 #include "chrome/browser/views/options/languages_page_view.h"
10 10
(...skipping 21 matching lines...) Expand all
32 #include "third_party/skia/include/core/SkBitmap.h" 32 #include "third_party/skia/include/core/SkBitmap.h"
33 #include "unicode/uloc.h" 33 #include "unicode/uloc.h"
34 #include "views/controls/button/radio_button.h" 34 #include "views/controls/button/radio_button.h"
35 #include "views/controls/tabbed_pane/tabbed_pane.h" 35 #include "views/controls/tabbed_pane/tabbed_pane.h"
36 #include "views/controls/table/table_view.h" 36 #include "views/controls/table/table_view.h"
37 #include "views/grid_layout.h" 37 #include "views/grid_layout.h"
38 #include "views/standard_layout.h" 38 #include "views/standard_layout.h"
39 #include "views/widget/widget.h" 39 #include "views/widget/widget.h"
40 #include "views/window/window.h" 40 #include "views/window/window.h"
41 41
42 static const char* const accept_language_list[] = {
43 "af", // Afrikaans
44 "am", // Amharic
45 "ar", // Arabic
46 "az", // Azerbaijani
47 "be", // Belarusian
48 "bg", // Bulgarian
49 "bh", // Bihari
50 "bn", // Bengali
51 "br", // Breton
52 "bs", // Bosnian
53 "ca", // Catalan
54 "co", // Corsican
55 "cs", // Czech
56 "cy", // Welsh
57 "da", // Danish
58 "de", // German
59 "de-AT", // German (Austria)
60 "de-CH", // German (Switzerland)
61 "de-DE", // German (Germany)
62 "el", // Greek
63 "en", // English
64 "en-AU", // English (Austrailia)
65 "en-CA", // English (Canada)
66 "en-GB", // English (UK)
67 "en-NZ", // English (New Zealand)
68 "en-US", // English (US)
69 "en-ZA", // English (South Africa)
70 "eo", // Esperanto
71 // TODO(jungshik) : Do we want to list all es-Foo for Latin-American
72 // Spanish speaking countries?
73 "es", // Spanish
74 "et", // Estonian
75 "eu", // Basque
76 "fa", // Persian
77 "fi", // Finnish
78 "fil", // Filipino
79 "fo", // Faroese
80 "fr", // French
81 "fr-CA", // French (Canada)
82 "fr-CH", // French (Switzerland)
83 "fr-FR", // French (France)
84 "fy", // Frisian
85 "ga", // Irish
86 "gd", // Scots Gaelic
87 "gl", // Galician
88 "gn", // Guarani
89 "gu", // Gujarati
90 "he", // Hebrew
91 "hi", // Hindi
92 "hr", // Croatian
93 "hu", // Hungarian
94 "hy", // Armenian
95 "ia", // Interlingua
96 "id", // Indonesian
97 "is", // Icelandic
98 "it", // Italian
99 "it-CH", // Italian (Switzerland)
100 "it-IT", // Italian (Italy)
101 "ja", // Japanese
102 "jw", // Javanese
103 "ka", // Georgian
104 "kk", // Kazakh
105 "km", // Cambodian
106 "kn", // Kannada
107 "ko", // Korean
108 "ku", // Kurdish
109 "ky", // Kyrgyz
110 "la", // Latin
111 "ln", // Lingala
112 "lo", // Laothian
113 "lt", // Lithuanian
114 "lv", // Latvian
115 "mk", // Macedonian
116 "ml", // Malayalam
117 "mn", // Mongolian
118 "mo", // Moldavian
119 "mr", // Marathi
120 "ms", // Malay
121 "mt", // Maltese
122 "nb", // Norwegian (Bokmal)
123 "ne", // Nepali
124 "nl", // Dutch
125 "nn", // Norwegian (Nynorsk)
126 "no", // Norwegian
127 "oc", // Occitan
128 "or", // Oriya
129 "pa", // Punjabi
130 "pl", // Polish
131 "ps", // Pashto
132 "pt", // Portuguese
133 "pt-BR", // Portuguese (Brazil)
134 "pt-PT", // Portuguese (Portugal)
135 "qu", // Quechua
136 "rm", // Romansh
137 "ro", // Romanian
138 "ru", // Russian
139 "sd", // Sindhi
140 "sh", // Serbo-Croatian
141 "si", // Sinhalese
142 "sk", // Slovak
143 "sl", // Slovenian
144 "sn", // Shona
145 "so", // Somali
146 "sq", // Albanian
147 "sr", // Serbian
148 "st", // Sesotho
149 "su", // Sundanese
150 "sv", // Swedish
151 "sw", // Swahili
152 "ta", // Tamil
153 "te", // Telugu
154 "tg", // Tajik
155 "th", // Thai
156 "ti", // Tigrinya
157 "tk", // Turkmen
158 "to", // Tonga
159 "tr", // Turkish
160 "tt", // Tatar
161 "tw", // Twi
162 "ug", // Uighur
163 "uk", // Ukrainian
164 "ur", // Urdu
165 "uz", // Uzbek
166 "vi", // Vietnamese
167 "xh", // Xhosa
168 "yi", // Yiddish
169 "yo", // Yoruba
170 "zh", // Chinese
171 "zh-CN", // Chinese (Simplified)
172 "zh-TW", // Chinese (Traditional)
173 "zu", // Zulu
174 };
175
176 /////////////////////////////////////////////////////////////////////////////// 42 ///////////////////////////////////////////////////////////////////////////////
177 // AddLanguageWindowView 43 // AddLanguageWindowView
178 // 44 //
179 // This opens another window from where a new accept language can be selected. 45 // This opens another window from where a new accept language can be selected.
180 // 46 //
181 class AddLanguageWindowView : public views::View, 47 class AddLanguageWindowView : public views::View,
182 public views::Combobox::Listener, 48 public views::Combobox::Listener,
183 public views::DialogDelegate { 49 public views::DialogDelegate {
184 public: 50 public:
185 AddLanguageWindowView(LanguagesPageView* language_delegate, Profile* profile); 51 AddLanguageWindowView(LanguagesPageView* language_delegate, Profile* profile);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 views::View* parent, 148 views::View* parent,
283 views::View* child) { 149 views::View* child) {
284 // Can't init before we're inserted into a Widget, because we require 150 // Can't init before we're inserted into a Widget, because we require
285 // a HWND to parent native child controls to. 151 // a HWND to parent native child controls to.
286 if (is_add && child == this) 152 if (is_add && child == this)
287 Init(); 153 Init();
288 } 154 }
289 155
290 void AddLanguageWindowView::Init() { 156 void AddLanguageWindowView::Init() {
291 // Determine Locale Codes. 157 // Determine Locale Codes.
158 const std::string app_locale = g_browser_process->GetApplicationLocale();
292 std::vector<std::string> locale_codes; 159 std::vector<std::string> locale_codes;
293 const std::string app_locale = g_browser_process->GetApplicationLocale(); 160 l10n_util::GetAcceptLanguagesForLocale(app_locale, &locale_codes);
294 for (size_t i = 0; i < arraysize(accept_language_list); ++i) { 161
295 string16 display_name =
296 l10n_util::GetDisplayNameForLocale(accept_language_list[i],
297 app_locale, false);
298 // This is a hack. If ICU doesn't have a translated name for
299 // this language, GetDisplayNameForLocale will just return the
300 // language code. In that case, we skip it.
301 // TODO(jungshik) : Put them at the of the list with language codes
302 // enclosed by brackets.
303 if (IsStringASCII(display_name) &&
304 UTF16ToASCII(display_name) == accept_language_list[i])
305 continue;
306 locale_codes.push_back(accept_language_list[i]);
307 }
308 accept_language_combobox_model_.reset(new LanguageComboboxModel( 162 accept_language_combobox_model_.reset(new LanguageComboboxModel(
309 profile_, locale_codes)); 163 profile_, locale_codes));
310 accept_language_combobox_ = new views::Combobox( 164 accept_language_combobox_ = new views::Combobox(
311 accept_language_combobox_model_.get()); 165 accept_language_combobox_model_.get());
312 accept_language_combobox_->SetSelectedItem(0); 166 accept_language_combobox_->SetSelectedItem(0);
313 accept_language_combobox_->set_listener(this); 167 accept_language_combobox_->set_listener(this);
314 AddChildView(accept_language_combobox_); 168 AddChildView(accept_language_combobox_);
315 } 169 }
316 170
317 LanguagesPageView::LanguagesPageView(Profile* profile) 171 LanguagesPageView::LanguagesPageView(Profile* profile)
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 new AddLanguageWindowView(this, profile()))->Show(); 222 new AddLanguageWindowView(this, profile()))->Show();
369 language_table_edited_ = true; 223 language_table_edited_ = true;
370 } else if (sender == enable_spellchecking_checkbox_) { 224 } else if (sender == enable_spellchecking_checkbox_) {
371 enable_spellcheck_checkbox_clicked_ = true; 225 enable_spellcheck_checkbox_clicked_ = true;
372 } else if (sender == enable_autospellcorrect_checkbox_) { 226 } else if (sender == enable_autospellcorrect_checkbox_) {
373 enable_autospellcorrect_checkbox_clicked_ = true; 227 enable_autospellcorrect_checkbox_clicked_ = true;
374 } 228 }
375 } 229 }
376 230
377 void LanguagesPageView::OnAddLanguage(const std::string& new_language) { 231 void LanguagesPageView::OnAddLanguage(const std::string& new_language) {
378 language_order_table_model_->Add(new_language); 232 if (language_order_table_model_->Add(new_language)) {
379 language_order_table_->Select(language_order_table_model_->RowCount() - 1); 233 language_order_table_->Select(language_order_table_model_->RowCount() - 1);
380 OnSelectionChanged(); 234 OnSelectionChanged();
235 }
381 } 236 }
382 237
383 void LanguagesPageView::InitControlLayout() { 238 void LanguagesPageView::InitControlLayout() {
384 // Define the buttons. 239 // Define the buttons.
385 add_button_ = new views::NativeButton(this, l10n_util::GetString( 240 add_button_ = new views::NativeButton(this, l10n_util::GetString(
386 IDS_FONT_LANGUAGE_SETTING_LANGUAGES_SELECTOR_ADD_BUTTON_LABEL)); 241 IDS_FONT_LANGUAGE_SETTING_LANGUAGES_SELECTOR_ADD_BUTTON_LABEL));
387 remove_button_ = new views::NativeButton(this, l10n_util::GetString( 242 remove_button_ = new views::NativeButton(this, l10n_util::GetString(
388 IDS_FONT_LANGUAGE_SETTING_LANGUAGES_SELECTOR_REMOVE_BUTTON_LABEL)); 243 IDS_FONT_LANGUAGE_SETTING_LANGUAGES_SELECTOR_REMOVE_BUTTON_LABEL));
389 remove_button_->SetEnabled(false); 244 remove_button_->SetEnabled(false);
390 move_up_button_ = new views::NativeButton(this, l10n_util::GetString( 245 move_up_button_ = new views::NativeButton(this, l10n_util::GetString(
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 } 575 }
721 576
722 if (enable_spellcheck_checkbox_clicked_) 577 if (enable_spellcheck_checkbox_clicked_)
723 enable_spellcheck_.SetValue(enable_spellchecking_checkbox_->checked()); 578 enable_spellcheck_.SetValue(enable_spellchecking_checkbox_->checked());
724 579
725 if (enable_autospellcorrect_checkbox_clicked_) { 580 if (enable_autospellcorrect_checkbox_clicked_) {
726 enable_autospellcorrect_.SetValue( 581 enable_autospellcorrect_.SetValue(
727 enable_autospellcorrect_checkbox_->checked()); 582 enable_autospellcorrect_checkbox_->checked());
728 } 583 }
729 } 584 }
OLDNEW
« no previous file with comments | « chrome/browser/language_order_table_model.cc ('k') | chrome/chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698