summaryrefslogtreecommitdiff
path: root/pango/pango-attributes.c
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2000-07-02 22:04:51 +0000
committerOwen Taylor <otaylor@src.gnome.org>2000-07-02 22:04:51 +0000
commit8e49176b74e6b7730f298dcfb61baa1aadd36065 (patch)
tree7cfddc9baa08e23d56a90645e597336ab9ac65be /pango/pango-attributes.c
parent6870ed61201c6c8545c59861a148647e39a3b7ed (diff)
downloadpango-8e49176b74e6b7730f298dcfb61baa1aadd36065.tar.gz
New function that inserts before other attributes with matching start
Sun Jul 2 17:59:56 2000 Owen Taylor <otaylor@redhat.com> * pango/pango-attributes.[ch] (pango_attr_list_insert_before): New function that inserts before other attributes with matching start index. * pango/pango-layout.[ch] (pango_layout_set_font_description): Add the ability to set a default font description on the layout, overriding the font description from the context.
Diffstat (limited to 'pango/pango-attributes.c')
-rw-r--r--pango/pango-attributes.c65
1 files changed, 48 insertions, 17 deletions
diff --git a/pango/pango-attributes.c b/pango/pango-attributes.c
index 695fa0f8..a688cab6 100644
--- a/pango/pango-attributes.c
+++ b/pango/pango-attributes.c
@@ -649,31 +649,21 @@ pango_attr_list_copy (PangoAttrList *list)
return new;
}
-/**
- * pango_attr_list_insert:
- * @list: a #PangoAttrList
- * @attr: the attribute to insert. Ownership of this value is
- * assumed by the list.
- *
- * Insert the given attribute into the #PangoAttrList. It will
- * be inserted after all other attributes with a matching
- * @start_index.
- **/
-void
-pango_attr_list_insert (PangoAttrList *list,
- PangoAttribute *attr)
+static void
+pango_attr_list_insert_internal (PangoAttrList *list,
+ PangoAttribute *attr,
+ gboolean before)
{
GSList *tmp_list, *prev, *link;
gint start_index = attr->start_index;
- g_return_if_fail (list != NULL);
-
if (!list->attributes)
{
list->attributes = g_slist_prepend (NULL, attr);
list->attributes_tail = list->attributes;
}
- else if (((PangoAttribute *)list->attributes_tail->data)->start_index <= start_index)
+ else if (((PangoAttribute *)list->attributes_tail->data)->start_index < start_index ||
+ (!before && ((PangoAttribute *)list->attributes_tail->data)->start_index == start_index))
{
g_slist_append (list->attributes_tail, attr);
}
@@ -685,7 +675,8 @@ pango_attr_list_insert (PangoAttrList *list,
{
PangoAttribute *tmp_attr = tmp_list->data;
- if (tmp_attr->start_index > start_index)
+ if (tmp_attr->start_index > start_index ||
+ (before && tmp_attr->start_index == start_index))
{
link = g_slist_alloc ();
link->next = tmp_list;
@@ -707,6 +698,46 @@ pango_attr_list_insert (PangoAttrList *list,
}
/**
+ * pango_attr_list_insert:
+ * @list: a #PangoAttrList
+ * @attr: the attribute to insert. Ownership of this value is
+ * assumed by the list.
+ *
+ * Insert the given attribute into the #PangoAttrList. It will
+ * be inserted after all other attributes with a matching
+ * @start_index.
+ **/
+void
+pango_attr_list_insert (PangoAttrList *list,
+ PangoAttribute *attr)
+{
+ g_return_if_fail (list != NULL);
+ g_return_if_fail (attr != NULL);
+
+ pango_attr_list_insert_internal (list, attr, FALSE);
+}
+
+/**
+ * pango_attr_list_insert_before:
+ * @list: a #PangoAttrList
+ * @attr: the attribute to insert. Ownership of this value is
+ * assumed by the list.
+ *
+ * Insert the given attribute into the #PangoAttrList. It will
+ * be inserted before all other attributes with a matching
+ * @start_index.
+ **/
+void
+pango_attr_list_insert_before (PangoAttrList *list,
+ PangoAttribute *attr)
+{
+ g_return_if_fail (list != NULL);
+ g_return_if_fail (attr != NULL);
+
+ pango_attr_list_insert_internal (list, attr, TRUE);
+}
+
+/**
* pango_attr_list_change:
* @list: a #PangoAttrList
* @attr: the attribute to insert. Ownership of this value is