2 * (LIBGLABELS) Template library for GLABELS
4 * paper.c: paper module
6 * Copyright (C) 2003, 2004 Jim Evins <evins@snaught.com>.
8 * This file is part of the LIBGLABELS library.
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Library General Public
12 * License as published by the Free Software Foundation; either
13 * version 2 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Library General Public License for more details.
20 * You should have received a copy of the GNU Library General Public
21 * License along with this library; if not, write to the Free
22 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
29 #include <glib/gi18n.h>
30 #include <glib/gmem.h>
31 #include <glib/gstrfuncs.h>
32 #include <glib/gmessages.h>
35 #include "libglabels-private.h"
37 /*===========================================*/
39 /*===========================================*/
42 /*===========================================*/
44 /*===========================================*/
47 /*===========================================*/
48 /* Local function prototypes */
49 /*===========================================*/
52 /*===========================================*/
54 /*===========================================*/
58 * @id: Id of paper definition. (E.g. US-Letter, A4, etc.) Should be
60 * @name: Localized name of paper.
61 * @width: Width of paper in points.
62 * @height: Height of paper in points.
63 * @pwg_size: PWG 5101.1-2002 size name.
65 * Allocates and constructs a new #lglPaper structure.
67 * Returns: a pointer to a newly allocated #lglPaper structure.
71 lgl_paper_new (gchar *id,
79 paper = g_new0 (lglPaper,1);
81 paper->id = g_strdup (id);
82 paper->name = g_strdup (name);
84 paper->height = height;
85 paper->pwg_size = g_strdup (pwg_size);
93 * @orig: #lglPaper structure to be duplicated.
95 * Duplicates an existing #lglPaper structure.
97 * Returns: a pointer to a newly allocated #lglPaper structure.
100 lglPaper *lgl_paper_dup (const lglPaper *orig)
104 g_return_val_if_fail (orig, NULL);
106 paper = g_new0 (lglPaper,1);
108 paper->id = g_strdup (orig->id);
109 paper->name = g_strdup (orig->name);
110 paper->width = orig->width;
111 paper->height = orig->height;
112 paper->pwg_size = g_strdup (orig->pwg_size);
120 * @paper: pointer to #lglPaper structure to be freed.
122 * Free all memory associated with an existing #lglPaper structure.
125 void lgl_paper_free (lglPaper *paper)
128 if ( paper != NULL ) {
133 g_free (paper->name);
136 g_free (paper->pwg_size);
137 paper->pwg_size = NULL;