Chromium Code Reviews| Index: chrome/browser/ui/gtk/website_settings/website_settings_popup_gtk.cc |
| diff --git a/chrome/browser/ui/gtk/website_settings/website_settings_popup_gtk.cc b/chrome/browser/ui/gtk/website_settings/website_settings_popup_gtk.cc |
| index e2650abf1e1909ca3ac0940fb836ba4c0775cbf7..ac4c62ed610fa21d31abee840c7cd60d87b074af 100644 |
| --- a/chrome/browser/ui/gtk/website_settings/website_settings_popup_gtk.cc |
| +++ b/chrome/browser/ui/gtk/website_settings/website_settings_popup_gtk.cc |
| @@ -17,12 +17,15 @@ |
| #include "chrome/browser/ui/gtk/gtk_util.h" |
| #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
| #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" |
| +#include "chrome/browser/ui/gtk/nine_box.h" |
| #include "chrome/browser/ui/gtk/website_settings/permission_selector.h" |
| #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| #include "chrome/browser/ui/website_settings/website_settings.h" |
| #include "chrome/browser/ui/website_settings/website_settings_utils.h" |
| +#include "chrome/common/chrome_notification_types.h" |
| #include "chrome/common/url_constants.h" |
| #include "content/public/browser/cert_store.h" |
| +#include "content/public/browser/notification_service.h" |
| #include "content/public/browser/user_metrics.h" |
| #include "googleurl/src/gurl.h" |
| #include "grit/chromium_strings.h" |
| @@ -33,6 +36,8 @@ |
| #include "ui/base/gtk/gtk_hig_constants.h" |
| #include "ui/base/l10n/l10n_util.h" |
| #include "ui/base/resource/resource_bundle.h" |
| +#include "ui/gfx/image/cairo_cached_surface.h" |
| +#include "ui/gfx/image/image.h" |
| using content::OpenURLParams; |
| @@ -41,26 +46,29 @@ namespace { |
| // The width of the popup. |
| const int kPopupWidth = 400; |
| +// Spacing between consecutive tabs in the tabstrip. |
| +const int kInterTabSpacing = 2; |
| + |
| +// Spacing between start of tab and tab text. |
| +const int kTabTextHorizontalMargin = 12; |
| + |
| +// The vertical lift of the tab's text off the bottom of the tab. |
| +const int kTabTextBaseline = 4; |
| + |
| // The max width of the text labels on the connection tab. |
| const int kConnectionTabTextWidth = 300; |
| -// The padding used for sections on the connection tab. |
| -const int kConnectionTabSectionPadding = 10; |
| - |
| -// The background color of the tabs if a theme other than the native GTK theme |
| -// is selected. |
| -const GdkColor kBackgroundColor = GDK_COLOR_RGB(0xff, 0xff, 0xff); |
| // The text color of the site identity status label for websites with a |
| // verified identity. |
| const GdkColor kGdkGreen = GDK_COLOR_RGB(0x29, 0x8a, 0x27); |
| GtkWidget* CreateTextLabel(const std::string& text, |
| int width, |
| - GtkThemeService* theme_service) { |
| - GtkWidget* label = theme_service->BuildLabel(text, ui::kGdkBlack); |
| + GtkThemeService* theme_service, |
| + const GdkColor& color) { |
| + GtkWidget* label = theme_service->BuildLabel(text, color); |
| if (width > 0) |
| gtk_util::SetLabelWidth(label, width); |
| - gtk_label_set_selectable(GTK_LABEL(label), TRUE); |
| gtk_label_set_line_wrap_mode(GTK_LABEL(label), PANGO_WRAP_WORD_CHAR); |
| return label; |
| } |
| @@ -79,7 +87,7 @@ void SetConnectionSection(GtkWidget* section_box, |
| DCHECK(section_box); |
| ClearContainer(section_box); |
| gtk_container_set_border_width(GTK_CONTAINER(section_box), |
| - kConnectionTabSectionPadding); |
| + ui::kContentAreaBorder); |
| GtkWidget* hbox = gtk_hbox_new(FALSE, ui::kControlSpacing); |
| @@ -103,7 +111,6 @@ GtkWidget* CreatePermissionTabSection(std::string section_title, |
| GtkWidget* title_hbox = gtk_hbox_new(FALSE, ui::kControlSpacing); |
| GtkWidget* label = theme_service->BuildLabel(section_title, ui::kGdkBlack); |
| - gtk_label_set_selectable(GTK_LABEL(label), TRUE); |
| PangoAttrList* attributes = pango_attr_list_new(); |
| pango_attr_list_insert(attributes, |
| pango_attr_weight_new(PANGO_WEIGHT_BOLD)); |
| @@ -137,7 +144,7 @@ class InternalPageInfoPopupGtk : public BubbleDelegateGtk { |
| InternalPageInfoPopupGtk::InternalPageInfoPopupGtk( |
| gfx::NativeWindow parent, Profile* profile) { |
| - GtkWidget* contents = gtk_hbox_new(FALSE, ui::kContentAreaSpacing); |
| + GtkWidget* contents = gtk_hbox_new(FALSE, ui::kLabelSpacing); |
| gtk_container_set_border_width(GTK_CONTAINER(contents), |
| ui::kContentAreaBorder); |
| // Add the popup icon. |
| @@ -151,7 +158,6 @@ InternalPageInfoPopupGtk::InternalPageInfoPopupGtk( |
| GtkThemeService* theme_service = GtkThemeService::GetFrom(profile); |
| GtkWidget* label = theme_service->BuildLabel( |
| l10n_util::GetStringUTF8(IDS_PAGE_INFO_INTERNAL_PAGE), ui::kGdkBlack); |
| - gtk_label_set_selectable(GTK_LABEL(label), FALSE); |
| PangoAttrList* attributes = pango_attr_list_new(); |
| pango_attr_list_insert(attributes, |
| pango_attr_weight_new(PANGO_WEIGHT_BOLD)); |
| @@ -228,6 +234,9 @@ WebsiteSettingsPopupGtk::WebsiteSettingsPopupGtk( |
| anchor_ = browser_window-> |
| GetToolbar()->GetLocationBarView()->location_icon_widget(); |
| + registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
| + content::Source<ThemeService>(theme_service_)); |
| + |
| InitContents(); |
| BubbleGtk::ArrowLocationGtk arrow_location = base::i18n::IsRTL() ? |
| @@ -268,9 +277,7 @@ void WebsiteSettingsPopupGtk::BubbleClosing(BubbleGtk* bubble, |
| void WebsiteSettingsPopupGtk::InitContents() { |
| if (!contents_) { |
| - contents_ = gtk_vbox_new(FALSE, ui::kContentAreaSpacing); |
| - gtk_container_set_border_width(GTK_CONTAINER(contents_), |
| - ui::kContentAreaBorder); |
| + contents_ = gtk_vbox_new(FALSE, 0); |
| } else { |
| gtk_util::RemoveAllChildren(contents_); |
| } |
| @@ -278,10 +285,14 @@ void WebsiteSettingsPopupGtk::InitContents() { |
| // Create popup header. |
| header_box_ = gtk_vbox_new(FALSE, ui::kControlSpacing); |
| gtk_box_pack_start(GTK_BOX(contents_), header_box_, FALSE, FALSE, 0); |
| + gtk_container_set_border_width(GTK_CONTAINER(header_box_), |
| + ui::kContentAreaBorder); |
| // Create the container for the contents of the permissions tab. |
| - GtkWidget* permission_tab_contents = gtk_vbox_new(FALSE, ui::kControlSpacing); |
| - gtk_container_set_border_width(GTK_CONTAINER(permission_tab_contents), 10); |
| + GtkWidget* permission_tab_contents = |
| + gtk_vbox_new(FALSE, ui::kContentAreaSpacing); |
| + gtk_container_set_border_width(GTK_CONTAINER(permission_tab_contents), |
| + ui::kContentAreaBorder); |
| cookies_section_contents_ = gtk_vbox_new(FALSE, ui::kControlSpacing); |
| std::string title = l10n_util::GetStringUTF8( |
| IDS_WEBSITE_SETTINGS_TITLE_SITE_DATA); |
| @@ -290,9 +301,6 @@ void WebsiteSettingsPopupGtk::InitContents() { |
| cookies_section_contents_, |
| theme_service_), |
| FALSE, FALSE, 0); |
| - gtk_box_pack_start(GTK_BOX(permission_tab_contents), |
| - gtk_hseparator_new(), |
| - FALSE, FALSE, 0); |
| permissions_section_contents_ = gtk_vbox_new(FALSE, ui::kControlSpacing); |
| title = l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_TITLE_SITE_PERMISSIONS); |
| gtk_box_pack_start(GTK_BOX(permission_tab_contents), |
| @@ -301,19 +309,19 @@ void WebsiteSettingsPopupGtk::InitContents() { |
| theme_service_), |
| FALSE, FALSE, 0); |
| - // Create the container for the contents of the identity tab. |
| - GtkWidget* connection_tab = gtk_vbox_new(FALSE, ui::kControlSpacing); |
| - identity_contents_ = gtk_vbox_new(FALSE, ui::kControlSpacing); |
| + // Create the container for the contents of the connection tab. |
| + GtkWidget* connection_tab = gtk_vbox_new(FALSE, 0); |
| + identity_contents_ = gtk_vbox_new(FALSE, 0); |
| gtk_box_pack_start(GTK_BOX(connection_tab), identity_contents_, FALSE, FALSE, |
| 0); |
| gtk_box_pack_start(GTK_BOX(connection_tab), gtk_hseparator_new(), FALSE, |
| FALSE, 0); |
| - connection_contents_ = gtk_vbox_new(FALSE, ui::kControlSpacing); |
| + connection_contents_ = gtk_vbox_new(FALSE, 0); |
| gtk_box_pack_start(GTK_BOX(connection_tab), connection_contents_, FALSE, |
| FALSE, 0); |
| gtk_box_pack_start(GTK_BOX(connection_tab), gtk_hseparator_new(), FALSE, |
| FALSE, 0); |
| - first_visit_contents_ = gtk_vbox_new(FALSE, ui::kControlSpacing); |
| + first_visit_contents_ = gtk_vbox_new(FALSE, 0); |
| gtk_box_pack_start(GTK_BOX(connection_tab), first_visit_contents_, FALSE, |
| FALSE, 0); |
| gtk_box_pack_start(GTK_BOX(connection_tab), gtk_hseparator_new(), FALSE, |
| @@ -323,39 +331,90 @@ void WebsiteSettingsPopupGtk::InitContents() { |
| l10n_util::GetStringUTF8(IDS_PAGE_INFO_HELP_CENTER_LINK)); |
| GtkWidget* help_link_hbox = gtk_hbox_new(FALSE, 0); |
| gtk_container_set_border_width(GTK_CONTAINER(help_link_hbox), |
| - kConnectionTabSectionPadding); |
| + ui::kContentAreaBorder); |
| gtk_box_pack_start(GTK_BOX(help_link_hbox), help_link, FALSE, FALSE, 0); |
| gtk_box_pack_start(GTK_BOX(connection_tab), help_link_hbox, FALSE, FALSE, 0); |
| g_signal_connect(help_link, "clicked", |
| G_CALLBACK(OnHelpLinkClickedThunk), this); |
| + // Create tabstrip (used only for Chrome-theme mode). |
| + GtkWidget* tabstrip = gtk_hbox_new(FALSE, kInterTabSpacing); |
| + tabstrip_alignment_ = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); |
| + gtk_alignment_set_padding(GTK_ALIGNMENT(tabstrip_alignment_), 0, 0, |
| + ui::kContentAreaBorder, ui::kContentAreaBorder); |
| + int tab_height = ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed( |
| + IDR_WEBSITE_SETTINGS_TAB_LEFT2).ToImageSkia()->height(); |
| + gtk_widget_set_size_request(tabstrip_alignment_, -1, tab_height); |
| + g_signal_connect(tabstrip_alignment_, "expose-event", |
| + G_CALLBACK(&OnTabstripExposeThunk), this); |
| + gtk_container_add(GTK_CONTAINER(tabstrip_alignment_), tabstrip); |
| + gtk_box_pack_start(GTK_BOX(contents_), tabstrip_alignment_, FALSE, FALSE, 0); |
| + |
| + gtk_box_pack_start(GTK_BOX(tabstrip), |
| + BuildTab(IDS_WEBSITE_SETTINGS_TAB_LABEL_PERMISSIONS), |
| + FALSE, FALSE, 0); |
| + gtk_box_pack_start(GTK_BOX(tabstrip), |
| + BuildTab(IDS_WEBSITE_SETTINGS_TAB_LABEL_CONNECTION), |
| + FALSE, FALSE, 0); |
| + |
| // Create tab container and add all tabs. |
| notebook_ = gtk_notebook_new(); |
| - if (theme_service_->UsingNativeTheme()) |
| - gtk_widget_modify_bg(notebook_, GTK_STATE_NORMAL, NULL); |
| - else |
| - gtk_widget_modify_bg(notebook_, GTK_STATE_NORMAL, &kBackgroundColor); |
| + gtk_notebook_set_tab_hborder(GTK_NOTEBOOK(notebook_), 0); |
| - GtkWidget* label = theme_service_->BuildLabel( |
| - l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_TAB_LABEL_PERMISSIONS), |
| - ui::kGdkBlack); |
| - gtk_widget_show(label); |
| + GtkWidget* label = gtk_label_new(l10n_util::GetStringUTF8( |
| + IDS_WEBSITE_SETTINGS_TAB_LABEL_PERMISSIONS).c_str()); |
| + gtk_misc_set_padding(GTK_MISC(label), kTabTextHorizontalMargin, 0); |
| gtk_notebook_insert_page(GTK_NOTEBOOK(notebook_), permission_tab_contents, |
| label, TAB_ID_PERMISSIONS); |
| - label = theme_service_->BuildLabel( |
| - l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_TAB_LABEL_CONNECTION), |
| - ui::kGdkBlack); |
| - gtk_widget_show(label); |
| + label = gtk_label_new(l10n_util::GetStringUTF8( |
| + IDS_WEBSITE_SETTINGS_TAB_LABEL_CONNECTION).c_str()); |
| + gtk_misc_set_padding(GTK_MISC(label), kTabTextHorizontalMargin, 0); |
| gtk_notebook_insert_page(GTK_NOTEBOOK(notebook_), connection_tab, label, |
| TAB_ID_CONNECTION); |
| DCHECK_EQ(gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook_)), NUM_TAB_IDS); |
| gtk_box_pack_start(GTK_BOX(contents_), notebook_, FALSE, FALSE, 0); |
| + |
| + theme_service_->InitThemesFor(this); |
| gtk_widget_show_all(contents_); |
| } |
| +GtkWidget* WebsiteSettingsPopupGtk::BuildTab(int ids) { |
| + GtkWidget* tab = gtk_event_box_new(); |
| + gtk_event_box_set_visible_window(GTK_EVENT_BOX(tab), FALSE); |
| + GtkWidget* label = gtk_label_new(l10n_util::GetStringUTF8(ids).c_str()); |
| + gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &ui::kGdkBlack); |
| + gtk_misc_set_padding(GTK_MISC(label), |
| + kTabTextHorizontalMargin, kTabTextBaseline); |
| + gtk_misc_set_alignment(GTK_MISC(label), 0.5, 1.0); |
| + gtk_container_add(GTK_CONTAINER(tab), label); |
| + g_signal_connect(tab, "button-press-event", |
| + G_CALLBACK(&OnTabButtonPressThunk), this); |
| + g_signal_connect(tab, "expose-event", |
| + G_CALLBACK(&OnTabExposeThunk), this); |
| + return tab; |
| +} |
| + |
| +void WebsiteSettingsPopupGtk::Observe( |
| + int type, |
| + const content::NotificationSource& source, |
| + const content::NotificationDetails& details) { |
| + DCHECK_EQ(chrome::NOTIFICATION_BROWSER_THEME_CHANGED, type); |
| + |
| + if (theme_service_->UsingNativeTheme()) { |
| + gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook_), TRUE); |
| + gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook_), TRUE); |
| + gtk_widget_set_no_show_all(tabstrip_alignment_, TRUE); |
| + } else { |
| + gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook_), FALSE); |
| + gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook_), FALSE); |
| + gtk_widget_set_no_show_all(tabstrip_alignment_, FALSE); |
| + gtk_widget_show_all(tabstrip_alignment_); |
| + } |
| +} |
| + |
| void WebsiteSettingsPopupGtk::OnPermissionChanged( |
| PermissionSelector* selector) { |
| presenter_->OnSitePermissionChanged(selector->GetType(), |
| @@ -393,7 +452,6 @@ void WebsiteSettingsPopupGtk::SetCookieInfo( |
| base::IntToString16(it->blocked)); |
| GtkWidget* info = theme_service_->BuildLabel(info_str, ui::kGdkBlack); |
| - gtk_label_set_selectable(GTK_LABEL(info), TRUE); |
| const int kPadding = 4; |
| gtk_box_pack_start(GTK_BOX(cookies_info), info, FALSE, FALSE, kPadding); |
| @@ -435,22 +493,16 @@ void WebsiteSettingsPopupGtk::SetIdentityInfo( |
| gtk_label_set_attributes(GTK_LABEL(identity_label), attributes); |
| pango_attr_list_unref(attributes); |
| gtk_box_pack_start(GTK_BOX(hbox), identity_label, FALSE, FALSE, 0); |
| - GtkWidget* close_button = gtk_button_new(); |
| - gtk_button_set_relief(GTK_BUTTON(close_button), GTK_RELIEF_NONE); |
| - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| - GdkPixbuf* pixbuf = rb.GetNativeImageNamed(IDR_CLOSE_BAR_H).ToGdkPixbuf(); |
| - GtkWidget* image = gtk_image_new_from_pixbuf(pixbuf); |
| - gtk_button_set_image(GTK_BUTTON(close_button), image); |
| - g_signal_connect(close_button, "clicked", |
| + close_button_.reset(CustomDrawButton::CloseButton(theme_service_)); |
| + g_signal_connect(close_button_->widget(), "clicked", |
| G_CALLBACK(OnCloseButtonClickedThunk), this); |
| - gtk_box_pack_start(GTK_BOX(hbox), close_button, FALSE, FALSE, 0); |
| - int label_width = kPopupWidth - gdk_pixbuf_get_width(pixbuf); |
| + gtk_box_pack_start(GTK_BOX(hbox), close_button_->widget(), FALSE, FALSE, 0); |
| + int label_width = kPopupWidth - close_button_->SurfaceWidth(); |
| gtk_util::SetLabelWidth(identity_label, label_width); |
| gtk_box_pack_start(GTK_BOX(header_box_), hbox, FALSE, FALSE, 0); |
| std::string identity_status_text; |
| - const GdkColor* color = |
| - theme_service_->UsingNativeTheme() ? NULL : &ui::kGdkBlack; |
| + const GdkColor* color = &ui::kGdkBlack; |
| switch (identity_info.identity_status) { |
| case WebsiteSettings::SITE_IDENTITY_STATUS_CERT: |
| @@ -458,17 +510,15 @@ void WebsiteSettingsPopupGtk::SetIdentityInfo( |
| case WebsiteSettings::SITE_IDENTITY_STATUS_EV_CERT: |
| identity_status_text = |
| l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_IDENTITY_VERIFIED); |
| - if (!theme_service_->UsingNativeTheme()) |
| - color = &kGdkGreen; |
| + color = &kGdkGreen; |
| break; |
| default: |
| identity_status_text = |
| l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_IDENTITY_NOT_VERIFIED); |
| break; |
| } |
| - GtkWidget* status_label = |
| - CreateTextLabel(identity_status_text, kPopupWidth, theme_service_); |
| - gtk_widget_modify_fg(status_label, GTK_STATE_NORMAL, color); |
| + GtkWidget* status_label = CreateTextLabel( |
| + identity_status_text, kPopupWidth, theme_service_, *color); |
| gtk_box_pack_start( |
| GTK_BOX(header_box_), status_label, FALSE, FALSE, 0); |
| gtk_widget_show_all(header_box_); |
| @@ -477,7 +527,7 @@ void WebsiteSettingsPopupGtk::SetIdentityInfo( |
| GtkWidget* section_content = gtk_vbox_new(FALSE, ui::kControlSpacing); |
| GtkWidget* identity_description = |
| CreateTextLabel(identity_info.identity_status_description, |
| - kConnectionTabTextWidth, theme_service_); |
| + kConnectionTabTextWidth, theme_service_, ui::kGdkBlack); |
| gtk_box_pack_start(GTK_BOX(section_content), identity_description, FALSE, |
| FALSE, 0); |
| if (identity_info.cert_id) { |
| @@ -499,7 +549,7 @@ void WebsiteSettingsPopupGtk::SetIdentityInfo( |
| // Create connection section. |
| GtkWidget* connection_description = |
| CreateTextLabel(identity_info.connection_status_description, |
| - kConnectionTabTextWidth, theme_service_); |
| + kConnectionTabTextWidth, theme_service_, ui::kGdkBlack); |
| section_content = gtk_vbox_new(FALSE, ui::kControlSpacing); |
| gtk_box_pack_start(GTK_BOX(section_content), connection_description, FALSE, |
| FALSE, 0); |
| @@ -510,22 +560,22 @@ void WebsiteSettingsPopupGtk::SetIdentityInfo( |
| } |
| void WebsiteSettingsPopupGtk::SetFirstVisit(const string16& first_visit) { |
| - GtkWidget* titel = theme_service_->BuildLabel( |
| + GtkWidget* title = theme_service_->BuildLabel( |
| l10n_util::GetStringUTF8(IDS_PAGE_INFO_SITE_INFO_TITLE), |
| ui::kGdkBlack); |
| - gtk_label_set_selectable(GTK_LABEL(titel), TRUE); |
| PangoAttrList* attributes = pango_attr_list_new(); |
| pango_attr_list_insert(attributes, |
| pango_attr_weight_new(PANGO_WEIGHT_BOLD)); |
| - gtk_label_set_attributes(GTK_LABEL(titel), attributes); |
| + gtk_label_set_attributes(GTK_LABEL(title), attributes); |
| pango_attr_list_unref(attributes); |
| - gtk_misc_set_alignment(GTK_MISC(titel), 0, 0); |
| + gtk_misc_set_alignment(GTK_MISC(title), 0, 0); |
| GtkWidget* first_visit_label = CreateTextLabel(UTF16ToUTF8(first_visit), |
| kConnectionTabTextWidth, |
| - theme_service_); |
| + theme_service_, |
| + ui::kGdkBlack); |
| GtkWidget* section_contents = gtk_vbox_new(FALSE, ui::kControlSpacing); |
| - gtk_box_pack_start(GTK_BOX(section_contents), titel, FALSE, FALSE, 0); |
| + gtk_box_pack_start(GTK_BOX(section_contents), title, FALSE, FALSE, 0); |
| gtk_box_pack_start( |
| GTK_BOX(section_contents), first_visit_label, FALSE, FALSE, 0); |
| @@ -569,6 +619,107 @@ void WebsiteSettingsPopupGtk::SetSelectedTab(TabId tab_id) { |
| static_cast<gint>(tab_id)); |
| } |
| +int WebsiteSettingsPopupGtk::TabstripButtonToTabIndex(GtkWidget* button) { |
| + GList* tabs = gtk_container_get_children(GTK_CONTAINER(button->parent)); |
| + int i = 0; |
| + for (GList* it = tabs; it; it = g_list_next(it), ++i) { |
| + if (it->data == button) |
| + break; |
| + } |
| + g_list_free(tabs); |
| + |
| + return i; |
| +} |
| + |
| +gboolean WebsiteSettingsPopupGtk::OnTabButtonPress( |
| + GtkWidget* widget, GdkEvent* event) { |
| + gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook_), |
| + TabstripButtonToTabIndex(widget)); |
| + gtk_widget_queue_draw(tabstrip_alignment_); |
| + return FALSE; |
| +} |
| + |
| +gboolean WebsiteSettingsPopupGtk::OnTabExpose( |
| + GtkWidget* widget, GdkEventExpose* event) { |
| + if (gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook_)) != |
| + TabstripButtonToTabIndex(widget)) { |
| + return FALSE; |
| + } |
| + |
| + NineBox nine(IDR_WEBSITE_SETTINGS_TAB_LEFT2, |
| + IDR_WEBSITE_SETTINGS_TAB_CENTER2, |
| + IDR_WEBSITE_SETTINGS_TAB_RIGHT2, |
| + 0, 0, 0, 0, 0, 0); |
| + nine.RenderToWidget(widget); |
| + gtk_container_propagate_expose(GTK_CONTAINER(widget), |
| + gtk_bin_get_child(GTK_BIN(widget)), |
| + event); |
| + |
| + return TRUE; |
| +} |
| + |
| +gboolean WebsiteSettingsPopupGtk::OnTabstripExpose( |
| + GtkWidget* widget, GdkEventExpose* event) { |
| + int tab_idx = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook_)); |
| + GtkWidget* tabstrip = gtk_bin_get_child(GTK_BIN(tabstrip_alignment_)); |
| + GList* tabs = gtk_container_get_children(GTK_CONTAINER(tabstrip)); |
| + GtkWidget* selected_tab = GTK_WIDGET(g_list_nth_data(tabs, tab_idx)); |
| + g_list_free(tabs); |
| + GtkAllocation tab_bounds; |
| + gtk_widget_get_allocation(selected_tab, &tab_bounds); |
| + |
| + cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(gtk_widget_get_window(widget))); |
| + GtkAllocation allocation; |
| + gtk_widget_get_allocation(widget, &allocation); |
| + ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| + |
| + // Draw the shadows that abut the selected tab. |
|
markusheintz_
2012/09/19 16:44:44
nit: typo abut
|
| + gfx::CairoCachedSurface* left_tab_shadow = |
| + rb.GetNativeImageNamed(IDR_WEBSITE_SETTINGS_TABSTRIP_LEFT).ToCairo(); |
| + int tab_shadow_width = left_tab_shadow->Width(); |
| + left_tab_shadow->SetSource(cr, widget, |
| + tab_bounds.x - tab_shadow_width, allocation.y); |
| + cairo_paint(cr); |
| + |
| + gfx::CairoCachedSurface* right_tab_shadow = |
| + rb.GetNativeImageNamed(IDR_WEBSITE_SETTINGS_TABSTRIP_RIGHT).ToCairo(); |
| + right_tab_shadow->SetSource(cr, widget, |
| + tab_bounds.x + tab_bounds.width, allocation.y); |
| + cairo_paint(cr); |
| + |
| + // Draw the shadow for the inactive part of the tabstrip. |
| + gfx::CairoCachedSurface* tiling_shadow = |
| + rb.GetNativeImageNamed(IDR_WEBSITE_SETTINGS_TABSTRIP_CENTER).ToCairo(); |
| + |
| + tiling_shadow->SetSource(cr, widget, allocation.x, allocation.y); |
| + cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT); |
| + |
| + GdkRectangle left_tiling_area = |
| + { allocation.x, allocation.y, |
| + tab_bounds.x - tab_shadow_width, allocation.height }; |
| + GdkRectangle invalid_left_tiling_area; |
| + if (gdk_rectangle_intersect(&left_tiling_area, &event->area, |
| + &invalid_left_tiling_area)) { |
| + gdk_cairo_rectangle(cr, &invalid_left_tiling_area); |
| + cairo_fill(cr); |
| + } |
| + |
| + GdkRectangle right_tiling_area = |
| + { tab_bounds.x + tab_bounds.width + tab_shadow_width, |
| + allocation.y, |
| + allocation.width, |
| + allocation.height }; |
| + GdkRectangle invalid_right_tiling_area; |
| + if (gdk_rectangle_intersect(&right_tiling_area, &event->area, |
| + &invalid_right_tiling_area)) { |
| + gdk_cairo_rectangle(cr, &invalid_right_tiling_area); |
| + cairo_fill(cr); |
| + } |
| + |
| + cairo_destroy(cr); |
| + return FALSE; |
| +} |
| + |
| void WebsiteSettingsPopupGtk::OnCookiesLinkClicked(GtkWidget* widget) { |
| // Count how often the Collected Cookies dialog is opened. |
| content::RecordAction( |