| 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_link_button.h" | 5 #include "chrome/browser/gtk/gtk_chrome_link_button.h" |
| 6 | 6 |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "chrome/common/gtk_util.h" |
| 10 | 11 |
| 11 static const gchar* kLinkMarkup = "<u><span color=\"%s\">%s</span></u>"; | 12 static const gchar* kLinkMarkup = "<u><span color=\"%s\">%s</span></u>"; |
| 12 | 13 |
| 13 namespace { | 14 namespace { |
| 14 | 15 |
| 15 // Set the GTK style on our custom link button. We don't want any border around | 16 // Set the GTK style on our custom link button. We don't want any border around |
| 16 // the link text. | 17 // the link text. |
| 17 void SetLinkButtonStyle() { | 18 void SetLinkButtonStyle() { |
| 18 static bool style_was_set = false; | 19 static bool style_was_set = false; |
| 19 | 20 |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 | 176 |
| 176 // We put a label in a button so we can connect to the click event. We don't | 177 // We put a label in a button so we can connect to the click event. We don't |
| 177 // let the button draw itself; catch all expose events to the button and pass | 178 // let the button draw itself; catch all expose events to the button and pass |
| 178 // them through to the label. | 179 // them through to the label. |
| 179 button->label = gtk_label_new(NULL); | 180 button->label = gtk_label_new(NULL); |
| 180 button->blue_markup = NULL; | 181 button->blue_markup = NULL; |
| 181 button->red_markup = NULL; | 182 button->red_markup = NULL; |
| 182 button->is_blue = TRUE; | 183 button->is_blue = TRUE; |
| 183 button->native_markup = NULL; | 184 button->native_markup = NULL; |
| 184 button->using_native_theme = TRUE; | 185 button->using_native_theme = TRUE; |
| 185 button->hand_cursor = gdk_cursor_new(GDK_HAND2); | 186 button->hand_cursor = gtk_util::GetCursor(GDK_HAND2); |
| 186 button->text = NULL; | 187 button->text = NULL; |
| 187 | 188 |
| 188 gtk_container_add(GTK_CONTAINER(button), button->label); | 189 gtk_container_add(GTK_CONTAINER(button), button->label); |
| 189 gtk_widget_set_name(GTK_WIDGET(button), "chrome-link-button"); | 190 gtk_widget_set_name(GTK_WIDGET(button), "chrome-link-button"); |
| 190 gtk_widget_set_app_paintable(GTK_WIDGET(button), TRUE); | 191 gtk_widget_set_app_paintable(GTK_WIDGET(button), TRUE); |
| 191 } | 192 } |
| 192 | 193 |
| 193 GtkWidget* gtk_chrome_link_button_new(const char* text) { | 194 GtkWidget* gtk_chrome_link_button_new(const char* text) { |
| 194 GtkWidget* lb = GTK_WIDGET(g_object_new(GTK_TYPE_CHROME_LINK_BUTTON, NULL)); | 195 GtkWidget* lb = GTK_WIDGET(g_object_new(GTK_TYPE_CHROME_LINK_BUTTON, NULL)); |
| 195 GTK_CHROME_LINK_BUTTON(lb)->text = strdup(text); | 196 GTK_CHROME_LINK_BUTTON(lb)->text = strdup(text); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 207 void gtk_chrome_link_button_set_use_gtk_theme(GtkChromeLinkButton* button, | 208 void gtk_chrome_link_button_set_use_gtk_theme(GtkChromeLinkButton* button, |
| 208 gboolean use_gtk) { | 209 gboolean use_gtk) { |
| 209 if (use_gtk != button->using_native_theme) { | 210 if (use_gtk != button->using_native_theme) { |
| 210 button->using_native_theme = use_gtk; | 211 button->using_native_theme = use_gtk; |
| 211 if (GTK_WIDGET_VISIBLE(button)) | 212 if (GTK_WIDGET_VISIBLE(button)) |
| 212 gtk_widget_queue_draw(GTK_WIDGET(button)); | 213 gtk_widget_queue_draw(GTK_WIDGET(button)); |
| 213 } | 214 } |
| 214 } | 215 } |
| 215 | 216 |
| 216 G_END_DECLS | 217 G_END_DECLS |
| OLD | NEW |