[gtk+] label: Make attr_list_merge() use sane merging rules
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] label: Make attr_list_merge() use sane merging rules
- Date: Fri, 6 Jan 2012 04:24:44 +0000 (UTC)
commit d6bb8a63aaea0be9ea304a82950da95135863bb1
Author: Benjamin Otte <otte redhat com>
Date: Fri Jan 6 05:10:50 2012 +0100
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.
gtk/gtklabel.c | 30 +++++++++---------------------
1 files changed, 9 insertions(+), 21 deletions(-)
---
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index fe34fe4..9597f56 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]