label: Make attr_list_merge() use sane merging rules

Instead of "attribute with later start index wins, make sure the
attribute list that is merged from takes precedence. This now gives the
multiple attribute lists we use in the label an order:

1) gtk_label_set_attributes()
  These attributes override everything. It's what the function's there
  for after all.
2) markup of label
  Other user-specified attributes come next.
3) attributes for links
  When we apply custom attributes on parts of the text, we put them
  last. We don't want to mess with what the user does. Also, we change
  color and underline, so we usually have something to show.
This commit is contained in:
Benjamin Otte 2012-01-06 05:10:50 +01:00
parent e78e4d8dd8
commit d6bb8a63aa

View File

@ -2034,31 +2034,19 @@ gtk_label_set_use_underline_internal (GtkLabel *label,
}
}
static gboolean
my_pango_attr_list_merge_filter (PangoAttribute *attribute,
gpointer list)
{
pango_attr_list_change (list, pango_attribute_copy (attribute));
return FALSE;
}
static void
my_pango_attr_list_merge (PangoAttrList *into,
PangoAttrList *from)
{
PangoAttrIterator *iter;
PangoAttribute *attr;
GSList *iter_attrs, *l;
iter = pango_attr_list_get_iterator (from);
if (iter)
{
do
{
iter_attrs = pango_attr_iterator_get_attrs (iter);
for (l = iter_attrs; l; l = l->next)
{
attr = l->data;
pango_attr_list_insert (into, attr);
}
g_slist_free (iter_attrs);
}
while (pango_attr_iterator_next (iter));
pango_attr_iterator_destroy (iter);
}
pango_attr_list_filter (from, my_pango_attr_list_merge_filter, into);
}
/* Calculates text, attrs and mnemonic_keyval from