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

Side by Side Diff: chrome/browser/ui/gtk/website_settings/website_settings_popup_gtk.cc

Issue 10834410: (GTK only) Add icons to the conenction tab of the website settings UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 | « chrome/browser/ui/gtk/website_settings/website_settings_popup_gtk.h ('k') | no next file » | 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/website_settings/website_settings_popup_gtk.h" 5 #include "chrome/browser/ui/gtk/website_settings/website_settings_popup_gtk.h"
6 6
7 #include "base/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/certificate_viewer.h" 10 #include "chrome/browser/certificate_viewer.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 int width, 44 int width,
45 GtkThemeService* theme_service) { 45 GtkThemeService* theme_service) {
46 GtkWidget* label = theme_service->BuildLabel(text, ui::kGdkBlack); 46 GtkWidget* label = theme_service->BuildLabel(text, ui::kGdkBlack);
47 if (width > 0) 47 if (width > 0)
48 gtk_util::SetLabelWidth(label, width); 48 gtk_util::SetLabelWidth(label, width);
49 gtk_label_set_selectable(GTK_LABEL(label), TRUE); 49 gtk_label_set_selectable(GTK_LABEL(label), TRUE);
50 gtk_label_set_line_wrap_mode(GTK_LABEL(label), PANGO_WRAP_WORD_CHAR); 50 gtk_label_set_line_wrap_mode(GTK_LABEL(label), PANGO_WRAP_WORD_CHAR);
51 return label; 51 return label;
52 } 52 }
53 53
54 void ClearContainer(GtkWidget* container) {
55 GList* child = gtk_container_get_children(GTK_CONTAINER(container));
56 while (child) {
57 gtk_container_remove(GTK_CONTAINER(container), GTK_WIDGET(child->data));
58 child = child->next;
59 }
60 }
61
62 void SetConnectionSection(GtkWidget* section_box,
63 const gfx::Image& icon,
64 GtkWidget* content_box) {
65 DCHECK(section_box);
66 ClearContainer(section_box);
67 const int kSectionPadding = 10;
68 gtk_container_set_border_width(GTK_CONTAINER(section_box), kSectionPadding);
69
70 GtkWidget* hbox = gtk_hbox_new(FALSE, ui::kControlSpacing);
71
72 GdkPixbuf* pixbuf = icon.ToGdkPixbuf();
73 GtkWidget* image = gtk_image_new_from_pixbuf(pixbuf);
74 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
75 gtk_misc_set_alignment(GTK_MISC(image), 0, 0);
76
77 gtk_box_pack_start(GTK_BOX(hbox), content_box, TRUE, TRUE, 0);
78
79 gtk_box_pack_start(GTK_BOX(section_box), hbox, TRUE, TRUE, 0);
80 gtk_widget_show_all(section_box);
81 }
82
54 class InternalPageInfoPopupGtk : public BubbleDelegateGtk { 83 class InternalPageInfoPopupGtk : public BubbleDelegateGtk {
55 public: 84 public:
56 explicit InternalPageInfoPopupGtk(gfx::NativeWindow parent, 85 explicit InternalPageInfoPopupGtk(gfx::NativeWindow parent,
57 Profile* profile); 86 Profile* profile);
58 virtual ~InternalPageInfoPopupGtk(); 87 virtual ~InternalPageInfoPopupGtk();
59 88
60 private: 89 private:
61 // BubbleDelegateGtk implementation. 90 // BubbleDelegateGtk implementation.
62 virtual void BubbleClosing(BubbleGtk* bubble, bool closed_by_escape) OVERRIDE; 91 virtual void BubbleClosing(BubbleGtk* bubble, bool closed_by_escape) OVERRIDE;
63 92
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 : parent_(parent), 171 : parent_(parent),
143 contents_(NULL), 172 contents_(NULL),
144 theme_service_(GtkThemeService::GetFrom(profile)), 173 theme_service_(GtkThemeService::GetFrom(profile)),
145 profile_(profile), 174 profile_(profile),
146 tab_contents_(tab_contents), 175 tab_contents_(tab_contents),
147 browser_(NULL), 176 browser_(NULL),
148 cert_id_(0), 177 cert_id_(0),
149 header_box_(NULL), 178 header_box_(NULL),
150 cookies_section_contents_(NULL), 179 cookies_section_contents_(NULL),
151 permissions_section_contents_(NULL), 180 permissions_section_contents_(NULL),
152 identity_tab_contents_(NULL), 181 identity_contents_(NULL),
182 connection_contents_(NULL),
153 first_visit_contents_(NULL), 183 first_visit_contents_(NULL),
154 presenter_(NULL) { 184 presenter_(NULL) {
155 BrowserWindowGtk* browser_window = 185 BrowserWindowGtk* browser_window =
156 BrowserWindowGtk::GetBrowserWindowForNativeWindow(parent); 186 BrowserWindowGtk::GetBrowserWindowForNativeWindow(parent);
157 browser_ = browser_window->browser(); 187 browser_ = browser_window->browser();
158 anchor_ = browser_window-> 188 anchor_ = browser_window->
159 GetToolbar()->GetLocationBarView()->location_icon_widget(); 189 GetToolbar()->GetLocationBarView()->location_icon_widget();
160 190
161 InitContents(); 191 InitContents();
162 192
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 gtk_hseparator_new(), 253 gtk_hseparator_new(),
224 FALSE, FALSE, 0); 254 FALSE, FALSE, 0);
225 permissions_section_contents_ = gtk_vbox_new(FALSE, ui::kControlSpacing); 255 permissions_section_contents_ = gtk_vbox_new(FALSE, ui::kControlSpacing);
226 title = l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_TITLE_SITE_PERMISSIONS); 256 title = l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_TITLE_SITE_PERMISSIONS);
227 gtk_box_pack_start(GTK_BOX(permission_tab_contents), 257 gtk_box_pack_start(GTK_BOX(permission_tab_contents),
228 CreateSection(title, 258 CreateSection(title,
229 permissions_section_contents_), 259 permissions_section_contents_),
230 FALSE, FALSE, 0); 260 FALSE, FALSE, 0);
231 261
232 // Create the container for the contents of the identity tab. 262 // Create the container for the contents of the identity tab.
233 GtkWidget* info_tab = gtk_vbox_new(FALSE, ui::kControlSpacing); 263 GtkWidget* connection_tab = gtk_vbox_new(FALSE, ui::kControlSpacing);
234 identity_tab_contents_ = gtk_vbox_new(FALSE, ui::kControlSpacing); 264 identity_contents_ = gtk_vbox_new(FALSE, ui::kControlSpacing);
235 gtk_container_set_border_width(GTK_CONTAINER(identity_tab_contents_), 10); 265 gtk_box_pack_start(GTK_BOX(connection_tab), identity_contents_, FALSE, FALSE,
236 gtk_box_pack_start(GTK_BOX(info_tab), 266 0);
237 identity_tab_contents_, 267 gtk_box_pack_start(GTK_BOX(connection_tab), gtk_hseparator_new(), FALSE,
238 FALSE, FALSE, 0); 268 FALSE, 0);
269 connection_contents_ = gtk_vbox_new(FALSE, ui::kControlSpacing);
270 gtk_box_pack_start(GTK_BOX(connection_tab), connection_contents_, FALSE,
271 FALSE, 0);
272 gtk_box_pack_start(GTK_BOX(connection_tab), gtk_hseparator_new(), FALSE,
273 FALSE, 0);
239 first_visit_contents_ = gtk_vbox_new(FALSE, ui::kControlSpacing); 274 first_visit_contents_ = gtk_vbox_new(FALSE, ui::kControlSpacing);
240 GtkWidget* history_contents = CreateSection( 275 gtk_box_pack_start(GTK_BOX(connection_tab), first_visit_contents_, FALSE,
241 l10n_util::GetStringUTF8(IDS_PAGE_INFO_SITE_INFO_TITLE), 276 FALSE, 0);
242 first_visit_contents_);
243 gtk_container_set_border_width(GTK_CONTAINER(history_contents), 10);
244 gtk_box_pack_start(GTK_BOX(info_tab), gtk_hseparator_new(), FALSE, FALSE, 0);
245 gtk_box_pack_start(GTK_BOX(info_tab), history_contents, FALSE, FALSE, 0);
246 277
247 // Create tab container and add all tabs. 278 // Create tab container and add all tabs.
248 GtkWidget* notebook = gtk_notebook_new(); 279 GtkWidget* notebook = gtk_notebook_new();
249 if (theme_service_->UsingNativeTheme()) 280 if (theme_service_->UsingNativeTheme())
250 gtk_widget_modify_bg(notebook, GTK_STATE_NORMAL, NULL); 281 gtk_widget_modify_bg(notebook, GTK_STATE_NORMAL, NULL);
251 else 282 else
252 gtk_widget_modify_bg(notebook, GTK_STATE_NORMAL, &kBackgroundColor); 283 gtk_widget_modify_bg(notebook, GTK_STATE_NORMAL, &kBackgroundColor);
253 284
254 GtkWidget* label = theme_service_->BuildLabel( 285 GtkWidget* label = theme_service_->BuildLabel(
255 l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_TAB_LABEL_PERMISSIONS), 286 l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_TAB_LABEL_PERMISSIONS),
256 ui::kGdkBlack); 287 ui::kGdkBlack);
257 gtk_widget_show(label); 288 gtk_widget_show(label);
258 gtk_notebook_append_page( 289 gtk_notebook_append_page(
259 GTK_NOTEBOOK(notebook), permission_tab_contents, label); 290 GTK_NOTEBOOK(notebook), permission_tab_contents, label);
260 291
261 label = theme_service_->BuildLabel( 292 label = theme_service_->BuildLabel(
262 l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_TAB_LABEL_CONNECTION), 293 l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_TAB_LABEL_CONNECTION),
263 ui::kGdkBlack); 294 ui::kGdkBlack);
264 gtk_widget_show(label); 295 gtk_widget_show(label);
265 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), info_tab, label); 296 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), connection_tab, label);
266 297
267 gtk_box_pack_start(GTK_BOX(contents_), notebook, FALSE, FALSE, 0); 298 gtk_box_pack_start(GTK_BOX(contents_), notebook, FALSE, FALSE, 0);
268 gtk_widget_show_all(contents_); 299 gtk_widget_show_all(contents_);
269 } 300 }
270 301
271 void WebsiteSettingsPopupGtk::ClearContainer(GtkWidget* container) {
272 GList* child = gtk_container_get_children(GTK_CONTAINER(container));
273 while (child) {
274 gtk_container_remove(GTK_CONTAINER(container), GTK_WIDGET(child->data));
275 child = child->next;
276 }
277 }
278
279 GtkWidget* WebsiteSettingsPopupGtk::CreateSection(std::string section_title, 302 GtkWidget* WebsiteSettingsPopupGtk::CreateSection(std::string section_title,
280 GtkWidget* section_content) { 303 GtkWidget* section_content) {
281 GtkWidget* section_box = gtk_vbox_new(FALSE, ui::kControlSpacing); 304 GtkWidget* section_box = gtk_vbox_new(FALSE, ui::kControlSpacing);
282 305
283 // Add Section title 306 // Add Section title
284 GtkWidget* title_hbox = gtk_hbox_new(FALSE, ui::kControlSpacing); 307 GtkWidget* title_hbox = gtk_hbox_new(FALSE, ui::kControlSpacing);
285 308
286 GtkWidget* label = theme_service_->BuildLabel(section_title, 309 GtkWidget* label = theme_service_->BuildLabel(section_title,
287 ui::kGdkBlack); 310 ui::kGdkBlack);
288 gtk_label_set_selectable(GTK_LABEL(label), TRUE); 311 gtk_label_set_selectable(GTK_LABEL(label), TRUE);
289 PangoAttrList* attributes = pango_attr_list_new(); 312 PangoAttrList* attributes = pango_attr_list_new();
290 pango_attr_list_insert(attributes, 313 pango_attr_list_insert(attributes,
291 pango_attr_weight_new(PANGO_WEIGHT_BOLD)); 314 pango_attr_weight_new(PANGO_WEIGHT_BOLD));
292 gtk_label_set_attributes(GTK_LABEL(label), attributes); 315 gtk_label_set_attributes(GTK_LABEL(label), attributes);
293 pango_attr_list_unref(attributes); 316 pango_attr_list_unref(attributes);
294 gtk_util::SetLabelWidth(label, 400);
295 gtk_box_pack_start(GTK_BOX(section_box), title_hbox, FALSE, FALSE, 0); 317 gtk_box_pack_start(GTK_BOX(section_box), title_hbox, FALSE, FALSE, 0);
296 318
297 gtk_box_pack_start(GTK_BOX(title_hbox), label, FALSE, FALSE, 0); 319 gtk_box_pack_start(GTK_BOX(title_hbox), label, FALSE, FALSE, 0);
298 320
299 // Add section content 321 // Add section content
300 gtk_box_pack_start(GTK_BOX(section_box), section_content, FALSE, FALSE, 0); 322 gtk_box_pack_start(GTK_BOX(section_box), section_content, FALSE, FALSE, 0);
301 return section_box; 323 return section_box;
324 }
302 325
303 }
304 326
305 void WebsiteSettingsPopupGtk::OnPermissionChanged( 327 void WebsiteSettingsPopupGtk::OnPermissionChanged(
306 PermissionSelector* selector) { 328 PermissionSelector* selector) {
307 presenter_->OnSitePermissionChanged(selector->type(), 329 presenter_->OnSitePermissionChanged(selector->type(),
308 selector->setting()); 330 selector->setting());
309 } 331 }
310 332
311 void WebsiteSettingsPopupGtk::OnComboboxShown() { 333 void WebsiteSettingsPopupGtk::OnComboboxShown() {
312 bubble_->HandlePointerAndKeyboardUngrabbedByContent(); 334 bubble_->HandlePointerAndKeyboardUngrabbedByContent();
313 } 335 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 identity_status_text = 416 identity_status_text =
395 l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_IDENTITY_NOT_VERIFIED); 417 l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_IDENTITY_NOT_VERIFIED);
396 break; 418 break;
397 } 419 }
398 GtkWidget* status_label = 420 GtkWidget* status_label =
399 CreateTextLabel(identity_status_text, 400, theme_service_); 421 CreateTextLabel(identity_status_text, 400, theme_service_);
400 gtk_box_pack_start( 422 gtk_box_pack_start(
401 GTK_BOX(header_box_), status_label, FALSE, FALSE, 0); 423 GTK_BOX(header_box_), status_label, FALSE, FALSE, 0);
402 gtk_widget_show_all(header_box_); 424 gtk_widget_show_all(header_box_);
403 425
404 // Create identity tab contents.
405 DCHECK(identity_tab_contents_);
406 ClearContainer(identity_tab_contents_);
407
408 // Create identity section. 426 // Create identity section.
427 GtkWidget* section_content = gtk_vbox_new(FALSE, ui::kControlSpacing);
409 GtkWidget* identity_description = 428 GtkWidget* identity_description =
410 CreateTextLabel(identity_info.identity_status_description, 300, 429 CreateTextLabel(identity_info.identity_status_description, 300,
411 theme_service_); 430 theme_service_);
412 GtkWidget* identity_box = gtk_vbox_new(FALSE, ui::kControlSpacing); 431 gtk_box_pack_start(GTK_BOX(section_content), identity_description, FALSE,
413 gtk_box_pack_start(GTK_BOX(identity_box), identity_description, FALSE, FALSE, 432 FALSE, 0);
414 0);
415 if (identity_info.cert_id) { 433 if (identity_info.cert_id) {
416 cert_id_ = identity_info.cert_id; 434 cert_id_ = identity_info.cert_id;
417 GtkWidget* view_cert_link = theme_service_->BuildChromeLinkButton( 435 GtkWidget* view_cert_link = theme_service_->BuildChromeLinkButton(
418 l10n_util::GetStringUTF8(IDS_PAGEINFO_CERT_INFO_BUTTON)); 436 l10n_util::GetStringUTF8(IDS_PAGEINFO_CERT_INFO_BUTTON));
419 g_signal_connect(view_cert_link, "clicked", 437 g_signal_connect(view_cert_link, "clicked",
420 G_CALLBACK(OnViewCertLinkClickedThunk), this); 438 G_CALLBACK(OnViewCertLinkClickedThunk), this);
421 GtkWidget* link_hbox = gtk_hbox_new(FALSE, 0); 439 GtkWidget* link_hbox = gtk_hbox_new(FALSE, 0);
422 gtk_box_pack_start(GTK_BOX(link_hbox), view_cert_link, 440 gtk_box_pack_start(GTK_BOX(link_hbox), view_cert_link,
423 FALSE, FALSE, 0); 441 FALSE, FALSE, 0);
424 gtk_box_pack_start(GTK_BOX(identity_box), link_hbox, FALSE, FALSE, 0); 442 gtk_box_pack_start(GTK_BOX(section_content), link_hbox, FALSE, FALSE, 0);
425 } 443 }
426 444 SetConnectionSection(
445 identity_contents_,
446 WebsiteSettingsUI::GetIdentityIcon(identity_info.identity_status),
447 section_content);
427 448
428 // Create connection section. 449 // Create connection section.
429 GtkWidget* connection_description = 450 GtkWidget* connection_description =
430 CreateTextLabel(identity_info.connection_status_description, 300, 451 CreateTextLabel(identity_info.connection_status_description, 300,
431 theme_service_); 452 theme_service_);
432 GtkWidget* connection_box = gtk_vbox_new(FALSE, ui::kControlSpacing); 453 section_content = gtk_vbox_new(FALSE, ui::kControlSpacing);
433 gtk_box_pack_start(GTK_BOX(connection_box), connection_description, FALSE, 454 gtk_box_pack_start(GTK_BOX(section_content), connection_description, FALSE,
434 FALSE, 0); 455 FALSE, 0);
435 456 SetConnectionSection(
436 // Add to contents. 457 connection_contents_,
437 gtk_box_pack_start( 458 WebsiteSettingsUI::GetConnectionIcon(identity_info.connection_status),
438 GTK_BOX(identity_tab_contents_), CreateSection( 459 section_content);
439 l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_TITLE_IDENTITY),
440 identity_box),
441 TRUE,
442 FALSE,
443 0);
444 gtk_box_pack_start(GTK_BOX(identity_tab_contents_),
445 gtk_hseparator_new(),
446 FALSE, FALSE, 0);
447 gtk_box_pack_start(
448 GTK_BOX(identity_tab_contents_),
449 CreateSection(
450 l10n_util::GetStringUTF8(
451 IDS_WEBSITE_SETTINGS_TITLE_CONNECTION),
452 connection_box),
453 TRUE,
454 FALSE,
455 0);
456
457 gtk_widget_show_all(identity_tab_contents_);
458 } 460 }
459 461
460 void WebsiteSettingsPopupGtk::SetFirstVisit(const string16& first_visit) { 462 void WebsiteSettingsPopupGtk::SetFirstVisit(const string16& first_visit) {
461 DCHECK(first_visit_contents_); 463 GtkWidget* titel = theme_service_->BuildLabel(
462 ClearContainer(first_visit_contents_); 464 l10n_util::GetStringUTF8(IDS_PAGE_INFO_SITE_INFO_TITLE),
465 ui::kGdkBlack);
466 gtk_label_set_selectable(GTK_LABEL(titel), TRUE);
467 PangoAttrList* attributes = pango_attr_list_new();
468 pango_attr_list_insert(attributes,
469 pango_attr_weight_new(PANGO_WEIGHT_BOLD));
470 gtk_label_set_attributes(GTK_LABEL(titel), attributes);
471 pango_attr_list_unref(attributes);
472 gtk_misc_set_alignment(GTK_MISC(titel), 0, 0);
463 473
464 GtkWidget* first_visit_label = CreateTextLabel(UTF16ToUTF8(first_visit), 400, 474 GtkWidget* first_visit_label = CreateTextLabel(UTF16ToUTF8(first_visit), 400,
465 theme_service_); 475 theme_service_);
476 GtkWidget* section_contents = gtk_vbox_new(FALSE, ui::kControlSpacing);
477 gtk_box_pack_start(GTK_BOX(section_contents), titel, FALSE, FALSE, 0);
466 gtk_box_pack_start( 478 gtk_box_pack_start(
467 GTK_BOX(first_visit_contents_), first_visit_label, FALSE, FALSE, 0); 479 GTK_BOX(section_contents), first_visit_label, FALSE, FALSE, 0);
468 gtk_widget_show_all(first_visit_contents_); 480
481 SetConnectionSection(
482 first_visit_contents_,
483 WebsiteSettingsUI::GetFirstVisitIcon(first_visit),
484 section_contents);
469 } 485 }
470 486
471 void WebsiteSettingsPopupGtk::SetPermissionInfo( 487 void WebsiteSettingsPopupGtk::SetPermissionInfo(
472 const PermissionInfoList& permission_info_list) { 488 const PermissionInfoList& permission_info_list) {
473 DCHECK(permissions_section_contents_); 489 DCHECK(permissions_section_contents_);
474 ClearContainer(permissions_section_contents_); 490 ClearContainer(permissions_section_contents_);
475 // Clear the map since the UI is reconstructed. 491 // Clear the map since the UI is reconstructed.
476 selectors_.clear(); 492 selectors_.clear();
477 493
478 for (PermissionInfoList::const_iterator permission = 494 for (PermissionInfoList::const_iterator permission =
(...skipping 21 matching lines...) Expand all
500 tab_contents_); 516 tab_contents_);
501 bubble_->Close(); 517 bubble_->Close();
502 } 518 }
503 519
504 void WebsiteSettingsPopupGtk::OnViewCertLinkClicked(GtkWidget* widget) { 520 void WebsiteSettingsPopupGtk::OnViewCertLinkClicked(GtkWidget* widget) {
505 DCHECK_NE(cert_id_, 0); 521 DCHECK_NE(cert_id_, 0);
506 ShowCertificateViewerByID( 522 ShowCertificateViewerByID(
507 tab_contents_->web_contents(), GTK_WINDOW(parent_), cert_id_); 523 tab_contents_->web_contents(), GTK_WINDOW(parent_), cert_id_);
508 bubble_->Close(); 524 bubble_->Close();
509 } 525 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/website_settings/website_settings_popup_gtk.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698