[goffice] Handle underline tags as named tags in textbuffer



commit 77c1f0a2ef57853ac0d7d1043fb070a0affee219
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Tue May 15 13:24:51 2012 -0600

    Handle underline tags as named tags in textbuffer
    
    2012-05-15 Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* goffice/utils/go-pango-extras.c
    	(go_load_pango_attributes_into_buffer_filter): remove underline
    	(go_load_pango_attributes_into_buffer_named_filter): add underline
    	(go_create_std_tags_for_buffer): create underline tags
    	(go_load_pango_attributes_into_buffer): handle underline tags as named tags

 ChangeLog                       |    8 ++++++++
 NEWS                            |    3 ++-
 goffice/utils/go-pango-extras.c |   37 +++++++++++++++++++++++++++++--------
 3 files changed, 39 insertions(+), 9 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 249ec67..8a88879 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2012-05-15 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* goffice/utils/go-pango-extras.c
+	(go_load_pango_attributes_into_buffer_filter): remove underline
+	(go_load_pango_attributes_into_buffer_named_filter): add underline
+	(go_create_std_tags_for_buffer): create underline tags
+	(go_load_pango_attributes_into_buffer): handle underline tags as named tags
+
 2012-05-15  Jean Brefort  <jean brefort normalesup org>
 
 	* goffice/canvas/goc-group.c: moved transfrom to GocItem.
diff --git a/NEWS b/NEWS
index 3e4299b..93ee056 100644
--- a/NEWS
+++ b/NEWS
@@ -1,7 +1,8 @@
 goffice 0.9.4:
 
 Andreas:
-	* Add go_pango_attrs_to_markup, partial inverse to pango_parse_markup
+	* Add go_pango_attrs_to_markup, partial inverse to pango_parse_markup.
+	* Handle underline tags as named tags in textbuffer.
 
 Jean:
 	* Fixed logfit equation typo. [#675560]
diff --git a/goffice/utils/go-pango-extras.c b/goffice/utils/go-pango-extras.c
index ca11d23..edac05f 100644
--- a/goffice/utils/go-pango-extras.c
+++ b/goffice/utils/go-pango-extras.c
@@ -272,7 +272,6 @@ go_load_pango_attributes_into_buffer_filter (PangoAttribute *attribute,
 					  G_GNUC_UNUSED gpointer data)
 {
 	return ((PANGO_ATTR_FOREGROUND == attribute->klass->type) ||
-		(PANGO_ATTR_UNDERLINE == attribute->klass->type) ||
 		(PANGO_ATTR_RISE == attribute->klass->type));
 }
 
@@ -282,6 +281,7 @@ go_load_pango_attributes_into_buffer_named_filter (PangoAttribute *attribute,
 {
 	return ((PANGO_ATTR_STYLE == attribute->klass->type) ||
 		(PANGO_ATTR_WEIGHT == attribute->klass->type) ||
+		(PANGO_ATTR_UNDERLINE == attribute->klass->type) ||
 		(PANGO_ATTR_STRIKETHROUGH == attribute->klass->type));
 }
 
@@ -318,6 +318,16 @@ go_create_std_tags_for_buffer (GtkTextBuffer *buffer)
 				    "weight-set", TRUE, NULL);
 	gtk_text_buffer_create_tag (buffer, "PANGO_WEIGHT_ULTRAHEAVY", "weight", 1000,
 				    "weight-set", TRUE, NULL);
+	gtk_text_buffer_create_tag (buffer, "PANGO_UNDERLINE_NONE", "underline", PANGO_UNDERLINE_NONE,
+				    "underline-set", TRUE, NULL);
+	gtk_text_buffer_create_tag (buffer, "PANGO_UNDERLINE_SINGLE", "underline", PANGO_UNDERLINE_SINGLE,
+				    "underline-set", TRUE, NULL);
+	gtk_text_buffer_create_tag (buffer, "PANGO_UNDERLINE_DOUBLE", "underline", PANGO_UNDERLINE_DOUBLE,
+				    "underline-set", TRUE, NULL);
+	gtk_text_buffer_create_tag (buffer, "PANGO_UNDERLINE_LOW", "underline", PANGO_UNDERLINE_LOW,
+				    "underline-set", TRUE, NULL);
+	gtk_text_buffer_create_tag (buffer, "PANGO_UNDERLINE_ERROR", "underline", PANGO_UNDERLINE_ERROR,
+				    "underline-set", TRUE, NULL);
 }
 
 static gint
@@ -389,6 +399,24 @@ go_load_pango_attributes_into_buffer (PangoAttrList  *markup, GtkTextBuffer *buf
 						gtk_text_buffer_apply_tag (buffer, tag,
 									   &start_iter, &end_iter);
 						break;
+					case PANGO_ATTR_UNDERLINE:
+						val = ((PangoAttrInt *)attribute)->value;
+						if (val == PANGO_UNDERLINE_NONE)
+							gtk_text_buffer_apply_tag_by_name (buffer,"PANGO_UNDERLINE_NONE",
+											   &start_iter, &end_iter);
+						else if (val == PANGO_UNDERLINE_SINGLE)
+							gtk_text_buffer_apply_tag_by_name (buffer,"PANGO_UNDERLINE_SINGLE",
+											   &start_iter, &end_iter);
+						else if (val == PANGO_UNDERLINE_DOUBLE)
+							gtk_text_buffer_apply_tag_by_name (buffer,"PANGO_UNDERLINE_DOUBLE",
+											   &start_iter, &end_iter);
+						else if (val == PANGO_UNDERLINE_LOW)
+							gtk_text_buffer_apply_tag_by_name (buffer,"PANGO_UNDERLINE_LOW",
+											   &start_iter, &end_iter);
+						else if (val == PANGO_UNDERLINE_ERROR)
+							gtk_text_buffer_apply_tag_by_name (buffer,"PANGO_UNDERLINE_ERROR",
+											   &start_iter, &end_iter);
+						break;
 					case PANGO_ATTR_WEIGHT:
 						val = ((PangoAttrInt *)attribute)->value;
 						if (val < (PANGO_WEIGHT_THIN + PANGO_WEIGHT_ULTRALIGHT)/2)
@@ -465,13 +493,6 @@ go_load_pango_attributes_into_buffer (PangoAttrList  *markup, GtkTextBuffer *buf
 							      NULL);
 						g_free (string);
 						break;
-					case PANGO_ATTR_UNDERLINE:
-						g_object_set (G_OBJECT (tag),
-							      "underline",
-							      ((PangoAttrInt *)attribute)->value,
-							      "underline-set", TRUE,
-							      NULL);
-						break;
 					case PANGO_ATTR_RISE:
 						g_object_set (G_OBJECT (tag),
 							      "rise",



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]