[glabels/vala] Write text object to glabels file.
- From: Jim Evins <jimevins src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glabels/vala] Write text object to glabels file.
- Date: Tue, 31 Jul 2012 02:15:19 +0000 (UTC)
commit 923cafb772aa3d95d1c608111a41978351fba7af
Author: Jim Evins <evins snaught com>
Date: Mon Jul 30 22:14:11 2012 -0400
Write text object to glabels file.
glabels/xml_label.vala | 80 +++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 75 insertions(+), 5 deletions(-)
---
diff --git a/glabels/xml_label.vala b/glabels/xml_label.vala
index a0104f1..e0d7ea2 100644
--- a/glabels/xml_label.vala
+++ b/glabels/xml_label.vala
@@ -185,10 +185,6 @@ namespace glabels
switch (child->name)
{
- case "Object-text":
- parse_object_text_node( child, label );
- break;
-
case "Object-box":
parse_object_box_node( child, label );
break;
@@ -209,6 +205,10 @@ namespace glabels
/* TODO. */
break;
+ case "Object-text":
+ parse_object_text_node( child, label );
+ break;
+
default:
if ( child->is_text() == 0 )
{
@@ -581,13 +581,83 @@ namespace glabels
XmlUtil.set_prop_length( node, "w", object.w );
XmlUtil.set_prop_length( node, "h", object.h );
+ /* align attr */
+ XmlUtil.set_prop_string( node, "align", EnumUtil.align_to_string( object.text_alignment ) );
+
+ /* valign attr */
+ XmlUtil.set_prop_string( node, "valign", EnumUtil.valign_to_string( object.text_valignment ) );
+
+ /* auto_shrink attr */
+ XmlUtil.set_prop_bool( node, "auto_shrink", object.auto_shrink );
+
/* affine attrs */
create_affine_attrs( node, object );
/* shadow attrs */
create_shadow_attrs( node, object );
- // TODO: create contents.
+ /* Add children */
+ create_toplevel_span_node( node, ns, object );
+ }
+
+
+ private void create_toplevel_span_node( Xml.Node parent,
+ Xml.Ns ns,
+ LabelObjectText object )
+ {
+ unowned Xml.Node *node = parent.new_child( ns, "Span" );
+
+ /* font_family attr */
+ XmlUtil.set_prop_string( node, "font_family", object.font_family );
+
+ /* font_size attr */
+ XmlUtil.set_prop_double( node, "font_size", object.font_size );
+
+ /* font_weight attr */
+ XmlUtil.set_prop_string( node, "font_weight", EnumUtil.weight_to_string( object.font_weight ) );
+
+ /* font_italic attr */
+ XmlUtil.set_prop_bool( node, "font_italic", object.font_italic_flag );
+
+ /* color attrs */
+ if ( object.text_color_node.field_flag )
+ {
+ XmlUtil.set_prop_string( node, "color_field", object.text_color_node.key );
+ }
+ else
+ {
+ XmlUtil.set_prop_uint_hex( node, "color", object.text_color_node.color.to_legacy_color() );
+ }
+
+ /* line_spacing attr */
+ XmlUtil.set_prop_double( node, "line_spacing", object.text_line_spacing );
+
+ /* Build children */
+ TextLines lines = object.get_lines();
+ bool first_line = true;
+ foreach (TextLine line in lines.lines)
+ {
+ if ( !first_line )
+ {
+ node->new_child( ns, "NL" );
+ }
+
+ foreach (TextNode text_node in line.nodes)
+ {
+ if ( text_node.field_flag )
+ {
+ unowned Xml.Node *child = node->new_child( ns, "Field" );
+ XmlUtil.set_prop_string( child, "name", text_node.data );
+ }
+ else
+ {
+ node->add_content( text_node.data );
+ }
+ }
+
+ first_line = false;
+ }
+
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]