| 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/advanced_contents_gtk.h" | 5 #include "chrome/browser/gtk/options/advanced_contents_gtk.h" |
| 6 | 6 |
| 7 #include <sys/types.h> | 7 #include <sys/types.h> |
| 8 #include <sys/wait.h> | 8 #include <sys/wait.h> |
| 9 | 9 |
| 10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 return label; | 51 return label; |
| 52 } | 52 } |
| 53 | 53 |
| 54 GtkWidget* CreateCheckButtonWithWrappedLabel(int string_id) { | 54 GtkWidget* CreateCheckButtonWithWrappedLabel(int string_id) { |
| 55 GtkWidget* checkbox = gtk_check_button_new(); | 55 GtkWidget* checkbox = gtk_check_button_new(); |
| 56 gtk_container_add(GTK_CONTAINER(checkbox), | 56 gtk_container_add(GTK_CONTAINER(checkbox), |
| 57 CreateWrappedLabel(string_id)); | 57 CreateWrappedLabel(string_id)); |
| 58 return checkbox; | 58 return checkbox; |
| 59 } | 59 } |
| 60 | 60 |
| 61 // Don't let the widget handle scroll events. Instead, pass it on to the |
| 62 // parent widget. |
| 63 gboolean PassScrollToParent(GtkWidget* widget, GdkEvent* event, |
| 64 gpointer unused) { |
| 65 if (widget->parent) |
| 66 gtk_propagate_event(widget->parent, event); |
| 67 |
| 68 return TRUE; |
| 69 } |
| 70 |
| 71 // Recursively search for a combo box among the children of |widget|. |
| 72 void SearchForComboBox(GtkWidget* widget, gpointer data) { |
| 73 if (GTK_IS_COMBO_BOX(widget)) { |
| 74 *reinterpret_cast<GtkWidget**>(data) = widget; |
| 75 } else if (GTK_IS_CONTAINER(widget)) { |
| 76 gtk_container_foreach(GTK_CONTAINER(widget), SearchForComboBox, data); |
| 77 } |
| 78 } |
| 79 |
| 80 // Letting the combo boxes in the advanced options page handle scroll events is |
| 81 // annoying because they fight with the scrolled window. Also, |
| 82 // GtkFileChooserButton is buggy in that if you scroll on it very quickly it |
| 83 // spews Gtk-WARNINGs, which causes us to crash in debug. This function disables |
| 84 // scrolling for the combo box in |widget| (the first one it finds in a DFS). |
| 85 void DisableScrolling(GtkWidget* widget) { |
| 86 gpointer combo_box_ptr = NULL; |
| 87 SearchForComboBox(widget, &combo_box_ptr); |
| 88 |
| 89 if (!combo_box_ptr) { |
| 90 NOTREACHED() << " Did not find a combo box in this widget."; |
| 91 return; |
| 92 } |
| 93 |
| 94 g_signal_connect(GTK_WIDGET(combo_box_ptr), "scroll-event", |
| 95 G_CALLBACK(PassScrollToParent), NULL); |
| 96 } |
| 97 |
| 61 } // anonymous namespace | 98 } // anonymous namespace |
| 62 | 99 |
| 63 | 100 |
| 64 /////////////////////////////////////////////////////////////////////////////// | 101 /////////////////////////////////////////////////////////////////////////////// |
| 65 // DownloadSection | 102 // DownloadSection |
| 66 | 103 |
| 67 class DownloadSection : public OptionsPageBase { | 104 class DownloadSection : public OptionsPageBase { |
| 68 public: | 105 public: |
| 69 explicit DownloadSection(Profile* profile); | 106 explicit DownloadSection(Profile* profile); |
| 70 virtual ~DownloadSection() {} | 107 virtual ~DownloadSection() {} |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 : OptionsPageBase(profile), initializing_(true) { | 147 : OptionsPageBase(profile), initializing_(true) { |
| 111 page_ = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); | 148 page_ = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); |
| 112 | 149 |
| 113 // Download location options. | 150 // Download location options. |
| 114 download_location_button_ = gtk_file_chooser_button_new( | 151 download_location_button_ = gtk_file_chooser_button_new( |
| 115 l10n_util::GetStringUTF8( | 152 l10n_util::GetStringUTF8( |
| 116 IDS_OPTIONS_DOWNLOADLOCATION_BROWSE_WINDOW_TITLE).c_str(), | 153 IDS_OPTIONS_DOWNLOADLOCATION_BROWSE_WINDOW_TITLE).c_str(), |
| 117 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); | 154 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); |
| 118 g_signal_connect(download_location_button_, "selection-changed", | 155 g_signal_connect(download_location_button_, "selection-changed", |
| 119 G_CALLBACK(OnDownloadLocationChanged), this); | 156 G_CALLBACK(OnDownloadLocationChanged), this); |
| 157 DisableScrolling(download_location_button_); |
| 158 |
| 120 // Add the default download path to the list of shortcuts in the selector. | 159 // Add the default download path to the list of shortcuts in the selector. |
| 121 FilePath default_download_path; | 160 FilePath default_download_path; |
| 122 if (!PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS, | 161 if (!PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS, |
| 123 &default_download_path)) { | 162 &default_download_path)) { |
| 124 NOTREACHED(); | 163 NOTREACHED(); |
| 125 } else { | 164 } else { |
| 126 if (!gtk_file_chooser_add_shortcut_folder( | 165 if (!gtk_file_chooser_add_shortcut_folder( |
| 127 GTK_FILE_CHOOSER(download_location_button_), | 166 GTK_FILE_CHOOSER(download_location_button_), |
| 128 default_download_path.value().c_str(), | 167 default_download_path.value().c_str(), |
| 129 NULL)) { | 168 NULL)) { |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 l10n_util::GetStringUTF8(IDS_OPTIONS_COOKIES_ACCEPT_LABEL).c_str()); | 502 l10n_util::GetStringUTF8(IDS_OPTIONS_COOKIES_ACCEPT_LABEL).c_str()); |
| 464 gtk_misc_set_alignment(GTK_MISC(cookie_description_label), 0, 0); | 503 gtk_misc_set_alignment(GTK_MISC(cookie_description_label), 0, 0); |
| 465 gtk_box_pack_start(GTK_BOX(page_), cookie_description_label, FALSE, FALSE, 0); | 504 gtk_box_pack_start(GTK_BOX(page_), cookie_description_label, FALSE, FALSE, 0); |
| 466 | 505 |
| 467 GtkWidget* cookie_controls = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); | 506 GtkWidget* cookie_controls = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); |
| 468 gtk_box_pack_start(GTK_BOX(page_), | 507 gtk_box_pack_start(GTK_BOX(page_), |
| 469 OptionsLayoutBuilderGtk::IndentWidget(cookie_controls), | 508 OptionsLayoutBuilderGtk::IndentWidget(cookie_controls), |
| 470 FALSE, FALSE, 0); | 509 FALSE, FALSE, 0); |
| 471 | 510 |
| 472 cookie_behavior_combobox_ = gtk_combo_box_new_text(); | 511 cookie_behavior_combobox_ = gtk_combo_box_new_text(); |
| 512 DisableScrolling(cookie_behavior_combobox_); |
| 473 gtk_combo_box_append_text( | 513 gtk_combo_box_append_text( |
| 474 GTK_COMBO_BOX(cookie_behavior_combobox_), | 514 GTK_COMBO_BOX(cookie_behavior_combobox_), |
| 475 l10n_util::GetStringUTF8(IDS_OPTIONS_COOKIES_ACCEPT_ALL_COOKIES).c_str()); | 515 l10n_util::GetStringUTF8(IDS_OPTIONS_COOKIES_ACCEPT_ALL_COOKIES).c_str()); |
| 476 gtk_combo_box_append_text( | 516 gtk_combo_box_append_text( |
| 477 GTK_COMBO_BOX(cookie_behavior_combobox_), | 517 GTK_COMBO_BOX(cookie_behavior_combobox_), |
| 478 l10n_util::GetStringUTF8( | 518 l10n_util::GetStringUTF8( |
| 479 IDS_OPTIONS_COOKIES_RESTRICT_THIRD_PARTY_COOKIES).c_str()); | 519 IDS_OPTIONS_COOKIES_RESTRICT_THIRD_PARTY_COOKIES).c_str()); |
| 480 gtk_combo_box_append_text( | 520 gtk_combo_box_append_text( |
| 481 GTK_COMBO_BOX(cookie_behavior_combobox_), | 521 GTK_COMBO_BOX(cookie_behavior_combobox_), |
| 482 l10n_util::GetStringUTF8(IDS_OPTIONS_COOKIES_BLOCK_ALL_COOKIES).c_str()); | 522 l10n_util::GetStringUTF8(IDS_OPTIONS_COOKIES_BLOCK_ALL_COOKIES).c_str()); |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 847 l10n_util::GetStringUTF8(IDS_OPTIONS_ADVANCED_SECTION_TITLE_CONTENT), | 887 l10n_util::GetStringUTF8(IDS_OPTIONS_ADVANCED_SECTION_TITLE_CONTENT), |
| 848 web_content_section_->get_page_widget(), false); | 888 web_content_section_->get_page_widget(), false); |
| 849 | 889 |
| 850 security_section_.reset(new SecuritySection(profile_)); | 890 security_section_.reset(new SecuritySection(profile_)); |
| 851 options_builder.AddOptionGroup( | 891 options_builder.AddOptionGroup( |
| 852 l10n_util::GetStringUTF8(IDS_OPTIONS_ADVANCED_SECTION_TITLE_SECURITY), | 892 l10n_util::GetStringUTF8(IDS_OPTIONS_ADVANCED_SECTION_TITLE_SECURITY), |
| 853 security_section_->get_page_widget(), false); | 893 security_section_->get_page_widget(), false); |
| 854 | 894 |
| 855 page_ = options_builder.get_page_widget(); | 895 page_ = options_builder.get_page_widget(); |
| 856 } | 896 } |
| OLD | NEW |