OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 | 4 |
5 #include "chrome/browser/ui/gtk/edit_search_engine_dialog.h" | 5 #include "chrome/browser/ui/gtk/edit_search_engine_dialog.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
9 #include "base/i18n/case_conversion.h" | 9 #include "base/i18n/case_conversion.h" |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 | 172 |
173 GtkWidget* controls = gtk_util::CreateLabeledControlsGroup(NULL, | 173 GtkWidget* controls = gtk_util::CreateLabeledControlsGroup(NULL, |
174 l10n_util::GetStringUTF8( | 174 l10n_util::GetStringUTF8( |
175 IDS_SEARCH_ENGINES_EDITOR_DESCRIPTION_LABEL).c_str(), | 175 IDS_SEARCH_ENGINES_EDITOR_DESCRIPTION_LABEL).c_str(), |
176 gtk_util::CreateEntryImageHBox(title_entry_, title_image_), | 176 gtk_util::CreateEntryImageHBox(title_entry_, title_image_), |
177 l10n_util::GetStringUTF8(IDS_SEARCH_ENGINES_EDITOR_KEYWORD_LABEL).c_str(), | 177 l10n_util::GetStringUTF8(IDS_SEARCH_ENGINES_EDITOR_KEYWORD_LABEL).c_str(), |
178 gtk_util::CreateEntryImageHBox(keyword_entry_, keyword_image_), | 178 gtk_util::CreateEntryImageHBox(keyword_entry_, keyword_image_), |
179 l10n_util::GetStringUTF8(IDS_SEARCH_ENGINES_EDITOR_URL_LABEL).c_str(), | 179 l10n_util::GetStringUTF8(IDS_SEARCH_ENGINES_EDITOR_URL_LABEL).c_str(), |
180 gtk_util::CreateEntryImageHBox(url_entry_, url_image_), | 180 gtk_util::CreateEntryImageHBox(url_entry_, url_image_), |
181 NULL); | 181 NULL); |
182 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog_)->vbox), controls, | 182 |
183 FALSE, FALSE, 0); | 183 GtkWidget* content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog_)); |
| 184 gtk_box_pack_start(GTK_BOX(content_area), controls, FALSE, FALSE, 0); |
184 | 185 |
185 // On RTL UIs (such as Arabic and Hebrew) the description text is not | 186 // On RTL UIs (such as Arabic and Hebrew) the description text is not |
186 // displayed correctly since it contains the substring "%s". This substring | 187 // displayed correctly since it contains the substring "%s". This substring |
187 // is not interpreted by the Unicode BiDi algorithm as an LTR string and | 188 // is not interpreted by the Unicode BiDi algorithm as an LTR string and |
188 // therefore the end result is that the following right to left text is | 189 // therefore the end result is that the following right to left text is |
189 // displayed: ".three two s% one" (where 'one', 'two', etc. are words in | 190 // displayed: ".three two s% one" (where 'one', 'two', etc. are words in |
190 // Hebrew). | 191 // Hebrew). |
191 // | 192 // |
192 // In order to fix this problem we transform the substring "%s" so that it | 193 // In order to fix this problem we transform the substring "%s" so that it |
193 // is displayed correctly when rendered in an RTL context. | 194 // is displayed correctly when rendered in an RTL context. |
194 std::string description = | 195 std::string description = |
195 l10n_util::GetStringUTF8(IDS_SEARCH_ENGINES_EDITOR_URL_DESCRIPTION_LABEL); | 196 l10n_util::GetStringUTF8(IDS_SEARCH_ENGINES_EDITOR_URL_DESCRIPTION_LABEL); |
196 if (base::i18n::IsRTL()) { | 197 if (base::i18n::IsRTL()) { |
197 const std::string reversed_percent("s%"); | 198 const std::string reversed_percent("s%"); |
198 std::string::size_type percent_index = description.find("%s"); | 199 std::string::size_type percent_index = description.find("%s"); |
199 if (percent_index != std::string::npos) { | 200 if (percent_index != std::string::npos) { |
200 description.replace(percent_index, | 201 description.replace(percent_index, |
201 reversed_percent.length(), | 202 reversed_percent.length(), |
202 reversed_percent); | 203 reversed_percent); |
203 } | 204 } |
204 } | 205 } |
205 | 206 |
206 GtkWidget* description_label = gtk_label_new(description.c_str()); | 207 GtkWidget* description_label = gtk_label_new(description.c_str()); |
207 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog_)->vbox), description_label, | 208 gtk_box_pack_start(GTK_BOX(content_area), description_label, |
208 FALSE, FALSE, 0); | 209 FALSE, FALSE, 0); |
209 | 210 |
210 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog_)->vbox), | 211 gtk_box_set_spacing(GTK_BOX(content_area), ui::kContentAreaSpacing); |
211 ui::kContentAreaSpacing); | |
212 | 212 |
213 EnableControls(); | 213 EnableControls(); |
214 | 214 |
215 gtk_util::ShowDialog(dialog_); | 215 gtk_util::ShowDialog(dialog_); |
216 | 216 |
217 g_signal_connect(dialog_, "response", G_CALLBACK(OnResponseThunk), this); | 217 g_signal_connect(dialog_, "response", G_CALLBACK(OnResponseThunk), this); |
218 g_signal_connect(dialog_, "destroy", G_CALLBACK(OnWindowDestroyThunk), this); | 218 g_signal_connect(dialog_, "destroy", G_CALLBACK(OnWindowDestroyThunk), this); |
219 } | 219 } |
220 | 220 |
221 string16 EditSearchEngineDialog::GetTitleInput() const { | 221 string16 EditSearchEngineDialog::GetTitleInput() const { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 GetURLInput()); | 271 GetURLInput()); |
272 } else { | 272 } else { |
273 controller_->CleanUpCancelledAdd(); | 273 controller_->CleanUpCancelledAdd(); |
274 } | 274 } |
275 gtk_widget_destroy(dialog_); | 275 gtk_widget_destroy(dialog_); |
276 } | 276 } |
277 | 277 |
278 void EditSearchEngineDialog::OnWindowDestroy(GtkWidget* widget) { | 278 void EditSearchEngineDialog::OnWindowDestroy(GtkWidget* widget) { |
279 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 279 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
280 } | 280 } |
OLD | NEW |