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

Side by Side Diff: chrome/browser/ui/gtk/content_setting_bubble_gtk.cc

Issue 10948037: [gtk] fix theming of content settings bubble (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/ui/gtk/gtk_theme_service.h » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/content_setting_bubble_gtk.h" 5 #include "chrome/browser/ui/gtk/content_setting_bubble_gtk.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 void ContentSettingBubbleGtk::BuildBubble() { 93 void ContentSettingBubbleGtk::BuildBubble() {
94 GtkThemeService* theme_provider = GtkThemeService::GetFrom(profile_); 94 GtkThemeService* theme_provider = GtkThemeService::GetFrom(profile_);
95 95
96 GtkWidget* bubble_content = gtk_vbox_new(FALSE, ui::kControlSpacing); 96 GtkWidget* bubble_content = gtk_vbox_new(FALSE, ui::kControlSpacing);
97 gtk_container_set_border_width(GTK_CONTAINER(bubble_content), kContentBorder); 97 gtk_container_set_border_width(GTK_CONTAINER(bubble_content), kContentBorder);
98 98
99 const ContentSettingBubbleModel::BubbleContent& content = 99 const ContentSettingBubbleModel::BubbleContent& content =
100 content_setting_bubble_model_->bubble_content(); 100 content_setting_bubble_model_->bubble_content();
101 if (!content.title.empty()) { 101 if (!content.title.empty()) {
102 // Add the content label. 102 // Add the content label.
103 GtkWidget* label = gtk_label_new(content.title.c_str()); 103 GtkWidget* label = theme_provider->BuildLabel(content.title.c_str(),
104 ui::kGdkBlack);
104 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); 105 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
105 gtk_box_pack_start(GTK_BOX(bubble_content), label, FALSE, FALSE, 0); 106 gtk_box_pack_start(GTK_BOX(bubble_content), label, FALSE, FALSE, 0);
106 } 107 }
107 108
108 const std::set<std::string>& plugins = content.resource_identifiers; 109 const std::set<std::string>& plugins = content.resource_identifiers;
109 if (!plugins.empty()) { 110 if (!plugins.empty()) {
110 GtkWidget* list_content = gtk_vbox_new(FALSE, ui::kControlSpacing); 111 GtkWidget* list_content = gtk_vbox_new(FALSE, ui::kControlSpacing);
111 112
112 for (std::set<std::string>::const_iterator it = plugins.begin(); 113 for (std::set<std::string>::const_iterator it = plugins.begin();
113 it != plugins.end(); ++it) { 114 it != plugins.end(); ++it) {
114 std::string name = UTF16ToUTF8( 115 std::string name = UTF16ToUTF8(
115 PluginService::GetInstance()->GetPluginGroupName(*it)); 116 PluginService::GetInstance()->GetPluginGroupName(*it));
116 if (name.empty()) 117 if (name.empty())
117 name = *it; 118 name = *it;
118 119
119 GtkWidget* label = gtk_label_new(BuildElidedText(name).c_str()); 120 GtkWidget* label = theme_provider->BuildLabel(
121 BuildElidedText(name).c_str(), ui::kGdkBlack);
120 GtkWidget* label_box = gtk_hbox_new(FALSE, 0); 122 GtkWidget* label_box = gtk_hbox_new(FALSE, 0);
121 gtk_box_pack_start(GTK_BOX(label_box), label, FALSE, FALSE, 0); 123 gtk_box_pack_start(GTK_BOX(label_box), label, FALSE, FALSE, 0);
122 124
123 gtk_box_pack_start(GTK_BOX(list_content), 125 gtk_box_pack_start(GTK_BOX(list_content),
124 label_box, 126 label_box,
125 FALSE, FALSE, 0); 127 FALSE, FALSE, 0);
126 } 128 }
127 gtk_box_pack_start(GTK_BOX(bubble_content), list_content, FALSE, FALSE, 129 gtk_box_pack_start(GTK_BOX(bubble_content), list_content, FALSE, FALSE,
128 ui::kControlSpacing); 130 ui::kControlSpacing);
129 } 131 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 } 171 }
170 172
171 const ContentSettingBubbleModel::RadioGroup& radio_group = 173 const ContentSettingBubbleModel::RadioGroup& radio_group =
172 content.radio_group; 174 content.radio_group;
173 for (ContentSettingBubbleModel::RadioItems::const_iterator i = 175 for (ContentSettingBubbleModel::RadioItems::const_iterator i =
174 radio_group.radio_items.begin(); 176 radio_group.radio_items.begin();
175 i != radio_group.radio_items.end(); ++i) { 177 i != radio_group.radio_items.end(); ++i) {
176 std::string elided = BuildElidedText(*i); 178 std::string elided = BuildElidedText(*i);
177 GtkWidget* radio = 179 GtkWidget* radio =
178 radio_group_gtk_.empty() ? 180 radio_group_gtk_.empty() ?
179 gtk_radio_button_new_with_label(NULL, elided.c_str()) : 181 gtk_radio_button_new(NULL) :
180 gtk_radio_button_new_with_label_from_widget( 182 gtk_radio_button_new_from_widget(
181 GTK_RADIO_BUTTON(radio_group_gtk_[0]), 183 GTK_RADIO_BUTTON(radio_group_gtk_[0]));
182 elided.c_str()); 184 GtkWidget* label =
185 theme_provider->BuildLabel(elided.c_str(), ui::kGdkBlack);
186 gtk_container_add(GTK_CONTAINER(radio), label);
183 gtk_box_pack_start(GTK_BOX(bubble_content), radio, FALSE, FALSE, 0); 187 gtk_box_pack_start(GTK_BOX(bubble_content), radio, FALSE, FALSE, 0);
184 if (i - radio_group.radio_items.begin() == radio_group.default_item) { 188 if (i - radio_group.radio_items.begin() == radio_group.default_item) {
185 // We must set the default value before we attach the signal handlers 189 // We must set the default value before we attach the signal handlers
186 // or pain occurs. 190 // or pain occurs.
187 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio), TRUE); 191 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio), TRUE);
188 } 192 }
189 if (!content.radio_group_enabled) 193 if (!content.radio_group_enabled)
190 gtk_widget_set_sensitive(radio, FALSE); 194 gtk_widget_set_sensitive(radio, FALSE);
191 radio_group_gtk_.push_back(radio); 195 radio_group_gtk_.push_back(radio);
192 } 196 }
193 for (std::vector<GtkWidget*>::const_iterator i = radio_group_gtk_.begin(); 197 for (std::vector<GtkWidget*>::const_iterator i = radio_group_gtk_.begin();
194 i != radio_group_gtk_.end(); ++i) { 198 i != radio_group_gtk_.end(); ++i) {
195 // We can attach signal handlers now that all defaults are set. 199 // We can attach signal handlers now that all defaults are set.
196 g_signal_connect(*i, "toggled", G_CALLBACK(OnRadioToggledThunk), this); 200 g_signal_connect(*i, "toggled", G_CALLBACK(OnRadioToggledThunk), this);
197 } 201 }
198 202
199 for (std::vector<ContentSettingBubbleModel::DomainList>::const_iterator i = 203 for (std::vector<ContentSettingBubbleModel::DomainList>::const_iterator i =
200 content.domain_lists.begin(); 204 content.domain_lists.begin();
201 i != content.domain_lists.end(); ++i) { 205 i != content.domain_lists.end(); ++i) {
202 // Put each list into its own vbox to allow spacing between lists. 206 // Put each list into its own vbox to allow spacing between lists.
203 GtkWidget* list_content = gtk_vbox_new(FALSE, ui::kControlSpacing); 207 GtkWidget* list_content = gtk_vbox_new(FALSE, ui::kControlSpacing);
204 208
205 GtkWidget* label = gtk_label_new(BuildElidedText(i->title).c_str()); 209 GtkWidget* label = theme_provider->BuildLabel(
210 BuildElidedText(i->title).c_str(), ui::kGdkBlack);
206 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); 211 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
207 GtkWidget* label_box = gtk_hbox_new(FALSE, 0); 212 GtkWidget* label_box = gtk_hbox_new(FALSE, 0);
208 gtk_box_pack_start(GTK_BOX(label_box), label, FALSE, FALSE, 0); 213 gtk_box_pack_start(GTK_BOX(label_box), label, FALSE, FALSE, 0);
209 gtk_box_pack_start(GTK_BOX(list_content), label_box, FALSE, FALSE, 0); 214 gtk_box_pack_start(GTK_BOX(list_content), label_box, FALSE, FALSE, 0);
210 for (std::set<std::string>::const_iterator j = i->hosts.begin(); 215 for (std::set<std::string>::const_iterator j = i->hosts.begin();
211 j != i->hosts.end(); ++j) { 216 j != i->hosts.end(); ++j) {
212 gtk_box_pack_start(GTK_BOX(list_content), 217 gtk_box_pack_start(GTK_BOX(list_content),
213 gtk_util::IndentWidget(gtk_util::CreateBoldLabel(*j)), 218 gtk_util::IndentWidget(gtk_util::CreateBoldLabel(*j)),
214 FALSE, FALSE, 0); 219 FALSE, FALSE, 0);
215 } 220 }
216 gtk_box_pack_start(GTK_BOX(bubble_content), list_content, FALSE, FALSE, 221 gtk_box_pack_start(GTK_BOX(bubble_content), list_content, FALSE, FALSE,
217 ui::kControlSpacing); 222 ui::kControlSpacing);
218 } 223 }
219 224
220 if (!content.custom_link.empty()) { 225 if (!content.custom_link.empty()) {
221 GtkWidget* custom_link_box = gtk_hbox_new(FALSE, 0); 226 GtkWidget* custom_link_box = gtk_hbox_new(FALSE, 0);
222 GtkWidget* custom_link = NULL; 227 GtkWidget* custom_link = NULL;
223 if (content.custom_link_enabled) { 228 if (content.custom_link_enabled) {
224 custom_link = gtk_chrome_link_button_new(content.custom_link.c_str()); 229 custom_link =
230 theme_provider->BuildChromeLinkButton(content.custom_link.c_str());
225 g_signal_connect(custom_link, "clicked", 231 g_signal_connect(custom_link, "clicked",
226 G_CALLBACK(OnCustomLinkClickedThunk), this); 232 G_CALLBACK(OnCustomLinkClickedThunk), this);
227 } else { 233 } else {
228 custom_link = gtk_label_new(content.custom_link.c_str()); 234 custom_link = theme_provider->BuildLabel(content.custom_link.c_str(),
235 ui::kGdkBlack);
229 gtk_misc_set_alignment(GTK_MISC(custom_link), 0, 0.5); 236 gtk_misc_set_alignment(GTK_MISC(custom_link), 0, 0.5);
230 } 237 }
231 DCHECK(custom_link); 238 DCHECK(custom_link);
232 gtk_box_pack_start(GTK_BOX(custom_link_box), custom_link, FALSE, FALSE, 0); 239 gtk_box_pack_start(GTK_BOX(custom_link_box), custom_link, FALSE, FALSE, 0);
233 gtk_box_pack_start(GTK_BOX(bubble_content), custom_link_box, 240 gtk_box_pack_start(GTK_BOX(bubble_content), custom_link_box,
234 FALSE, FALSE, 0); 241 FALSE, FALSE, 0);
235 } 242 }
236 243
237 gtk_box_pack_start(GTK_BOX(bubble_content), gtk_hseparator_new(), 244 gtk_box_pack_start(GTK_BOX(bubble_content), gtk_hseparator_new(),
238 FALSE, FALSE, 0); 245 FALSE, FALSE, 0);
239 246
240 GtkWidget* bottom_box = gtk_hbox_new(FALSE, 0); 247 GtkWidget* bottom_box = gtk_hbox_new(FALSE, 0);
241 248
242 GtkWidget* manage_link = 249 GtkWidget* manage_link =
243 gtk_chrome_link_button_new(content.manage_link.c_str()); 250 theme_provider->BuildChromeLinkButton(content.manage_link.c_str());
244 g_signal_connect(manage_link, "clicked", G_CALLBACK(OnManageLinkClickedThunk), 251 g_signal_connect(manage_link, "clicked", G_CALLBACK(OnManageLinkClickedThunk),
245 this); 252 this);
246 gtk_box_pack_start(GTK_BOX(bottom_box), manage_link, FALSE, FALSE, 0); 253 gtk_box_pack_start(GTK_BOX(bottom_box), manage_link, FALSE, FALSE, 0);
247 254
248 GtkWidget* button = gtk_button_new_with_label( 255 GtkWidget* button = gtk_button_new_with_label(
249 l10n_util::GetStringUTF8(IDS_DONE).c_str()); 256 l10n_util::GetStringUTF8(IDS_DONE).c_str());
250 g_signal_connect(button, "clicked", G_CALLBACK(OnCloseButtonClickedThunk), 257 g_signal_connect(button, "clicked", G_CALLBACK(OnCloseButtonClickedThunk),
251 this); 258 this);
252 gtk_box_pack_end(GTK_BOX(bottom_box), button, FALSE, FALSE, 0); 259 gtk_box_pack_end(GTK_BOX(bottom_box), button, FALSE, FALSE, 0);
253 260
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 317
311 void ContentSettingBubbleGtk::OnCustomLinkClicked(GtkWidget* button) { 318 void ContentSettingBubbleGtk::OnCustomLinkClicked(GtkWidget* button) {
312 content_setting_bubble_model_->OnCustomLinkClicked(); 319 content_setting_bubble_model_->OnCustomLinkClicked();
313 Close(); 320 Close();
314 } 321 }
315 322
316 void ContentSettingBubbleGtk::OnManageLinkClicked(GtkWidget* button) { 323 void ContentSettingBubbleGtk::OnManageLinkClicked(GtkWidget* button) {
317 content_setting_bubble_model_->OnManageLinkClicked(); 324 content_setting_bubble_model_->OnManageLinkClicked();
318 Close(); 325 Close();
319 } 326 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/gtk/gtk_theme_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698