2 * (GLABELS) Label and Business Card Creation program for GNOME
4 * xml-paper.c: paper xml module
6 * Copyright (C) 2003 Jim Evins <evins@snaught.com>.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #include "xml-paper.h"
33 /*===========================================*/
35 /*===========================================*/
37 /*===========================================*/
39 /*===========================================*/
41 /*===========================================*/
42 /* Local function prototypes */
43 /*===========================================*/
45 glPaper *gl_xml_paper_parse_paper (xmlNodePtr paper_node);
49 /*****************************************************************************/
50 /* Read papers from paper file. */
51 /*****************************************************************************/
53 gl_xml_paper_read_papers_from_file (GList *papers,
57 xmlNodePtr root, node;
60 gl_debug (DEBUG_PAPER, "START");
64 doc = xmlParseFile (xml_filename);
66 g_warning ("\"%s\" is not a glabels paper file (not XML)",
71 root = xmlDocGetRootElement (doc);
72 if (!root || !root->name) {
73 g_warning ("\"%s\" is not a glabels paper file (no root node)",
78 if (!xmlStrEqual (root->name, "Glabels-paper-sizes")) {
79 g_warning ("\"%s\" is not a glabels paper file (wrong root node)",
85 for (node = root->xmlChildrenNode; node != NULL; node = node->next) {
87 if (xmlStrEqual (node->name, "Paper-size")) {
88 paper = gl_xml_paper_parse_paper (node);
89 papers = g_list_append (papers, paper);
91 if ( !xmlNodeIsText(node) ) {
92 if (!xmlStrEqual (node->name,"comment")) {
93 g_warning ("bad node = \"%s\"",node->name);
101 gl_debug (DEBUG_PAPER, "END");
105 /*****************************************************************************/
106 /* Parse XML paper Node. */
107 /*****************************************************************************/
109 gl_xml_paper_parse_paper (xmlNodePtr paper_node)
114 gl_debug (DEBUG_PAPER, "START");
116 paper = g_new0 (glPaper, 1);
118 paper->id = xmlGetProp (paper_node, "id");
120 name = xmlGetProp (paper_node, "_name");
122 paper->name = gettext (name);
124 paper->name = xmlGetProp (paper_node, "name");
127 paper->width = gl_xml_get_prop_length (paper_node, "width", 0);
128 paper->height = gl_xml_get_prop_length (paper_node, "height", 0);
130 gl_debug (DEBUG_PAPER, "END");