summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk/custom_button.cc
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-26 20:18:21 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-26 20:18:21 +0000
commit6463cb2a117dcd866a12becb513cfdba935c16e5 (patch)
tree929c60acd2a4bd78e9b6f4ccbbf0c3bfa4bcf495 /chrome/browser/gtk/custom_button.cc
parent32d0ef5d82ef2e972635245107825e776072dc82 (diff)
downloadchromium_src-6463cb2a117dcd866a12becb513cfdba935c16e5.zip
chromium_src-6463cb2a117dcd866a12becb513cfdba935c16e5.tar.gz
chromium_src-6463cb2a117dcd866a12becb513cfdba935c16e5.tar.bz2
Refactor back/forward buttons to their own class. Fix them so the menu pops up on drags and the buttons look depressed when the menu is showing.
BUG=12427 TEST=back/forward button behavior should be as on windows (see bug desc. for details). Review URL: http://codereview.chromium.org/113806 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16898 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/custom_button.cc')
-rw-r--r--chrome/browser/gtk/custom_button.cc18
1 files changed, 15 insertions, 3 deletions
diff --git a/chrome/browser/gtk/custom_button.cc b/chrome/browser/gtk/custom_button.cc
index ed1f0b3..e438016 100644
--- a/chrome/browser/gtk/custom_button.cc
+++ b/chrome/browser/gtk/custom_button.cc
@@ -14,7 +14,8 @@ CustomDrawButtonBase::CustomDrawButtonBase(
int normal_id,
int active_id,
int highlight_id,
- int depressed_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.GetPixbufNamed(normal_id) : NULL;
@@ -30,11 +31,12 @@ CustomDrawButtonBase::~CustomDrawButtonBase() {
}
gboolean CustomDrawButtonBase::OnExpose(GtkWidget* widget, GdkEventExpose* e) {
- GdkPixbuf* pixbuf = pixbufs(GTK_WIDGET_STATE(widget));
+ GdkPixbuf* pixbuf = pixbufs_[paint_override_ >= 0 ?
+ paint_override_ : GTK_WIDGET_STATE(widget)];
// Fall back to the default image if we don't have one for this state.
if (!pixbuf)
- pixbuf = pixbufs(GTK_STATE_NORMAL);
+ pixbuf = pixbufs_[GTK_STATE_NORMAL];
if (!pixbuf)
return FALSE;
@@ -73,6 +75,16 @@ CustomDrawButton::~CustomDrawButton() {
widget_.Destroy();
}
+void CustomDrawButton::SetPaintOverride(GtkStateType state) {
+ button_base_.set_paint_override(state);
+ gtk_widget_queue_draw(widget_.get());
+}
+
+void CustomDrawButton::UnsetPaintOverride() {
+ button_base_.set_paint_override(-1);
+ gtk_widget_queue_draw(widget_.get());
+}
+
// static
gboolean CustomDrawButton::OnExpose(GtkWidget* widget,
GdkEventExpose* e,