1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
4 * (LIBGLABELS) Template library for GLABELS
6 * category.c: template category module
8 * Copyright (C) 2001-2006 Jim Evins <evins@snaught.com>.
10 * This file is part of the LIBGLABELS library.
12 * This library is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Library General Public
14 * License as published by the Free Software Foundation; either
15 * version 2 of the License, or (at your option) any later version.
17 * This library is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Library General Public License for more details.
22 * You should have received a copy of the GNU Library General Public
23 * License along with this library; if not, write to the Free
24 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
31 #include <glib/gi18n.h>
32 #include <glib/gmem.h>
33 #include <glib/gstrfuncs.h>
34 #include <glib/gmessages.h>
37 #include "libglabels-private.h"
39 /*===========================================*/
41 /*===========================================*/
44 /*===========================================*/
46 /*===========================================*/
49 /*===========================================*/
50 /* Local function prototypes */
51 /*===========================================*/
54 /*===========================================*/
56 /*===========================================*/
59 * @id: Id of category definition. (E.g. label, card, etc.) Should be
61 * @name: Localized name of category.
63 * Allocates and constructs a new #lglCategory structure.
65 * Returns: a pointer to a newly allocated #lglCategory structure.
69 lgl_category_new (gchar *id,
72 lglCategory *category;
74 category = g_new0 (lglCategory,1);
75 category->id = g_strdup (id);
76 category->name = g_strdup (name);
84 * @orig: #lglCategory structure to be duplicated.
86 * Duplicates an existing #lglCategory structure.
88 * Returns: a pointer to a newly allocated #lglCategory structure.
91 lglCategory *lgl_category_dup (const lglCategory *orig)
93 lglCategory *category;
95 g_return_val_if_fail (orig, NULL);
97 category = g_new0 (lglCategory,1);
99 category->id = g_strdup (orig->id);
100 category->name = g_strdup (orig->name);
108 * @category: pointer to #lglCategory structure to be freed.
110 * Free all memory associated with an existing #lglCategory structure.
113 void lgl_category_free (lglCategory *category)
116 if ( category != NULL ) {
118 g_free (category->id);
121 g_free (category->name);
122 category->name = NULL;