summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk/browser_actions_toolbar_gtk.cc
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-17 01:13:37 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-17 01:13:37 +0000
commitfee8f0222a5f2a377ba5d7f2d3383481c02eafac (patch)
tree0542f26a1076b07d0857298b7a9fc694a61422cb /chrome/browser/gtk/browser_actions_toolbar_gtk.cc
parent8fa18a33d2dee21f748139ef503d08ebb4b706af (diff)
downloadchromium_src-fee8f0222a5f2a377ba5d7f2d3383481c02eafac.zip
chromium_src-fee8f0222a5f2a377ba5d7f2d3383481c02eafac.tar.gz
chromium_src-fee8f0222a5f2a377ba5d7f2d3383481c02eafac.tar.bz2
Add a pref for the number of showing icons in the browser actions toolbar.
Also fix some issues on GTK concerning the proper behavior when adding/removing browser actions (container sizing + chevron visibility). Windows uses a different pref (kBrowserActionContainerWidth), which is measured in pixels; it should be migrated to the new pref. Also, register extension prefs during startup. BUG=32101 TEST=manual Review URL: http://codereview.chromium.org/841007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41800 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/browser_actions_toolbar_gtk.cc')
-rw-r--r--chrome/browser/gtk/browser_actions_toolbar_gtk.cc35
1 files changed, 23 insertions, 12 deletions
diff --git a/chrome/browser/gtk/browser_actions_toolbar_gtk.cc b/chrome/browser/gtk/browser_actions_toolbar_gtk.cc
index 7a9ecdf..60c509f 100644
--- a/chrome/browser/gtk/browser_actions_toolbar_gtk.cc
+++ b/chrome/browser/gtk/browser_actions_toolbar_gtk.cc
@@ -277,6 +277,8 @@ class BrowserActionButton : public NotificationObserver,
friend class BrowserActionsToolbarGtk;
};
+// BrowserActionsToolbarGtk ----------------------------------------------------
+
BrowserActionsToolbarGtk::BrowserActionsToolbarGtk(Browser* browser)
: browser_(browser),
profile_(browser->profile()),
@@ -330,8 +332,11 @@ BrowserActionsToolbarGtk::BrowserActionsToolbarGtk(Browser* browser)
G_CALLBACK(OnHierarchyChangedThunk), this);
int showing_actions = model_->GetVisibleIconCount();
- if (showing_actions >= 0)
+ if (showing_actions >= 0) {
SetButtonHBoxWidth(WidthForIconCount(showing_actions));
+ if (showing_actions < static_cast<int>(model_->size()))
+ gtk_widget_show(overflow_button_.widget());
+ }
ViewIDUtil::SetID(button_hbox_, VIEW_ID_BROWSER_ACTION_TOOLBAR);
}
@@ -453,21 +458,21 @@ void BrowserActionsToolbarGtk::AnimateToShowNIcons(int count) {
resize_animation_.Show();
}
-void BrowserActionsToolbarGtk::ButtonAddedOrRemoved() {
- // TODO(estade): this is a little bit janky looking when the removed button
- // is not the farthest right button.
+void BrowserActionsToolbarGtk::BrowserActionAdded(Extension* extension,
+ int index) {
+ CreateButtonForExtension(extension, index);
+
+ // If we are still initializing the container, don't bother animating.
+ if (model_->size() != extension_button_map_.size())
+ return;
+
+ // Animate the addition if we are showing all browser action buttons.
if (!GTK_WIDGET_VISIBLE(overflow_button_.widget())) {
AnimateToShowNIcons(button_count());
model_->SetVisibleIconCount(button_count());
}
}
-void BrowserActionsToolbarGtk::BrowserActionAdded(Extension* extension,
- int index) {
- CreateButtonForExtension(extension, index);
- ButtonAddedOrRemoved();
-}
-
void BrowserActionsToolbarGtk::BrowserActionRemoved(Extension* extension) {
if (drag_button_ != NULL) {
// Break the current drag.
@@ -475,7 +480,13 @@ void BrowserActionsToolbarGtk::BrowserActionRemoved(Extension* extension) {
}
RemoveButtonForExtension(extension);
- ButtonAddedOrRemoved();
+
+ if (!GTK_WIDGET_VISIBLE(overflow_button_.widget())) {
+ AnimateToShowNIcons(button_count());
+ model_->SetVisibleIconCount(button_count());
+ } else if (button_count() <= model_->GetVisibleIconCount()) {
+ gtk_widget_hide(overflow_button_.widget());
+ }
}
void BrowserActionsToolbarGtk::BrowserActionMoved(Extension* extension,
@@ -556,7 +567,6 @@ void BrowserActionsToolbarGtk::SetButtonHBoxWidth(int new_width) {
gtk_chrome_shrinkable_hbox_get_visible_child_count(
GTK_CHROME_SHRINKABLE_HBOX(button_hbox_));
- model_->SetVisibleIconCount(showing_icon_count);
if (model_->size() > static_cast<size_t>(showing_icon_count)) {
if (!GTK_WIDGET_VISIBLE(overflow_button_.widget())) {
// When the overflow chevron shows for the first time, take that
@@ -698,6 +708,7 @@ gboolean BrowserActionsToolbarGtk::OnGripperButtonRelease(
gtk_chrome_shrinkable_hbox_get_visible_child_count(
GTK_CHROME_SHRINKABLE_HBOX(button_hbox_));
AnimateToShowNIcons(visible_icon_count);
+ model_->SetVisibleIconCount(visible_icon_count);
return FALSE;
}