summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-28 00:28:35 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-28 00:28:35 +0000
commit357f1705d94ad22ef188f381e9b5277a41e3e96c (patch)
tree382ff76f7e824c216873316c066c3f985f669b10 /chrome/browser/gtk
parente2cc2e694c2cbf6092fc5549963e764bf3b1ba0d (diff)
downloadchromium_src-357f1705d94ad22ef188f381e9b5277a41e3e96c.zip
chromium_src-357f1705d94ad22ef188f381e9b5277a41e3e96c.tar.gz
chromium_src-357f1705d94ad22ef188f381e9b5277a41e3e96c.tar.bz2
[GTK] fix extension install bubble positioning.
This should fix the position of the extension install bubble for both visible and overflow browser actions. Mirrors the approach used on windows. BUG=53326 TEST=manual Review URL: http://codereview.chromium.org/3218001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57757 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r--chrome/browser/gtk/browser_actions_toolbar_gtk.cc11
-rw-r--r--chrome/browser/gtk/browser_actions_toolbar_gtk.h5
-rw-r--r--chrome/browser/gtk/extension_installed_bubble_gtk.cc32
-rw-r--r--chrome/browser/gtk/extension_installed_bubble_gtk.h4
4 files changed, 40 insertions, 12 deletions
diff --git a/chrome/browser/gtk/browser_actions_toolbar_gtk.cc b/chrome/browser/gtk/browser_actions_toolbar_gtk.cc
index 0f2a332..a825d94 100644
--- a/chrome/browser/gtk/browser_actions_toolbar_gtk.cc
+++ b/chrome/browser/gtk/browser_actions_toolbar_gtk.cc
@@ -392,14 +392,13 @@ BrowserActionsToolbarGtk::BrowserActionsToolbarGtk(Browser* browser)
G_CALLBACK(OnGripperButtonReleaseThunk), this);
signals_.Connect(gripper, "button-press-event",
G_CALLBACK(OnGripperButtonPressThunk), this);
- signals_.Connect(overflow_button_->widget(), "button-press-event",
+ signals_.Connect(chevron(), "button-press-event",
G_CALLBACK(OnOverflowButtonPressThunk), this);
// |overflow_alignment| adds padding to the right of the browser action
// buttons, but only appears when the overflow menu is showing.
overflow_alignment_ = gtk_alignment_new(0, 0, 1, 1);
- gtk_container_add(GTK_CONTAINER(overflow_alignment_),
- overflow_button_->widget());
+ gtk_container_add(GTK_CONTAINER(overflow_alignment_), chevron());
// |overflow_area_| holds the overflow chevron and the separator, which
// is only shown in GTK+ theme mode.
@@ -661,7 +660,7 @@ void BrowserActionsToolbarGtk::ExecuteCommand(int command_id) {
if (browser_action->HasPopup(tab_id)) {
ExtensionPopupGtk::Show(
browser_action->GetPopupUrl(tab_id), browser(),
- overflow_button_->widget(),
+ chevron(),
false);
} else {
ExtensionBrowserEventRouter::GetInstance()->BrowserActionExecuted(
@@ -709,7 +708,7 @@ void BrowserActionsToolbarGtk::UpdateChevronVisibility() {
// take that much space away from |button_hbox_| to make the drag look
// smoother.
GtkRequisition req;
- gtk_widget_size_request(overflow_button_->widget(), &req);
+ gtk_widget_size_request(chevron(), &req);
gint overflow_width = req.width;
gtk_widget_size_request(button_hbox_.get(), &req);
gint button_hbox_width = req.width;
@@ -882,7 +881,7 @@ gboolean BrowserActionsToolbarGtk::OnOverflowButtonPress(
G_CALLBACK(OnOverflowMenuButtonPressThunk), this);
overflow_button_->SetPaintOverride(GTK_STATE_ACTIVE);
- overflow_menu_->PopupAsFromKeyEvent(overflow_button_->widget());
+ overflow_menu_->PopupAsFromKeyEvent(chevron());
return FALSE;
}
diff --git a/chrome/browser/gtk/browser_actions_toolbar_gtk.h b/chrome/browser/gtk/browser_actions_toolbar_gtk.h
index 672e9c3..b80ef59 100644
--- a/chrome/browser/gtk/browser_actions_toolbar_gtk.h
+++ b/chrome/browser/gtk/browser_actions_toolbar_gtk.h
@@ -42,6 +42,7 @@ class BrowserActionsToolbarGtk : public ExtensionToolbarModel::Observer,
virtual ~BrowserActionsToolbarGtk();
GtkWidget* widget() { return hbox_.get(); }
+ GtkWidget* chevron() { return overflow_button_->widget(); }
// Returns the widget in use by the BrowserActionButton corresponding to
// |extension|. Used in positioning the ExtensionInstalledBubble for
@@ -63,6 +64,10 @@ class BrowserActionsToolbarGtk : public ExtensionToolbarModel::Observer,
const NotificationSource& source,
const NotificationDetails& details);
+ bool animating() {
+ return resize_animation_.is_animating();
+ }
+
private:
friend class BrowserActionButton;
diff --git a/chrome/browser/gtk/extension_installed_bubble_gtk.cc b/chrome/browser/gtk/extension_installed_bubble_gtk.cc
index abaa32d..7d97f9a 100644
--- a/chrome/browser/gtk/extension_installed_bubble_gtk.cc
+++ b/chrome/browser/gtk/extension_installed_bubble_gtk.cc
@@ -32,6 +32,12 @@ const int kIconSize = 43;
const int kTextColumnVerticalSpacing = 7;
const int kTextColumnWidth = 350;
+// When showing the bubble for a new browser action, we may have to wait for
+// the toolbar to finish animating to know where the item's final position
+// will be.
+const int kAnimationWaitRetries = 10;
+const int kAnimationWaitMS = 50;
+
// Padding between content and edge of info bubble.
const int kContentBorder = 7;
@@ -47,7 +53,8 @@ ExtensionInstalledBubbleGtk::ExtensionInstalledBubbleGtk(Extension *extension,
SkBitmap icon)
: extension_(extension),
browser_(browser),
- icon_(icon) {
+ icon_(icon),
+ animation_wait_retries_(kAnimationWaitRetries) {
AddRef(); // Balanced in Close().
if (extension_->browser_action()) {
@@ -91,16 +98,29 @@ void ExtensionInstalledBubbleGtk::ShowInternal() {
GtkWidget* reference_widget = NULL;
if (type_ == BROWSER_ACTION) {
- reference_widget = browser_window->GetToolbar()->GetBrowserActionsToolbar()
- ->GetBrowserActionWidget(extension_);
+ BrowserActionsToolbarGtk* toolbar =
+ browser_window->GetToolbar()->GetBrowserActionsToolbar();
+
+ if (toolbar->animating() && animation_wait_retries_-- > 0) {
+ MessageLoopForUI::current()->PostDelayedTask(
+ FROM_HERE,
+ NewRunnableMethod(this, &ExtensionInstalledBubbleGtk::ShowInternal),
+ kAnimationWaitMS);
+ return;
+ }
+
+ reference_widget = toolbar->GetBrowserActionWidget(extension_);
// glib delays recalculating layout, but we need reference_widget to know
// its coordinates, so we force a check_resize here.
gtk_container_check_resize(GTK_CONTAINER(
browser_window->GetToolbar()->widget()));
// If the widget is not visible then browser_window could be incognito
- // with this extension disabled. Fall back to default position.
- if (reference_widget && !GTK_WIDGET_VISIBLE(reference_widget))
- reference_widget = NULL;
+ // with this extension disabled. Try showing it on the chevron.
+ // If that fails, fall back to default position.
+ if (reference_widget && !GTK_WIDGET_VISIBLE(reference_widget)) {
+ reference_widget = GTK_WIDGET_VISIBLE(toolbar->chevron()) ?
+ toolbar->chevron() : NULL;
+ }
} else if (type_ == PAGE_ACTION) {
LocationBarViewGtk* location_bar_view =
browser_window->GetToolbar()->GetLocationBarView();
diff --git a/chrome/browser/gtk/extension_installed_bubble_gtk.h b/chrome/browser/gtk/extension_installed_bubble_gtk.h
index 7bf2983..17b6672d 100644
--- a/chrome/browser/gtk/extension_installed_bubble_gtk.h
+++ b/chrome/browser/gtk/extension_installed_bubble_gtk.h
@@ -80,6 +80,10 @@ class ExtensionInstalledBubbleGtk
NotificationRegistrar registrar_;
BubbleType type_;
+ // The number of times to retry showing the bubble if the browser action
+ // toolbar is animating.
+ int animation_wait_retries_;
+
// The 'x' that the user can press to hide the info bubble shelf.
scoped_ptr<CustomDrawButton> close_button_;