+2005-10-23 Jim Evins <evins@snaught.com>
+
+ reviewed by: <delete if not using a buddy>
+
+ * libglabels/xml.h:
+ * libglabels/xml.c: (gl_xml_get_prop_string),
+ (gl_xml_get_prop_i18n_string), (gl_xml_set_prop_string),
+ (gl_xml_is_node), (gl_xml_get_node_content):
+ Added new XML utility functions.
+ * libglabels/xml-paper.c:
+ * libglabels/xml-template.c:
+ * src/xml-label.c:
+ Cleanup by using new xml utilities created above.
+ * libglabels/paper.c: (gl_paper_free):
+ * src/file.c: (new_response):
+ * src/object-editor-image-page.c: (add_image_filters_to_chooser):
+ * src/pixbuf-cache.c: (gl_pixbuf_cache_add_pixbuf),
+ (gl_pixbuf_cache_get_pixbuf):
+ * src/ui-property-bar.c:
+ (gl_ui_property_bar_construct_color_combo):
+ * src/view-highlight.c: (gl_view_highlight_finalize):
+ * src/view-image.c: (update_object_from_editor_cb):
+ * src/view.c: (gl_view_finalize), (draw_bg_fg_layers),
+ (draw_bg_fg_rounded_rect), (draw_bg_fg_round), (draw_bg_fg_cd),
+ (draw_bg_fg_cd_bc), (draw_markup_layer), (draw_markup_margin),
+ (draw_markup_margin_rect), (draw_markup_margin_rounded_rect),
+ (draw_markup_margin_round), (draw_markup_margin_cd),
+ (draw_markup_margin_cd_bc):
+ * src/wdgt-mini-preview.c: (mini_outline_list_new):
+ * src/wdgt-rotate-label.c: (gl_wdgt_rotate_label_finalize):
+ Plugged various memory leaks located with valgrind.
+ * src/view-image.c: (update_canvas_item_from_object_cb):
+ Don't allow a width or height of zero when drawing pixbuf.
+
2005-10-22 Jim Evins <evins@snaught.com>
* libglabels/xml-paper.c:
if ( paper != NULL ) {
g_free (paper->id);
- paper->name = NULL;
+ paper->id = NULL;
g_free (paper->name);
paper->name = NULL;
xmlFreeDoc (papers_doc);
return papers;
}
- if (!xmlStrEqual (root->name, (xmlChar *)"Glabels-paper-sizes")) {
+ if (!gl_xml_is_node (root, "Glabels-paper-sizes")) {
g_warning ("\"%s\" is not a glabels paper file (wrong root node)",
papers_doc->name);
xmlFreeDoc (papers_doc);
for (node = root->xmlChildrenNode; node != NULL; node = node->next) {
- if (xmlStrEqual (node->name, (xmlChar *)"Paper-size")) {
+ if (gl_xml_is_node (node, "Paper-size")) {
paper = gl_xml_paper_parse_paper_node (node);
papers = g_list_append (papers, paper);
} else {
if ( !xmlNodeIsText(node) ) {
- if (!xmlStrEqual (node->name,(xmlChar *)"comment")) {
+ if (!gl_xml_is_node (node, "comment")) {
g_warning ("bad node = \"%s\"",node->name);
}
}
gl_xml_paper_parse_paper_node (xmlNodePtr paper_node)
{
glPaper *paper;
- xmlChar *id, *name;
+ gchar *id, *name;
gdouble width, height;
LIBXML_TEST_VERSION;
- id = xmlGetProp (paper_node, (xmlChar *)"id");
+ id = gl_xml_get_prop_string (paper_node, "id", NULL);
- name = xmlGetProp (paper_node, (xmlChar *)"_name");
- if (name != NULL) {
-
- xmlChar *tmp = (xmlChar *)gettext ((char *)name);
-
- if (tmp != name) {
- xmlFree (name);
- name = xmlStrdup (tmp);
- }
-
- } else {
- name = xmlGetProp (paper_node, (xmlChar *)"name");
- }
+ name = gl_xml_get_prop_i18n_string (paper_node, "name", NULL);
width = gl_xml_get_prop_length (paper_node, "width", 0);
height = gl_xml_get_prop_length (paper_node, "height", 0);
- paper = gl_paper_new ((gchar *)id, (gchar *)name, width, height);
+ paper = gl_paper_new (id, name, width, height);
- xmlFree (id);
- xmlFree (name);
+ g_free (id);
+ g_free (name);
return paper;
}
templates_doc->URL);
return templates;
}
- if (!xmlStrEqual (root->name, (xmlChar *)"Glabels-templates")) {
+ if (!gl_xml_is_node (root, "Glabels-templates")) {
g_warning ("\"%s\" is not a glabels template file (wrong root node)",
templates_doc->URL);
return templates;
for (node = root->xmlChildrenNode; node != NULL; node = node->next) {
- if (xmlStrEqual (node->name, (xmlChar *)"Template")) {
+ if (gl_xml_is_node (node, "Template")) {
template = gl_xml_template_parse_template_node (node);
templates = g_list_append (templates, template);
} else {
if ( !xmlNodeIsText(node) ) {
- if (!xmlStrEqual (node->name,(xmlChar *)"comment")) {
+ if (!gl_xml_is_node (node,"comment")) {
g_warning ("bad node = \"%s\"",node->name);
}
}
glTemplate *
gl_xml_template_parse_template_node (const xmlNodePtr template_node)
{
- xmlChar *name;
- xmlChar *description;
- xmlChar *page_size;
+ gchar *name;
+ gchar *description;
+ gchar *page_size;
gdouble page_width, page_height;
glPaper *paper = NULL;
glTemplate *template;
xmlNodePtr node;
- name = xmlGetProp (template_node, (xmlChar *)"name");
+ name = gl_xml_get_prop_string (template_node, "name", NULL);
+ description = gl_xml_get_prop_i18n_string (template_node, "description", NULL);
+ page_size = gl_xml_get_prop_string (template_node, "size", NULL);
- description = xmlGetProp (template_node, (xmlChar *)"_description");
- if (description != NULL) {
-
- xmlChar *tmp = (xmlChar *)gettext ((char *)description);
-
- if (tmp != description) {
- xmlFree (description);
- description = xmlStrdup (tmp);
- }
-
- } else {
- description = xmlGetProp (template_node, (xmlChar *)"description");
- }
-
- page_size = xmlGetProp (template_node, (xmlChar *)"size");
- if (gl_paper_is_id_other ((gchar *)page_size)) {
+ if (gl_paper_is_id_other (page_size)) {
page_width = gl_xml_get_prop_length (template_node, "width", 0);
page_height = gl_xml_get_prop_length (template_node, "height", 0);
} else {
- paper = gl_paper_from_id ((gchar *)page_size);
+ paper = gl_paper_from_id (page_size);
if (paper == NULL) {
/* This should always be an id, but just in case a name
slips by! */
g_warning (_("Unknown page size id \"%s\", trying as name"),
page_size);
- paper = gl_paper_from_name ((gchar *)page_size);
- xmlFree (page_size);
- page_size = xmlStrdup ((xmlChar *)paper->id);
+ paper = gl_paper_from_name (page_size);
+ g_free (page_size);
+ page_size = g_strdup (paper->id);
}
if (paper != NULL) {
page_width = paper->width;
paper = NULL;
}
- template = gl_template_new ((gchar *)name,
- (gchar *)description,
- (gchar *)page_size,
+ template = gl_template_new (name,
+ description,
+ page_size,
page_width, page_height);
for (node = template_node->xmlChildrenNode; node != NULL;
node = node->next) {
- if (xmlStrEqual (node->name, (xmlChar *)"Label-rectangle")) {
+ if (gl_xml_is_node (node, "Label-rectangle")) {
xml_parse_label_rectangle_node (node, template);
- } else if (xmlStrEqual (node->name, (xmlChar *)"Label-round")) {
+ } else if (gl_xml_is_node (node, "Label-round")) {
xml_parse_label_round_node (node, template);
- } else if (xmlStrEqual (node->name, (xmlChar *)"Label-cd")) {
+ } else if (gl_xml_is_node (node, "Label-cd")) {
xml_parse_label_cd_node (node, template);
- } else if (xmlStrEqual (node->name, (xmlChar *)"Alias")) {
+ } else if (gl_xml_is_node (node, "Alias")) {
xml_parse_alias_node (node, template);
} else {
if (!xmlNodeIsText (node)) {
- if (!xmlStrEqual (node->name,(xmlChar *)"comment")) {
+ if (!gl_xml_is_node (node,"comment")) {
g_warning ("bad node = \"%s\"",node->name);
}
}
}
}
- xmlFree (name);
- xmlFree (description);
- xmlFree (page_size);
+ g_free (name);
+ g_free (description);
+ g_free (page_size);
return template;
}
xml_parse_label_rectangle_node (xmlNodePtr label_node,
glTemplate *template)
{
- xmlChar *id;
- xmlChar *tmp;
+ gchar *id;
+ gchar *tmp;
gdouble x_waste, y_waste;
gdouble w, h, r;
glTemplateLabelType *label_type;
xmlNodePtr node;
- id = xmlGetProp (label_node, (xmlChar *)"id");
+ id = gl_xml_get_prop_string (label_node, "id", NULL);
- if (tmp = xmlGetProp (label_node, (xmlChar *)"waste")) {
+ if (tmp = gl_xml_get_prop_string (label_node, "waste", NULL)) {
/* Handle single "waste" property. */
x_waste = y_waste = gl_xml_get_prop_length (label_node, "waste", 0);
- xmlFree (tmp);
+ g_free (tmp);
} else {
x_waste = gl_xml_get_prop_length (label_node, "x_waste", 0);
y_waste = gl_xml_get_prop_length (label_node, "y_waste", 0);
for (node = label_node->xmlChildrenNode; node != NULL;
node = node->next) {
- if (xmlStrEqual (node->name, (xmlChar *)"Layout")) {
+ if (gl_xml_is_node (node, "Layout")) {
xml_parse_layout_node (node, label_type);
- } else if (xmlStrEqual (node->name, (xmlChar *)"Markup-margin")) {
+ } else if (gl_xml_is_node (node, "Markup-margin")) {
xml_parse_markup_margin_node (node, label_type);
- } else if (xmlStrEqual (node->name, (xmlChar *)"Markup-line")) {
+ } else if (gl_xml_is_node (node, "Markup-line")) {
xml_parse_markup_line_node (node, label_type);
- } else if (xmlStrEqual (node->name, (xmlChar *)"Markup-circle")) {
+ } else if (gl_xml_is_node (node, "Markup-circle")) {
xml_parse_markup_circle_node (node, label_type);
} else if (!xmlNodeIsText (node)) {
- if (!xmlStrEqual (node->name, (xmlChar *)"comment")) {
+ if (!gl_xml_is_node (node, "comment")) {
g_warning ("bad node = \"%s\"",node->name);
}
}
}
- xmlFree (id);
+ g_free (id);
}
/*--------------------------------------------------------------------------*/
xml_parse_label_round_node (xmlNodePtr label_node,
glTemplate *template)
{
- xmlChar *id;
+ gchar *id;
gdouble waste;
gdouble r;
glTemplateLabelType *label_type;
xmlNodePtr node;
- id = xmlGetProp (label_node, (xmlChar *)"id");
+ id = gl_xml_get_prop_string (label_node, "id", NULL);
waste = gl_xml_get_prop_length (label_node, "waste", 0);
r = gl_xml_get_prop_length (label_node, "radius", 0);
for (node = label_node->xmlChildrenNode; node != NULL;
node = node->next) {
- if (xmlStrEqual (node->name, (xmlChar *)"Layout")) {
+ if (gl_xml_is_node (node, "Layout")) {
xml_parse_layout_node (node, label_type);
- } else if (xmlStrEqual (node->name, (xmlChar *)"Markup-margin")) {
+ } else if (gl_xml_is_node (node, "Markup-margin")) {
xml_parse_markup_margin_node (node, label_type);
- } else if (xmlStrEqual (node->name, (xmlChar *)"Markup-line")) {
+ } else if (gl_xml_is_node (node, "Markup-line")) {
xml_parse_markup_line_node (node, label_type);
- } else if (xmlStrEqual (node->name, (xmlChar *)"Markup-circle")) {
+ } else if (gl_xml_is_node (node, "Markup-circle")) {
xml_parse_markup_circle_node (node, label_type);
} else if (!xmlNodeIsText (node)) {
- if (!xmlStrEqual (node->name, (xmlChar *)"comment")) {
+ if (!gl_xml_is_node (node, "comment")) {
g_warning ("bad node = \"%s\"",node->name);
}
}
}
- xmlFree (id);
+ g_free (id);
}
/*--------------------------------------------------------------------------*/
xml_parse_label_cd_node (xmlNodePtr label_node,
glTemplate *template)
{
- xmlChar *id;
+ gchar *id;
gdouble waste;
gdouble r1, r2, w, h;
glTemplateLabelType *label_type;
xmlNodePtr node;
- id = xmlGetProp (label_node, (xmlChar *)"id");
+ id = gl_xml_get_prop_string (label_node, "id", NULL);
waste = gl_xml_get_prop_length (label_node, "waste", 0);
r1 = gl_xml_get_prop_length (label_node, "radius", 0);
r2 = gl_xml_get_prop_length (label_node, "hole", 0);
for (node = label_node->xmlChildrenNode; node != NULL;
node = node->next) {
- if (xmlStrEqual (node->name, (xmlChar *)"Layout")) {
+ if (gl_xml_is_node (node, "Layout")) {
xml_parse_layout_node (node, label_type);
- } else if (xmlStrEqual (node->name, (xmlChar *)"Markup-margin")) {
+ } else if (gl_xml_is_node (node, "Markup-margin")) {
xml_parse_markup_margin_node (node, label_type);
- } else if (xmlStrEqual (node->name, (xmlChar *)"Markup-line")) {
+ } else if (gl_xml_is_node (node, "Markup-line")) {
xml_parse_markup_line_node (node, label_type);
- } else if (xmlStrEqual (node->name, (xmlChar *)"Markup-circle")) {
+ } else if (gl_xml_is_node (node, "Markup-circle")) {
xml_parse_markup_circle_node (node, label_type);
} else if (!xmlNodeIsText (node)) {
- if (!xmlStrEqual (node->name, (xmlChar *)"comment")) {
+ if (!gl_xml_is_node (node, "comment")) {
g_warning ("bad node = \"%s\"",node->name);
}
}
}
- xmlFree (id);
+ g_free (id);
}
/*--------------------------------------------------------------------------*/
for (node = layout_node->xmlChildrenNode; node != NULL;
node = node->next) {
if (!xmlNodeIsText (node)) {
- if (!xmlStrEqual (node->name, (xmlChar *)"comment")) {
+ if (!gl_xml_is_node (node, "comment")) {
g_warning ("bad node = \"%s\"",node->name);
}
}
for (node = markup_node->xmlChildrenNode; node != NULL;
node = node->next) {
if (!xmlNodeIsText (node)) {
- if (!xmlStrEqual (node->name, (xmlChar *)"comment")) {
+ if (!gl_xml_is_node (node, "comment")) {
g_warning ("bad node = \"%s\"",node->name);
}
}
for (node = markup_node->xmlChildrenNode; node != NULL;
node = node->next) {
if (!xmlNodeIsText (node)) {
- if (!xmlStrEqual (node->name, (xmlChar *)"comment")) {
+ if (!gl_xml_is_node (node, "comment")) {
g_warning ("bad node = \"%s\"",node->name);
}
}
for (node = markup_node->xmlChildrenNode; node != NULL;
node = node->next) {
if (!xmlNodeIsText (node)) {
- if (!xmlStrEqual (node->name, (xmlChar *)"comment")) {
+ if (!gl_xml_is_node (node, "comment")) {
g_warning ("bad node = \"%s\"",node->name);
}
}
xml_parse_alias_node (xmlNodePtr alias_node,
glTemplate *template)
{
- xmlChar *name;
+ gchar *name;
- name = xmlGetProp (alias_node, (xmlChar *)"name");
+ name = gl_xml_get_prop_string (alias_node, "name", NULL);
gl_template_add_alias (template, (gchar *)name);
- xmlFree (name);
+ g_free (name);
}
/**
node = xmlNewChild (root, ns, (xmlChar *)"Template", NULL);
- xmlSetProp (node, (xmlChar *)"name", (xmlChar *)template->name);
+ gl_xml_set_prop_string (node, "name", template->name);
- xmlSetProp (node, (xmlChar *)"size", (xmlChar *)template->page_size);
+ gl_xml_set_prop_string (node, "size", template->page_size);
if (xmlStrEqual ((xmlChar *)template->page_size, (xmlChar *)"Other")) {
gl_xml_set_prop_length (node, "width", template->page_width);
}
- xmlSetProp (node, (xmlChar *)"description", (xmlChar *)template->description);
+ gl_xml_set_prop_string (node, "description", template->description);
for ( p=template->label_types; p != NULL; p=p->next ) {
label_type = (glTemplateLabelType *)p->data;
case GL_TEMPLATE_SHAPE_RECT:
node = xmlNewChild(root, ns, (xmlChar *)"Label-rectangle", NULL);
- xmlSetProp (node, (xmlChar *)"id", (xmlChar *)label_type->id);
- gl_xml_set_prop_length (node, "width", label_type->size.rect.w);
- gl_xml_set_prop_length (node, "height", label_type->size.rect.h);
- gl_xml_set_prop_length (node, "round", label_type->size.rect.r);
- gl_xml_set_prop_length (node, "x_waste", label_type->size.rect.x_waste);
- gl_xml_set_prop_length (node, "y_waste", label_type->size.rect.y_waste);
+ gl_xml_set_prop_string (node, "id", label_type->id);
+ gl_xml_set_prop_length (node, "width", label_type->size.rect.w);
+ gl_xml_set_prop_length (node, "height", label_type->size.rect.h);
+ gl_xml_set_prop_length (node, "round", label_type->size.rect.r);
+ gl_xml_set_prop_length (node, "x_waste", label_type->size.rect.x_waste);
+ gl_xml_set_prop_length (node, "y_waste", label_type->size.rect.y_waste);
break;
case GL_TEMPLATE_SHAPE_ROUND:
node = xmlNewChild(root, ns, (xmlChar *)"Label-round", NULL);
- xmlSetProp (node, (xmlChar *)"id", (xmlChar *)label_type->id);
+ gl_xml_set_prop_string (node, "id", label_type->id);
gl_xml_set_prop_length (node, "radius", label_type->size.round.r);
gl_xml_set_prop_length (node, "waste", label_type->size.round.waste);
break;
case GL_TEMPLATE_SHAPE_CD:
node = xmlNewChild(root, ns, (xmlChar *)"Label-cd", NULL);
- xmlSetProp (node, (xmlChar *)"id", (xmlChar *)label_type->id);
- gl_xml_set_prop_length (node, "radius", label_type->size.cd.r1);
- gl_xml_set_prop_length (node, "hole", label_type->size.cd.r2);
+ gl_xml_set_prop_string (node, "id", label_type->id);
+ gl_xml_set_prop_length (node, "radius", label_type->size.cd.r1);
+ gl_xml_set_prop_length (node, "hole", label_type->size.cd.r2);
if (label_type->size.cd.w != 0.0) {
gl_xml_set_prop_length (node, "width", label_type->size.cd.w);
}
xmlNodePtr node;
node = xmlNewChild (root, ns, (xmlChar *)"Alias", NULL);
- xmlSetProp (node, (xmlChar *)"name", (xmlChar *)name);
+ gl_xml_set_prop_string (node, "name", name);
}
/****************************************************************************/
+/**
+ * gl_xml_get_prop_string:
+ * @node: the libxml2 #xmlNodePtr of the node
+ * @property: the property name
+ * @default_val: a default value to return if property not found
+ *
+ * Return value of property as a string.
+ *
+ * Returns: the property as a pointer to a gchar string. This string should
+ * be freed with g_free().
+ *
+ */
+gchar *
+gl_xml_get_prop_string (xmlNodePtr node,
+ const gchar *property,
+ const gchar *default_val)
+{
+ gchar *val;
+ xmlChar *string;
+
+ string = xmlGetProp (node, (xmlChar *)property);
+ if ( string != NULL ) {
+ val = g_strdup ((gchar *)string);
+ xmlFree (string);
+ return val;
+ }
+
+ if (default_val) {
+ return g_strdup (default_val);
+ }
+
+ return NULL;
+}
+
+
+/**
+ * gl_xml_get_prop_i18n_string:
+ * @node: the libxml2 #xmlNodePtr of the node
+ * @property: the property name
+ * @default_val: a default value to return if property not found
+ *
+ * Return value of a translatable property as a string.
+ *
+ * Returns: the property as a pointer to a gchar string. This string should
+ * be freed with g_free().
+ *
+ */
+gchar *
+gl_xml_get_prop_i18n_string (xmlNodePtr node,
+ const gchar *property,
+ const gchar *default_val)
+{
+ gchar *_property;
+ gchar *val;
+ xmlChar *string;
+
+ _property = g_strdup_printf ("_%s", property);
+ string = xmlGetProp (node, (xmlChar *)_property);
+ g_free (_property);
+
+ if ( string != NULL ) {
+
+ val = g_strdup (gettext ((char *)string));
+ xmlFree (string);
+ return val;
+
+ }
+
+ string = xmlGetProp (node, (xmlChar *)property);
+ if ( string != NULL ) {
+ val = g_strdup ((gchar *)string);
+ xmlFree (string);
+ return val;
+ }
+
+ if (default_val) {
+ return g_strdup (default_val);
+ }
+
+ return NULL;
+}
+
+
/**
* gl_xml_get_prop_double:
* @node: the libxml2 #xmlNodePtr of the node
}
+/**
+ * gl_xml_set_prop_string:
+ * @node: the libxml2 #xmlNodePtr of the node
+ * @property: the property name
+ * @val: the value to set
+ *
+ * Set a property from a string.
+ *
+ */
+void
+gl_xml_set_prop_string (xmlNodePtr node,
+ const gchar *property,
+ const gchar *val)
+{
+ if (val != NULL) {
+ xmlSetProp (node, (xmlChar *)property, (xmlChar *)val);
+ }
+}
+
+
/**
* gl_xml_set_prop_double:
* @node: the libxml2 #xmlNodePtr of the node
g_free (string_unit);
}
+/**
+ * gl_xml_is_node
+ * @node: the libxml2 #xmlNodePtr of the node
+ * @property: the node name
+ *
+ * Test if a node name matches given name.
+ *
+ * Returns: TRUE if the name of the node matches. Otherwise FALSE.
+ *
+ */
+gboolean
+gl_xml_is_node (xmlNodePtr node,
+ const gchar *name)
+{
+ return xmlStrEqual (node->name, (xmlChar *)name);
+}
+
+
+/**
+ * gl_xml_get_node_content
+ * @node: the libxml2 #xmlNodePtr of the node
+ *
+ * Get the content of a node.
+ *
+ * Returns: the property as a pointer to a gchar string. This string should
+ * be freed with g_free().
+ */
+gchar *
+gl_xml_get_node_content (xmlNodePtr node)
+{
+ xmlChar *xml_content;
+ gchar *g_content;
+
+ xml_content = xmlNodeGetContent (node);
+
+ if (xml_content != NULL) {
+
+ g_content = g_strdup ((gchar *)xml_content);
+ xmlFree (xml_content);
+ return g_content;
+
+ }
+
+ return NULL;
+}
+
+
/**
* gl_xml_set_default_units:
* @units: default units selection (#glUnitsType)
G_BEGIN_DECLS
+/*
+ * Get property functions
+ */
+gchar * gl_xml_get_prop_string (xmlNodePtr node,
+ const gchar *property,
+ const gchar *default_val);
+
+gchar * gl_xml_get_prop_i18n_string (xmlNodePtr node,
+ const gchar *property,
+ const gchar *default_val);
+
gdouble gl_xml_get_prop_double (xmlNodePtr node,
const gchar *property,
gdouble default_val);
gdouble default_val);
+/*
+ * Set property functions
+ */
+void gl_xml_set_prop_string (xmlNodePtr node,
+ const gchar *property,
+ const gchar *val);
+
void gl_xml_set_prop_double (xmlNodePtr node,
const gchar *property,
gdouble val);
const gchar *property,
gdouble val);
+/*
+ * Other node functions
+ */
+gboolean gl_xml_is_node (xmlNodePtr node,
+ const gchar *name);
+
+gchar * gl_xml_get_node_content (xmlNodePtr node);
+
+/*
+ * Misc functions
+ */
void gl_xml_set_default_units (glUnitsType units);
G_END_DECLS
gl_label_set_template (label, template);
gl_label_set_rotate_flag (label, rotate_flag);
+ gl_template_free (template);
+
window =
GL_WINDOW (g_object_get_data (G_OBJECT (dlg),
"parent_window"));
/* Individual image filters */
formats = gdk_pixbuf_get_formats ();
for (it = formats; it != NULL; it = it->next) {
- char *filter_name;
+ gchar *filter_name;
GdkPixbufFormat *format;
filter = gtk_file_filter_new ();
+ gchar *description, *name;
format = (GdkPixbufFormat*) it->data;
/* Filter name: First description then file extension, eg. "The PNG-Format (*.png)".*/
- filter_name = g_strdup_printf (_("%s (*.%s)"),
- gdk_pixbuf_format_get_description (format),
- gdk_pixbuf_format_get_name (format));
+ description = gdk_pixbuf_format_get_description (format);
+ name = gdk_pixbuf_format_get_name (format);
+ filter_name = g_strdup_printf (_("%s (*.%s)"), description, name);
+ g_free (description);
+ g_free (name);
gtk_file_filter_set_name (filter, filter_name);
g_free (filter_name);
}
/*****************************************************************************/
-/* Add pixbuf to cache explicitly. */
+/* Add pixbuf to cache explicitly (not a reference). */
/*****************************************************************************/
void
gl_pixbuf_cache_add_pixbuf (GHashTable *pixbuf_cache,
record = g_new0 (CacheRecord, 1);
record->key = g_strdup (name);
- record->references = 0;
- record->pixbuf = pixbuf;
+ record->references = 0; /* Nobody has referenced it yet. */
+ record->pixbuf = g_object_ref (G_OBJECT (pixbuf));
g_hash_table_insert (pixbuf_cache, record->key, record);
record = g_hash_table_lookup (pixbuf_cache, name);
if (record != NULL) {
- gl_debug (DEBUG_PIXBUF_CACHE, "END cached");
record->references++;
+ gl_debug (DEBUG_PIXBUF_CACHE, "references=%d", record->references);
+ gl_debug (DEBUG_PIXBUF_CACHE, "END cached");
return record->pixbuf;
}
color_combo_box_set_preview_relief (COLOR_COMBO(color_combo), GTK_RELIEF_NORMAL);
+ g_object_unref (G_OBJECT (pixbuf));
+
return color_combo;
}
gtk_object_destroy (GTK_OBJECT(view_highlight->private->position_group));
+ if (view_highlight->private) {
+ g_free (view_highlight->private);
+ }
+
G_OBJECT_CLASS (parent_class)->finalize (object);
gl_debug (DEBUG_VIEW, "END");
/* Private macros and constants. */
/*========================================================*/
-#define DELTA 0.01
+#define MIN_IMAGE_SIZE 0.01
/*========================================================*/
/* Private types. */
/* Query properties of object. */
gl_label_object_get_size (GL_LABEL_OBJECT(object), &w, &h);
+ w = MAX (w, MIN_IMAGE_SIZE);
+ h = MAX (h, MIN_IMAGE_SIZE);
pixbuf = gl_label_image_get_pixbuf (GL_LABEL_IMAGE(object), NULL);
/* Adjust appearance of analogous canvas item. */
filename = gl_object_editor_get_image (editor);
gl_label_image_set_filename (GL_LABEL_IMAGE(object), filename);
+ gl_text_node_free (&filename);
/* Setting filename may have modified the size. */
gl_label_object_get_size (object, &w, &h);
view = GL_VIEW (object);
+ if (view->default_font_family) {
+ g_free (view->default_font_family);
+ }
+
G_OBJECT_CLASS (parent_class)->finalize (object);
gl_debug (DEBUG_VIEW, "END");
g_warning ("Unknown template label style");
break;
}
+
+ gl_template_free (template);
}
/*---------------------------------------------------------------------------*/
NULL);
gnome_canvas_points_free (points);
+ gl_template_free (template);
gl_debug (DEBUG_VIEW, "END");
}
"outline_color_rgba", OUTLINE_COLOR,
NULL);
+ gl_template_free (template);
+
gl_debug (DEBUG_VIEW, "END");
}
"outline_color_rgba", OUTLINE_COLOR,
NULL);
+ gl_template_free (template);
+
gl_debug (DEBUG_VIEW, "END");
}
NULL);
gnome_canvas_points_free (points);
+ gl_template_free (template);
gl_debug (DEBUG_VIEW, "END");
}
break;
}
}
+
+ gl_template_free (template);
+
}
/*---------------------------------------------------------------------------*/
g_warning ("Unknown template label style");
break;
}
+
+ gl_template_free (template);
}
/*---------------------------------------------------------------------------*/
"outline_color_rgba", MARKUP_COLOR,
NULL);
+ gl_template_free (template);
+
gl_debug (DEBUG_VIEW, "END");
}
"outline_color_rgba", MARKUP_COLOR,
NULL);
gnome_canvas_points_free (points);
+ gl_template_free (template);
gl_debug (DEBUG_VIEW, "END");
}
"outline_color_rgba", MARKUP_COLOR,
NULL);
+ gl_template_free (template);
+
gl_debug (DEBUG_VIEW, "END");
}
"outline_color_rgba", MARKUP_COLOR,
NULL);
+ gl_template_free (template);
+
gl_debug (DEBUG_VIEW, "END");
}
"outline_color_rgba", MARKUP_COLOR,
NULL);
+
+ gl_template_free (template);
+
gl_debug (DEBUG_VIEW, "END");
}
list = g_list_append (list, item);
}
+ g_free (origins);
+
gl_debug (DEBUG_MINI_PREVIEW, "END");
return list;
}
rotate_select = GL_WDGT_ROTATE_LABEL (object);
+ if (rotate_select->template) {
+ gl_template_free (rotate_select->template);
+ rotate_select->template = NULL;
+ }
+
G_OBJECT_CLASS (parent_class)->finalize (object);
}
*status = XML_LABEL_OK;
- if (!xmlStrEqual (root->name, (xmlChar *)"Glabels-document")) {
+ if (!gl_xml_is_node (root, "Glabels-document")) {
g_warning (_("Bad root node = \"%s\""), root->name);
*status = XML_LABEL_ERROR_OPEN_PARSE;
return NULL;
/* Pass 1, extract data nodes to pre-load cache. */
for (child_node = root->xmlChildrenNode; child_node != NULL; child_node = child_node->next) {
- if (xmlStrEqual (child_node->name, (xmlChar *)"Data")) {
+ if (gl_xml_is_node (child_node, "Data")) {
xml_parse_data (child_node, label);
}
}
child_node != NULL;
child_node = child_node->next) {
- if (xmlStrEqual (child_node->name, (xmlChar *)"Template")) {
+ if (gl_xml_is_node (child_node, "Template")) {
template = gl_xml_template_parse_template_node (child_node);
if (!template) {
g_object_unref (label);
gl_template_register (template);
gl_label_set_template (label, template);
gl_template_free (template);
- } else if (xmlStrEqual (child_node->name, (xmlChar *)"Objects")) {
+ } else if (gl_xml_is_node (child_node, "Objects")) {
xml_parse_objects (child_node, label);
- } else if (xmlStrEqual (child_node->name, (xmlChar *)"Merge")) {
+ } else if (gl_xml_is_node (child_node, "Merge")) {
xml_parse_merge_fields (child_node, label);
- } else if (xmlStrEqual (child_node->name, (xmlChar *)"Data")) {
+ } else if (gl_xml_is_node (child_node, "Data")) {
/* Handled in pass 1. */
} else {
if (!xmlNodeIsText (child_node)) {
for (child = node->xmlChildrenNode; child != NULL; child = child->next) {
- if (xmlStrEqual (child->name, (xmlChar *)"Object-text")) {
+ if (gl_xml_is_node (child, "Object-text")) {
xml_parse_object_text (child, label);
- } else if (xmlStrEqual (child->name, (xmlChar *)"Object-box")) {
+ } else if (gl_xml_is_node (child, "Object-box")) {
xml_parse_object_box (child, label);
- } else if (xmlStrEqual (child->name, (xmlChar *)"Object-ellipse")) {
+ } else if (gl_xml_is_node (child, "Object-ellipse")) {
xml_parse_object_ellipse (child, label);
- } else if (xmlStrEqual (child->name, (xmlChar *)"Object-line")) {
+ } else if (gl_xml_is_node (child, "Object-line")) {
xml_parse_object_line (child, label);
- } else if (xmlStrEqual (child->name, (xmlChar *)"Object-image")) {
+ } else if (gl_xml_is_node (child, "Object-image")) {
xml_parse_object_image (child, label);
- } else if (xmlStrEqual (child->name, (xmlChar *)"Object-barcode")) {
+ } else if (gl_xml_is_node (child, "Object-barcode")) {
xml_parse_object_barcode (child, label);
} else {
if (!xmlNodeIsText (child)) {
GObject *object;
gdouble x, y;
gdouble w, h;
- xmlChar *string;
+ gchar *string;
GtkJustification just;
gboolean auto_shrink;
gdouble affine[6];
gl_label_object_set_size (GL_LABEL_OBJECT(object), w, h);
/* justify attr */
- string = xmlGetProp (node, (xmlChar *)"justify");
- just = gl_util_string_to_just ((gchar *)string);
- xmlFree (string);
+ string = gl_xml_get_prop_string (node, "justify", NULL);
+ just = gl_util_string_to_just (string);
+ g_free (string);
gl_label_object_set_text_alignment (GL_LABEL_OBJECT(object), just);
/* auto_shrink attr */
/* Process children */
for (child = node->xmlChildrenNode; child != NULL; child = child->next) {
- if (xmlStrEqual (child->name,(xmlChar *) "Span")) {
+ if (gl_xml_is_node (child, "Span")) {
xml_parse_toplevel_span (child, GL_LABEL_OBJECT(object));
break;
} else {
gdouble line_width;
glColorNode *line_color_node;
gdouble affine[6];
- xmlChar *string;
+ gchar *string;
glColorNode *fill_color_node;
gl_debug (DEBUG_XML, "START");
gl_label_object_set_line_width (GL_LABEL_OBJECT(object), line_width);
line_color_node = gl_color_node_new_default ();
- string = xmlGetProp (node, (xmlChar *)"line_color_field");
+ string = gl_xml_get_prop_string (node, "line_color_field", NULL);
if ( string ) {
line_color_node->field_flag = TRUE;
- line_color_node->key = g_strdup ((gchar *)string);
- xmlFree (string);
+ line_color_node->key = string;
} else {
line_color_node->color = gl_xml_get_prop_uint (node, "line_color", 0);
}
/* fill attrs */
fill_color_node = gl_color_node_new_default ();
- string = xmlGetProp (node, (xmlChar *)"fill_color_field");
+ string = gl_xml_get_prop_string (node, "fill_color_field", NULL);
if ( string ) {
fill_color_node->field_flag = TRUE;
- fill_color_node->key = g_strdup ((gchar *)string);
+ fill_color_node->key = string;
} else {
fill_color_node->color = gl_xml_get_prop_uint (node, "fill_color", 0);
}
gdouble line_width;
glColorNode *line_color_node;
gdouble affine[6];
- xmlChar *string;
+ gchar *string;
glColorNode *fill_color_node;
gl_debug (DEBUG_XML, "START");
gl_label_object_set_line_width (GL_LABEL_OBJECT(object), line_width);
line_color_node = gl_color_node_new_default ();
- string = xmlGetProp (node, (xmlChar *)"line_color_field");
+ string = gl_xml_get_prop_string (node, "line_color_field", NULL);
if ( string ) {
line_color_node->field_flag = TRUE;
- line_color_node->key = g_strdup ((gchar *)string);
- xmlFree (string);
+ line_color_node->key = string;
} else {
line_color_node->color = gl_xml_get_prop_uint (node, "line_color", 0);
}
/* fill attrs */
fill_color_node = gl_color_node_new_default ();
- string = xmlGetProp (node, (xmlChar *)"fill_color_field");
+ string = gl_xml_get_prop_string (node, "fill_color_field", NULL);
if ( string ) {
fill_color_node->field_flag = TRUE;
- fill_color_node->key = g_strdup ((gchar *)string);
- xmlFree (string);
+ fill_color_node->key = string;
} else {
fill_color_node->color = gl_xml_get_prop_uint (node, "fill_color", 0);
}
gdouble line_width;
glColorNode *line_color_node;
gdouble affine[6];
- xmlChar *string;
+ gchar *string;
gl_debug (DEBUG_XML, "START");
gl_label_object_set_line_width (GL_LABEL_OBJECT(object), line_width);
line_color_node = gl_color_node_new_default ();
- string = xmlGetProp (node, (xmlChar *)"line_color_field");
+ string = gl_xml_get_prop_string (node, "line_color_field", NULL);
if ( string ) {
line_color_node->field_flag = TRUE;
- line_color_node->key = g_strdup ((gchar *)string);
- xmlFree (string);
+ line_color_node->key = string;
} else {
line_color_node->color = gl_xml_get_prop_uint (node, "line_color", 0);
}
GObject *object;
gdouble x, y;
gdouble w, h;
- xmlChar *string;
+ gchar *string;
glTextNode *filename;
gdouble affine[6];
gl_label_object_set_position (GL_LABEL_OBJECT(object), x, y);
/* src or field attr */
- string = xmlGetProp (node, (xmlChar *)"src");
+ string = gl_xml_get_prop_string (node, "src", NULL);
if ( string ) {
filename = g_new0 (glTextNode, 1);
filename->field_flag = FALSE;
gl_text_node_free (&filename);
xmlFree (string);
} else {
- string = xmlGetProp (node, (xmlChar *)"field");
+ string = gl_xml_get_prop_string (node, "field", NULL);
if ( string ) {
filename = g_new0 (glTextNode, 1);
filename->field_flag = TRUE;
GObject *object;
gdouble x, y;
gdouble w, h;
- xmlChar *string;
+ gchar *string;
glTextNode *text_node;
- xmlChar *id;
+ gchar *id;
gboolean text_flag;
gboolean checksum_flag;
glColorNode *color_node;
gl_label_object_set_size (GL_LABEL_OBJECT(object), w, h);
/* prop attrs */
- id = xmlGetProp (node, (xmlChar *)"style");
+ id = gl_xml_get_prop_string (node, "style", NULL);
text_flag = gl_xml_get_prop_boolean (node, "text", FALSE);
checksum_flag = gl_xml_get_prop_boolean (node, "checksum", TRUE);
format_digits = gl_xml_get_prop_uint (node, "format", 10);
gl_label_barcode_set_props (GL_LABEL_BARCODE(object),
(gchar *)id, text_flag, checksum_flag, format_digits);
- xmlFree (id);
+ g_free (id);
color_node = gl_color_node_new_default ();
- string = xmlGetProp (node, (xmlChar *)"color_field");
+ string = gl_xml_get_prop_string (node, "color_field", NULL);
if ( string ) {
color_node->field_flag = TRUE;
- color_node->key = g_strdup ((gchar *)string);
- xmlFree (string);
+ color_node->key = string;
} else {
color_node->color = gl_xml_get_prop_uint (node, "color", 0);
}
gl_color_node_free (&color_node);
/* data or field attr */
- string = xmlGetProp (node, (xmlChar *)"data");
+ string = gl_xml_get_prop_string (node, "data", NULL);
if ( string ) {
text_node = g_new0 (glTextNode, 1);
text_node->field_flag = FALSE;
- text_node->data = g_strdup ((gchar *)string);
+ text_node->data = string;
gl_label_barcode_set_data (GL_LABEL_BARCODE(object), text_node);
gl_text_node_free (&text_node);
- xmlFree (string);
} else {
- string = xmlGetProp (node, (xmlChar *)"field");
+ string = gl_xml_get_prop_string (node, "field", NULL);
if ( string ) {
text_node = g_new0 (glTextNode, 1);
text_node->field_flag = TRUE;
- text_node->data = g_strdup ((gchar *)string);
+ text_node->data = string;
gl_label_barcode_set_data (GL_LABEL_BARCODE(object), text_node);
gl_text_node_free (&text_node);
- xmlFree (string);
} else {
g_warning ("Missing Object-barcode data or field attr");
}
glLabel *label)
{
xmlNodePtr child;
- xmlChar *string;
+ gchar *string;
glMerge *merge;
gl_debug (DEBUG_XML, "START");
- string = xmlGetProp (node, (xmlChar *)"type");
- merge = gl_merge_new ((gchar *)string);
- xmlFree (string);
+ string = gl_xml_get_prop_string (node, "type", NULL);
+ merge = gl_merge_new (string);
+ g_free (string);
- string = xmlGetProp (node, (xmlChar *)"src");
- gl_merge_set_src (merge, (gchar *)string);
- xmlFree (string);
+ string = gl_xml_get_prop_string (node, "src", NULL);
+ gl_merge_set_src (merge, string);
+ g_free (string);
gl_label_set_merge (label, merge);
for (child = node->xmlChildrenNode; child != NULL; child = child->next) {
- if (xmlStrEqual (child->name, (xmlChar *)"Pixdata")) {
+ if (gl_xml_is_node (child, "Pixdata")) {
xml_parse_pixdata (child, label);
} else {
if (!xmlNodeIsText (child)) {
xml_parse_pixdata (xmlNodePtr node,
glLabel *label)
{
- xmlChar *name, *base64;
+ gchar *name, *base64;
guchar *stream;
guint stream_length;
gboolean ret;
gl_debug (DEBUG_XML, "START");
- name = xmlGetProp (node, (xmlChar *)"name");
- base64 = xmlNodeGetContent (node);
+ name = gl_xml_get_prop_string (node, "name", NULL);
+ base64 = gl_xml_get_node_content (node);
stream = gl_base64_decode ((gchar *)base64, &stream_length);
pixdata = g_new0 (GdkPixdata, 1);
gl_pixbuf_cache_add_pixbuf (pixbuf_cache, (gchar *)name, pixbuf);
}
- xmlFree (name);
- xmlFree (base64);
+ g_free (name);
+ g_free (base64);
g_free (stream);
g_free (pixdata);
xml_parse_toplevel_span (xmlNodePtr node,
glLabelObject *object)
{
- xmlChar *font_family;
+ gchar *font_family;
gdouble font_size;
GnomeFontWeight font_weight;
gboolean font_italic_flag;
glColorNode *color_node;
gdouble text_line_spacing;
- xmlChar *string;
+ gchar *string;
GList *lines, *text_nodes;
xmlNodePtr child;
glTextNode *text_node;
gl_debug (DEBUG_XML, "START");
/* Font family attr */
- font_family = xmlGetProp (node, (xmlChar *)"font_family");
- gl_label_object_set_font_family (object, (gchar *)font_family);
- xmlFree (font_family);
+ font_family = gl_xml_get_prop_string (node, "font_family", "Sans");
+ gl_label_object_set_font_family (object, font_family);
+ g_free (font_family);
/* Font size attr */
font_size = gl_xml_get_prop_double (node, "font_size", 0.0);
gl_label_object_set_font_size (object, font_size);
/* Font weight attr */
- string = xmlGetProp (node, (xmlChar *)"font_weight");
- font_weight = gl_util_string_to_weight ((gchar *)string);
- xmlFree (string);
+ string = gl_xml_get_prop_string (node, "font_weight", NULL);
+ font_weight = gl_util_string_to_weight (string);
+ g_free (string);
gl_label_object_set_font_weight (object, font_weight);
/* Font italic flag attr */
/* Text color attr */
color_node = gl_color_node_new_default ();
- string = xmlGetProp (node, (xmlChar *)"color_field");
+ string = gl_xml_get_prop_string (node, "color_field", NULL);
if ( string ) {
color_node->field_flag = TRUE;
- color_node->key = g_strdup ((gchar *)string);
- xmlFree (string);
+ color_node->key = string;
} else {
color_node->color = gl_xml_get_prop_uint (node, "color", 0);
}
for (child = node->xmlChildrenNode; child != NULL; child = child->next) {
if (xmlNodeIsText (child)) {
- xmlChar *data = xmlNodeGetContent (child);
+ gchar *data = gl_xml_get_node_content (child);
- /* Hack: if the first char is LF, it's a xml formatting string */
+ /* Hack: if the first char is LF, it's an xml formatting string */
if (data[0] != '\n') {
/* Literal text */
text_node = g_new0 (glTextNode, 1);
text_node->data = g_strdup ((gchar *)data);
text_nodes = g_list_append (text_nodes, text_node);
}
- xmlFree (data);
+ g_free (data);
- } else if (xmlStrEqual (child->name, (xmlChar *)"Span")) {
+ } else if (gl_xml_is_node (child, "Span")) {
g_warning ("Unexpected rich text (not supported, yet!)");
- } else if (xmlStrEqual (child->name, (xmlChar *)"Field")) {
+ } else if (gl_xml_is_node (child, "Field")) {
/* Field node */
- string = xmlGetProp (child, (xmlChar *)"name");
+ string = gl_xml_get_prop_string (child, "name", NULL);
text_node = g_new0 (glTextNode, 1);
text_node->field_flag = TRUE;
- text_node->data = g_strdup ((gchar *)string);
+ text_node->data = string;
text_nodes = g_list_append (text_nodes, text_node);
- xmlFree (string);
- } else if (xmlStrEqual (child->name, (xmlChar *)"NL")) {
+ } else if (gl_xml_is_node (child, "NL")) {
/* Store line. */
lines = g_list_append (lines, text_nodes);
rotate_flag = gl_label_get_rotate_flag (label);
node = xmlNewChild (root, ns, (xmlChar *)"Objects", NULL);
- xmlSetProp (node, (xmlChar *)"id", (xmlChar *)"0");
+ gl_xml_set_prop_string (node, "id", "0");
gl_xml_set_prop_boolean (node, "rotate", rotate_flag);
for (p = label->objects; p != NULL; p = p->next) {
/* justify attr */
just = gl_label_object_get_text_alignment (object);
- xmlSetProp (node, (xmlChar *)"justify", (xmlChar *)gl_util_just_to_string (just));
+ gl_xml_set_prop_string (node, "justify", gl_util_just_to_string (just));
/* auto_shrink attr */
auto_shrink = gl_label_text_get_auto_shrink (GL_LABEL_TEXT (object));
line_color_node = gl_label_object_get_line_color (GL_LABEL_OBJECT(object));
if (line_color_node->field_flag)
{
- xmlSetProp (node, (xmlChar *)"line_color_field", (xmlChar *)line_color_node->key);
+ gl_xml_set_prop_string (node, "line_color_field", line_color_node->key);
}
else
{
fill_color_node = gl_label_object_get_fill_color (GL_LABEL_OBJECT(object));
if (fill_color_node->field_flag)
{
- xmlSetProp (node, (xmlChar *)"fill_color_field", (xmlChar *)fill_color_node->key);
+ gl_xml_set_prop_string (node, "fill_color_field", fill_color_node->key);
}
else
{
line_color_node = gl_label_object_get_line_color (GL_LABEL_OBJECT(object));
if (line_color_node->field_flag)
{
- xmlSetProp (node, (xmlChar *)"line_color_field", (xmlChar *)line_color_node->key);
+ gl_xml_set_prop_string (node, "line_color_field", line_color_node->key);
}
else
{
fill_color_node = gl_label_object_get_fill_color (GL_LABEL_OBJECT(object));
if (fill_color_node->field_flag)
{
- xmlSetProp (node, (xmlChar *)"fill_color_field", (xmlChar *)fill_color_node->key);
+ gl_xml_set_prop_string (node, "fill_color_field", fill_color_node->key);
}
else
{
line_color_node = gl_label_object_get_line_color (GL_LABEL_OBJECT(object));
if (line_color_node->field_flag)
{
- xmlSetProp (node, (xmlChar *)"line_color_field", (xmlChar *)line_color_node->key);
+ gl_xml_set_prop_string (node, "line_color_field", line_color_node->key);
}
else
{
/* src OR field attr */
filename = gl_label_image_get_filename (GL_LABEL_IMAGE(object));
if (filename->field_flag) {
- xmlSetProp (node, (xmlChar *)"field", (xmlChar *)filename->data);
+ gl_xml_set_prop_string (node, "field", filename->data);
} else {
- xmlSetProp (node, (xmlChar *)"src", (xmlChar *)filename->data);
+ gl_xml_set_prop_string (node, "src", filename->data);
}
gl_text_node_free (&filename);
/* Barcode properties attrs */
gl_label_barcode_get_props (GL_LABEL_BARCODE(object),
&id, &text_flag, &checksum_flag, &format_digits);
- xmlSetProp (node, (xmlChar *)"style", (xmlChar *)id);
+ gl_xml_set_prop_string (node, "style", id);
gl_xml_set_prop_boolean (node, "text", text_flag);
gl_xml_set_prop_boolean (node, "checksum", checksum_flag);
color_node = gl_label_object_get_line_color (GL_LABEL_OBJECT(object));
if (color_node->field_flag)
{
- xmlSetProp (node, (xmlChar *)"color_field", (xmlChar *)color_node->key);
+ gl_xml_set_prop_string (node, "color_field", color_node->key);
}
else
{
/* data OR field attr */
text_node = gl_label_barcode_get_data (GL_LABEL_BARCODE(object));
if (text_node->field_flag) {
- xmlSetProp (node, (xmlChar *)"field", (xmlChar *)text_node->data);
+ gl_xml_set_prop_string (node, "field", text_node->data);
gl_xml_set_prop_int (node, "format", format_digits);
} else {
- xmlSetProp (node, (xmlChar *)"data", (xmlChar *)text_node->data);
+ gl_xml_set_prop_string (node, "data", text_node->data);
}
gl_text_node_free (&text_node);
node = xmlNewChild (root, ns, (xmlChar *)"Merge", NULL);
string = gl_merge_get_name (merge);
- xmlSetProp (node, (xmlChar *)"type", (xmlChar *)string);
+ gl_xml_set_prop_string (node, "type", string);
g_free (string);
string = gl_merge_get_src (merge);
- xmlSetProp (node, (xmlChar *)"src", (xmlChar *)string);
+ gl_xml_set_prop_string (node, "src", string);
g_free (string);
g_object_unref (G_OBJECT(merge));
base64 = gl_base64_encode (stream, stream_length);
node = xmlNewChild (root, ns, (xmlChar *)"Pixdata", (xmlChar *)base64);
- xmlSetProp (node, (xmlChar *)"name", (xmlChar *)name);
- xmlSetProp (node, (xmlChar *)"encoding", (xmlChar *)"Base64");
+ gl_xml_set_prop_string (node, "name", name);
+ gl_xml_set_prop_string (node, "encoding", "Base64");
gl_pixbuf_cache_remove_pixbuf (pixbuf_cache, name);
color_node = gl_label_object_get_text_color (GL_LABEL_OBJECT(object_text));
if (color_node->field_flag)
{
- xmlSetProp (node, (xmlChar *)"color_field", (xmlChar *)color_node->key);
+ gl_xml_set_prop_string (node, "color_field", color_node->key);
}
else
{
gl_color_node_free (&color_node);
just = gl_label_object_get_text_alignment (GL_LABEL_OBJECT(object_text));
- xmlSetProp (node, (xmlChar *)"font_family", (xmlChar *)font_family);
+ gl_xml_set_prop_string (node, "font_family", font_family);
gl_xml_set_prop_double (node, "font_size", font_size);
- xmlSetProp (node, (xmlChar *)"font_weight", (xmlChar *)gl_util_weight_to_string (font_weight));
+ gl_xml_set_prop_string (node, "font_weight", gl_util_weight_to_string (font_weight));
gl_xml_set_prop_boolean (node, "font_italic", font_italic_flag);
gl_xml_set_prop_double (node, "line_spacing", text_line_spacing);
if (text_node->field_flag) {
child = xmlNewChild (node, ns, (xmlChar *)"Field", NULL);
- xmlSetProp (child, (xmlChar *)"name", (xmlChar *)text_node->data);
+ gl_xml_set_prop_string (child, "name", text_node->data);
} else {
xmlNodeAddContent (node, (xmlChar *)text_node->data);
}