| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/gtk/gtk_chrome_button.h" | 5 #include "chrome/browser/gtk/gtk_chrome_button.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/gfx/gtk_util.h" | 8 #include "base/gfx/gtk_util.h" |
| 9 #include "chrome/browser/gtk/nine_box.h" | 9 #include "chrome/browser/gtk/nine_box.h" |
| 10 | 10 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 // If true, we use images provided by the theme instead of GTK's default | 32 // If true, we use images provided by the theme instead of GTK's default |
| 33 // button rendering. | 33 // button rendering. |
| 34 gboolean use_gtk_rendering; | 34 gboolean use_gtk_rendering; |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 G_DEFINE_TYPE(GtkChromeButton, gtk_chrome_button, GTK_TYPE_BUTTON) | 37 G_DEFINE_TYPE(GtkChromeButton, gtk_chrome_button, GTK_TYPE_BUTTON) |
| 38 static gboolean gtk_chrome_button_expose(GtkWidget* widget, | 38 static gboolean gtk_chrome_button_expose(GtkWidget* widget, |
| 39 GdkEventExpose* event); | 39 GdkEventExpose* event); |
| 40 | 40 |
| 41 static void gtk_chrome_button_class_init(GtkChromeButtonClass* button_class) { | 41 static void gtk_chrome_button_class_init(GtkChromeButtonClass* button_class) { |
| 42 gtk_rc_parse_string( |
| 43 "style \"chrome-button\" {" |
| 44 " GtkButton::child-displacement-x = 0" |
| 45 " GtkButton::child-displacement-y = 0" |
| 46 "}" |
| 47 "widget \"*chrome-button\" style \"chrome-button\""); |
| 48 |
| 42 GObjectClass* gobject_class = G_OBJECT_CLASS(button_class); | 49 GObjectClass* gobject_class = G_OBJECT_CLASS(button_class); |
| 43 GtkWidgetClass* widget_class = reinterpret_cast<GtkWidgetClass*>(button_class)
; | 50 GtkWidgetClass* widget_class = reinterpret_cast<GtkWidgetClass*>(button_class)
; |
| 44 widget_class->expose_event = gtk_chrome_button_expose; | 51 widget_class->expose_event = gtk_chrome_button_expose; |
| 45 | 52 |
| 46 g_nine_box_prelight = new NineBox( | 53 g_nine_box_prelight = new NineBox( |
| 47 IDR_TEXTBUTTON_TOP_LEFT_H, | 54 IDR_TEXTBUTTON_TOP_LEFT_H, |
| 48 IDR_TEXTBUTTON_TOP_H, | 55 IDR_TEXTBUTTON_TOP_H, |
| 49 IDR_TEXTBUTTON_TOP_RIGHT_H, | 56 IDR_TEXTBUTTON_TOP_RIGHT_H, |
| 50 IDR_TEXTBUTTON_LEFT_H, | 57 IDR_TEXTBUTTON_LEFT_H, |
| 51 IDR_TEXTBUTTON_CENTER_H, | 58 IDR_TEXTBUTTON_CENTER_H, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 66 IDR_TEXTBUTTON_BOTTOM_RIGHT_P); | 73 IDR_TEXTBUTTON_BOTTOM_RIGHT_P); |
| 67 | 74 |
| 68 g_type_class_add_private(gobject_class, sizeof(GtkChromeButtonPrivate)); | 75 g_type_class_add_private(gobject_class, sizeof(GtkChromeButtonPrivate)); |
| 69 } | 76 } |
| 70 | 77 |
| 71 static void gtk_chrome_button_init(GtkChromeButton* button) { | 78 static void gtk_chrome_button_init(GtkChromeButton* button) { |
| 72 GtkChromeButtonPrivate* priv = GTK_CHROME_BUTTON_GET_PRIVATE(button); | 79 GtkChromeButtonPrivate* priv = GTK_CHROME_BUTTON_GET_PRIVATE(button); |
| 73 priv->paint_state = -1; | 80 priv->paint_state = -1; |
| 74 priv->use_gtk_rendering = FALSE; | 81 priv->use_gtk_rendering = FALSE; |
| 75 | 82 |
| 83 gtk_widget_set_name(GTK_WIDGET(button), "chrome-button"); |
| 76 gtk_widget_set_app_paintable(GTK_WIDGET(button), TRUE); | 84 gtk_widget_set_app_paintable(GTK_WIDGET(button), TRUE); |
| 77 | 85 |
| 78 GTK_WIDGET_UNSET_FLAGS(button, GTK_CAN_FOCUS); | 86 GTK_WIDGET_UNSET_FLAGS(button, GTK_CAN_FOCUS); |
| 79 } | 87 } |
| 80 | 88 |
| 81 static gboolean gtk_chrome_button_expose(GtkWidget* widget, | 89 static gboolean gtk_chrome_button_expose(GtkWidget* widget, |
| 82 GdkEventExpose* event) { | 90 GdkEventExpose* event) { |
| 83 GtkChromeButtonPrivate *priv = GTK_CHROME_BUTTON_GET_PRIVATE(widget); | 91 GtkChromeButtonPrivate *priv = GTK_CHROME_BUTTON_GET_PRIVATE(widget); |
| 84 int paint_state = priv->paint_state < 0 ? | 92 int paint_state = priv->paint_state < 0 ? |
| 85 GTK_WIDGET_STATE(widget) : priv->paint_state; | 93 GTK_WIDGET_STATE(widget) : priv->paint_state; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 } | 148 } |
| 141 | 149 |
| 142 void gtk_chrome_button_set_use_gtk_rendering(GtkChromeButton* button, | 150 void gtk_chrome_button_set_use_gtk_rendering(GtkChromeButton* button, |
| 143 gboolean value) { | 151 gboolean value) { |
| 144 g_return_if_fail(GTK_IS_CHROME_BUTTON(button)); | 152 g_return_if_fail(GTK_IS_CHROME_BUTTON(button)); |
| 145 GtkChromeButtonPrivate *priv = GTK_CHROME_BUTTON_GET_PRIVATE(button); | 153 GtkChromeButtonPrivate *priv = GTK_CHROME_BUTTON_GET_PRIVATE(button); |
| 146 priv->use_gtk_rendering = value; | 154 priv->use_gtk_rendering = value; |
| 147 } | 155 } |
| 148 | 156 |
| 149 G_END_DECLS | 157 G_END_DECLS |
| OLD | NEW |