From: Paolo Borelli Date: Sun, 5 Jul 2015 22:20:08 +0000 (+0200) Subject: pango: make merge_attrs return the merged list X-Git-Tag: archive/raspbian/4.4.1+ds1-2+rpi1^2~18^2~24^2~9133 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=803430a779c284fa038fcc45f00c188ed504e826;p=gtk4.git pango: make merge_attrs return the merged list This simplifies all the callers --- diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index af876dbca4..9d768c40cc 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -6253,7 +6253,6 @@ gtk_entry_create_layout (GtkEntry *entry, GtkWidget *widget = GTK_WIDGET (entry); GtkStyleContext *context; PangoLayout *layout; - PangoAttrList *style_attrs; PangoAttrList *tmp_attrs; gboolean placeholder_layout; @@ -6269,13 +6268,10 @@ gtk_entry_create_layout (GtkEntry *entry, layout = gtk_widget_create_pango_layout (widget, NULL); pango_layout_set_single_paragraph_mode (layout, TRUE); - style_attrs = _gtk_style_context_get_pango_attributes (context); - tmp_attrs = style_attrs ? style_attrs : pango_attr_list_new (); - - if (priv->attrs) - { - _gtk_pango_attr_list_merge (tmp_attrs, priv->attrs); - } + tmp_attrs = _gtk_style_context_get_pango_attributes (context); + tmp_attrs = _gtk_pango_attr_list_merge (tmp_attrs, priv->attrs); + if (!tmp_attrs) + tmp_attrs = pango_attr_list_new (); placeholder_layout = show_placeholder_text (entry); if (placeholder_layout) diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c index 92b8ee9e8e..fd8da41866 100644 --- a/gtk/gtklabel.c +++ b/gtk/gtklabel.c @@ -3465,36 +3465,17 @@ gtk_label_update_layout_attributes (GtkLabel *label) attrs = NULL; style_attrs = _gtk_style_context_get_pango_attributes (context); - if (style_attrs) - { - if (attrs) - _gtk_pango_attr_list_merge (attrs, style_attrs); - else - attrs = pango_attr_list_ref (style_attrs); - pango_attr_list_unref (style_attrs); - } - - if (priv->markup_attrs) - { - if (attrs) - _gtk_pango_attr_list_merge (attrs, priv->markup_attrs); - else - attrs = pango_attr_list_ref (priv->markup_attrs); - } - - if (priv->attrs) - { - if (attrs) - _gtk_pango_attr_list_merge (attrs, priv->attrs); - else - attrs = pango_attr_list_ref (priv->attrs); - } + attrs = _gtk_pango_attr_list_merge (attrs, style_attrs); + attrs = _gtk_pango_attr_list_merge (attrs, priv->markup_attrs); + attrs = _gtk_pango_attr_list_merge (attrs, priv->attrs); pango_layout_set_attributes (priv->layout, attrs); if (attrs) pango_attr_list_unref (attrs); + if (style_attrs) + pango_attr_list_unref (style_attrs); } static void diff --git a/gtk/gtkpango.c b/gtk/gtkpango.c index 261fac7c3d..63d445f385 100644 --- a/gtk/gtkpango.c +++ b/gtk/gtkpango.c @@ -1300,14 +1300,24 @@ attr_list_merge_filter (PangoAttribute *attribute, /* * _gtk_pango_attr_list_merge: - * @into: a #PangoAttrList where attributes are merged. - * @from: a #PangoAttrList with the attributes to merge + * @into: a #PangoAttrList where attributes are merged or %NULL + * @from: a #PangoAttrList with the attributes to merge or %NULL * * Merges attributes from @from into @into. + * + * Returns: the merged list. */ -void +PangoAttrList * _gtk_pango_attr_list_merge (PangoAttrList *into, PangoAttrList *from) { - pango_attr_list_filter (from, attr_list_merge_filter, into); + if (from) + { + if (into) + pango_attr_list_filter (from, attr_list_merge_filter, into); + else + return pango_attr_list_ref (from); + } + + return into; } diff --git a/gtk/gtkpango.h b/gtk/gtkpango.h index f5383372a5..0d6e6c00d0 100644 --- a/gtk/gtkpango.h +++ b/gtk/gtkpango.h @@ -79,8 +79,8 @@ gchar *_gtk_pango_get_text_after (PangoLayout *layout, gint *start_offset, gint *end_offset); -void _gtk_pango_attr_list_merge (PangoAttrList *into, - PangoAttrList *from); +PangoAttrList *_gtk_pango_attr_list_merge (PangoAttrList *into, + PangoAttrList *from); G_END_DECLS