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

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

Issue 10834279: Give request-to-act badges a grey background, and increase spacing to make it fit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Avoid changing Mac edit field width when script badges disabled 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
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/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
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
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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 web_intents_hbox_.Destroy(); 435 web_intents_hbox_.Destroy();
433 } 436 }
434 437
435 void LocationBarViewGtk::Init(bool popup_window_mode) { 438 void LocationBarViewGtk::Init(bool popup_window_mode) {
436 popup_window_mode_ = popup_window_mode; 439 popup_window_mode_ = popup_window_mode;
437 440
438 Profile* profile = browser_->profile(); 441 Profile* profile = browser_->profile();
439 theme_service_ = GtkThemeService::GetFrom(profile); 442 theme_service_ = GtkThemeService::GetFrom(profile);
440 443
441 // Create the widget first, so we can pass it to the OmniboxViewGtk. 444 // Create the widget first, so we can pass it to the OmniboxViewGtk.
442 hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding)); 445 hbox_.Own(gtk_hbox_new(FALSE, InnerPadding()));
443 gtk_container_set_border_width(GTK_CONTAINER(hbox_.get()), kHboxBorder); 446 gtk_container_set_border_width(GTK_CONTAINER(hbox_.get()), kHboxBorder);
444 // We will paint for the alignment, to paint the background and border. 447 // We will paint for the alignment, to paint the background and border.
445 gtk_widget_set_app_paintable(hbox_.get(), TRUE); 448 gtk_widget_set_app_paintable(hbox_.get(), TRUE);
446 // Redraw the whole location bar when it changes size (e.g., when toggling 449 // Redraw the whole location bar when it changes size (e.g., when toggling
447 // the home button on/off. 450 // the home button on/off.
448 gtk_widget_set_redraw_on_allocate(hbox_.get(), TRUE); 451 gtk_widget_set_redraw_on_allocate(hbox_.get(), TRUE);
449 452
450 // Now initialize the OmniboxViewGtk. 453 // Now initialize the OmniboxViewGtk.
451 location_entry_.reset(new OmniboxViewGtk(this, toolbar_model_, browser_, 454 location_entry_.reset(new OmniboxViewGtk(this, toolbar_model_, browser_,
452 command_updater_, popup_window_mode_, hbox_.get())); 455 command_updater_, popup_window_mode_, hbox_.get()));
453 location_entry_->Init(); 456 location_entry_->Init();
454 457
455 g_signal_connect(hbox_.get(), "expose-event", 458 g_signal_connect(hbox_.get(), "expose-event",
456 G_CALLBACK(&HandleExposeThunk), this); 459 G_CALLBACK(&HandleExposeThunk), this);
457 460
458 BuildSiteTypeArea(); 461 BuildSiteTypeArea();
459 462
460 // Put |tab_to_search_box_|, |location_entry_|, and |tab_to_search_hint_| into 463 // Put |tab_to_search_box_|, |location_entry_|, and |tab_to_search_hint_| into
461 // a sub hbox, so that we can make this part horizontally shrinkable without 464 // a sub hbox, so that we can make this part horizontally shrinkable without
462 // affecting other elements in the location bar. 465 // affecting other elements in the location bar.
463 entry_box_ = gtk_hbox_new(FALSE, kInnerPadding); 466 entry_box_ = gtk_hbox_new(FALSE, InnerPadding());
464 gtk_widget_show(entry_box_); 467 gtk_widget_show(entry_box_);
465 gtk_widget_set_size_request(entry_box_, 0, -1); 468 gtk_widget_set_size_request(entry_box_, 0, -1);
466 gtk_box_pack_start(GTK_BOX(hbox_.get()), entry_box_, TRUE, TRUE, 0); 469 gtk_box_pack_start(GTK_BOX(hbox_.get()), entry_box_, TRUE, TRUE, 0);
467 470
468 // We need to adjust the visibility of the search hint widgets according to 471 // We need to adjust the visibility of the search hint widgets according to
469 // the horizontal space in the |entry_box_|. 472 // the horizontal space in the |entry_box_|.
470 g_signal_connect(entry_box_, "size-allocate", 473 g_signal_connect(entry_box_, "size-allocate",
471 G_CALLBACK(&OnEntryBoxSizeAllocateThunk), this); 474 G_CALLBACK(&OnEntryBoxSizeAllocateThunk), this);
472 475
473 // Tab to search (the keyword box on the left hand side). 476 // Tab to search (the keyword box on the left hand side).
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 if (extensions::switch_utils::IsActionBoxEnabled()) { 549 if (extensions::switch_utils::IsActionBoxEnabled()) {
547 // TODO(mpcomplete): should we hide this if ShouldOnlyShowLocation()==true? 550 // TODO(mpcomplete): should we hide this if ShouldOnlyShowLocation()==true?
548 action_box_button_.reset(new ActionBoxButtonGtk(browser_)); 551 action_box_button_.reset(new ActionBoxButtonGtk(browser_));
549 552
550 // TODO(mpcomplete): Figure out why CustomDrawButton is offset 3 pixels. 553 // TODO(mpcomplete): Figure out why CustomDrawButton is offset 3 pixels.
551 // This offset corrects the strange offset of CustomDrawButton. 554 // This offset corrects the strange offset of CustomDrawButton.
552 const int kMagicActionBoxYOffset = 3; 555 const int kMagicActionBoxYOffset = 3;
553 GtkWidget* alignment = gtk_alignment_new(0, 0, 1, 1); 556 GtkWidget* alignment = gtk_alignment_new(0, 0, 1, 1);
554 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 557 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment),
555 0, kMagicActionBoxYOffset, 558 0, kMagicActionBoxYOffset,
556 0, kInnerPadding); 559 0, InnerPadding());
557 gtk_container_add(GTK_CONTAINER(alignment), action_box_button_->widget()); 560 gtk_container_add(GTK_CONTAINER(alignment), action_box_button_->widget());
558 561
559 gtk_box_pack_end(GTK_BOX(hbox_.get()), alignment, 562 gtk_box_pack_end(GTK_BOX(hbox_.get()), alignment,
560 FALSE, FALSE, 0); 563 FALSE, FALSE, 0);
561 } 564 }
562 565
563 if (browser_defaults::bookmarks_enabled && !ShouldOnlyShowLocation()) { 566 if (browser_defaults::bookmarks_enabled && !ShouldOnlyShowLocation()) {
564 // Hide the star icon in popups, app windows, etc. 567 // Hide the star icon in popups, app windows, etc.
565 CreateStarButton(); 568 CreateStarButton();
566 gtk_box_pack_end(GTK_BOX(hbox_.get()), star_.get(), FALSE, FALSE, 0); 569 gtk_box_pack_end(GTK_BOX(hbox_.get()), star_.get(), FALSE, FALSE, 0);
567 } 570 }
568 571
569 CreateZoomButton(); 572 CreateZoomButton();
570 gtk_box_pack_end(GTK_BOX(hbox_.get()), zoom_.get(), FALSE, FALSE, 0); 573 gtk_box_pack_end(GTK_BOX(hbox_.get()), zoom_.get(), FALSE, FALSE, 0);
571 574
572 content_setting_hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding + 1)); 575 content_setting_hbox_.Own(gtk_hbox_new(FALSE, InnerPadding() + 1));
573 gtk_widget_set_name(content_setting_hbox_.get(), 576 gtk_widget_set_name(content_setting_hbox_.get(),
574 "chrome-content-setting-hbox"); 577 "chrome-content-setting-hbox");
575 gtk_box_pack_end(GTK_BOX(hbox_.get()), content_setting_hbox_.get(), 578 gtk_box_pack_end(GTK_BOX(hbox_.get()), content_setting_hbox_.get(),
576 FALSE, FALSE, 1); 579 FALSE, FALSE, 1);
577 580
578 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { 581 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) {
579 ContentSettingImageViewGtk* content_setting_view = 582 ContentSettingImageViewGtk* content_setting_view =
580 new ContentSettingImageViewGtk( 583 new ContentSettingImageViewGtk(
581 static_cast<ContentSettingsType>(i), this); 584 static_cast<ContentSettingsType>(i), this);
582 content_setting_views_.push_back(content_setting_view); 585 content_setting_views_.push_back(content_setting_view);
583 gtk_box_pack_end(GTK_BOX(content_setting_hbox_.get()), 586 gtk_box_pack_end(GTK_BOX(content_setting_hbox_.get()),
584 content_setting_view->widget(), FALSE, FALSE, 0); 587 content_setting_view->widget(), FALSE, FALSE, 0);
585 } 588 }
586 589
587 page_action_hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding)); 590 page_action_hbox_.Own(gtk_hbox_new(FALSE, InnerPadding()));
588 gtk_widget_set_name(page_action_hbox_.get(), 591 gtk_widget_set_name(page_action_hbox_.get(),
589 "chrome-page-action-hbox"); 592 "chrome-page-action-hbox");
590 gtk_box_pack_end(GTK_BOX(hbox_.get()), page_action_hbox_.get(), 593 gtk_box_pack_end(GTK_BOX(hbox_.get()), page_action_hbox_.get(),
591 FALSE, FALSE, 0); 594 FALSE, FALSE, 0);
592 595
593 web_intents_hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding)); 596 web_intents_hbox_.Own(gtk_hbox_new(FALSE, InnerPadding()));
594 gtk_widget_set_name(web_intents_hbox_.get(), 597 gtk_widget_set_name(web_intents_hbox_.get(),
595 "chrome-web-intents-hbox"); 598 "chrome-web-intents-hbox");
596 gtk_box_pack_end(GTK_BOX(hbox_.get()), web_intents_hbox_.get(), 599 gtk_box_pack_end(GTK_BOX(hbox_.get()), web_intents_hbox_.get(),
597 FALSE, FALSE, 0); 600 FALSE, FALSE, 0);
598 gtk_box_pack_end(GTK_BOX(web_intents_hbox_.get()), 601 gtk_box_pack_end(GTK_BOX(web_intents_hbox_.get()),
599 web_intents_button_view_->widget(), FALSE, FALSE, 0); 602 web_intents_button_view_->widget(), FALSE, FALSE, 0);
600 603
601 // Now that we've created the widget hierarchy, connect to the main |hbox_|'s 604 // Now that we've created the widget hierarchy, connect to the main |hbox_|'s
602 // size-allocate so we can do proper resizing and eliding on 605 // size-allocate so we can do proper resizing and eliding on
603 // |security_info_label_|. 606 // |security_info_label_|.
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 ViewID debug_id, 805 ViewID debug_id,
803 int tooltip_id, 806 int tooltip_id,
804 gboolean (click_callback)(GtkWidget*, GdkEventButton*, gpointer)) { 807 gboolean (click_callback)(GtkWidget*, GdkEventButton*, gpointer)) {
805 *image = image_id ? 808 *image = image_id ?
806 gtk_image_new_from_pixbuf( 809 gtk_image_new_from_pixbuf(
807 theme_service_->GetImageNamed(image_id)->ToGdkPixbuf()) : 810 theme_service_->GetImageNamed(image_id)->ToGdkPixbuf()) :
808 gtk_image_new(); 811 gtk_image_new();
809 812
810 GtkWidget* alignment = gtk_alignment_new(0, 0, 1, 1); 813 GtkWidget* alignment = gtk_alignment_new(0, 0, 1, 1);
811 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 0, 0, 814 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 0, 0,
812 0, kInnerPadding); 815 0, InnerPadding());
813 gtk_container_add(GTK_CONTAINER(alignment), *image); 816 gtk_container_add(GTK_CONTAINER(alignment), *image);
814 817
815 GtkWidget* result = gtk_event_box_new(); 818 GtkWidget* result = gtk_event_box_new();
816 gtk_event_box_set_visible_window(GTK_EVENT_BOX(result), FALSE); 819 gtk_event_box_set_visible_window(GTK_EVENT_BOX(result), FALSE);
817 gtk_container_add(GTK_CONTAINER(result), alignment); 820 gtk_container_add(GTK_CONTAINER(result), alignment);
818 gtk_widget_show_all(result); 821 gtk_widget_show_all(result);
819 822
820 if (debug_id != VIEW_ID_NONE) 823 if (debug_id != VIEW_ID_NONE)
821 ViewIDUtil::SetID(result, debug_id); 824 ViewIDUtil::SetID(result, debug_id);
822 825
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
982 } 985 }
983 986
984 WebContents* contents = GetWebContents(); 987 WebContents* contents = GetWebContents();
985 if (!page_action_views_.empty() && contents) { 988 if (!page_action_views_.empty() && contents) {
986 GURL url = chrome::GetActiveWebContents(browser())->GetURL(); 989 GURL url = chrome::GetActiveWebContents(browser())->GetURL();
987 990
988 for (size_t i = 0; i < page_action_views_.size(); i++) { 991 for (size_t i = 0; i < page_action_views_.size(); i++) {
989 page_action_views_[i]->UpdateVisibility( 992 page_action_views_[i]->UpdateVisibility(
990 toolbar_model_->input_in_progress() ? NULL : contents, url); 993 toolbar_model_->input_in_progress() ? NULL : contents, url);
991 } 994 }
995 gtk_widget_queue_draw(hbox_.get());
992 } 996 }
993 997
994 // If there are no visible page actions, hide the hbox too, so that it does 998 // If there are no visible page actions, hide the hbox too, so that it does
995 // not affect the padding in the location bar. 999 // not affect the padding in the location bar.
996 gtk_widget_set_visible(page_action_hbox_.get(), 1000 gtk_widget_set_visible(page_action_hbox_.get(),
997 PageActionVisibleCount() && !ShouldOnlyShowLocation()); 1001 PageActionVisibleCount() && !ShouldOnlyShowLocation());
998 } 1002 }
999 1003
1000 void LocationBarViewGtk::InvalidatePageActions() { 1004 void LocationBarViewGtk::InvalidatePageActions() {
1001 size_t count_before = page_action_views_.size(); 1005 size_t count_before = page_action_views_.size();
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1174 left = IDR_LOCATIONBG_L; 1178 left = IDR_LOCATIONBG_L;
1175 center = IDR_LOCATIONBG_C; 1179 center = IDR_LOCATIONBG_C;
1176 right = IDR_LOCATIONBG_R; 1180 right = IDR_LOCATIONBG_R;
1177 } 1181 }
1178 1182
1179 NineBox background(left, center, right, 1183 NineBox background(left, center, right,
1180 0, 0, 0, 0, 0, 0); 1184 0, 0, 0, 0, 0, 0);
1181 background.RenderToWidget(widget); 1185 background.RenderToWidget(widget);
1182 } 1186 }
1183 1187
1188 // Draw ExtensionAction backgrounds and borders, if necessary. The borders
1189 // appear exactly between the elements, so they can't draw the borders
1190 // themselves.
1191 gfx::CanvasSkiaPaint canvas(event, /*opaque=*/false);
1192 for (ScopedVector<PageActionViewGtk>::const_iterator
1193 page_action_view = page_action_views_.begin();
1194 page_action_view != page_action_views_.end();
1195 ++page_action_view) {
1196 if ((*page_action_view)->IsVisible()) {
1197 // Figure out where the page action is drawn so we can draw
1198 // borders to its left and right.
1199 GtkAllocation allocation;
1200 gtk_widget_get_allocation((*page_action_view)->widget(), &allocation);
1201 ExtensionAction* action = (*page_action_view)->page_action();
1202 gfx::Rect bounds(allocation);
1203 // Make the bounding rectangle include the whole vertical range of the
1204 // location bar, and the mid-point pixels between adjacent page actions.
1205 //
1206 // For odd InnerPadding()s, "InnerPadding() + 1" includes the mid-point
1207 // between two page actions in the bounding rectangle. For even paddings,
1208 // the +1 is dropped, which is right since there is no pixel at the
1209 // mid-point.
1210 bounds.Inset(-(InnerPadding() + 1) / 2,
1211 theme_service_->UsingNativeTheme() ? -1 : 0);
1212 location_bar_util::PaintExtensionActionBackground(
1213 *action, SessionID::IdForTab(GetWebContents()),
1214 &canvas, bounds,
1215 theme_service_->get_location_bar_text_color(),
1216 theme_service_->get_location_bar_bg_color());
1217 }
1218 }
1219 // Destroying |canvas| draws the background.
1220
1184 return FALSE; // Continue propagating the expose. 1221 return FALSE; // Continue propagating the expose.
1185 } 1222 }
1186 1223
1187 void LocationBarViewGtk::UpdateSiteTypeArea() { 1224 void LocationBarViewGtk::UpdateSiteTypeArea() {
1188 // The icon is always visible except when the |tab_to_search_alignment_| is 1225 // The icon is always visible except when the |tab_to_search_alignment_| is
1189 // visible. 1226 // visible.
1190 if (!location_entry_->model()->keyword().empty() && 1227 if (!location_entry_->model()->keyword().empty() &&
1191 !location_entry_->model()->is_keyword_hint()) { 1228 !location_entry_->model()->is_keyword_hint()) {
1192 gtk_widget_hide(site_type_area()); 1229 gtk_widget_hide(site_type_area());
1193 return; 1230 return;
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
1577 command_updater_->UpdateCommandEnabled(IDC_CHROME_TO_MOBILE_PAGE, 1614 command_updater_->UpdateCommandEnabled(IDC_CHROME_TO_MOBILE_PAGE,
1578 !toolbar_model_->input_in_progress() && service && service->HasMobiles()); 1615 !toolbar_model_->input_in_progress() && service && service->HasMobiles());
1579 } 1616 }
1580 1617
1581 bool LocationBarViewGtk::ShouldOnlyShowLocation() { 1618 bool LocationBarViewGtk::ShouldOnlyShowLocation() {
1582 return !browser_->is_type_tabbed(); 1619 return !browser_->is_type_tabbed();
1583 } 1620 }
1584 1621
1585 void LocationBarViewGtk::AdjustChildrenVisibility() { 1622 void LocationBarViewGtk::AdjustChildrenVisibility() {
1586 int text_width = location_entry_->TextWidth(); 1623 int text_width = location_entry_->TextWidth();
1587 int available_width = entry_box_width_ - text_width - kInnerPadding; 1624 int available_width = entry_box_width_ - text_width - InnerPadding();
1588 1625
1589 // Only one of |tab_to_search_alignment_| and |tab_to_search_hint_| can be 1626 // Only one of |tab_to_search_alignment_| and |tab_to_search_hint_| can be
1590 // visible at the same time. 1627 // visible at the same time.
1591 if (!show_selected_keyword_ && 1628 if (!show_selected_keyword_ &&
1592 gtk_widget_get_visible(tab_to_search_alignment_)) { 1629 gtk_widget_get_visible(tab_to_search_alignment_)) {
1593 gtk_widget_hide(tab_to_search_alignment_); 1630 gtk_widget_hide(tab_to_search_alignment_);
1594 } else if (!show_keyword_hint_ && 1631 } else if (!show_keyword_hint_ &&
1595 gtk_widget_get_visible(tab_to_search_hint_)) { 1632 gtk_widget_get_visible(tab_to_search_hint_)) {
1596 gtk_widget_hide(tab_to_search_hint_); 1633 gtk_widget_hide(tab_to_search_hint_);
1597 } 1634 }
1598 1635
1599 if (show_selected_keyword_) { 1636 if (show_selected_keyword_) {
1600 GtkRequisition box, full_label, partial_label; 1637 GtkRequisition box, full_label, partial_label;
1601 gtk_widget_size_request(tab_to_search_box_, &box); 1638 gtk_widget_size_request(tab_to_search_box_, &box);
1602 gtk_widget_size_request(tab_to_search_full_label_, &full_label); 1639 gtk_widget_size_request(tab_to_search_full_label_, &full_label);
1603 gtk_widget_size_request(tab_to_search_partial_label_, &partial_label); 1640 gtk_widget_size_request(tab_to_search_partial_label_, &partial_label);
1604 int full_partial_width_diff = full_label.width - partial_label.width; 1641 int full_partial_width_diff = full_label.width - partial_label.width;
1605 int full_box_width; 1642 int full_box_width;
1606 int partial_box_width; 1643 int partial_box_width;
1607 if (gtk_widget_get_visible(tab_to_search_full_label_)) { 1644 if (gtk_widget_get_visible(tab_to_search_full_label_)) {
1608 full_box_width = box.width; 1645 full_box_width = box.width;
1609 partial_box_width = full_box_width - full_partial_width_diff; 1646 partial_box_width = full_box_width - full_partial_width_diff;
1610 } else { 1647 } else {
1611 partial_box_width = box.width; 1648 partial_box_width = box.width;
1612 full_box_width = partial_box_width + full_partial_width_diff; 1649 full_box_width = partial_box_width + full_partial_width_diff;
1613 } 1650 }
1614 1651
1615 if (partial_box_width >= entry_box_width_ - kInnerPadding) { 1652 if (partial_box_width >= entry_box_width_ - InnerPadding()) {
1616 gtk_widget_hide(tab_to_search_alignment_); 1653 gtk_widget_hide(tab_to_search_alignment_);
1617 } else if (full_box_width >= available_width) { 1654 } else if (full_box_width >= available_width) {
1618 gtk_widget_hide(tab_to_search_full_label_); 1655 gtk_widget_hide(tab_to_search_full_label_);
1619 gtk_widget_show(tab_to_search_partial_label_); 1656 gtk_widget_show(tab_to_search_partial_label_);
1620 gtk_widget_show(tab_to_search_alignment_); 1657 gtk_widget_show(tab_to_search_alignment_);
1621 } else if (full_box_width < available_width) { 1658 } else if (full_box_width < available_width) {
1622 gtk_widget_hide(tab_to_search_partial_label_); 1659 gtk_widget_hide(tab_to_search_partial_label_);
1623 gtk_widget_show(tab_to_search_full_label_); 1660 gtk_widget_show(tab_to_search_full_label_);
1624 gtk_widget_show(tab_to_search_alignment_); 1661 gtk_widget_show(tab_to_search_alignment_);
1625 } 1662 }
1626 } else if (show_keyword_hint_) { 1663 } else if (show_keyword_hint_) {
1627 GtkRequisition leading, icon, trailing; 1664 GtkRequisition leading, icon, trailing;
1628 gtk_widget_size_request(tab_to_search_hint_leading_label_, &leading); 1665 gtk_widget_size_request(tab_to_search_hint_leading_label_, &leading);
1629 gtk_widget_size_request(tab_to_search_hint_icon_, &icon); 1666 gtk_widget_size_request(tab_to_search_hint_icon_, &icon);
1630 gtk_widget_size_request(tab_to_search_hint_trailing_label_, &trailing); 1667 gtk_widget_size_request(tab_to_search_hint_trailing_label_, &trailing);
1631 int full_width = leading.width + icon.width + trailing.width; 1668 int full_width = leading.width + icon.width + trailing.width;
1632 1669
1633 if (icon.width >= entry_box_width_ - kInnerPadding) { 1670 if (icon.width >= entry_box_width_ - InnerPadding()) {
1634 gtk_widget_hide(tab_to_search_hint_); 1671 gtk_widget_hide(tab_to_search_hint_);
1635 } else if (full_width >= available_width) { 1672 } else if (full_width >= available_width) {
1636 gtk_widget_hide(tab_to_search_hint_leading_label_); 1673 gtk_widget_hide(tab_to_search_hint_leading_label_);
1637 gtk_widget_hide(tab_to_search_hint_trailing_label_); 1674 gtk_widget_hide(tab_to_search_hint_trailing_label_);
1638 gtk_widget_show(tab_to_search_hint_); 1675 gtk_widget_show(tab_to_search_hint_);
1639 } else if (full_width < available_width) { 1676 } else if (full_width < available_width) {
1640 gtk_widget_show(tab_to_search_hint_leading_label_); 1677 gtk_widget_show(tab_to_search_hint_leading_label_);
1641 gtk_widget_show(tab_to_search_hint_trailing_label_); 1678 gtk_widget_show(tab_to_search_hint_trailing_label_);
1642 gtk_widget_show(tab_to_search_hint_); 1679 gtk_widget_show(tab_to_search_hint_);
1643 } 1680 }
1644 } 1681 }
1645 } 1682 }
1646 1683
1647 //////////////////////////////////////////////////////////////////////////////// 1684 ////////////////////////////////////////////////////////////////////////////////
1648 // LocationBarViewGtk::PageToolViewGtk 1685 // LocationBarViewGtk::PageToolViewGtk
1649 1686
1650 LocationBarViewGtk::PageToolViewGtk::PageToolViewGtk( 1687 LocationBarViewGtk::PageToolViewGtk::PageToolViewGtk(
1651 const LocationBarViewGtk* parent) 1688 const LocationBarViewGtk* parent)
1652 : alignment_(gtk_alignment_new(0, 0, 1, 1)), 1689 : alignment_(gtk_alignment_new(0, 0, 1, 1)),
1653 event_box_(gtk_event_box_new()), 1690 event_box_(gtk_event_box_new()),
1654 hbox_(gtk_hbox_new(FALSE, kInnerPadding)), 1691 hbox_(gtk_hbox_new(FALSE, InnerPadding())),
1655 image_(gtk_image_new()), 1692 image_(gtk_image_new()),
1656 label_(gtk_label_new(NULL)), 1693 label_(gtk_label_new(NULL)),
1657 parent_(parent), 1694 parent_(parent),
1658 animation_(this), 1695 animation_(this),
1659 weak_factory_(this) { 1696 weak_factory_(this) {
1660 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment_.get()), 1, 1, 0, 0); 1697 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment_.get()), 1, 1, 0, 0);
1661 gtk_container_add(GTK_CONTAINER(alignment_.get()), event_box_.get()); 1698 gtk_container_add(GTK_CONTAINER(alignment_.get()), event_box_.get());
1662 1699
1663 // Make the event box not visible so it does not paint a background. 1700 // Make the event box not visible so it does not paint a background.
1664 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_.get()), FALSE); 1701 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_.get()), FALSE);
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
2114 } 2151 }
2115 2152
2116 void LocationBarViewGtk::PageActionViewGtk::InspectPopup( 2153 void LocationBarViewGtk::PageActionViewGtk::InspectPopup(
2117 ExtensionAction* action) { 2154 ExtensionAction* action) {
2118 ExtensionPopupGtk::Show( 2155 ExtensionPopupGtk::Show(
2119 action->GetPopupUrl(current_tab_id_), 2156 action->GetPopupUrl(current_tab_id_),
2120 owner_->browser_, 2157 owner_->browser_,
2121 event_box_.get(), 2158 event_box_.get(),
2122 ExtensionPopupGtk::SHOW_AND_INSPECT); 2159 ExtensionPopupGtk::SHOW_AND_INSPECT);
2123 } 2160 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698