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 3 // found in the LICENSE file. 4 5 // Creates a link button that shows |text| in blue and underlined. The cursor 6 // changes to a hand when over the link. This is like the GTK LinkButton, but 7 // it doesn't call the global URI link handler, etc. It is a button subclass, 8 // so you can just handle the clicked signal. 9 10 #ifndef CHROME_BROWSER_UI_GTK_GTK_CHROME_LINK_BUTTON_H_ 11 #define CHROME_BROWSER_UI_GTK_GTK_CHROME_LINK_BUTTON_H_ 12 #pragma once 13 14 #include <gdk/gdk.h> 15 #include <gtk/gtk.h> 16 17 G_BEGIN_DECLS 18 19 #define GTK_TYPE_CHROME_LINK_BUTTON (gtk_chrome_link_button_get_type ()) 20 #define GTK_CHROME_LINK_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), \ 21 GTK_TYPE_CHROME_LINK_BUTTON, \ 22 GtkChromeLinkButton)) 23 #define GTK_CHROME_LINK_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), \ 24 GTK_TYPE_CHROME_LINK_BUTTON, \ 25 GtkChromeLinkButtonClass)) 26 #define GTK_IS_CHROME_LINK_BUTTON(obj) \ 27 (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_CHROME_LINK_BUTTON)) 28 #define GTK_IS_CHROME_LINK_BUTTON_CLASS(klass) \ 29 (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_CHROME_LINK_BUTTON)) 30 #define GTK_CHROME_LINK_BUTTON_GET_CLASS(obj) \ 31 (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_CHROME_LINK_BUTTON, \ 32 GtkChromeLinkButton)) 33 34 typedef struct _GtkChromeLinkButton GtkChromeLinkButton; 35 typedef struct _GtkChromeLinkButtonClass GtkChromeLinkButtonClass; 36 37 struct _GtkChromeLinkButton { 38 GtkButton button; 39 GtkWidget* label; 40 gchar* normal_markup; 41 gchar* pressed_markup; 42 gboolean is_normal; 43 gchar normal_color[9]; 44 gchar* native_markup; 45 gboolean using_native_theme; 46 GdkCursor* hand_cursor; 47 gchar* text; 48 gboolean uses_markup; 49 }; 50 51 struct _GtkChromeLinkButtonClass { 52 GtkButtonClass parent_class; 53 }; 54 55 // Make a link button with display text |text|. 56 GtkWidget* gtk_chrome_link_button_new(const char* text); 57 58 // As above, but don't escape markup in the text. 59 GtkWidget* gtk_chrome_link_button_new_with_markup(const char* markup); 60 61 // Set whether the link button draws natively (using "link-color"). The default 62 // is TRUE. 63 void gtk_chrome_link_button_set_use_gtk_theme(GtkChromeLinkButton* button, 64 gboolean use_gtk); 65 66 // Set the label text of the link. 67 void gtk_chrome_link_button_set_label(GtkChromeLinkButton* button, 68 const char* text); 69 70 // Set the color when the link is in a normal state (i.e. not pressed). 71 // If not set, or called NULL |color|, the color will be blue. 72 void gtk_chrome_link_button_set_normal_color(GtkChromeLinkButton* button, 73 const GdkColor* color); 74 75 GType gtk_chrome_link_button_get_type(); 76 77 G_END_DECLS 78 79 #endif // CHROME_BROWSER_UI_GTK_GTK_CHROME_LINK_BUTTON_H_ 80