Chromium Code Reviews| Index: chrome/browser/ui/gtk/gtk_chrome_link_button.cc |
| diff --git a/chrome/browser/ui/gtk/gtk_chrome_link_button.cc b/chrome/browser/ui/gtk/gtk_chrome_link_button.cc |
| index c9eb6fc5cac2d0e3d911535e2ab3a190dcd93a4b..bb96f78bd079e045a3962d82f940f42b6bbfca94 100644 |
| --- a/chrome/browser/ui/gtk/gtk_chrome_link_button.cc |
| +++ b/chrome/browser/ui/gtk/gtk_chrome_link_button.cc |
| @@ -11,6 +11,7 @@ |
| #include "ui/gfx/gtk_util.h" |
| static const gchar* kLinkMarkup = "<u><span color=\"%s\">%s</span></u>"; |
| +static const gchar* kInsensitiveLinkMarkup = "<span color=\"%s\">%s</span>"; |
| namespace { |
| @@ -40,6 +41,8 @@ static void gtk_chrome_link_button_destroy_text_resources( |
| button->native_markup = NULL; |
| g_free(button->normal_markup); |
| button->normal_markup = NULL; |
| + g_free(button->insensitive_markup); |
| + button->insensitive_markup = NULL; |
| g_free(button->pressed_markup); |
| button->pressed_markup = NULL; |
| @@ -64,6 +67,8 @@ static void gtk_chrome_link_button_set_text(GtkChromeLinkButton* button) { |
| button->normal_markup = NULL; |
| g_free(button->pressed_markup); |
| button->pressed_markup = NULL; |
| + g_free(button->insensitive_markup); |
| + button->insensitive_markup = NULL; |
| gchar* text = button->text; |
| gboolean uses_markup = button->uses_markup; |
| @@ -73,11 +78,17 @@ static void gtk_chrome_link_button_set_text(GtkChromeLinkButton* button) { |
| button->normal_color, |
| text); |
| button->pressed_markup = g_markup_printf_escaped(kLinkMarkup, "red", text); |
| + button->insensitive_markup = g_markup_printf_escaped(kInsensitiveLinkMarkup, |
| + "black", |
|
James Hawkins
2012/03/30 21:35:02
Do we need to read system prefs for this color?
Evan Stade
2012/03/30 21:38:25
I don't think this will look too good on dark GTK
binji
2012/03/30 23:03:51
Done.
|
| + text); |
| } else { |
| button->normal_markup = g_strdup_printf(kLinkMarkup, button->normal_color, |
| text); |
| button->pressed_markup = g_strdup_printf(kLinkMarkup, "red", text); |
| + button->insensitive_markup = g_strdup_printf(kInsensitiveLinkMarkup, |
| + "black", |
| + text); |
| } |
| // Get the current GTK theme's link button text color. |
| @@ -120,16 +131,25 @@ static gboolean gtk_chrome_link_button_expose(GtkWidget* widget, |
| GdkEventExpose* event) { |
| GtkChromeLinkButton* button = GTK_CHROME_LINK_BUTTON(widget); |
| GtkWidget* label = button->label; |
| - |
| - if (gtk_widget_get_state(widget) == GTK_STATE_ACTIVE && button->is_normal) { |
| - gtk_label_set_markup(GTK_LABEL(label), button->pressed_markup); |
| - button->is_normal = FALSE; |
| - } else if (gtk_widget_get_state(widget) != GTK_STATE_ACTIVE && |
| - !button->is_normal) { |
| - gtk_label_set_markup(GTK_LABEL(label), |
| - button->using_native_theme ? button->native_markup : |
| - button->normal_markup); |
| - button->is_normal = TRUE; |
| + GtkStateType widget_state = gtk_widget_get_state(widget); |
| + |
| + if (widget_state != button->label_state) { |
| + switch (widget_state) { |
| + case GTK_STATE_NORMAL: |
| + gtk_label_set_markup(GTK_LABEL(label), |
| + button->using_native_theme ? button->native_markup : |
| + button->normal_markup); |
| + break; |
| + case GTK_STATE_ACTIVE: |
| + gtk_label_set_markup(GTK_LABEL(label), button->pressed_markup); |
| + break; |
| + case GTK_STATE_INSENSITIVE: |
| + gtk_label_set_markup(GTK_LABEL(label), button->insensitive_markup); |
| + break; |
| + default: |
| + break; |
| + } |
| + button->label_state = widget_state; |
| } |
| // Draw the link inside the button. |
| @@ -195,7 +215,7 @@ static void gtk_chrome_link_button_init(GtkChromeLinkButton* button) { |
| button->label = gtk_label_new(NULL); |
| button->normal_markup = NULL; |
| button->pressed_markup = NULL; |
| - button->is_normal = TRUE; |
| + button->label_state = GTK_STATE_NORMAL; |
| strncpy(button->normal_color, "blue", 9); |
| button->native_markup = NULL; |
| button->using_native_theme = TRUE; |