| 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 #include "chrome/common/gtk_util.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 style_was_set = true; | 23 style_was_set = true; |
| 24 | 24 |
| 25 gtk_rc_parse_string( | 25 gtk_rc_parse_string( |
| 26 "style \"chrome-link-button\" {" | 26 "style \"chrome-link-button\" {" |
| 27 " GtkButton::inner-border = {0, 0, 0, 0}" | 27 " GtkButton::inner-border = {0, 0, 0, 0}" |
| 28 " GtkButton::child-displacement-x = 0" | 28 " GtkButton::child-displacement-x = 0" |
| 29 " GtkButton::child-displacement-y = 0" | 29 " GtkButton::child-displacement-y = 0" |
| 30 " xthickness = 0" | 30 " xthickness = 0" |
| 31 " ythickness = 0" | 31 " ythickness = 0" |
| 32 "}" | 32 "}" |
| 33 "widget \"*chrome-link-button\" style \"chrome-link-button\""); | 33 "widget_class \"*.<GtkChromeLinkButton>\" style \"chrome-link-button\""); |
| 34 } | 34 } |
| 35 | 35 |
| 36 } // namespace | 36 } // namespace |
| 37 | 37 |
| 38 G_BEGIN_DECLS | 38 G_BEGIN_DECLS |
| 39 G_DEFINE_TYPE(GtkChromeLinkButton, gtk_chrome_link_button, GTK_TYPE_BUTTON) | 39 G_DEFINE_TYPE(GtkChromeLinkButton, gtk_chrome_link_button, GTK_TYPE_BUTTON) |
| 40 | 40 |
| 41 // Should be called after we are realized so that the "link-color" property | 41 // Should be called after we are realized so that the "link-color" property |
| 42 // can be read. | 42 // can be read. |
| 43 static void gtk_chrome_link_button_set_text(GtkChromeLinkButton* button) { | 43 static void gtk_chrome_link_button_set_text(GtkChromeLinkButton* button) { |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 button->label = gtk_label_new(NULL); | 180 button->label = gtk_label_new(NULL); |
| 181 button->blue_markup = NULL; | 181 button->blue_markup = NULL; |
| 182 button->red_markup = NULL; | 182 button->red_markup = NULL; |
| 183 button->is_blue = TRUE; | 183 button->is_blue = TRUE; |
| 184 button->native_markup = NULL; | 184 button->native_markup = NULL; |
| 185 button->using_native_theme = TRUE; | 185 button->using_native_theme = TRUE; |
| 186 button->hand_cursor = gtk_util::GetCursor(GDK_HAND2); | 186 button->hand_cursor = gtk_util::GetCursor(GDK_HAND2); |
| 187 button->text = NULL; | 187 button->text = NULL; |
| 188 | 188 |
| 189 gtk_container_add(GTK_CONTAINER(button), button->label); | 189 gtk_container_add(GTK_CONTAINER(button), button->label); |
| 190 gtk_widget_set_name(GTK_WIDGET(button), "chrome-link-button"); | |
| 191 gtk_widget_set_app_paintable(GTK_WIDGET(button), TRUE); | 190 gtk_widget_set_app_paintable(GTK_WIDGET(button), TRUE); |
| 192 } | 191 } |
| 193 | 192 |
| 194 GtkWidget* gtk_chrome_link_button_new(const char* text) { | 193 GtkWidget* gtk_chrome_link_button_new(const char* text) { |
| 195 GtkWidget* lb = GTK_WIDGET(g_object_new(GTK_TYPE_CHROME_LINK_BUTTON, NULL)); | 194 GtkWidget* lb = GTK_WIDGET(g_object_new(GTK_TYPE_CHROME_LINK_BUTTON, NULL)); |
| 196 GTK_CHROME_LINK_BUTTON(lb)->text = strdup(text); | 195 GTK_CHROME_LINK_BUTTON(lb)->text = strdup(text); |
| 197 GTK_CHROME_LINK_BUTTON(lb)->uses_markup = FALSE; | 196 GTK_CHROME_LINK_BUTTON(lb)->uses_markup = FALSE; |
| 198 return lb; | 197 return lb; |
| 199 } | 198 } |
| 200 | 199 |
| 201 GtkWidget* gtk_chrome_link_button_new_with_markup(const char* markup) { | 200 GtkWidget* gtk_chrome_link_button_new_with_markup(const char* markup) { |
| 202 GtkWidget* lb = GTK_WIDGET(g_object_new(GTK_TYPE_CHROME_LINK_BUTTON, NULL)); | 201 GtkWidget* lb = GTK_WIDGET(g_object_new(GTK_TYPE_CHROME_LINK_BUTTON, NULL)); |
| 203 GTK_CHROME_LINK_BUTTON(lb)->text = strdup(markup); | 202 GTK_CHROME_LINK_BUTTON(lb)->text = strdup(markup); |
| 204 GTK_CHROME_LINK_BUTTON(lb)->uses_markup = TRUE; | 203 GTK_CHROME_LINK_BUTTON(lb)->uses_markup = TRUE; |
| 205 return lb; | 204 return lb; |
| 206 } | 205 } |
| 207 | 206 |
| 208 void gtk_chrome_link_button_set_use_gtk_theme(GtkChromeLinkButton* button, | 207 void gtk_chrome_link_button_set_use_gtk_theme(GtkChromeLinkButton* button, |
| 209 gboolean use_gtk) { | 208 gboolean use_gtk) { |
| 210 if (use_gtk != button->using_native_theme) { | 209 if (use_gtk != button->using_native_theme) { |
| 211 button->using_native_theme = use_gtk; | 210 button->using_native_theme = use_gtk; |
| 212 if (GTK_WIDGET_VISIBLE(button)) | 211 if (GTK_WIDGET_VISIBLE(button)) |
| 213 gtk_widget_queue_draw(GTK_WIDGET(button)); | 212 gtk_widget_queue_draw(GTK_WIDGET(button)); |
| 214 } | 213 } |
| 215 } | 214 } |
| 216 | 215 |
| 217 G_END_DECLS | 216 G_END_DECLS |
| OLD | NEW |