Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 | 4 |
| 5 #include "chrome/browser/gtk/options/content_page_gtk.h" | 5 #include "chrome/browser/gtk/options/content_page_gtk.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "base/gfx/gtk_util.h" | 9 #include "base/gfx/gtk_util.h" |
| 10 #include "chrome/browser/browser_list.h" | 10 #include "chrome/browser/browser_list.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 options_builder.AddOptionGroup( | 42 options_builder.AddOptionGroup( |
| 43 l10n_util::GetStringUTF8(IDS_THEMES_GROUP_NAME), | 43 l10n_util::GetStringUTF8(IDS_THEMES_GROUP_NAME), |
| 44 InitThemesGroup(), false); | 44 InitThemesGroup(), false); |
| 45 page_ = options_builder.get_page_widget(); | 45 page_ = options_builder.get_page_widget(); |
| 46 | 46 |
| 47 // Add preferences observers. | 47 // Add preferences observers. |
| 48 ask_to_save_passwords_.Init(prefs::kPasswordManagerEnabled, | 48 ask_to_save_passwords_.Init(prefs::kPasswordManagerEnabled, |
| 49 profile->GetPrefs(), this); | 49 profile->GetPrefs(), this); |
| 50 ask_to_save_form_autofill_.Init(prefs::kFormAutofillEnabled, | 50 ask_to_save_form_autofill_.Init(prefs::kFormAutofillEnabled, |
| 51 profile->GetPrefs(), this); | 51 profile->GetPrefs(), this); |
| 52 use_custom_chrome_frame_.Init(prefs::kUseCustomChromeFrame, | |
| 53 profile->GetPrefs(), this); | |
| 52 | 54 |
| 53 // Load initial values | 55 // Load initial values |
| 54 NotifyPrefChanged(NULL); | 56 NotifyPrefChanged(NULL); |
| 55 } | 57 } |
| 56 | 58 |
| 57 ContentPageGtk::~ContentPageGtk() { | 59 ContentPageGtk::~ContentPageGtk() { |
| 58 } | 60 } |
| 59 | 61 |
| 60 void ContentPageGtk::NotifyPrefChanged(const std::wstring* pref_name) { | 62 void ContentPageGtk::NotifyPrefChanged(const std::wstring* pref_name) { |
| 61 initializing_ = true; | 63 initializing_ = true; |
| 62 if (!pref_name || *pref_name == prefs::kPasswordManagerEnabled) { | 64 if (!pref_name || *pref_name == prefs::kPasswordManagerEnabled) { |
|
Evan Stade
2009/09/08 18:09:53
I don't get the logic of these conditions, can't w
| |
| 63 if (ask_to_save_passwords_.GetValue()) { | 65 if (ask_to_save_passwords_.GetValue()) { |
| 64 gtk_toggle_button_set_active( | 66 gtk_toggle_button_set_active( |
| 65 GTK_TOGGLE_BUTTON(passwords_asktosave_radio_), TRUE); | 67 GTK_TOGGLE_BUTTON(passwords_asktosave_radio_), TRUE); |
| 66 } else { | 68 } else { |
| 67 gtk_toggle_button_set_active( | 69 gtk_toggle_button_set_active( |
| 68 GTK_TOGGLE_BUTTON(passwords_neversave_radio_), TRUE); | 70 GTK_TOGGLE_BUTTON(passwords_neversave_radio_), TRUE); |
| 69 } | 71 } |
| 70 } | 72 } |
| 71 if (!pref_name || *pref_name == prefs::kFormAutofillEnabled) { | 73 if (!pref_name || *pref_name == prefs::kFormAutofillEnabled) { |
| 72 if (ask_to_save_form_autofill_.GetValue()) { | 74 if (ask_to_save_form_autofill_.GetValue()) { |
| 73 gtk_toggle_button_set_active( | 75 gtk_toggle_button_set_active( |
| 74 GTK_TOGGLE_BUTTON(form_autofill_asktosave_radio_), TRUE); | 76 GTK_TOGGLE_BUTTON(form_autofill_asktosave_radio_), TRUE); |
| 75 } else { | 77 } else { |
| 76 gtk_toggle_button_set_active( | 78 gtk_toggle_button_set_active( |
| 77 GTK_TOGGLE_BUTTON(form_autofill_neversave_radio_), TRUE); | 79 GTK_TOGGLE_BUTTON(form_autofill_neversave_radio_), TRUE); |
| 78 } | 80 } |
| 79 } | 81 } |
| 82 if (!pref_name || *pref_name == prefs::kUseCustomChromeFrame) { | |
| 83 gtk_toggle_button_set_active( | |
| 84 GTK_TOGGLE_BUTTON(system_title_bar_checkbox_), | |
| 85 !use_custom_chrome_frame_.GetValue()); | |
| 86 } | |
| 80 initializing_ = false; | 87 initializing_ = false; |
| 81 } | 88 } |
| 82 | 89 |
| 83 /////////////////////////////////////////////////////////////////////////////// | 90 /////////////////////////////////////////////////////////////////////////////// |
| 84 // ContentPageGtk, private: | 91 // ContentPageGtk, private: |
| 85 | 92 |
| 86 GtkWidget* ContentPageGtk::InitPasswordSavingGroup() { | 93 GtkWidget* ContentPageGtk::InitPasswordSavingGroup() { |
| 87 GtkWidget* vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); | 94 GtkWidget* vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); |
| 88 | 95 |
| 89 // Ask to save radio button. | 96 // Ask to save radio button. |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 GtkWidget* clear_data_button = gtk_button_new_with_label( | 172 GtkWidget* clear_data_button = gtk_button_new_with_label( |
| 166 l10n_util::GetStringUTF8(IDS_OPTIONS_CLEAR_DATA_BUTTON).c_str()); | 173 l10n_util::GetStringUTF8(IDS_OPTIONS_CLEAR_DATA_BUTTON).c_str()); |
| 167 g_signal_connect(G_OBJECT(clear_data_button), "clicked", | 174 g_signal_connect(G_OBJECT(clear_data_button), "clicked", |
| 168 G_CALLBACK(OnClearBrowsingDataButtonClicked), this); | 175 G_CALLBACK(OnClearBrowsingDataButtonClicked), this); |
| 169 gtk_box_pack_start(GTK_BOX(button_hbox), clear_data_button, FALSE, FALSE, 0); | 176 gtk_box_pack_start(GTK_BOX(button_hbox), clear_data_button, FALSE, FALSE, 0); |
| 170 | 177 |
| 171 return vbox; | 178 return vbox; |
| 172 } | 179 } |
| 173 | 180 |
| 174 GtkWidget* ContentPageGtk::InitThemesGroup() { | 181 GtkWidget* ContentPageGtk::InitThemesGroup() { |
| 182 GtkWidget* vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); | |
| 175 GtkWidget* hbox = gtk_hbox_new(FALSE, gtk_util::kControlSpacing); | 183 GtkWidget* hbox = gtk_hbox_new(FALSE, gtk_util::kControlSpacing); |
| 176 | 184 |
| 185 // "Use system title bar and borders" checkbox. | |
| 186 system_title_bar_checkbox_ = gtk_check_button_new_with_label( | |
| 187 l10n_util::GetStringUTF8(IDS_SHOW_WINDOW_DECORATIONS).c_str()); | |
| 188 g_signal_connect(G_OBJECT(system_title_bar_checkbox_), "clicked", | |
| 189 G_CALLBACK(OnSystemTitleBarCheckboxClicked), this); | |
| 190 gtk_box_pack_start(GTK_BOX(vbox), system_title_bar_checkbox_, | |
| 191 FALSE, FALSE, 0); | |
| 192 | |
| 177 // GTK theme button. | 193 // GTK theme button. |
| 178 GtkWidget* gtk_theme_button = gtk_button_new_with_label( | 194 GtkWidget* gtk_theme_button = gtk_button_new_with_label( |
| 179 l10n_util::GetStringUTF8(IDS_THEMES_GTK_BUTTON).c_str()); | 195 l10n_util::GetStringUTF8(IDS_THEMES_GTK_BUTTON).c_str()); |
| 180 g_signal_connect(G_OBJECT(gtk_theme_button), "clicked", | 196 g_signal_connect(G_OBJECT(gtk_theme_button), "clicked", |
| 181 G_CALLBACK(OnGtkThemeButtonClicked), this); | 197 G_CALLBACK(OnGtkThemeButtonClicked), this); |
| 182 gtk_box_pack_start(GTK_BOX(hbox), gtk_theme_button, FALSE, FALSE, 0); | 198 gtk_box_pack_start(GTK_BOX(hbox), gtk_theme_button, FALSE, FALSE, 0); |
| 183 | 199 |
| 184 // Reset theme button. | 200 // Reset theme button. |
| 185 GtkWidget* themes_reset_button = gtk_button_new_with_label( | 201 GtkWidget* themes_reset_button = gtk_button_new_with_label( |
| 186 l10n_util::GetStringUTF8(IDS_THEMES_RESET_BUTTON).c_str()); | 202 l10n_util::GetStringUTF8(IDS_THEMES_RESET_BUTTON).c_str()); |
| 187 g_signal_connect(G_OBJECT(themes_reset_button), "clicked", | 203 g_signal_connect(G_OBJECT(themes_reset_button), "clicked", |
| 188 G_CALLBACK(OnResetDefaultThemeButtonClicked), this); | 204 G_CALLBACK(OnResetDefaultThemeButtonClicked), this); |
| 189 gtk_box_pack_start(GTK_BOX(hbox), themes_reset_button, FALSE, FALSE, 0); | 205 gtk_box_pack_start(GTK_BOX(hbox), themes_reset_button, FALSE, FALSE, 0); |
| 190 | 206 |
| 191 // Get themes button. | 207 // Get themes button. |
| 192 GtkWidget* themes_gallery_button = gtk_button_new_with_label( | 208 GtkWidget* themes_gallery_button = gtk_button_new_with_label( |
| 193 l10n_util::GetStringUTF8(IDS_THEMES_GALLERY_BUTTON).c_str()); | 209 l10n_util::GetStringUTF8(IDS_THEMES_GALLERY_BUTTON).c_str()); |
| 194 g_signal_connect(G_OBJECT(themes_gallery_button), "clicked", | 210 g_signal_connect(G_OBJECT(themes_gallery_button), "clicked", |
| 195 G_CALLBACK(OnGetThemesButtonClicked), this); | 211 G_CALLBACK(OnGetThemesButtonClicked), this); |
| 196 gtk_box_pack_start(GTK_BOX(hbox), themes_gallery_button, FALSE, FALSE, 0); | 212 gtk_box_pack_start(GTK_BOX(hbox), themes_gallery_button, FALSE, FALSE, 0); |
| 197 | 213 |
| 198 return hbox; | 214 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
| 215 | |
| 216 return vbox; | |
| 199 } | 217 } |
| 200 | 218 |
| 201 // static | 219 // static |
| 202 void ContentPageGtk::OnImportButtonClicked(GtkButton* widget, | 220 void ContentPageGtk::OnImportButtonClicked(GtkButton* widget, |
| 203 ContentPageGtk* page) { | 221 ContentPageGtk* page) { |
| 204 ImportDialogGtk::Show( | 222 ImportDialogGtk::Show( |
| 205 GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(widget))), | 223 GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(widget))), |
| 206 page->profile()); | 224 page->profile()); |
| 207 } | 225 } |
| 208 | 226 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 234 void ContentPageGtk::OnGetThemesButtonClicked(GtkButton* widget, | 252 void ContentPageGtk::OnGetThemesButtonClicked(GtkButton* widget, |
| 235 ContentPageGtk* page) { | 253 ContentPageGtk* page) { |
| 236 page->UserMetricsRecordAction(L"Options_ThemesGallery", | 254 page->UserMetricsRecordAction(L"Options_ThemesGallery", |
| 237 page->profile()->GetPrefs()); | 255 page->profile()->GetPrefs()); |
| 238 BrowserList::GetLastActive()->OpenURL( | 256 BrowserList::GetLastActive()->OpenURL( |
| 239 GURL(l10n_util::GetStringUTF8(IDS_THEMES_GALLERY_URL)), | 257 GURL(l10n_util::GetStringUTF8(IDS_THEMES_GALLERY_URL)), |
| 240 GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK); | 258 GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK); |
| 241 } | 259 } |
| 242 | 260 |
| 243 // static | 261 // static |
| 262 void ContentPageGtk::OnSystemTitleBarCheckboxClicked(GtkButton* widget, | |
| 263 ContentPageGtk* page) { | |
| 264 bool use_custom = !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); | |
| 265 page->use_custom_chrome_frame_.SetValue(use_custom); | |
| 266 } | |
| 267 | |
| 268 // static | |
| 244 void ContentPageGtk::OnPasswordsExceptionsButtonClicked(GtkButton* widget, | 269 void ContentPageGtk::OnPasswordsExceptionsButtonClicked(GtkButton* widget, |
| 245 ContentPageGtk* page) { | 270 ContentPageGtk* page) { |
| 246 ShowPasswordsExceptionsWindow(page->profile()); | 271 ShowPasswordsExceptionsWindow(page->profile()); |
| 247 } | 272 } |
| 248 | 273 |
| 249 // static | 274 // static |
| 250 void ContentPageGtk::OnPasswordRadioToggled(GtkToggleButton* widget, | 275 void ContentPageGtk::OnPasswordRadioToggled(GtkToggleButton* widget, |
| 251 ContentPageGtk* page) { | 276 ContentPageGtk* page) { |
| 252 if (page->initializing_) | 277 if (page->initializing_) |
| 253 return; | 278 return; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 286 GTK_TOGGLE_BUTTON(page->form_autofill_asktosave_radio_)); | 311 GTK_TOGGLE_BUTTON(page->form_autofill_asktosave_radio_)); |
| 287 if (enabled) { | 312 if (enabled) { |
| 288 page->UserMetricsRecordAction(L"Options_FormAutofill_Enable", | 313 page->UserMetricsRecordAction(L"Options_FormAutofill_Enable", |
| 289 page->profile()->GetPrefs()); | 314 page->profile()->GetPrefs()); |
| 290 } else { | 315 } else { |
| 291 page->UserMetricsRecordAction(L"Options_FormAutofill_Disable", | 316 page->UserMetricsRecordAction(L"Options_FormAutofill_Disable", |
| 292 page->profile()->GetPrefs()); | 317 page->profile()->GetPrefs()); |
| 293 } | 318 } |
| 294 page->ask_to_save_form_autofill_.SetValue(enabled); | 319 page->ask_to_save_form_autofill_.SetValue(enabled); |
| 295 } | 320 } |
| OLD | NEW |