+/**
+ * gtk_label_set_attributes:
+ * @label: a #GtkLabel
+ * @attrs: a #PangoAttrList
+ *
+ * Sets a #PangoAttrList; the attributes in the list are applied to the
+ * label text.
+ **/
+void
+gtk_label_set_attributes (GtkLabel *label,
+ PangoAttrList *attrs)
+{
+ g_return_if_fail (GTK_IS_LABEL (label));
+
+ if (attrs)
+ pango_attr_list_ref (attrs);
+
+ if (label->attrs)
+ pango_attr_list_unref (label->attrs);
+
+ label->attrs = attrs;
+}
+
+static guint
+set_markup (GtkLabel *label,
+ const gchar *str,
+ gboolean with_uline)
+{
+ gchar *text = NULL;
+ GError *error = NULL;
+ PangoAttrList *attrs = NULL;
+ gunichar accel_char = 0;
+
+ if (str == NULL)
+ str = "";
+
+ if (!pango_parse_markup (str,
+ -1,
+ with_uline ? '_' : 0,
+ &attrs,
+ &text,
+ with_uline ? &accel_char : NULL,
+ &error))
+ {
+ g_warning ("Failed to set label from markup due to error parsing markup: %s",
+ error->message);
+ g_error_free (error);
+ return 0;
+ }
+
+ if (text)
+ gtk_label_set_text (label, text);
+
+ if (attrs)
+ {
+ gtk_label_set_attributes (label, attrs);
+ pango_attr_list_unref (attrs);
+ }
+
+ if (accel_char != 0)
+ return gdk_keyval_to_lower (accel_char);
+ else
+ return GDK_VoidSymbol;
+}
+
+/**
+ * gtk_label_set_markup:
+ * @label: a #GtkLabel
+ * @str: a markup string (see <link linkend="PangoMarkupFormat">Pango markup format</link>)
+ *
+ * Parses @str which is marked up with the Pango text markup language,
+ * setting the label's text and attribute list based on the parse results.
+ **/
+void
+gtk_label_set_markup (GtkLabel *label,
+ const gchar *str)
+{
+ g_return_if_fail (GTK_IS_LABEL (label));
+
+ set_markup (label, str, FALSE);
+}
+
+/**
+ * gtk_label_set_markup:
+ * @label: a #GtkLabel
+ * @str: a markup string (see <link linkend="PangoMarkupFormat">Pango markup format</link>)
+ *
+ * Parses @str which is marked up with the Pango text markup language,
+ * setting the label's text and attribute list based on the parse results.
+ * If characters in @str are preceded by an underscore, they are underlined
+ * indicating that they represent a keyboard accelerator, and the GDK
+ * keyval for the first underlined accelerator is returned. If there are
+ * no underlines in the text, GDK_VoidSymbol will be returned.
+ **/
+guint
+gtk_label_set_markup_with_accel (GtkLabel *label,
+ const gchar *str)
+{
+ g_return_if_fail (GTK_IS_LABEL (label));
+
+ return set_markup (label, str, TRUE);
+}
+