[gtk/wip/baedert/for-master: 8/10] label: Pull all pango attributes from the theme



commit dcdd1a2a589380750379076ce72b8cfdd5b5c57e
Author: Timm Bäder <mail baedert org>
Date:   Sun Apr 12 09:07:57 2020 +0200

    label: Pull all pango attributes from the theme
    
    Dont' force an underline attribute here. Just ask the theme for the
    text-decoration.

 gtk/gtklabel.c | 41 +++++++++++++++++++++++++++--------------
 1 file changed, 27 insertions(+), 14 deletions(-)
---
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 4cdc03a959..0e440c93e5 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -2993,8 +2993,6 @@ gtk_label_update_layout_attributes (GtkLabel *label)
 
   if (priv->select_info && priv->select_info->links)
     {
-      const GdkRGBA *link_color;
-      PangoAttribute *attribute;
       guint i;
 
       attrs = pango_attr_list_new ();
@@ -3002,21 +3000,36 @@ gtk_label_update_layout_attributes (GtkLabel *label)
       for (i = 0; i < priv->select_info->n_links; i++)
         {
           const GtkLabelLink *link = &priv->select_info->links[i];
-
-          attribute = pango_attr_underline_new (TRUE);
-          attribute->start_index = link->start;
-          attribute->end_index = link->end;
-          pango_attr_list_insert (attrs, attribute);
+          const GdkRGBA *link_color;
+          PangoAttrList *link_attrs;
+          PangoAttribute *attr;
+          GSList *attributes;
+          GSList *l;
 
           style = gtk_css_node_get_style (link->cssnode);
-          link_color = gtk_css_color_value_get_rgba (style->core->color);
+          link_attrs = gtk_css_style_get_pango_attributes (style);
+
+          attributes = pango_attr_list_get_attributes (link_attrs);
+          for (l = attributes; l; l = l->next)
+            {
+              attr = l->data;
 
-          attribute = pango_attr_foreground_new (link_color->red * 65535,
-                                                 link_color->green * 65535,
-                                                 link_color->blue * 65535);
-          attribute->start_index = link->start;
-          attribute->end_index = link->end;
-          pango_attr_list_insert (attrs, attribute);
+              attr->start_index = link->start;
+              attr->end_index = link->end;
+              pango_attr_list_insert (attrs, attr);
+            }
+
+          g_slist_free (attributes);
+
+          link_color = gtk_css_color_value_get_rgba (style->core->color);
+          attr = pango_attr_foreground_new (link_color->red * 65535,
+                                            link_color->green * 65535,
+                                            link_color->blue * 65535);
+          attr->start_index = link->start;
+          attr->end_index = link->end;
+          pango_attr_list_insert (attrs, attr);
+
+          pango_attr_list_unref (link_attrs);
         }
     }
   else if (priv->markup_attrs && priv->attrs)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]