diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-21 21:36:44 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-21 21:36:44 +0000 |
commit | 651f749bb3ee9a7d6a9c239f703351a499e16832 (patch) | |
tree | 99578982937b20fdd32856fe1b6b970e659b715d /chrome/browser/gtk/gtk_chrome_button.cc | |
parent | 987bdf20d17d5a869027032300f1fdd62f6539cf (diff) | |
download | chromium_src-651f749bb3ee9a7d6a9c239f703351a499e16832.zip chromium_src-651f749bb3ee9a7d6a9c239f703351a499e16832.tar.gz chromium_src-651f749bb3ee9a7d6a9c239f703351a499e16832.tar.bz2 |
Linux: Make page/app menu buttons depress while they're showing the menus.
TEST=click the page/app menu buttons. Observe that they are looking active. Dismiss the menu. Observe that the buttons are normal again.
Review URL: http://codereview.chromium.org/113724
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16664 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/gtk_chrome_button.cc')
-rw-r--r-- | chrome/browser/gtk/gtk_chrome_button.cc | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/chrome/browser/gtk/gtk_chrome_button.cc b/chrome/browser/gtk/gtk_chrome_button.cc index 93b0218..ceddef2 100644 --- a/chrome/browser/gtk/gtk_chrome_button.cc +++ b/chrome/browser/gtk/gtk_chrome_button.cc @@ -20,11 +20,22 @@ NineBox* g_nine_box_active; G_BEGIN_DECLS +#define GTK_CHROME_BUTTON_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o),\ + GTK_TYPE_CHROME_BUTTON,\ + GtkChromeButtonPrivate)) +typedef struct _GtkChromeButtonPrivate GtkChromeButtonPrivate; + +struct _GtkChromeButtonPrivate +{ + int paint_state; +}; + G_DEFINE_TYPE (GtkChromeButton, gtk_chrome_button, GTK_TYPE_BUTTON) static gboolean gtk_chrome_button_expose(GtkWidget* widget, GdkEventExpose* event); static void gtk_chrome_button_class_init(GtkChromeButtonClass *button_class) { + GObjectClass *gobject_class = G_OBJECT_CLASS(button_class); GtkWidgetClass* widget_class = (GtkWidgetClass*)button_class; widget_class->expose_event = gtk_chrome_button_expose; @@ -49,18 +60,27 @@ static void gtk_chrome_button_class_init(GtkChromeButtonClass *button_class) { IDR_TEXTBUTTON_BOTTOM_LEFT_P, IDR_TEXTBUTTON_BOTTOM_P, IDR_TEXTBUTTON_BOTTOM_RIGHT_P); + + g_type_class_add_private(gobject_class, sizeof(GtkChromeButtonPrivate)); } static void gtk_chrome_button_init(GtkChromeButton* button) { + GtkChromeButtonPrivate *priv = GTK_CHROME_BUTTON_GET_PRIVATE(button); + priv->paint_state = -1; + gtk_widget_set_app_paintable(GTK_WIDGET(button), TRUE); } static gboolean gtk_chrome_button_expose(GtkWidget* widget, GdkEventExpose* event) { + GtkChromeButtonPrivate *priv = GTK_CHROME_BUTTON_GET_PRIVATE(widget); + int paint_state = priv->paint_state < 0 ? + GTK_WIDGET_STATE(widget) : priv->paint_state; + NineBox* nine_box = NULL; - if (GTK_WIDGET_STATE(widget) == GTK_STATE_PRELIGHT) + if (paint_state == GTK_STATE_PRELIGHT) nine_box = g_nine_box_prelight; - else if (GTK_WIDGET_STATE(widget) == GTK_STATE_ACTIVE) + else if (paint_state == GTK_STATE_ACTIVE) nine_box = g_nine_box_active; // Only draw theme graphics if we have some. @@ -78,5 +98,24 @@ GtkWidget* gtk_chrome_button_new(void) { return GTK_WIDGET(g_object_new(GTK_TYPE_CHROME_BUTTON, NULL)); } +void gtk_chrome_button_set_paint_state(GtkChromeButton* button, + GtkStateType state) { + g_return_if_fail(GTK_IS_CHROME_BUTTON(button)); + + GtkChromeButtonPrivate *priv = GTK_CHROME_BUTTON_GET_PRIVATE(button); + priv->paint_state = state; + + gtk_widget_queue_draw(GTK_WIDGET(button)); +} + +void gtk_chrome_button_unset_paint_state(GtkChromeButton* button) { + g_return_if_fail(GTK_IS_CHROME_BUTTON(button)); + + GtkChromeButtonPrivate *priv = GTK_CHROME_BUTTON_GET_PRIVATE(button); + priv->paint_state = -1; + + gtk_widget_queue_draw(GTK_WIDGET(button)); +} + G_END_DECLS |