| OLD | NEW |
| 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/location_bar_view_gtk.h" | 5 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 const int kFirstRunBubbleLeftSpacing = 4; | 115 const int kFirstRunBubbleLeftSpacing = 4; |
| 116 | 116 |
| 117 // The padding around the top, bottom, and sides of the location bar hbox. | 117 // The padding around the top, bottom, and sides of the location bar hbox. |
| 118 // We don't want to edit control's text to be right against the edge, | 118 // We don't want to edit control's text to be right against the edge, |
| 119 // as well the tab to search box and other widgets need to have the padding on | 119 // as well the tab to search box and other widgets need to have the padding on |
| 120 // top and bottom to avoid drawing larger than the location bar space. | 120 // top and bottom to avoid drawing larger than the location bar space. |
| 121 const int kHboxBorder = 2; | 121 const int kHboxBorder = 2; |
| 122 | 122 |
| 123 // Padding between the elements in the bar. | 123 // Padding between the elements in the bar. |
| 124 const int kInnerPadding = 2; | 124 const int kInnerPadding = 2; |
| 125 | 125 const int kScriptBadgeInnerPadding = 9; |
| 126 // Padding between the right of the star and the edge of the URL entry. | |
| 127 const int kStarRightPadding = 2; | |
| 128 | 126 |
| 129 // Colors used to draw the EV certificate rounded bubble. | 127 // Colors used to draw the EV certificate rounded bubble. |
| 130 const GdkColor kEvSecureTextColor = GDK_COLOR_RGB(0x07, 0x95, 0x00); | 128 const GdkColor kEvSecureTextColor = GDK_COLOR_RGB(0x07, 0x95, 0x00); |
| 131 const GdkColor kEvSecureBackgroundColor = GDK_COLOR_RGB(0xef, 0xfc, 0xef); | 129 const GdkColor kEvSecureBackgroundColor = GDK_COLOR_RGB(0xef, 0xfc, 0xef); |
| 132 const GdkColor kEvSecureBorderColor = GDK_COLOR_RGB(0x90, 0xc3, 0x90); | 130 const GdkColor kEvSecureBorderColor = GDK_COLOR_RGB(0x90, 0xc3, 0x90); |
| 133 | 131 |
| 134 // Colors used to draw the Tab to Search rounded bubble. | 132 // Colors used to draw the Tab to Search rounded bubble. |
| 135 const GdkColor kKeywordBackgroundColor = GDK_COLOR_RGB(0xf0, 0xf4, 0xfa); | 133 const GdkColor kKeywordBackgroundColor = GDK_COLOR_RGB(0xf0, 0xf4, 0xfa); |
| 136 const GdkColor kKeywordBorderColor = GDK_COLOR_RGB(0xcb, 0xde, 0xf7); | 134 const GdkColor kKeywordBorderColor = GDK_COLOR_RGB(0xcb, 0xde, 0xf7); |
| 137 | 135 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 157 const GdkColor kContentSettingBorderColor = GDK_COLOR_RGB(0xe9, 0xb9, 0x66); | 155 const GdkColor kContentSettingBorderColor = GDK_COLOR_RGB(0xe9, 0xb9, 0x66); |
| 158 // Colors for the background gradient. | 156 // Colors for the background gradient. |
| 159 const GdkColor kContentSettingTopColor = GDK_COLOR_RGB(0xff, 0xf8, 0xd4); | 157 const GdkColor kContentSettingTopColor = GDK_COLOR_RGB(0xff, 0xf8, 0xd4); |
| 160 const GdkColor kContentSettingBottomColor = GDK_COLOR_RGB(0xff, 0xe6, 0xaf); | 158 const GdkColor kContentSettingBottomColor = GDK_COLOR_RGB(0xff, 0xe6, 0xaf); |
| 161 | 159 |
| 162 // Styling for gray button. | 160 // Styling for gray button. |
| 163 const GdkColor kGrayBorderColor = GDK_COLOR_RGB(0xa0, 0xa0, 0xa0); | 161 const GdkColor kGrayBorderColor = GDK_COLOR_RGB(0xa0, 0xa0, 0xa0); |
| 164 const GdkColor kTopColorGray = GDK_COLOR_RGB(0xe5, 0xe5, 0xe5); | 162 const GdkColor kTopColorGray = GDK_COLOR_RGB(0xe5, 0xe5, 0xe5); |
| 165 const GdkColor kBottomColorGray = GDK_COLOR_RGB(0xd0, 0xd0, 0xd0); | 163 const GdkColor kBottomColorGray = GDK_COLOR_RGB(0xd0, 0xd0, 0xd0); |
| 166 | 164 |
| 165 inline int InnerPadding() { |
| 166 return extensions::switch_utils::AreScriptBadgesEnabled() ? |
| 167 kScriptBadgeInnerPadding : kInnerPadding; |
| 168 } |
| 169 |
| 167 // If widget is visible, increment the int pointed to by count. | 170 // If widget is visible, increment the int pointed to by count. |
| 168 // Suitible for use with gtk_container_foreach. | 171 // Suitible for use with gtk_container_foreach. |
| 169 void CountVisibleWidgets(GtkWidget* widget, gpointer count) { | 172 void CountVisibleWidgets(GtkWidget* widget, gpointer count) { |
| 170 if (gtk_widget_get_visible(widget)) | 173 if (gtk_widget_get_visible(widget)) |
| 171 *static_cast<int*>(count) += 1; | 174 *static_cast<int*>(count) += 1; |
| 172 } | 175 } |
| 173 | 176 |
| 174 class ContentSettingImageViewGtk : public LocationBarViewGtk::PageToolViewGtk, | 177 class ContentSettingImageViewGtk : public LocationBarViewGtk::PageToolViewGtk, |
| 175 public BubbleDelegateGtk { | 178 public BubbleDelegateGtk { |
| 176 public: | 179 public: |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 web_intents_hbox_.Destroy(); | 434 web_intents_hbox_.Destroy(); |
| 432 } | 435 } |
| 433 | 436 |
| 434 void LocationBarViewGtk::Init(bool popup_window_mode) { | 437 void LocationBarViewGtk::Init(bool popup_window_mode) { |
| 435 popup_window_mode_ = popup_window_mode; | 438 popup_window_mode_ = popup_window_mode; |
| 436 | 439 |
| 437 Profile* profile = browser_->profile(); | 440 Profile* profile = browser_->profile(); |
| 438 theme_service_ = GtkThemeService::GetFrom(profile); | 441 theme_service_ = GtkThemeService::GetFrom(profile); |
| 439 | 442 |
| 440 // Create the widget first, so we can pass it to the OmniboxViewGtk. | 443 // Create the widget first, so we can pass it to the OmniboxViewGtk. |
| 441 hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding)); | 444 hbox_.Own(gtk_hbox_new(FALSE, InnerPadding())); |
| 442 gtk_container_set_border_width(GTK_CONTAINER(hbox_.get()), kHboxBorder); | 445 gtk_container_set_border_width(GTK_CONTAINER(hbox_.get()), kHboxBorder); |
| 443 // We will paint for the alignment, to paint the background and border. | 446 // We will paint for the alignment, to paint the background and border. |
| 444 gtk_widget_set_app_paintable(hbox_.get(), TRUE); | 447 gtk_widget_set_app_paintable(hbox_.get(), TRUE); |
| 445 // Redraw the whole location bar when it changes size (e.g., when toggling | 448 // Redraw the whole location bar when it changes size (e.g., when toggling |
| 446 // the home button on/off. | 449 // the home button on/off. |
| 447 gtk_widget_set_redraw_on_allocate(hbox_.get(), TRUE); | 450 gtk_widget_set_redraw_on_allocate(hbox_.get(), TRUE); |
| 448 | 451 |
| 449 // Now initialize the OmniboxViewGtk. | 452 // Now initialize the OmniboxViewGtk. |
| 450 location_entry_.reset(new OmniboxViewGtk(this, toolbar_model_, browser_, | 453 location_entry_.reset(new OmniboxViewGtk(this, toolbar_model_, browser_, |
| 451 command_updater_, popup_window_mode_, hbox_.get())); | 454 command_updater_, popup_window_mode_, hbox_.get())); |
| 452 location_entry_->Init(); | 455 location_entry_->Init(); |
| 453 | 456 |
| 454 g_signal_connect(hbox_.get(), "expose-event", | 457 g_signal_connect(hbox_.get(), "expose-event", |
| 455 G_CALLBACK(&HandleExposeThunk), this); | 458 G_CALLBACK(&HandleExposeThunk), this); |
| 456 | 459 |
| 457 BuildSiteTypeArea(); | 460 BuildSiteTypeArea(); |
| 458 | 461 |
| 459 // Put |tab_to_search_box_|, |location_entry_|, and |tab_to_search_hint_| into | 462 // Put |tab_to_search_box_|, |location_entry_|, and |tab_to_search_hint_| into |
| 460 // a sub hbox, so that we can make this part horizontally shrinkable without | 463 // a sub hbox, so that we can make this part horizontally shrinkable without |
| 461 // affecting other elements in the location bar. | 464 // affecting other elements in the location bar. |
| 462 entry_box_ = gtk_hbox_new(FALSE, kInnerPadding); | 465 entry_box_ = gtk_hbox_new(FALSE, InnerPadding()); |
| 463 gtk_widget_show(entry_box_); | 466 gtk_widget_show(entry_box_); |
| 464 gtk_widget_set_size_request(entry_box_, 0, -1); | 467 gtk_widget_set_size_request(entry_box_, 0, -1); |
| 465 gtk_box_pack_start(GTK_BOX(hbox_.get()), entry_box_, TRUE, TRUE, 0); | 468 gtk_box_pack_start(GTK_BOX(hbox_.get()), entry_box_, TRUE, TRUE, 0); |
| 466 | 469 |
| 467 // We need to adjust the visibility of the search hint widgets according to | 470 // We need to adjust the visibility of the search hint widgets according to |
| 468 // the horizontal space in the |entry_box_|. | 471 // the horizontal space in the |entry_box_|. |
| 469 g_signal_connect(entry_box_, "size-allocate", | 472 g_signal_connect(entry_box_, "size-allocate", |
| 470 G_CALLBACK(&OnEntryBoxSizeAllocateThunk), this); | 473 G_CALLBACK(&OnEntryBoxSizeAllocateThunk), this); |
| 471 | 474 |
| 472 // Tab to search (the keyword box on the left hand side). | 475 // Tab to search (the keyword box on the left hand side). |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableActionBox)) { | 548 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableActionBox)) { |
| 546 // TODO(mpcomplete): should we hide this if ShouldOnlyShowLocation()==true? | 549 // TODO(mpcomplete): should we hide this if ShouldOnlyShowLocation()==true? |
| 547 action_box_button_.reset(new ActionBoxButtonGtk(browser_)); | 550 action_box_button_.reset(new ActionBoxButtonGtk(browser_)); |
| 548 | 551 |
| 549 // TODO(mpcomplete): Figure out why CustomDrawButton is offset 3 pixels. | 552 // TODO(mpcomplete): Figure out why CustomDrawButton is offset 3 pixels. |
| 550 // This offset corrects the strange offset of CustomDrawButton. | 553 // This offset corrects the strange offset of CustomDrawButton. |
| 551 const int kMagicActionBoxYOffset = 3; | 554 const int kMagicActionBoxYOffset = 3; |
| 552 GtkWidget* alignment = gtk_alignment_new(0, 0, 1, 1); | 555 GtkWidget* alignment = gtk_alignment_new(0, 0, 1, 1); |
| 553 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), | 556 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), |
| 554 0, kMagicActionBoxYOffset, | 557 0, kMagicActionBoxYOffset, |
| 555 0, kInnerPadding); | 558 0, InnerPadding()); |
| 556 gtk_container_add(GTK_CONTAINER(alignment), action_box_button_->widget()); | 559 gtk_container_add(GTK_CONTAINER(alignment), action_box_button_->widget()); |
| 557 | 560 |
| 558 gtk_box_pack_end(GTK_BOX(hbox_.get()), alignment, | 561 gtk_box_pack_end(GTK_BOX(hbox_.get()), alignment, |
| 559 FALSE, FALSE, 0); | 562 FALSE, FALSE, 0); |
| 560 } else if (browser_defaults::bookmarks_enabled && !ShouldOnlyShowLocation()) { | 563 } else if (browser_defaults::bookmarks_enabled && !ShouldOnlyShowLocation()) { |
| 561 // Hide the star icon in popups, app windows, etc. | 564 // Hide the star icon in popups, app windows, etc. |
| 562 CreateStarButton(); | 565 CreateStarButton(); |
| 563 gtk_box_pack_end(GTK_BOX(hbox_.get()), star_.get(), FALSE, FALSE, 0); | 566 gtk_box_pack_end(GTK_BOX(hbox_.get()), star_.get(), FALSE, FALSE, 0); |
| 564 } | 567 } |
| 565 | 568 |
| 566 CreateZoomButton(); | 569 CreateZoomButton(); |
| 567 gtk_box_pack_end(GTK_BOX(hbox_.get()), zoom_.get(), FALSE, FALSE, 0); | 570 gtk_box_pack_end(GTK_BOX(hbox_.get()), zoom_.get(), FALSE, FALSE, 0); |
| 568 | 571 |
| 569 content_setting_hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding + 1)); | 572 content_setting_hbox_.Own(gtk_hbox_new(FALSE, InnerPadding() + 1)); |
| 570 gtk_widget_set_name(content_setting_hbox_.get(), | 573 gtk_widget_set_name(content_setting_hbox_.get(), |
| 571 "chrome-content-setting-hbox"); | 574 "chrome-content-setting-hbox"); |
| 572 gtk_box_pack_end(GTK_BOX(hbox_.get()), content_setting_hbox_.get(), | 575 gtk_box_pack_end(GTK_BOX(hbox_.get()), content_setting_hbox_.get(), |
| 573 FALSE, FALSE, 1); | 576 FALSE, FALSE, 1); |
| 574 | 577 |
| 575 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { | 578 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { |
| 576 ContentSettingImageViewGtk* content_setting_view = | 579 ContentSettingImageViewGtk* content_setting_view = |
| 577 new ContentSettingImageViewGtk( | 580 new ContentSettingImageViewGtk( |
| 578 static_cast<ContentSettingsType>(i), this); | 581 static_cast<ContentSettingsType>(i), this); |
| 579 content_setting_views_.push_back(content_setting_view); | 582 content_setting_views_.push_back(content_setting_view); |
| 580 gtk_box_pack_end(GTK_BOX(content_setting_hbox_.get()), | 583 gtk_box_pack_end(GTK_BOX(content_setting_hbox_.get()), |
| 581 content_setting_view->widget(), FALSE, FALSE, 0); | 584 content_setting_view->widget(), FALSE, FALSE, 0); |
| 582 } | 585 } |
| 583 | 586 |
| 584 page_action_hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding)); | 587 page_action_hbox_.Own(gtk_hbox_new(FALSE, InnerPadding())); |
| 585 gtk_widget_set_name(page_action_hbox_.get(), | 588 gtk_widget_set_name(page_action_hbox_.get(), |
| 586 "chrome-page-action-hbox"); | 589 "chrome-page-action-hbox"); |
| 587 gtk_box_pack_end(GTK_BOX(hbox_.get()), page_action_hbox_.get(), | 590 gtk_box_pack_end(GTK_BOX(hbox_.get()), page_action_hbox_.get(), |
| 588 FALSE, FALSE, 0); | 591 FALSE, FALSE, 0); |
| 589 | 592 |
| 590 web_intents_hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding)); | 593 web_intents_hbox_.Own(gtk_hbox_new(FALSE, InnerPadding())); |
| 591 gtk_widget_set_name(web_intents_hbox_.get(), | 594 gtk_widget_set_name(web_intents_hbox_.get(), |
| 592 "chrome-web-intents-hbox"); | 595 "chrome-web-intents-hbox"); |
| 593 gtk_box_pack_end(GTK_BOX(hbox_.get()), web_intents_hbox_.get(), | 596 gtk_box_pack_end(GTK_BOX(hbox_.get()), web_intents_hbox_.get(), |
| 594 FALSE, FALSE, 0); | 597 FALSE, FALSE, 0); |
| 595 gtk_box_pack_end(GTK_BOX(web_intents_hbox_.get()), | 598 gtk_box_pack_end(GTK_BOX(web_intents_hbox_.get()), |
| 596 web_intents_button_view_->widget(), FALSE, FALSE, 0); | 599 web_intents_button_view_->widget(), FALSE, FALSE, 0); |
| 597 | 600 |
| 598 // Now that we've created the widget hierarchy, connect to the main |hbox_|'s | 601 // Now that we've created the widget hierarchy, connect to the main |hbox_|'s |
| 599 // size-allocate so we can do proper resizing and eliding on | 602 // size-allocate so we can do proper resizing and eliding on |
| 600 // |security_info_label_|. | 603 // |security_info_label_|. |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 798 ViewID debug_id, | 801 ViewID debug_id, |
| 799 int tooltip_id, | 802 int tooltip_id, |
| 800 gboolean (click_callback)(GtkWidget*, GdkEventButton*, gpointer)) { | 803 gboolean (click_callback)(GtkWidget*, GdkEventButton*, gpointer)) { |
| 801 *image = image_id ? | 804 *image = image_id ? |
| 802 gtk_image_new_from_pixbuf( | 805 gtk_image_new_from_pixbuf( |
| 803 theme_service_->GetImageNamed(image_id)->ToGdkPixbuf()) : | 806 theme_service_->GetImageNamed(image_id)->ToGdkPixbuf()) : |
| 804 gtk_image_new(); | 807 gtk_image_new(); |
| 805 | 808 |
| 806 GtkWidget* alignment = gtk_alignment_new(0, 0, 1, 1); | 809 GtkWidget* alignment = gtk_alignment_new(0, 0, 1, 1); |
| 807 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 0, 0, | 810 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 0, 0, |
| 808 0, kInnerPadding); | 811 0, InnerPadding()); |
| 809 gtk_container_add(GTK_CONTAINER(alignment), *image); | 812 gtk_container_add(GTK_CONTAINER(alignment), *image); |
| 810 | 813 |
| 811 GtkWidget* result = gtk_event_box_new(); | 814 GtkWidget* result = gtk_event_box_new(); |
| 812 gtk_event_box_set_visible_window(GTK_EVENT_BOX(result), FALSE); | 815 gtk_event_box_set_visible_window(GTK_EVENT_BOX(result), FALSE); |
| 813 gtk_container_add(GTK_CONTAINER(result), alignment); | 816 gtk_container_add(GTK_CONTAINER(result), alignment); |
| 814 gtk_widget_show_all(result); | 817 gtk_widget_show_all(result); |
| 815 | 818 |
| 816 if (debug_id != VIEW_ID_NONE) | 819 if (debug_id != VIEW_ID_NONE) |
| 817 ViewIDUtil::SetID(result, debug_id); | 820 ViewIDUtil::SetID(result, debug_id); |
| 818 | 821 |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 974 } | 977 } |
| 975 | 978 |
| 976 WebContents* contents = GetWebContents(); | 979 WebContents* contents = GetWebContents(); |
| 977 if (!page_action_views_.empty() && contents) { | 980 if (!page_action_views_.empty() && contents) { |
| 978 GURL url = chrome::GetActiveWebContents(browser())->GetURL(); | 981 GURL url = chrome::GetActiveWebContents(browser())->GetURL(); |
| 979 | 982 |
| 980 for (size_t i = 0; i < page_action_views_.size(); i++) { | 983 for (size_t i = 0; i < page_action_views_.size(); i++) { |
| 981 page_action_views_[i]->UpdateVisibility( | 984 page_action_views_[i]->UpdateVisibility( |
| 982 toolbar_model_->input_in_progress() ? NULL : contents, url); | 985 toolbar_model_->input_in_progress() ? NULL : contents, url); |
| 983 } | 986 } |
| 987 gtk_widget_queue_draw(hbox_.get()); |
| 984 } | 988 } |
| 985 | 989 |
| 986 // If there are no visible page actions, hide the hbox too, so that it does | 990 // If there are no visible page actions, hide the hbox too, so that it does |
| 987 // not affect the padding in the location bar. | 991 // not affect the padding in the location bar. |
| 988 gtk_widget_set_visible(page_action_hbox_.get(), | 992 gtk_widget_set_visible(page_action_hbox_.get(), |
| 989 PageActionVisibleCount() && !ShouldOnlyShowLocation()); | 993 PageActionVisibleCount() && !ShouldOnlyShowLocation()); |
| 990 } | 994 } |
| 991 | 995 |
| 992 void LocationBarViewGtk::InvalidatePageActions() { | 996 void LocationBarViewGtk::InvalidatePageActions() { |
| 993 size_t count_before = page_action_views_.size(); | 997 size_t count_before = page_action_views_.size(); |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1167 left = IDR_LOCATIONBG_L; | 1171 left = IDR_LOCATIONBG_L; |
| 1168 center = IDR_LOCATIONBG_C; | 1172 center = IDR_LOCATIONBG_C; |
| 1169 right = IDR_LOCATIONBG_R; | 1173 right = IDR_LOCATIONBG_R; |
| 1170 } | 1174 } |
| 1171 | 1175 |
| 1172 NineBox background(left, center, right, | 1176 NineBox background(left, center, right, |
| 1173 0, 0, 0, 0, 0, 0); | 1177 0, 0, 0, 0, 0, 0); |
| 1174 background.RenderToWidget(widget); | 1178 background.RenderToWidget(widget); |
| 1175 } | 1179 } |
| 1176 | 1180 |
| 1181 // Draw ExtensionAction backgrounds and borders, if necessary. The borders |
| 1182 // appear exactly between the elements, so they can't draw the borders |
| 1183 // themselves. |
| 1184 gfx::CanvasSkiaPaint canvas(event, /*opaque=*/false); |
| 1185 for (ScopedVector<PageActionViewGtk>::const_iterator |
| 1186 page_action_view = page_action_views_.begin(); |
| 1187 page_action_view != page_action_views_.end(); |
| 1188 ++page_action_view) { |
| 1189 if ((*page_action_view)->IsVisible()) { |
| 1190 // Figure out where the page action is drawn so we can draw |
| 1191 // borders to its left and right. |
| 1192 GtkAllocation allocation; |
| 1193 gtk_widget_get_allocation((*page_action_view)->widget(), &allocation); |
| 1194 ExtensionAction* action = (*page_action_view)->page_action(); |
| 1195 gfx::Rect bounds(allocation); |
| 1196 // Make the bounding rectangle include the whole vertical range of the |
| 1197 // location bar, and the mid-point pixels between adjacent page actions. |
| 1198 // |
| 1199 // For odd InnerPadding()s, "InnerPadding() + 1" includes the mid-point |
| 1200 // between two page actions in the bounding rectangle. For even paddings, |
| 1201 // the +1 is dropped, which is right since there is no pixel at the |
| 1202 // mid-point. |
| 1203 bounds.Inset(-(InnerPadding() + 1) / 2, |
| 1204 theme_service_->UsingNativeTheme() ? -1 : 0); |
| 1205 action->PaintBackground(&canvas, bounds, |
| 1206 SessionID::IdForTab(GetTabContents())); |
| 1207 } |
| 1208 } |
| 1209 |
| 1177 return FALSE; // Continue propagating the expose. | 1210 return FALSE; // Continue propagating the expose. |
| 1178 } | 1211 } |
| 1179 | 1212 |
| 1180 void LocationBarViewGtk::UpdateSiteTypeArea() { | 1213 void LocationBarViewGtk::UpdateSiteTypeArea() { |
| 1181 // The icon is always visible except when the |tab_to_search_alignment_| is | 1214 // The icon is always visible except when the |tab_to_search_alignment_| is |
| 1182 // visible. | 1215 // visible. |
| 1183 if (!location_entry_->model()->keyword().empty() && | 1216 if (!location_entry_->model()->keyword().empty() && |
| 1184 !location_entry_->model()->is_keyword_hint()) { | 1217 !location_entry_->model()->is_keyword_hint()) { |
| 1185 gtk_widget_hide(site_type_area()); | 1218 gtk_widget_hide(site_type_area()); |
| 1186 return; | 1219 return; |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1545 gtk_widget_hide_all(star_.get()); | 1578 gtk_widget_hide_all(star_.get()); |
| 1546 } | 1579 } |
| 1547 } | 1580 } |
| 1548 | 1581 |
| 1549 bool LocationBarViewGtk::ShouldOnlyShowLocation() { | 1582 bool LocationBarViewGtk::ShouldOnlyShowLocation() { |
| 1550 return !browser_->is_type_tabbed(); | 1583 return !browser_->is_type_tabbed(); |
| 1551 } | 1584 } |
| 1552 | 1585 |
| 1553 void LocationBarViewGtk::AdjustChildrenVisibility() { | 1586 void LocationBarViewGtk::AdjustChildrenVisibility() { |
| 1554 int text_width = location_entry_->TextWidth(); | 1587 int text_width = location_entry_->TextWidth(); |
| 1555 int available_width = entry_box_width_ - text_width - kInnerPadding; | 1588 int available_width = entry_box_width_ - text_width - InnerPadding(); |
| 1556 | 1589 |
| 1557 // Only one of |tab_to_search_alignment_| and |tab_to_search_hint_| can be | 1590 // Only one of |tab_to_search_alignment_| and |tab_to_search_hint_| can be |
| 1558 // visible at the same time. | 1591 // visible at the same time. |
| 1559 if (!show_selected_keyword_ && | 1592 if (!show_selected_keyword_ && |
| 1560 gtk_widget_get_visible(tab_to_search_alignment_)) { | 1593 gtk_widget_get_visible(tab_to_search_alignment_)) { |
| 1561 gtk_widget_hide(tab_to_search_alignment_); | 1594 gtk_widget_hide(tab_to_search_alignment_); |
| 1562 } else if (!show_keyword_hint_ && | 1595 } else if (!show_keyword_hint_ && |
| 1563 gtk_widget_get_visible(tab_to_search_hint_)) { | 1596 gtk_widget_get_visible(tab_to_search_hint_)) { |
| 1564 gtk_widget_hide(tab_to_search_hint_); | 1597 gtk_widget_hide(tab_to_search_hint_); |
| 1565 } | 1598 } |
| 1566 | 1599 |
| 1567 if (show_selected_keyword_) { | 1600 if (show_selected_keyword_) { |
| 1568 GtkRequisition box, full_label, partial_label; | 1601 GtkRequisition box, full_label, partial_label; |
| 1569 gtk_widget_size_request(tab_to_search_box_, &box); | 1602 gtk_widget_size_request(tab_to_search_box_, &box); |
| 1570 gtk_widget_size_request(tab_to_search_full_label_, &full_label); | 1603 gtk_widget_size_request(tab_to_search_full_label_, &full_label); |
| 1571 gtk_widget_size_request(tab_to_search_partial_label_, &partial_label); | 1604 gtk_widget_size_request(tab_to_search_partial_label_, &partial_label); |
| 1572 int full_partial_width_diff = full_label.width - partial_label.width; | 1605 int full_partial_width_diff = full_label.width - partial_label.width; |
| 1573 int full_box_width; | 1606 int full_box_width; |
| 1574 int partial_box_width; | 1607 int partial_box_width; |
| 1575 if (gtk_widget_get_visible(tab_to_search_full_label_)) { | 1608 if (gtk_widget_get_visible(tab_to_search_full_label_)) { |
| 1576 full_box_width = box.width; | 1609 full_box_width = box.width; |
| 1577 partial_box_width = full_box_width - full_partial_width_diff; | 1610 partial_box_width = full_box_width - full_partial_width_diff; |
| 1578 } else { | 1611 } else { |
| 1579 partial_box_width = box.width; | 1612 partial_box_width = box.width; |
| 1580 full_box_width = partial_box_width + full_partial_width_diff; | 1613 full_box_width = partial_box_width + full_partial_width_diff; |
| 1581 } | 1614 } |
| 1582 | 1615 |
| 1583 if (partial_box_width >= entry_box_width_ - kInnerPadding) { | 1616 if (partial_box_width >= entry_box_width_ - InnerPadding()) { |
| 1584 gtk_widget_hide(tab_to_search_alignment_); | 1617 gtk_widget_hide(tab_to_search_alignment_); |
| 1585 } else if (full_box_width >= available_width) { | 1618 } else if (full_box_width >= available_width) { |
| 1586 gtk_widget_hide(tab_to_search_full_label_); | 1619 gtk_widget_hide(tab_to_search_full_label_); |
| 1587 gtk_widget_show(tab_to_search_partial_label_); | 1620 gtk_widget_show(tab_to_search_partial_label_); |
| 1588 gtk_widget_show(tab_to_search_alignment_); | 1621 gtk_widget_show(tab_to_search_alignment_); |
| 1589 } else if (full_box_width < available_width) { | 1622 } else if (full_box_width < available_width) { |
| 1590 gtk_widget_hide(tab_to_search_partial_label_); | 1623 gtk_widget_hide(tab_to_search_partial_label_); |
| 1591 gtk_widget_show(tab_to_search_full_label_); | 1624 gtk_widget_show(tab_to_search_full_label_); |
| 1592 gtk_widget_show(tab_to_search_alignment_); | 1625 gtk_widget_show(tab_to_search_alignment_); |
| 1593 } | 1626 } |
| 1594 } else if (show_keyword_hint_) { | 1627 } else if (show_keyword_hint_) { |
| 1595 GtkRequisition leading, icon, trailing; | 1628 GtkRequisition leading, icon, trailing; |
| 1596 gtk_widget_size_request(tab_to_search_hint_leading_label_, &leading); | 1629 gtk_widget_size_request(tab_to_search_hint_leading_label_, &leading); |
| 1597 gtk_widget_size_request(tab_to_search_hint_icon_, &icon); | 1630 gtk_widget_size_request(tab_to_search_hint_icon_, &icon); |
| 1598 gtk_widget_size_request(tab_to_search_hint_trailing_label_, &trailing); | 1631 gtk_widget_size_request(tab_to_search_hint_trailing_label_, &trailing); |
| 1599 int full_width = leading.width + icon.width + trailing.width; | 1632 int full_width = leading.width + icon.width + trailing.width; |
| 1600 | 1633 |
| 1601 if (icon.width >= entry_box_width_ - kInnerPadding) { | 1634 if (icon.width >= entry_box_width_ - InnerPadding()) { |
| 1602 gtk_widget_hide(tab_to_search_hint_); | 1635 gtk_widget_hide(tab_to_search_hint_); |
| 1603 } else if (full_width >= available_width) { | 1636 } else if (full_width >= available_width) { |
| 1604 gtk_widget_hide(tab_to_search_hint_leading_label_); | 1637 gtk_widget_hide(tab_to_search_hint_leading_label_); |
| 1605 gtk_widget_hide(tab_to_search_hint_trailing_label_); | 1638 gtk_widget_hide(tab_to_search_hint_trailing_label_); |
| 1606 gtk_widget_show(tab_to_search_hint_); | 1639 gtk_widget_show(tab_to_search_hint_); |
| 1607 } else if (full_width < available_width) { | 1640 } else if (full_width < available_width) { |
| 1608 gtk_widget_show(tab_to_search_hint_leading_label_); | 1641 gtk_widget_show(tab_to_search_hint_leading_label_); |
| 1609 gtk_widget_show(tab_to_search_hint_trailing_label_); | 1642 gtk_widget_show(tab_to_search_hint_trailing_label_); |
| 1610 gtk_widget_show(tab_to_search_hint_); | 1643 gtk_widget_show(tab_to_search_hint_); |
| 1611 } | 1644 } |
| 1612 } | 1645 } |
| 1613 } | 1646 } |
| 1614 | 1647 |
| 1615 //////////////////////////////////////////////////////////////////////////////// | 1648 //////////////////////////////////////////////////////////////////////////////// |
| 1616 // LocationBarViewGtk::PageToolViewGtk | 1649 // LocationBarViewGtk::PageToolViewGtk |
| 1617 | 1650 |
| 1618 LocationBarViewGtk::PageToolViewGtk::PageToolViewGtk( | 1651 LocationBarViewGtk::PageToolViewGtk::PageToolViewGtk( |
| 1619 const LocationBarViewGtk* parent) | 1652 const LocationBarViewGtk* parent) |
| 1620 : alignment_(gtk_alignment_new(0, 0, 1, 1)), | 1653 : alignment_(gtk_alignment_new(0, 0, 1, 1)), |
| 1621 event_box_(gtk_event_box_new()), | 1654 event_box_(gtk_event_box_new()), |
| 1622 hbox_(gtk_hbox_new(FALSE, kInnerPadding)), | 1655 hbox_(gtk_hbox_new(FALSE, InnerPadding())), |
| 1623 image_(gtk_image_new()), | 1656 image_(gtk_image_new()), |
| 1624 label_(gtk_label_new(NULL)), | 1657 label_(gtk_label_new(NULL)), |
| 1625 parent_(parent), | 1658 parent_(parent), |
| 1626 animation_(this), | 1659 animation_(this), |
| 1627 weak_factory_(this) { | 1660 weak_factory_(this) { |
| 1628 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment_.get()), 1, 1, 0, 0); | 1661 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment_.get()), 1, 1, 0, 0); |
| 1629 gtk_container_add(GTK_CONTAINER(alignment_.get()), event_box_.get()); | 1662 gtk_container_add(GTK_CONTAINER(alignment_.get()), event_box_.get()); |
| 1630 | 1663 |
| 1631 // Make the event box not visible so it does not paint a background. | 1664 // Make the event box not visible so it does not paint a background. |
| 1632 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_.get()), FALSE); | 1665 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_.get()), FALSE); |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2083 } | 2116 } |
| 2084 | 2117 |
| 2085 void LocationBarViewGtk::PageActionViewGtk::InspectPopup( | 2118 void LocationBarViewGtk::PageActionViewGtk::InspectPopup( |
| 2086 ExtensionAction* action) { | 2119 ExtensionAction* action) { |
| 2087 ExtensionPopupGtk::Show( | 2120 ExtensionPopupGtk::Show( |
| 2088 action->GetPopupUrl(current_tab_id_), | 2121 action->GetPopupUrl(current_tab_id_), |
| 2089 owner_->browser_, | 2122 owner_->browser_, |
| 2090 event_box_.get(), | 2123 event_box_.get(), |
| 2091 ExtensionPopupGtk::SHOW_AND_INSPECT); | 2124 ExtensionPopupGtk::SHOW_AND_INSPECT); |
| 2092 } | 2125 } |
| OLD | NEW |