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_link_button.h" | 5 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 | 8 |
9 #include "chrome/browser/ui/gtk/gtk_util.h" | 9 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 10 #include "ui/base/gtk/gtk_compat.h" |
10 #include "ui/gfx/gtk_util.h" | 11 #include "ui/gfx/gtk_util.h" |
11 | 12 |
12 static const gchar* kLinkMarkup = "<u><span color=\"%s\">%s</span></u>"; | 13 static const gchar* kLinkMarkup = "<u><span color=\"%s\">%s</span></u>"; |
13 | 14 |
14 namespace { | 15 namespace { |
15 | 16 |
16 // Set the GTK style on our custom link button. We don't want any border around | 17 // Set the GTK style on our custom link button. We don't want any border around |
17 // the link text. | 18 // the link text. |
18 void SetLinkButtonStyle() { | 19 void SetLinkButtonStyle() { |
19 static bool style_was_set = false; | 20 static bool style_was_set = false; |
(...skipping 27 matching lines...) Expand all Loading... |
47 } | 48 } |
48 | 49 |
49 } // namespace | 50 } // namespace |
50 | 51 |
51 G_BEGIN_DECLS | 52 G_BEGIN_DECLS |
52 G_DEFINE_TYPE(GtkChromeLinkButton, gtk_chrome_link_button, GTK_TYPE_BUTTON) | 53 G_DEFINE_TYPE(GtkChromeLinkButton, gtk_chrome_link_button, GTK_TYPE_BUTTON) |
53 | 54 |
54 static void gtk_chrome_link_button_set_text(GtkChromeLinkButton* button) { | 55 static void gtk_chrome_link_button_set_text(GtkChromeLinkButton* button) { |
55 // If we were called before we were realized, abort. We'll be called for | 56 // If we were called before we were realized, abort. We'll be called for |
56 // real when |button| is realized. | 57 // real when |button| is realized. |
57 if (!GTK_WIDGET_REALIZED(button)) | 58 if (!gtk_widget_get_realized(GTK_WIDGET(button))) |
58 return; | 59 return; |
59 | 60 |
60 g_free(button->native_markup); | 61 g_free(button->native_markup); |
61 button->native_markup = NULL; | 62 button->native_markup = NULL; |
62 g_free(button->normal_markup); | 63 g_free(button->normal_markup); |
63 button->normal_markup = NULL; | 64 button->normal_markup = NULL; |
64 g_free(button->pressed_markup); | 65 g_free(button->pressed_markup); |
65 button->pressed_markup = NULL; | 66 button->pressed_markup = NULL; |
66 | 67 |
67 gchar* text = button->text; | 68 gchar* text = button->text; |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 strncpy(button->normal_color, "blue", 9); | 254 strncpy(button->normal_color, "blue", 9); |
254 } | 255 } |
255 | 256 |
256 gtk_chrome_link_button_set_text(button); | 257 gtk_chrome_link_button_set_text(button); |
257 | 258 |
258 if (gtk_widget_get_visible(GTK_WIDGET(button))) | 259 if (gtk_widget_get_visible(GTK_WIDGET(button))) |
259 gtk_widget_queue_draw(GTK_WIDGET(button)); | 260 gtk_widget_queue_draw(GTK_WIDGET(button)); |
260 } | 261 } |
261 | 262 |
262 G_END_DECLS | 263 G_END_DECLS |
OLD | NEW |