diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-03 01:23:44 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-03 01:23:44 +0000 |
commit | cec7f4b46458b6d04ddb1d7452c78c3a97d95f59 (patch) | |
tree | ba902b65bbbb63f8ed6507ccf4a7362735995c0b | |
parent | 4b1c7bd254bd0b39c50d16aa6195a82515a6b1a5 (diff) | |
download | chromium_src-cec7f4b46458b6d04ddb1d7452c78c3a97d95f59.zip chromium_src-cec7f4b46458b6d04ddb1d7452c78c3a97d95f59.tar.gz chromium_src-cec7f4b46458b6d04ddb1d7452c78c3a97d95f59.tar.bz2 |
Merge 53741 - Cleanup: Rename gtk button state names to (a) match other platforms and (b) not be misleading (e.g. "depressed" where it should be "disabled"). Better indenting. Inline a function that has only one caller for simplicity.
BUG=50107
TEST=none
Review URL: http://codereview.chromium.org/3029032
TBR=pkasting@chromium.org
Review URL: http://codereview.chromium.org/3076023
git-svn-id: svn://svn.chromium.org/chrome/branches/472/src@54666 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/gtk/back_forward_button_gtk.cc | 24 | ||||
-rw-r--r-- | chrome/browser/gtk/browser_toolbar_gtk.cc | 33 | ||||
-rw-r--r-- | chrome/browser/gtk/browser_toolbar_gtk.h | 12 | ||||
-rw-r--r-- | chrome/browser/gtk/custom_button.cc | 56 | ||||
-rw-r--r-- | chrome/browser/gtk/custom_button.h | 26 |
5 files changed, 67 insertions, 84 deletions
diff --git a/chrome/browser/gtk/back_forward_button_gtk.cc b/chrome/browser/gtk/back_forward_button_gtk.cc index 3519502..72559cc 100644 --- a/chrome/browser/gtk/back_forward_button_gtk.cc +++ b/chrome/browser/gtk/back_forward_button_gtk.cc @@ -26,36 +26,34 @@ BackForwardButtonGtk::BackForwardButtonGtk(Browser* browser, bool is_forward) : browser_(browser), is_forward_(is_forward), show_menu_factory_(this) { - int normal, active, highlight, depressed, background, tooltip; + int normal, pushed, hover, disabled, background, tooltip; const char* stock; if (is_forward) { normal = IDR_FORWARD; - active = IDR_FORWARD_P; - highlight = IDR_FORWARD_H; - depressed = IDR_FORWARD_D; + pushed = IDR_FORWARD_P; + hover = IDR_FORWARD_H; + disabled = IDR_FORWARD_D; background = IDR_FORWARD_MASK; tooltip = IDS_TOOLTIP_FORWARD; stock = GTK_STOCK_GO_FORWARD; } else { normal = IDR_BACK; - active = IDR_BACK_P; - highlight = IDR_BACK_H; - depressed = IDR_BACK_D; + pushed = IDR_BACK_P; + hover = IDR_BACK_H; + disabled = IDR_BACK_D; background = IDR_BACK_MASK; tooltip = IDS_TOOLTIP_BACK; stock = GTK_STOCK_GO_BACK; } button_.reset(new CustomDrawButton( GtkThemeProvider::GetFrom(browser_->profile()), - normal, active, highlight, depressed, background, stock, + normal, pushed, hover, disabled, background, stock, GTK_ICON_SIZE_SMALL_TOOLBAR)); gtk_widget_set_tooltip_text(widget(), l10n_util::GetStringUTF8(tooltip).c_str()); - menu_model_.reset( - new BackForwardMenuModel(browser, - is_forward ? - BackForwardMenuModel::FORWARD_MENU : - BackForwardMenuModel::BACKWARD_MENU)); + menu_model_.reset(new BackForwardMenuModel(browser, is_forward ? + BackForwardMenuModel::FORWARD_MENU : + BackForwardMenuModel::BACKWARD_MENU)); g_signal_connect(widget(), "clicked", G_CALLBACK(OnClickThunk), this); diff --git a/chrome/browser/gtk/browser_toolbar_gtk.cc b/chrome/browser/gtk/browser_toolbar_gtk.cc index a36eae8..442eedb 100644 --- a/chrome/browser/gtk/browser_toolbar_gtk.cc +++ b/chrome/browser/gtk/browser_toolbar_gtk.cc @@ -175,10 +175,16 @@ void BrowserToolbarGtk::Init(Profile* profile, gtk_box_pack_start(GTK_BOX(toolbar_left_), reload_->widget(), FALSE, FALSE, 0); - home_.reset(BuildToolbarButton(IDR_HOME, IDR_HOME_P, IDR_HOME_H, 0, - IDR_BUTTON_MASK, - l10n_util::GetStringUTF8(IDS_TOOLTIP_HOME), - GTK_STOCK_HOME, kToolbarWidgetSpacing)); + home_.reset(new CustomDrawButton(GtkThemeProvider::GetFrom(profile_), + IDR_HOME, IDR_HOME_P, IDR_HOME_H, 0, + IDR_BUTTON_MASK, GTK_STOCK_HOME, + GTK_ICON_SIZE_SMALL_TOOLBAR)); + gtk_widget_set_tooltip_text(home_->widget(), + l10n_util::GetStringUTF8(IDS_TOOLTIP_HOME).c_str()); + g_signal_connect(home_->widget(), "clicked", + G_CALLBACK(OnButtonClickThunk), this); + gtk_box_pack_start(GTK_BOX(toolbar_left_), home_->widget(), FALSE, FALSE, + kToolbarWidgetSpacing); gtk_util::SetButtonTriggersNavigation(home_->widget()); gtk_box_pack_start(GTK_BOX(toolbar_), toolbar_left_, FALSE, FALSE, 0); @@ -426,25 +432,6 @@ void BrowserToolbarGtk::UpdateTabContents(TabContents* contents, // BrowserToolbarGtk, private -------------------------------------------------- -CustomDrawButton* BrowserToolbarGtk::BuildToolbarButton( - int normal_id, int active_id, int highlight_id, int depressed_id, - int background_id, const std::string& localized_tooltip, - const char* stock_id, int spacing) { - CustomDrawButton* button = new CustomDrawButton( - GtkThemeProvider::GetFrom(profile_), - normal_id, active_id, highlight_id, depressed_id, background_id, stock_id, - GTK_ICON_SIZE_SMALL_TOOLBAR); - - gtk_widget_set_tooltip_text(button->widget(), - localized_tooltip.c_str()); - g_signal_connect(button->widget(), "clicked", - G_CALLBACK(OnButtonClickThunk), this); - - gtk_box_pack_start(GTK_BOX(toolbar_left_), button->widget(), FALSE, FALSE, - spacing); - return button; -} - GtkWidget* BrowserToolbarGtk::BuildToolbarMenuButton( const std::string& localized_tooltip, OwnedWidgetGtk* owner) { diff --git a/chrome/browser/gtk/browser_toolbar_gtk.h b/chrome/browser/gtk/browser_toolbar_gtk.h index 511ac49..bfd8339 100644 --- a/chrome/browser/gtk/browser_toolbar_gtk.h +++ b/chrome/browser/gtk/browser_toolbar_gtk.h @@ -120,18 +120,6 @@ class BrowserToolbarGtk : public CommandUpdater::CommandObserver, virtual void ActiveWindowChanged(GdkWindow* active_window); private: - // Builds a toolbar button with all the properties set. - // |spacing| is the width of padding (in pixels) on the left and right of the - // button. - CustomDrawButton* BuildToolbarButton(int normal_id, - int active_id, - int highlight_id, - int depressed_id, - int background_id, - const std::string& localized_tooltip, - const char* stock_id, - int spacing); - // Create a menu for the toolbar given the icon id and tooltip. Returns the // widget created. GtkWidget* BuildToolbarMenuButton(const std::string& localized_tooltip, diff --git a/chrome/browser/gtk/custom_button.cc b/chrome/browser/gtk/custom_button.cc index 3fee8da..a31ba9a 100644 --- a/chrome/browser/gtk/custom_button.cc +++ b/chrome/browser/gtk/custom_button.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -19,14 +19,17 @@ #include "third_party/skia/include/core/SkBitmap.h" CustomDrawButtonBase::CustomDrawButtonBase(GtkThemeProvider* theme_provider, - int normal_id, int active_id, int highlight_id, int depressed_id, - int background_id) + int normal_id, + int pressed_id, + int hover_id, + int disabled_id, + int background_id) : background_image_(NULL), paint_override_(-1), normal_id_(normal_id), - active_id_(active_id), - highlight_id_(highlight_id), - depressed_id_(depressed_id), + pressed_id_(pressed_id), + hover_id_(hover_id), + disabled_id_(disabled_id), button_background_id_(background_id), theme_provider_(theme_provider), flipped_(false) { @@ -46,14 +49,14 @@ CustomDrawButtonBase::CustomDrawButtonBase(GtkThemeProvider* theme_provider, // Load the button images from the resource bundle. ResourceBundle& rb = ResourceBundle::GetSharedInstance(); surfaces_[GTK_STATE_NORMAL]->UsePixbuf( - normal_id ? rb.GetRTLEnabledPixbufNamed(normal_id) : NULL); + normal_id_ ? rb.GetRTLEnabledPixbufNamed(normal_id_) : NULL); surfaces_[GTK_STATE_ACTIVE]->UsePixbuf( - active_id ? rb.GetRTLEnabledPixbufNamed(active_id) : NULL); + pressed_id_ ? rb.GetRTLEnabledPixbufNamed(pressed_id_) : NULL); surfaces_[GTK_STATE_PRELIGHT]->UsePixbuf( - highlight_id ? rb.GetRTLEnabledPixbufNamed(highlight_id) : NULL); + hover_id_ ? rb.GetRTLEnabledPixbufNamed(hover_id_) : NULL); surfaces_[GTK_STATE_SELECTED]->UsePixbuf(NULL); surfaces_[GTK_STATE_INSENSITIVE]->UsePixbuf( - depressed_id ? rb.GetRTLEnabledPixbufNamed(depressed_id) : NULL); + disabled_id_ ? rb.GetRTLEnabledPixbufNamed(disabled_id_) : NULL); } } @@ -144,13 +147,13 @@ void CustomDrawButtonBase::Observe(NotificationType type, surfaces_[GTK_STATE_NORMAL]->UsePixbuf(normal_id_ ? theme_provider_->GetRTLEnabledPixbufNamed(normal_id_) : NULL); - surfaces_[GTK_STATE_ACTIVE]->UsePixbuf(active_id_ ? - theme_provider_->GetRTLEnabledPixbufNamed(active_id_) : NULL); - surfaces_[GTK_STATE_PRELIGHT]->UsePixbuf(highlight_id_ ? - theme_provider_->GetRTLEnabledPixbufNamed(highlight_id_) : NULL); + surfaces_[GTK_STATE_ACTIVE]->UsePixbuf(pressed_id_ ? + theme_provider_->GetRTLEnabledPixbufNamed(pressed_id_) : NULL); + surfaces_[GTK_STATE_PRELIGHT]->UsePixbuf(hover_id_ ? + theme_provider_->GetRTLEnabledPixbufNamed(hover_id_) : NULL); surfaces_[GTK_STATE_SELECTED]->UsePixbuf(NULL); - surfaces_[GTK_STATE_INSENSITIVE]->UsePixbuf(depressed_id_ ? - theme_provider_->GetRTLEnabledPixbufNamed(depressed_id_) : NULL); + surfaces_[GTK_STATE_INSENSITIVE]->UsePixbuf(disabled_id_ ? + theme_provider_->GetRTLEnabledPixbufNamed(disabled_id_) : NULL); // Use the tinted background in some themes. if (button_background_id_) { @@ -228,9 +231,11 @@ gboolean CustomDrawHoverController::OnLeave( // CustomDrawButton ------------------------------------------------------------ -CustomDrawButton::CustomDrawButton(int normal_id, int active_id, - int highlight_id, int depressed_id) - : button_base_(NULL, normal_id, active_id, highlight_id, depressed_id, 0), +CustomDrawButton::CustomDrawButton(int normal_id, + int pressed_id, + int hover_id, + int disabled_id) + : button_base_(NULL, normal_id, pressed_id, hover_id, disabled_id, 0), theme_provider_(NULL), gtk_stock_name_(NULL), icon_size_(GTK_ICON_SIZE_INVALID) { @@ -241,10 +246,15 @@ CustomDrawButton::CustomDrawButton(int normal_id, int active_id, } CustomDrawButton::CustomDrawButton(GtkThemeProvider* theme_provider, - int normal_id, int active_id, int highlight_id, int depressed_id, - int background_id, const char* stock_id, GtkIconSize stock_size) - : button_base_(theme_provider, normal_id, active_id, highlight_id, - depressed_id, background_id), + int normal_id, + int pressed_id, + int hover_id, + int disabled_id, + int background_id, + const char* stock_id, + GtkIconSize stock_size) + : button_base_(theme_provider, normal_id, pressed_id, hover_id, + disabled_id, background_id), theme_provider_(theme_provider), gtk_stock_name_(stock_id), icon_size_(stock_size) { diff --git a/chrome/browser/gtk/custom_button.h b/chrome/browser/gtk/custom_button.h index 7c79e42..3e8cda0 100644 --- a/chrome/browser/gtk/custom_button.h +++ b/chrome/browser/gtk/custom_button.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -33,9 +33,9 @@ class CustomDrawButtonBase : public NotificationObserver { // pass in NULL for |theme_provider|. CustomDrawButtonBase(GtkThemeProvider* theme_provider, int normal_id, - int active_id, - int highlight_id, - int depressed_id, + int pressed_id, + int hover_id, + int disabled_id, int background_id); ~CustomDrawButtonBase(); @@ -78,9 +78,9 @@ class CustomDrawButtonBase : public NotificationObserver { // We need to remember the image ids that the user passes in and the theme // provider so we can reload images if the user changes theme. int normal_id_; - int active_id_; - int highlight_id_; - int depressed_id_; + int pressed_id_; + int hover_id_; + int disabled_id_; int button_background_id_; GtkThemeProvider* theme_provider_; @@ -132,16 +132,16 @@ class CustomDrawButton : public NotificationObserver { // The constructor takes 4 resource ids. If a resource doesn't exist for a // button, pass in 0. CustomDrawButton(int normal_id, - int active_id, - int highlight_id, - int depressed_id); + int pressed_id, + int hover_id, + int disabled_id); // Same as above, but uses themed (and possibly tinted) images. CustomDrawButton(GtkThemeProvider* theme_provider, int normal_id, - int active_id, - int highlight_id, - int depressed_id, + int pressed_id, + int hover_id, + int disabled_id, int background_id, const char* stock_id, GtkIconSize stock_size); |