]> git.sur5r.net Git - glabels/blob - libglabels/lgl-category.c
Imported Upstream version 3.0.0
[glabels] / libglabels / lgl-category.c
1 /*
2  *  lgl-category.c
3  *  Copyright (C) 2006-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-category.h"
24
25 #include <glib/gi18n.h>
26 #include <glib.h>
27 #include <string.h>
28
29 #include "libglabels-private.h"
30
31
32 /*===========================================*/
33 /* Private types                             */
34 /*===========================================*/
35
36
37 /*===========================================*/
38 /* Private globals                           */
39 /*===========================================*/
40
41
42 /*===========================================*/
43 /* Local function prototypes                 */
44 /*===========================================*/
45
46
47 /*===========================================*/
48 /* Functions.                                */
49 /*===========================================*/
50
51 /**
52  * lgl_category_new:
53  * @id:     Id of category definition. (E.g. label, card, etc.)  Should be
54  *          unique.
55  * @name:   Localized name of category.
56  *
57  * Allocates and constructs a new #lglCategory structure.
58  *
59  * Returns: a pointer to a newly allocated #lglCategory structure.
60  *
61  */
62 lglCategory *
63 lgl_category_new (gchar             *id,
64                   gchar             *name)
65 {
66         lglCategory *category;
67
68         category         = g_new0 (lglCategory,1);
69         category->id     = g_strdup (id);
70         category->name   = g_strdup (name);
71
72         return category;
73 }
74
75
76 /**
77  * lgl_category_dup:
78  * @orig:  #lglCategory structure to be duplicated.
79  *
80  * Duplicates an existing #lglCategory structure.
81  *
82  * Returns: a pointer to a newly allocated #lglCategory structure.
83  *
84  */
85 lglCategory *lgl_category_dup (const lglCategory *orig)
86 {
87         lglCategory       *category;
88
89         g_return_val_if_fail (orig, NULL);
90
91         category = g_new0 (lglCategory,1);
92
93         category->id     = g_strdup (orig->id);
94         category->name   = g_strdup (orig->name);
95
96         return category;
97 }
98
99
100 /**
101  * lgl_category_free:
102  * @category:  pointer to #lglCategory structure to be freed.
103  *
104  * Free all memory associated with an existing #lglCategory structure.
105  *
106  */
107 void lgl_category_free (lglCategory *category)
108 {
109
110         if ( category != NULL )
111         {
112                 g_free (category->id);
113                 category->id = NULL;
114
115                 g_free (category->name);
116                 category->name = NULL;
117
118                 g_free (category);
119         }
120
121 }
122
123
124
125 /*
126  * Local Variables:       -- emacs
127  * mode: C                -- emacs
128  * c-basic-offset: 8      -- emacs
129  * tab-width: 8           -- emacs
130  * indent-tabs-mode: nil  -- emacs
131  * End:                   -- emacs
132  */