]> git.sur5r.net Git - glabels/blob - libglabels/lgl-paper.c
Upload to unstable
[glabels] / libglabels / lgl-paper.c
1 /*
2  *  lgl-paper.c
3  *  Copyright (C) 2003-2010  Jim Evins <evins@snaught.com>.
4  *
5  *  This file is part of libglabels.
6  *
7  *  libglabels is free software: you can redistribute it and/or modify
8  *  it under the terms of the GNU Lesser General Public License as published by
9  *  the Free Software Foundation, either version 3 of the License, or
10  *  (at your option) any later version.
11  *
12  *  libglabels is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU Lesser General Public License for more details.
16  *
17  *  You should have received a copy of the GNU Lesser General Public License
18  *  along with libglabels.  If not, see <http://www.gnu.org/licenses/>.
19  */
20
21 #include <config.h>
22
23 #include "lgl-paper.h"
24
25 #include <glib/gi18n.h>
26 #include <glib.h>
27 #include <string.h>
28
29 #include "libglabels-private.h"
30
31 /*===========================================*/
32 /* Private types                             */
33 /*===========================================*/
34
35
36 /*===========================================*/
37 /* Private globals                           */
38 /*===========================================*/
39
40
41 /*===========================================*/
42 /* Local function prototypes                 */
43 /*===========================================*/
44
45
46 /*===========================================*/
47 /* Functions.                                */
48 /*===========================================*/
49
50 /**
51  * lgl_paper_new:
52  * @id:       Id of paper definition. (E.g. US-Letter, A4, etc.)  Should be
53  *            unique.
54  * @name:     Localized name of paper.
55  * @width:    Width of paper in points.
56  * @height:   Height of paper in points.
57  * @pwg_size: PWG 5101.1-2002 size name.
58  *
59  * Allocates and constructs a new #lglPaper structure.
60  *
61  * Returns: a pointer to a newly allocated #lglPaper structure.
62  *
63  */
64 lglPaper *
65 lgl_paper_new (gchar             *id,
66                gchar             *name,
67                gdouble            width,
68                gdouble            height,
69                gchar             *pwg_size)
70 {
71         lglPaper *paper;
72
73         paper           = g_new0 (lglPaper,1);
74
75         paper->id       = g_strdup (id);
76         paper->name     = g_strdup (name);
77         paper->width    = width;
78         paper->height   = height;
79         paper->pwg_size = g_strdup (pwg_size);
80
81         return paper;
82 }
83
84
85 /**
86  * lgl_paper_dup:
87  * @orig:  #lglPaper structure to be duplicated.
88  *
89  * Duplicates an existing #lglPaper structure.
90  *
91  * Returns: a pointer to a newly allocated #lglPaper structure.
92  *
93  */
94 lglPaper *lgl_paper_dup (const lglPaper *orig)
95 {
96         lglPaper       *paper;
97
98         g_return_val_if_fail (orig, NULL);
99
100         paper = g_new0 (lglPaper,1);
101
102         paper->id       = g_strdup (orig->id);
103         paper->name     = g_strdup (orig->name);
104         paper->width    = orig->width;
105         paper->height   = orig->height;
106         paper->pwg_size = g_strdup (orig->pwg_size);
107
108         return paper;
109 }
110
111
112 /**
113  * lgl_paper_free:
114  * @paper:  pointer to #lglPaper structure to be freed.
115  *
116  * Free all memory associated with an existing #lglPaper structure.
117  *
118  */
119 void lgl_paper_free (lglPaper *paper)
120 {
121
122         if ( paper != NULL )
123         {
124                 g_free (paper->id);
125                 paper->id = NULL;
126
127                 g_free (paper->name);
128                 paper->name = NULL;
129
130                 g_free (paper->pwg_size);
131                 paper->pwg_size = NULL;
132
133                 g_free (paper);
134         }
135
136 }
137
138
139
140 /*
141  * Local Variables:       -- emacs
142  * mode: C                -- emacs
143  * c-basic-offset: 8      -- emacs
144  * tab-width: 8           -- emacs
145  * indent-tabs-mode: nil  -- emacs
146  * End:                   -- emacs
147  */