-
-
Notifications
You must be signed in to change notification settings - Fork 346
/
Copy patharvgccategory.c
144 lines (116 loc) · 3.77 KB
/
arvgccategory.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/* Aravis - Digital camera library
*
* Copyright © 2009-2025 Emmanuel Pacaud <[email protected]>
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*
* Author: Emmanuel Pacaud <[email protected]>
*/
/**
* SECTION: arvgccategory
* @short_description: Class for Category nodes
*/
#include <arvgccategory.h>
#include <arvgcpropertynode.h>
#include <arvgc.h>
#include <string.h>
struct _ArvGcCategory {
ArvGcFeatureNode base;
GSList *features;
};
struct _ArvGcCategoryClass {
ArvGcFeatureNodeClass parent_class;
};
G_DEFINE_TYPE (ArvGcCategory, arv_gc_category, ARV_TYPE_GC_FEATURE_NODE)
/* ArvDomNode implementation */
static const char *
arv_gc_category_get_node_name (ArvDomNode *node)
{
return "Category";
}
static gboolean
arv_gc_category_can_append_child (ArvDomNode *parent, ArvDomNode *child)
{
return ARV_IS_GC_PROPERTY_NODE (child);
}
/* ArvGcCategory implementation */
static void
_free_features (ArvGcCategory *category)
{
GSList *iter;
for (iter = category->features; iter != NULL; iter = iter->next)
g_free (iter->data);
g_slist_free (category->features);
category->features = NULL;
}
/**
* arv_gc_category_get_features:
* @category: a #ArvGcCategory
*
* Get a list of strings with the name of the features listed in the given category node.
*
* Returns: (element-type utf8) (transfer none): a list of strings.
*/
const GSList *
arv_gc_category_get_features (ArvGcCategory *category)
{
ArvDomNode *iter;
ArvGcNode *node;
g_return_val_if_fail (ARV_IS_GC_CATEGORY (category), NULL);
_free_features (category);
for (iter = arv_dom_node_get_first_child (ARV_DOM_NODE (category));
iter != NULL;
iter = arv_dom_node_get_next_sibling (iter)) {
if (arv_gc_property_node_get_node_type (ARV_GC_PROPERTY_NODE (iter)) ==
ARV_GC_PROPERTY_NODE_TYPE_P_FEATURE) {
node = arv_gc_property_node_get_linked_node (ARV_GC_PROPERTY_NODE (iter));
if (ARV_IS_GC_FEATURE_NODE (node)) {
char *name;
name = g_strdup (arv_gc_feature_node_get_name (ARV_GC_FEATURE_NODE (node)));
category->features = g_slist_append (category->features, name);
}
}
}
return category->features;
}
ArvGcNode *
arv_gc_category_new (void)
{
ArvGcNode *node;
node = g_object_new (ARV_TYPE_GC_CATEGORY, NULL);
return node;
}
static void
arv_gc_category_init (ArvGcCategory *gc_category)
{
gc_category->features = NULL;
}
static void
arv_gc_category_finalize (GObject *object)
{
ArvGcCategory *category = ARV_GC_CATEGORY (object);
_free_features (category);
G_OBJECT_CLASS (arv_gc_category_parent_class)->finalize (object);
}
static void
arv_gc_category_class_init (ArvGcCategoryClass *this_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (this_class);
ArvDomNodeClass *dom_node_class = ARV_DOM_NODE_CLASS (this_class);
object_class->finalize = arv_gc_category_finalize;
dom_node_class->get_node_name = arv_gc_category_get_node_name;
dom_node_class->can_append_child = arv_gc_category_can_append_child;
}