Chromium Code Reviews| Index: chrome/browser/ui/gtk/location_bar_view_gtk.cc |
| diff --git a/chrome/browser/ui/gtk/location_bar_view_gtk.cc b/chrome/browser/ui/gtk/location_bar_view_gtk.cc |
| index 05d3990a8acc46b39f2e99a349aa9fb5dc8e16d6..31e7ba9f094e737cc4eaa57e866f5ac143ace018 100644 |
| --- a/chrome/browser/ui/gtk/location_bar_view_gtk.cc |
| +++ b/chrome/browser/ui/gtk/location_bar_view_gtk.cc |
| @@ -386,10 +386,24 @@ GdkColor WebIntentsButtonViewGtk::gradient_bottom_color() const { |
| const GdkColor LocationBarViewGtk::kBackgroundColor = |
| GDK_COLOR_RGB(255, 255, 255); |
| +class LocationBarViewGtk::ShowStarBubbleAction { |
|
Evan Stade
2012/08/30 22:32:25
I'd just use a pair. At the very least it should b
|
| + public: |
| + ShowStarBubbleAction(GURL url, bool newly_bookmarked); |
| + |
| + GURL url_; |
| + bool newly_bookmarked_; |
| +}; |
| + |
| +LocationBarViewGtk::ShowStarBubbleAction::ShowStarBubbleAction( |
| + GURL url, |
| + bool newly_bookmarked) |
| + : url_(url), newly_bookmarked_(newly_bookmarked) {} |
| + |
| LocationBarViewGtk::LocationBarViewGtk(Browser* browser) |
| : zoom_image_(NULL), |
| star_image_(NULL), |
| starred_(false), |
| + star_sized_(false), |
| site_type_alignment_(NULL), |
| site_type_event_box_(NULL), |
| location_icon_image_(NULL), |
| @@ -557,7 +571,9 @@ void LocationBarViewGtk::Init(bool popup_window_mode) { |
| gtk_box_pack_end(GTK_BOX(hbox_.get()), alignment, |
| FALSE, FALSE, 0); |
| - } else if (browser_defaults::bookmarks_enabled && !ShouldOnlyShowLocation()) { |
| + } |
| + |
| + if (browser_defaults::bookmarks_enabled && !ShouldOnlyShowLocation()) { |
| // Hide the star icon in popups, app windows, etc. |
| CreateStarButton(); |
| gtk_box_pack_end(GTK_BOX(hbox_.get()), star_.get(), FALSE, FALSE, 0); |
| @@ -842,6 +858,10 @@ void LocationBarViewGtk::CreateStarButton() { |
| VIEW_ID_STAR_BUTTON, |
| IDS_TOOLTIP_STAR, |
| OnStarButtonPressThunk)); |
| + // We need to track when the star button is resized to show any bubble |
| + // attached to it at this time. |
| + g_signal_connect(star_image_, "size-allocate", |
| + G_CALLBACK(&OnStarButtonSizeAllocateThunk), this); |
| } |
| void LocationBarViewGtk::OnInputInProgress(bool in_progress) { |
| @@ -1459,6 +1479,17 @@ gboolean LocationBarViewGtk::OnZoomButtonPress(GtkWidget* widget, |
| return FALSE; |
| } |
| +void LocationBarViewGtk::OnStarButtonSizeAllocate(GtkWidget* sender, |
| + GtkAllocation* allocation) { |
| + if (show_star_bubble_action_.get()) { |
| + BookmarkBubbleGtk::Show(star_.get(), browser_->profile(), |
| + show_star_bubble_action_->url_, |
| + show_star_bubble_action_->newly_bookmarked_); |
| + show_star_bubble_action_.reset(); |
| + } |
| + star_sized_ = true; |
| +} |
| + |
| gboolean LocationBarViewGtk::OnStarButtonPress(GtkWidget* widget, |
| GdkEventButton* event) { |
| if (event->button == 1) { |
| @@ -1480,8 +1511,12 @@ void LocationBarViewGtk::ShowStarBubble(const GURL& url, |
| if (!star_.get()) |
| return; |
| - BookmarkBubbleGtk::Show(star_.get(), browser_->profile(), url, |
| - newly_bookmarked); |
| + if (star_sized_) |
|
Evan Stade
2012/08/30 22:32:25
curlies
beaudoin
2012/08/31 13:27:09
Done.
|
| + BookmarkBubbleGtk::Show(star_.get(), browser_->profile(), url, |
| + newly_bookmarked); |
| + else |
| + show_star_bubble_action_.reset( |
| + new ShowStarBubbleAction(url, newly_bookmarked)); |
| } |
| void LocationBarViewGtk::ShowChromeToMobileBubble() { |
| @@ -1532,15 +1567,20 @@ void LocationBarViewGtk::UpdateZoomIcon() { |
| void LocationBarViewGtk::UpdateStarIcon() { |
| if (!star_.get()) |
| return; |
| + // Indicate the star icon is not correctly sized. It will be marked as sized |
| + // when the next size-allocate signal is received by the star widget. |
| + star_sized_ = false; |
| bool star_enabled = !toolbar_model_->input_in_progress() && |
| edit_bookmarks_enabled_.GetValue(); |
| command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled); |
| + if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableActionBox) && |
| + !starred_) |
|
Evan Stade
2012/08/30 22:32:25
curlies
beaudoin
2012/08/31 13:27:09
Done.
|
| + star_enabled = false; |
| if (star_enabled) { |
| gtk_widget_show_all(star_.get()); |
| int id = starred_ ? IDR_STAR_LIT : IDR_STAR; |
| - gtk_image_set_from_pixbuf( |
| - GTK_IMAGE(star_image_), |
| - theme_service_->GetImageNamed(id)->ToGdkPixbuf()); |
| + gtk_image_set_from_pixbuf(GTK_IMAGE(star_image_), |
| + theme_service_->GetImageNamed(id)->ToGdkPixbuf()); |
| } else { |
| gtk_widget_hide_all(star_.get()); |
| } |