OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_settings_window_gtk.h" | 5 #include "chrome/browser/gtk/options/content_settings_window_gtk.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 | 83 |
84 gtk_window_set_default_size(GTK_WINDOW(dialog_), 500, -1); | 84 gtk_window_set_default_size(GTK_WINDOW(dialog_), 500, -1); |
85 // Allow browser windows to go in front of the options dialog in metacity. | 85 // Allow browser windows to go in front of the options dialog in metacity. |
86 gtk_window_set_type_hint(GTK_WINDOW(dialog_), GDK_WINDOW_TYPE_HINT_NORMAL); | 86 gtk_window_set_type_hint(GTK_WINDOW(dialog_), GDK_WINDOW_TYPE_HINT_NORMAL); |
87 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog_)->vbox), | 87 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog_)->vbox), |
88 gtk_util::kContentAreaSpacing); | 88 gtk_util::kContentAreaSpacing); |
89 gtk_util::SetWindowIcon(GTK_WINDOW(dialog_)); | 89 gtk_util::SetWindowIcon(GTK_WINDOW(dialog_)); |
90 | 90 |
91 notebook_ = gtk_notebook_new(); | 91 notebook_ = gtk_notebook_new(); |
92 | 92 |
93 gtk_notebook_append_page( | 93 const struct { |
94 GTK_NOTEBOOK(notebook_), | 94 int message_id; |
95 cookie_page_.get_page_widget(), | 95 GtkWidget* widget; |
96 gtk_label_new( | 96 } kNotebookPages[] = { |
97 l10n_util::GetStringUTF8(IDS_COOKIES_TAB_LABEL).c_str())); | 97 { IDS_COOKIES_TAB_LABEL, cookie_page_.get_page_widget() }, |
98 gtk_notebook_append_page( | 98 { IDS_IMAGES_TAB_LABEL, image_page_.get_page_widget() }, |
99 GTK_NOTEBOOK(notebook_), | 99 { IDS_JAVASCRIPT_TAB_LABEL, javascript_page_.get_page_widget() }, |
100 image_page_.get_page_widget(), | 100 { IDS_PLUGIN_TAB_LABEL, plugin_page_.get_page_widget() }, |
101 gtk_label_new( | 101 { IDS_POPUP_TAB_LABEL, popup_page_.get_page_widget() }, |
102 l10n_util::GetStringUTF8(IDS_IMAGES_TAB_LABEL).c_str())); | 102 { IDS_GEOLOCATION_TAB_LABEL, geolocation_page_.get_page_widget() }, |
103 gtk_notebook_append_page( | 103 }; |
104 GTK_NOTEBOOK(notebook_), | 104 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kNotebookPages); ++i) { |
105 javascript_page_.get_page_widget(), | 105 std::string label = l10n_util::GetStringUTF8(kNotebookPages[i].message_id); |
106 gtk_label_new( | 106 // Since the tabs are on the side, add some padding space to the label. |
107 l10n_util::GetStringUTF8(IDS_JAVASCRIPT_TAB_LABEL).c_str())); | 107 gtk_notebook_append_page( |
108 gtk_notebook_append_page( | 108 GTK_NOTEBOOK(notebook_), |
109 GTK_NOTEBOOK(notebook_), | 109 kNotebookPages[i].widget, |
110 plugin_page_.get_page_widget(), | 110 gtk_label_new((" " + label + " ").c_str())); |
111 gtk_label_new( | 111 } |
112 l10n_util::GetStringUTF8(IDS_PLUGIN_TAB_LABEL).c_str())); | 112 |
113 gtk_notebook_append_page( | 113 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook_), GTK_POS_LEFT); |
114 GTK_NOTEBOOK(notebook_), | |
115 popup_page_.get_page_widget(), | |
116 gtk_label_new( | |
117 l10n_util::GetStringUTF8(IDS_POPUP_TAB_LABEL).c_str())); | |
118 gtk_notebook_append_page( | |
119 GTK_NOTEBOOK(notebook_), | |
120 geolocation_page_.get_page_widget(), | |
121 gtk_label_new( | |
122 l10n_util::GetStringUTF8(IDS_GEOLOCATION_TAB_LABEL).c_str())); | |
123 | 114 |
124 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog_)->vbox), notebook_); | 115 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog_)->vbox), notebook_); |
125 | 116 |
126 DCHECK_EQ(gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook_)), | 117 DCHECK_EQ(gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook_)), |
127 CONTENT_SETTINGS_NUM_TYPES); | 118 CONTENT_SETTINGS_NUM_TYPES); |
128 | 119 |
129 // Need to show the notebook before connecting switch-page signal, otherwise | 120 // Need to show the notebook before connecting switch-page signal, otherwise |
130 // we'll immediately get a signal switching to page 0 and overwrite our | 121 // we'll immediately get a signal switching to page 0 and overwrite our |
131 // last_selected_page_ value. | 122 // last_selected_page_ value. |
132 gtk_util::ShowDialogWithLocalizedSize(dialog_, -1, -1, true); | 123 gtk_util::ShowDialogWithLocalizedSize(dialog_, -1, -1, true); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 int index = page_num; | 161 int index = page_num; |
171 DCHECK(index > CONTENT_SETTINGS_TYPE_DEFAULT && | 162 DCHECK(index > CONTENT_SETTINGS_TYPE_DEFAULT && |
172 index < CONTENT_SETTINGS_NUM_TYPES); | 163 index < CONTENT_SETTINGS_NUM_TYPES); |
173 last_selected_page_.SetValue(index); | 164 last_selected_page_.SetValue(index); |
174 } | 165 } |
175 | 166 |
176 void ContentSettingsWindowGtk::OnWindowDestroy(GtkWidget* widget) { | 167 void ContentSettingsWindowGtk::OnWindowDestroy(GtkWidget* widget) { |
177 settings_window = NULL; | 168 settings_window = NULL; |
178 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 169 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
179 } | 170 } |
OLD | NEW |