Revert "Add button tinting to the toolbar buttons."
This reverts commit r20396. TBR=erg Review URL: http://codereview.chromium.org/155367 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20399 0039d316-1c4b-4281-b951-d872f2087c98
Esse commit está contido em:
@@ -12,7 +12,6 @@
|
||||
#include "chrome/browser/browser.h"
|
||||
#include "chrome/browser/gtk/back_forward_menu_model_gtk.h"
|
||||
#include "chrome/browser/gtk/menu_gtk.h"
|
||||
#include "chrome/browser/profile.h"
|
||||
#include "chrome/common/gtk_util.h"
|
||||
#include "grit/generated_resources.h"
|
||||
#include "grit/theme_resources.h"
|
||||
@@ -42,8 +41,8 @@ BackForwardButtonGtk::BackForwardButtonGtk(Browser* browser, bool is_forward)
|
||||
tooltip = IDS_TOOLTIP_BACK;
|
||||
stock = GTK_STOCK_GO_BACK;
|
||||
}
|
||||
button_.reset(new CustomDrawButton(browser_->profile()->GetThemeProvider(),
|
||||
normal, active, highlight, depressed, stock));
|
||||
button_.reset(new CustomDrawButton(normal, active, highlight, depressed,
|
||||
stock));
|
||||
gtk_widget_set_tooltip_text(widget(),
|
||||
l10n_util::GetStringUTF8(tooltip).c_str());
|
||||
menu_model_.reset(new BackForwardMenuModelGtk(browser,
|
||||
|
||||
@@ -328,8 +328,8 @@ gfx::Rect BrowserToolbarGtk::GetPopupBounds() const {
|
||||
CustomDrawButton* BrowserToolbarGtk::BuildToolbarButton(
|
||||
int normal_id, int active_id, int highlight_id, int depressed_id,
|
||||
const std::string& localized_tooltip, const char* stock_id) {
|
||||
CustomDrawButton* button = new CustomDrawButton(profile_->GetThemeProvider(),
|
||||
normal_id, active_id, highlight_id, depressed_id, stock_id);
|
||||
CustomDrawButton* button = new CustomDrawButton(normal_id, active_id,
|
||||
highlight_id, depressed_id, stock_id);
|
||||
|
||||
gtk_widget_set_tooltip_text(button->widget(),
|
||||
localized_tooltip.c_str());
|
||||
|
||||
@@ -6,43 +6,28 @@
|
||||
|
||||
#include "app/l10n_util.h"
|
||||
#include "app/resource_bundle.h"
|
||||
#include "app/theme_provider.h"
|
||||
#include "base/basictypes.h"
|
||||
#include "base/gfx/gtk_util.h"
|
||||
#include "chrome/common/notification_service.h"
|
||||
|
||||
#include "grit/theme_resources.h"
|
||||
|
||||
CustomDrawButtonBase::CustomDrawButtonBase(ThemeProvider* theme_provider,
|
||||
int normal_id, int active_id, int highlight_id, int depressed_id)
|
||||
: paint_override_(-1),
|
||||
normal_id_(normal_id),
|
||||
active_id_(active_id),
|
||||
highlight_id_(highlight_id),
|
||||
depressed_id_(depressed_id),
|
||||
theme_provider_(theme_provider) {
|
||||
if (theme_provider) {
|
||||
// Load images by pretending that we got a BROWSER_THEME_CHANGED
|
||||
// notification.
|
||||
Observe(NotificationType::BROWSER_THEME_CHANGED,
|
||||
NotificationService::AllSources(),
|
||||
NotificationService::NoDetails());
|
||||
|
||||
registrar_.Add(this,
|
||||
NotificationType::BROWSER_THEME_CHANGED,
|
||||
NotificationService::AllSources());
|
||||
} else {
|
||||
// Load the button images from the resource bundle.
|
||||
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
|
||||
pixbufs_[GTK_STATE_NORMAL] =
|
||||
normal_id ? rb.GetRTLEnabledPixbufNamed(normal_id) : NULL;
|
||||
pixbufs_[GTK_STATE_ACTIVE] =
|
||||
active_id ? rb.GetRTLEnabledPixbufNamed(active_id) : NULL;
|
||||
pixbufs_[GTK_STATE_PRELIGHT] =
|
||||
highlight_id ? rb.GetRTLEnabledPixbufNamed(highlight_id) : NULL;
|
||||
pixbufs_[GTK_STATE_SELECTED] = NULL;
|
||||
pixbufs_[GTK_STATE_INSENSITIVE] =
|
||||
depressed_id ? rb.GetRTLEnabledPixbufNamed(depressed_id) : NULL;
|
||||
}
|
||||
CustomDrawButtonBase::CustomDrawButtonBase(
|
||||
int normal_id,
|
||||
int active_id,
|
||||
int highlight_id,
|
||||
int depressed_id)
|
||||
: paint_override_(-1) {
|
||||
// Load the button images from the resource bundle.
|
||||
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
|
||||
pixbufs_[GTK_STATE_NORMAL] =
|
||||
normal_id ? rb.GetRTLEnabledPixbufNamed(normal_id) : NULL;
|
||||
pixbufs_[GTK_STATE_ACTIVE] =
|
||||
active_id ? rb.GetRTLEnabledPixbufNamed(active_id) : NULL;
|
||||
pixbufs_[GTK_STATE_PRELIGHT] =
|
||||
highlight_id ? rb.GetRTLEnabledPixbufNamed(highlight_id) : NULL;
|
||||
pixbufs_[GTK_STATE_SELECTED] = NULL;
|
||||
pixbufs_[GTK_STATE_INSENSITIVE] =
|
||||
depressed_id ? rb.GetRTLEnabledPixbufNamed(depressed_id) : NULL;
|
||||
}
|
||||
|
||||
CustomDrawButtonBase::~CustomDrawButtonBase() {
|
||||
@@ -76,51 +61,24 @@ gboolean CustomDrawButtonBase::OnExpose(GtkWidget* widget, GdkEventExpose* e) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CustomDrawButtonBase::Observe(NotificationType type,
|
||||
const NotificationSource& source, const NotificationDetails& details) {
|
||||
DCHECK(theme_provider_);
|
||||
DCHECK(NotificationType::BROWSER_THEME_CHANGED == type);
|
||||
|
||||
// TODO(tc): Add GetRTLEnabledPixbufNamed to ThemeProviderGtk.
|
||||
pixbufs_[GTK_STATE_NORMAL] =
|
||||
normal_id_ ? theme_provider_->GetPixbufNamed(normal_id_) : NULL;
|
||||
pixbufs_[GTK_STATE_ACTIVE] =
|
||||
active_id_ ? theme_provider_->GetPixbufNamed(active_id_) : NULL;
|
||||
pixbufs_[GTK_STATE_PRELIGHT] =
|
||||
highlight_id_ ? theme_provider_->GetPixbufNamed(highlight_id_) : NULL;
|
||||
pixbufs_[GTK_STATE_SELECTED] = NULL;
|
||||
pixbufs_[GTK_STATE_INSENSITIVE] =
|
||||
depressed_id_ ? theme_provider_->GetPixbufNamed(depressed_id_) : NULL;
|
||||
}
|
||||
|
||||
CustomDrawButton::CustomDrawButton(int normal_id, int active_id,
|
||||
int highlight_id, int depressed_id, const char* stock_id)
|
||||
: button_base_(NULL, normal_id, active_id, highlight_id, depressed_id),
|
||||
gtk_stock_name_(stock_id),
|
||||
has_expose_signal_handler_(false) {
|
||||
Init();
|
||||
}
|
||||
|
||||
CustomDrawButton::CustomDrawButton(ThemeProvider* theme_provider,
|
||||
int normal_id, int active_id, int highlight_id, int depressed_id,
|
||||
CustomDrawButton::CustomDrawButton(
|
||||
int normal_id,
|
||||
int active_id,
|
||||
int highlight_id,
|
||||
int depressed_id,
|
||||
const char* stock_id)
|
||||
: button_base_(theme_provider, normal_id, active_id, highlight_id,
|
||||
depressed_id),
|
||||
: button_base_(normal_id, active_id, highlight_id, depressed_id),
|
||||
gtk_stock_name_(stock_id),
|
||||
has_expose_signal_handler_(false) {
|
||||
Init();
|
||||
widget_.Own(gtk_button_new());
|
||||
GTK_WIDGET_UNSET_FLAGS(widget_.get(), GTK_CAN_FOCUS);
|
||||
SetUseSystemTheme(false);
|
||||
}
|
||||
|
||||
CustomDrawButton::~CustomDrawButton() {
|
||||
widget_.Destroy();
|
||||
}
|
||||
|
||||
void CustomDrawButton::Init() {
|
||||
widget_.Own(gtk_button_new());
|
||||
GTK_WIDGET_UNSET_FLAGS(widget_.get(), GTK_CAN_FOCUS);
|
||||
SetUseSystemTheme(false);
|
||||
}
|
||||
|
||||
void CustomDrawButton::SetUseSystemTheme(bool use_gtk) {
|
||||
if (use_gtk && gtk_stock_name_) {
|
||||
gtk_button_set_image(
|
||||
|
||||
@@ -11,28 +11,20 @@
|
||||
|
||||
#include "base/gfx/rect.h"
|
||||
#include "base/scoped_ptr.h"
|
||||
#include "chrome/common/notification_observer.h"
|
||||
#include "chrome/common/notification_registrar.h"
|
||||
#include "chrome/common/owned_widget_gtk.h"
|
||||
|
||||
class ThemeProvider;
|
||||
|
||||
// These classes implement two kinds of custom-drawn buttons. They're
|
||||
// used on the toolbar and the bookmarks bar.
|
||||
|
||||
// CustomDrawButtonBase provides the base for building a custom drawn button.
|
||||
// It handles managing the pixbufs containing all the static images used to draw
|
||||
// the button. It also manages painting these pixbufs.
|
||||
class CustomDrawButtonBase : public NotificationObserver {
|
||||
class CustomDrawButtonBase {
|
||||
public:
|
||||
// If the images come from ResourceBundle rather than the theme provider,
|
||||
// pass in NULL for |theme_provider|.
|
||||
CustomDrawButtonBase(ThemeProvider* theme_provider,
|
||||
int normal_id,
|
||||
CustomDrawButtonBase(int normal_id,
|
||||
int active_id,
|
||||
int highlight_id,
|
||||
int depressed_id);
|
||||
|
||||
~CustomDrawButtonBase();
|
||||
|
||||
GdkPixbuf* pixbufs(int i) const { return pixbufs_[i]; }
|
||||
@@ -41,11 +33,6 @@ class CustomDrawButtonBase : public NotificationObserver {
|
||||
|
||||
void set_paint_override(int state) { paint_override_ = state; }
|
||||
|
||||
// Provide NotificationObserver implementation.
|
||||
virtual void Observe(NotificationType type,
|
||||
const NotificationSource& source,
|
||||
const NotificationDetails& details);
|
||||
|
||||
private:
|
||||
// We store one GdkPixbuf* for each possible state of the button;
|
||||
// INSENSITIVE is the last available state;
|
||||
@@ -54,17 +41,6 @@ class CustomDrawButtonBase : public NotificationObserver {
|
||||
// If non-negative, the state to paint the button.
|
||||
int paint_override_;
|
||||
|
||||
// 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_;
|
||||
ThemeProvider* theme_provider_;
|
||||
|
||||
// Used to listen for theme change notifications.
|
||||
NotificationRegistrar registrar_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(CustomDrawButtonBase);
|
||||
};
|
||||
|
||||
@@ -80,19 +56,9 @@ class CustomDrawButton {
|
||||
int highlight_id,
|
||||
int depressed_id,
|
||||
const char* stock_id);
|
||||
|
||||
// Same as above, but uses themed (and possibly tinted) images.
|
||||
CustomDrawButton(ThemeProvider* theme_provider,
|
||||
int normal_id,
|
||||
int active_id,
|
||||
int highlight_id,
|
||||
int depressed_id,
|
||||
const char* stock_id);
|
||||
|
||||
explicit CustomDrawButton(const std::string& filename);
|
||||
~CustomDrawButton();
|
||||
|
||||
void Init();
|
||||
|
||||
GtkWidget* widget() const { return widget_.get(); }
|
||||
|
||||
gfx::Rect bounds() const {
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include "chrome/app/chrome_dll_resource.h"
|
||||
#include "chrome/browser/browser.h"
|
||||
#include "chrome/browser/gtk/location_bar_view_gtk.h"
|
||||
#include "chrome/browser/profile.h"
|
||||
#include "grit/generated_resources.h"
|
||||
#include "grit/theme_resources.h"
|
||||
|
||||
@@ -22,10 +21,8 @@ GoButtonGtk::GoButtonGtk(LocationBarViewGtk* location_bar, Browser* browser)
|
||||
intended_mode_(MODE_GO),
|
||||
visible_mode_(MODE_GO),
|
||||
state_(BS_NORMAL),
|
||||
go_(browser->profile()->GetThemeProvider(), IDR_GO, IDR_GO_P, IDR_GO_H,
|
||||
0),
|
||||
stop_(browser->profile()->GetThemeProvider(), IDR_STOP, IDR_STOP_P,
|
||||
IDR_STOP_H, 0),
|
||||
go_(IDR_GO, IDR_GO_P, IDR_GO_H, 0),
|
||||
stop_(IDR_STOP, IDR_STOP_P, IDR_STOP_H, 0),
|
||||
widget_(gtk_button_new()) {
|
||||
gtk_widget_set_size_request(widget_.get(),
|
||||
gdk_pixbuf_get_width(go_.pixbufs(0)),
|
||||
|
||||
@@ -8,17 +8,14 @@
|
||||
#include "base/gfx/rect.h"
|
||||
#include "chrome/browser/gtk/bookmark_bubble_gtk.h"
|
||||
#include "chrome/browser/gtk/browser_toolbar_gtk.h"
|
||||
#include "chrome/browser/profile.h"
|
||||
#include "grit/theme_resources.h"
|
||||
|
||||
ToolbarStarToggleGtk::ToolbarStarToggleGtk(BrowserToolbarGtk* host)
|
||||
: host_(host),
|
||||
widget_(gtk_button_new()),
|
||||
is_starred_(false),
|
||||
unstarred_(host->profile()->GetThemeProvider(), IDR_STAR, IDR_STAR_P,
|
||||
IDR_STAR_H, IDR_STAR_D),
|
||||
starred_(host->profile()->GetThemeProvider(), IDR_STARRED, IDR_STARRED_P,
|
||||
IDR_STARRED_H, 0) {
|
||||
unstarred_(IDR_STAR, IDR_STAR_P, IDR_STAR_H, IDR_STAR_D),
|
||||
starred_(IDR_STARRED, IDR_STARRED_P, IDR_STARRED_H, 0) {
|
||||
gtk_widget_set_size_request(widget_.get(),
|
||||
gdk_pixbuf_get_width(unstarred_.pixbufs(0)),
|
||||
gdk_pixbuf_get_height(unstarred_.pixbufs(0)));
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário