| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/gtk/gtk_chrome_button.h" | 5 #include "chrome/browser/ui/gtk/gtk_chrome_button.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "chrome/browser/ui/gtk/nine_box.h" | 8 #include "chrome/browser/ui/gtk/nine_box.h" |
| 9 #include "grit/ui_resources.h" | 9 #include "grit/ui_resources.h" |
| 10 #include "ui/gfx/gtk_util.h" | 10 #include "ui/gfx/gtk_util.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 GObjectClass* gobject_class = G_OBJECT_CLASS(button_class); | 78 GObjectClass* gobject_class = G_OBJECT_CLASS(button_class); |
| 79 g_type_class_add_private(gobject_class, sizeof(GtkChromeButtonPrivate)); | 79 g_type_class_add_private(gobject_class, sizeof(GtkChromeButtonPrivate)); |
| 80 } | 80 } |
| 81 | 81 |
| 82 static void gtk_chrome_button_init(GtkChromeButton* button) { | 82 static void gtk_chrome_button_init(GtkChromeButton* button) { |
| 83 GtkChromeButtonPrivate* priv = GTK_CHROME_BUTTON_GET_PRIVATE(button); | 83 GtkChromeButtonPrivate* priv = GTK_CHROME_BUTTON_GET_PRIVATE(button); |
| 84 priv->paint_state = -1; | 84 priv->paint_state = -1; |
| 85 priv->use_gtk_rendering = FALSE; | 85 priv->use_gtk_rendering = FALSE; |
| 86 priv->hover_state = -1.0; | 86 priv->hover_state = -1.0; |
| 87 | 87 |
| 88 gtk_widget_set_can_focus(GTK_WIDGET(button), FALSE); | 88 GTK_WIDGET_UNSET_FLAGS(button, GTK_CAN_FOCUS); |
| 89 } | 89 } |
| 90 | 90 |
| 91 static gboolean gtk_chrome_button_expose(GtkWidget* widget, | 91 static gboolean gtk_chrome_button_expose(GtkWidget* widget, |
| 92 GdkEventExpose* event) { | 92 GdkEventExpose* event) { |
| 93 GtkChromeButtonPrivate *priv = GTK_CHROME_BUTTON_GET_PRIVATE(widget); | 93 GtkChromeButtonPrivate *priv = GTK_CHROME_BUTTON_GET_PRIVATE(widget); |
| 94 int paint_state = priv->paint_state < 0 ? | 94 int paint_state = priv->paint_state < 0 ? |
| 95 gtk_widget_get_state(widget) : priv->paint_state; | 95 GTK_WIDGET_STATE(widget) : priv->paint_state; |
| 96 | 96 |
| 97 if (priv->use_gtk_rendering) { | 97 if (priv->use_gtk_rendering) { |
| 98 // We have the superclass handle this expose when we aren't using custom | 98 // We have the superclass handle this expose when we aren't using custom |
| 99 // rendering AND we're in either the prelight or active state so that we | 99 // rendering AND we're in either the prelight or active state so that we |
| 100 // get the button border for the current GTK theme drawn. | 100 // get the button border for the current GTK theme drawn. |
| 101 if (paint_state == GTK_STATE_PRELIGHT || paint_state == GTK_STATE_ACTIVE) { | 101 if (paint_state == GTK_STATE_PRELIGHT || paint_state == GTK_STATE_ACTIVE) { |
| 102 // Set the state of button->depressed so we paint pressed even if the | 102 // Set the state of button->depressed so we paint pressed even if the |
| 103 // actual state of the button is something else. | 103 // actual state of the button is something else. |
| 104 GTK_BUTTON(widget)->depressed = (paint_state == GTK_STATE_ACTIVE); | 104 GTK_BUTTON(widget)->depressed = (paint_state == GTK_STATE_ACTIVE); |
| 105 return GTK_WIDGET_CLASS(gtk_chrome_button_parent_class)->expose_event | 105 return GTK_WIDGET_CLASS(gtk_chrome_button_parent_class)->expose_event |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 gdouble state) { | 164 gdouble state) { |
| 165 GtkChromeButtonPrivate* priv = GTK_CHROME_BUTTON_GET_PRIVATE(button); | 165 GtkChromeButtonPrivate* priv = GTK_CHROME_BUTTON_GET_PRIVATE(button); |
| 166 if (state >= 0.0 && state <= 1.0) | 166 if (state >= 0.0 && state <= 1.0) |
| 167 priv->hover_state = state; | 167 priv->hover_state = state; |
| 168 else | 168 else |
| 169 priv->hover_state = -1.0; | 169 priv->hover_state = -1.0; |
| 170 gtk_widget_queue_draw(GTK_WIDGET(button)); | 170 gtk_widget_queue_draw(GTK_WIDGET(button)); |
| 171 } | 171 } |
| 172 | 172 |
| 173 G_END_DECLS | 173 G_END_DECLS |
| OLD | NEW |