summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2017-01-05 16:36:14 -0500
committerMatthias Clasen <mclasen@redhat.com>2017-01-05 16:55:45 -0500
commitf3779b42c57b1bf628f83853f5ca532aa061bb12 (patch)
tree011eaa3b66fed5b06a5f9d6bcef96d37f0d7c08c
parent29dec067fb6b3ea835feb4ece4b0e7812a6909d2 (diff)
downloadgtk+-f3779b42c57b1bf628f83853f5ca532aa061bb12.tar.gz
Make it possible to set style classes for label links
This makes it possible to style links in labels differently in certain situations.
-rw-r--r--gtk/gtklabel.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 10e69f49bc..7a24f71f48 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -229,9 +229,10 @@
*
* Since 2.18, GTK+ supports markup for clickable hyperlinks in addition
* to regular Pango markup. The markup for links is borrowed from HTML,
- * using the `<a>` with “href“ and “title“ attributes. GTK+ renders links
+ * using the `<a>` with “href“, “title“ and “class“ attributes. GTK+ renders links
* similar to the way they appear in web browsers, with colored, underlined
- * text. The “title“ attribute is displayed as a tooltip on the link.
+ * text. The “title“ attribute is displayed as a tooltip on the link. The “class“
+ * attribute is used as style class on the CSS node for the link.
*
* An example looks like this:
*
@@ -2379,6 +2380,7 @@ start_element_handler (GMarkupParseContext *context,
GtkLabelLink *link;
const gchar *uri = NULL;
const gchar *title = NULL;
+ const gchar *class = NULL;
gboolean visited = FALSE;
gint line_number;
gint char_number;
@@ -2396,6 +2398,8 @@ start_element_handler (GMarkupParseContext *context,
uri = attribute_values[i];
else if (strcmp (attr, "title") == 0)
title = attribute_values[i];
+ else if (strcmp (attr, "class") == 0)
+ class = attribute_values[i];
else
{
g_set_error (error,
@@ -2443,6 +2447,9 @@ start_element_handler (GMarkupParseContext *context,
link->cssnode = gtk_css_node_new ();
gtk_css_node_set_name (link->cssnode, I_("link"));
gtk_css_node_set_parent (link->cssnode, widget_node);
+ if (class)
+ gtk_css_node_add_class (link->cssnode, g_quark_from_string (class));
+
state = gtk_css_node_get_state (widget_node);
if (visited)
state |= GTK_STATE_FLAG_VISITED;