]> git.sur5r.net Git - glabels/blob - glabels2/libglabels/paper.c
e4d266a610ebc91df11f4b534d2f13c3a371c183
[glabels] / glabels2 / libglabels / paper.c
1 /*
2  *  (LIBGLABELS) Template library for GLABELS
3  *
4  *  paper.c:  paper module
5  *
6  *  Copyright (C) 2003, 2004  Jim Evins <evins@snaught.com>.
7  *
8  *  This file is part of the LIBGLABELS library.
9  *
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.
14  *
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.
19  *
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,
23  *  MA 02111-1307, USA
24  */
25 #include <config.h>
26
27 #include "paper.h"
28
29 #include <glib/gi18n.h>
30 #include <glib/gmem.h>
31 #include <glib/gstrfuncs.h>
32 #include <glib/gmessages.h>
33 #include <string.h>
34
35 #include "libglabels-private.h"
36
37 /*===========================================*/
38 /* Private types                             */
39 /*===========================================*/
40
41
42 /*===========================================*/
43 /* Private globals                           */
44 /*===========================================*/
45
46
47 /*===========================================*/
48 /* Local function prototypes                 */
49 /*===========================================*/
50
51
52 /*===========================================*/
53 /* Functions.                                */
54 /*===========================================*/
55
56 /**
57  * lgl_paper_new:
58  * @id:     Id of paper definition. (E.g. US-Letter, A4, etc.)  Should be
59  *          unique.
60  * @name:   Localized name of paper.
61  * @width:  Width of paper in points.
62  * @height: Height of paper in points.
63  *
64  * Allocates and constructs a new #lglPaper structure.
65  *
66  * Returns: a pointer to a newly allocated #lglPaper structure.
67  *
68  */
69 lglPaper *
70 lgl_paper_new (gchar             *id,
71                gchar             *name,
72                gdouble            width,
73                gdouble            height)
74 {
75         lglPaper *paper;
76
77         paper         = g_new0 (lglPaper,1);
78         paper->id     = g_strdup (id);
79         paper->name   = g_strdup (name);
80         paper->width  = width;
81         paper->height = height;
82
83         return paper;
84 }
85
86
87 /**
88  * lgl_paper_dup:
89  * @orig:  #lglPaper structure to be duplicated.
90  *
91  * Duplicates an existing #lglPaper structure.
92  *
93  * Returns: a pointer to a newly allocated #lglPaper structure.
94  *
95  */
96 lglPaper *lgl_paper_dup (const lglPaper *orig)
97 {
98         lglPaper       *paper;
99
100         g_return_val_if_fail (orig, NULL);
101
102         paper = g_new0 (lglPaper,1);
103
104         paper->id     = g_strdup (orig->id);
105         paper->name   = g_strdup (orig->name);
106         paper->width  = orig->width;
107         paper->height = orig->height;
108
109         return paper;
110 }
111
112
113 /**
114  * lgl_paper_free:
115  * @paper:  pointer to #lglPaper structure to be freed.
116  *
117  * Free all memory associated with an existing #lglPaper structure.
118  *
119  */
120 void lgl_paper_free (lglPaper *paper)
121 {
122
123         if ( paper != NULL ) {
124
125                 g_free (paper->id);
126                 paper->id = NULL;
127
128                 g_free (paper->name);
129                 paper->name = NULL;
130
131                 g_free (paper);
132         }
133
134 }
135
136