annotate Plugins/Visualization/paranormal/pn/pncontainer.c @ 1591:02841f72b897 trunk

[svn] Cast variable to proper type before passing it into libxml2. Include necessary header to make this possible. Resolves 35 pointer signedness warnings on PPC.
author chainsaw
date Thu, 24 Aug 2006 11:40:00 -0700
parents 8b57cc165216
children 752949e9aec4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1507
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
1 /* Paranormal - A highly customizable audio visualization library
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
2 * Copyright (C) 2001 Jamie Gennis <jgennis@mindspring.com>
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
3 *
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
4 * This library is free software; you can redistribute it and/or
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
5 * modify it under the terms of the GNU Library General Public
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
6 * License as published by the Free Software Foundation; either
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
7 * version 2 of the License, or (at your option) any later version.
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
8 *
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
9 * This library is distributed in the hope that it will be useful,
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
12 * Library General Public License for more details.
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
13 *
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
14 * You should have received a copy of the GNU Library General Public
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
15 * License along with this library; if not, write to the Free
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
17 */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
18
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
19 #include <glib.h>
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
20 #include "pncontainer.h"
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
21 #include "pnactuatorfactory.h"
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
22 #include "pnerror.h"
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
23 #include "pnxml.h"
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
24
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
25 static void pn_container_class_init (PnContainerClass *class);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
26 static void pn_container_init (PnContainer *container,
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
27 PnContainerClass *class);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
28 /* PnObject methods */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
29 static void pn_container_destroy (PnObject *object);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
30
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
31 /* PnUserObject methods */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
32 static void pn_container_save_thyself (PnUserObject *user_object,
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
33 xmlNodePtr node);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
34 static void pn_container_load_thyself (PnUserObject *user_object,
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
35 xmlNodePtr node);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
36
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
37 /* PnActuator methods */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
38 static void pn_container_prepare (PnContainer *container,
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
39 PnImage *image);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
40
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
41 /* PnContainer methods */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
42 static gboolean pn_container_real_add_actuator (PnContainer *container,
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
43 PnActuator *actuator,
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
44 gint position);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
45
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
46 static PnActuatorClass *parent_class = NULL;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
47
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
48 GType
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
49 pn_container_get_type (void)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
50 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
51 static GType container_type = 0;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
52
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
53 if (! container_type)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
54 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
55 static const GTypeInfo container_info =
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
56 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
57 sizeof (PnContainerClass),
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
58 NULL, /* base_init */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
59 NULL, /* base_finalize */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
60 (GClassInitFunc) pn_container_class_init,
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
61 NULL, /* class_finalize */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
62 NULL, /* class_data */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
63 sizeof (PnContainer),
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
64 0, /* n_preallocs */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
65 (GInstanceInitFunc) pn_container_init
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
66 };
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
67
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
68 /* FIXME: should this be dynamic? */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
69 container_type = g_type_register_static (PN_TYPE_ACTUATOR,
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
70 "PnContainer",
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
71 &container_info,
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
72 G_TYPE_FLAG_ABSTRACT);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
73 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
74 return container_type;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
75 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
76
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
77 static void
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
78 pn_container_class_init (PnContainerClass *class)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
79 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
80 PnObjectClass *object_class;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
81 PnUserObjectClass *user_object_class;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
82 PnActuatorClass *actuator_class;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
83
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
84 parent_class = g_type_class_peek_parent (class);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
85
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
86 object_class = (PnObjectClass *) class;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
87 user_object_class = (PnUserObjectClass *) class;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
88 actuator_class = (PnActuatorClass *) class;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
89
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
90 /* PnObject signals */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
91 object_class->destroy = pn_container_destroy;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
92
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
93 /* PnUserObject methods */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
94 user_object_class->save_thyself = pn_container_save_thyself;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
95 user_object_class->load_thyself = pn_container_load_thyself;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
96
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
97 /* PnActuator methods */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
98 actuator_class->prepare = (PnActuatorPrepFunc) pn_container_prepare;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
99
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
100 /* PnContainer methods */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
101 class->add_actuator = pn_container_real_add_actuator;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
102 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
103
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
104 static void
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
105 pn_container_init (PnContainer *container, PnContainerClass *class)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
106 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
107 container->actuators = g_array_new (FALSE, FALSE, sizeof (PnActuator *));
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
108 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
109
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
110 static void
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
111 pn_container_destroy (PnObject *object)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
112 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
113 PnContainer *container;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
114
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
115 g_return_if_fail (object != NULL);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
116 g_return_if_fail (PN_IS_CONTAINER (object));
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
117
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
118 container = (PnContainer *) object;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
119
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
120 pn_container_remove_all_actuators (container);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
121 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
122
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
123 static void
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
124 pn_container_save_thyself (PnUserObject *user_object, xmlNodePtr node)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
125 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
126 PnContainer *container;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
127 PnActuator *actuator;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
128 xmlNodePtr actuators_node, actuator_node;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
129 guint i;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
130
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
131 g_return_if_fail (user_object != NULL);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
132 g_return_if_fail (PN_IS_CONTAINER (user_object));
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
133 g_return_if_fail (node != NULL);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
134
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
135 container = (PnContainer *) user_object;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
136
1591
02841f72b897 [svn] Cast variable to proper type before passing it into libxml2. Include necessary header to make this possible. Resolves 35 pointer signedness warnings on PPC.
chainsaw
parents: 1529
diff changeset
137 actuators_node = xmlNewChild (node, NULL, (xmlChar *) "Actuators", NULL);
1507
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
138
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
139 /* Save the actuators */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
140 for (i=0; i<container->actuators->len; i++)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
141 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
142 actuator = g_array_index (container->actuators, PnActuator *, i);
1591
02841f72b897 [svn] Cast variable to proper type before passing it into libxml2. Include necessary header to make this possible. Resolves 35 pointer signedness warnings on PPC.
chainsaw
parents: 1529
diff changeset
143 actuator_node = xmlNewChild (actuators_node, NULL, (xmlChar *) "BUG", NULL);
1507
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
144 pn_user_object_save_thyself (PN_USER_OBJECT (actuator), actuator_node);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
145 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
146
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
147 if (PN_USER_OBJECT_CLASS (parent_class)->save_thyself)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
148 PN_USER_OBJECT_CLASS (parent_class)->save_thyself (user_object, node);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
149 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
150
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
151 static void
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
152 pn_container_load_thyself (PnUserObject *user_object, const xmlNodePtr node)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
153 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
154 PnContainer *container;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
155 xmlNodePtr actuators_node, actuator_node;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
156 PnActuator *actuator;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
157
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
158 g_return_if_fail (user_object != NULL);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
159 g_return_if_fail (PN_IS_CONTAINER (user_object));
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
160 g_return_if_fail (node != NULL);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
161
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
162 container = (PnContainer *) user_object;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
163
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
164 /* FIXME: should these 'xmlChildrenNode' be 'xmlRootNode'? */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
165
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
166 /* find the 'actuators' node */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
167 for (actuators_node = node->xmlChildrenNode; actuators_node; actuators_node = actuators_node->next)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
168 if (g_strcasecmp (actuators_node->name, "Actuators") == 0)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
169 break;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
170
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
171 /* load each of the actuators */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
172 if (actuators_node)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
173 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
174 for (actuator_node = actuators_node->xmlChildrenNode; actuator_node; actuator_node = actuator_node->next)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
175 {
1529
8b57cc165216 [svn] - remove less noise
nenolod
parents: 1507
diff changeset
176 if (!g_strcasecmp(actuator_node->name, "text"))
8b57cc165216 [svn] - remove less noise
nenolod
parents: 1507
diff changeset
177 continue;
8b57cc165216 [svn] - remove less noise
nenolod
parents: 1507
diff changeset
178
1507
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
179 actuator = pn_actuator_factory_new_actuator_from_xml (actuator_node);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
180 if (actuator)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
181 /* FIXME: Should this be pn_container_real_add_actuator? */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
182 pn_container_add_actuator (container, actuator, PN_POSITION_TAIL);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
183 else
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
184 pn_error ("unknown actuator ecountered in container \"%s\": %s",
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
185 node->name,
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
186 actuator_node->name);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
187 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
188 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
189
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
190 if (PN_USER_OBJECT_CLASS (parent_class)->load_thyself)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
191 PN_USER_OBJECT_CLASS (parent_class)->load_thyself (user_object, node);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
192 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
193
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
194 static void
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
195 pn_container_prepare (PnContainer *container, PnImage *image)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
196 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
197 guint i;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
198
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
199 g_return_if_fail (container != NULL);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
200 g_return_if_fail (PN_IS_CONTAINER (container));
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
201 g_return_if_fail (image != NULL);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
202 g_return_if_fail (PN_IS_IMAGE (image));
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
203
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
204 for (i=0; i<container->actuators->len; i++)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
205 pn_actuator_prepare (g_array_index (container->actuators, PnActuator *, i), image);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
206 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
207
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
208 static gboolean
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
209 pn_container_real_add_actuator (PnContainer *container, PnActuator *actuator, gint position)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
210 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
211 g_return_val_if_fail (container != NULL, FALSE);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
212 g_return_val_if_fail (PN_IS_CONTAINER (container), FALSE);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
213 g_return_val_if_fail (actuator != NULL, FALSE);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
214 g_return_val_if_fail (PN_IS_ACTUATOR (actuator), FALSE);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
215 g_return_val_if_fail (position >= PN_POSITION_TAIL, FALSE);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
216
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
217 if (position == PN_POSITION_TAIL || position >= container->actuators->len)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
218 position = container->actuators->len;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
219
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
220 /* Just pass it on to the GArray insert function */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
221 g_array_insert_val (container->actuators, position, actuator);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
222
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
223 pn_object_ref (PN_OBJECT (actuator));
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
224 pn_object_sink (PN_OBJECT (actuator));
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
225
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
226 return TRUE;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
227 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
228
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
229 /**
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
230 * pn_container_add_actuator
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
231 * @container: a #PnContainer
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
232 * @actuator: the #PnActuator to add
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
233 * @position: the position at which to add the actuator
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
234 *
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
235 * Adds @actuator to @container. @position is the zero-based index
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
236 * in the list of actuators that the newly added actuator should have,
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
237 * or it can be the value %PN_POSITION_HEAD or %PN_POSITION_TAIL.
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
238 *
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
239 * Returns: %TRUE on success; %FALSE on failure
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
240 */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
241 gboolean
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
242 pn_container_add_actuator (PnContainer *container, PnActuator *actuator, gint position)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
243 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
244 g_return_val_if_fail (container != NULL, FALSE);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
245 g_return_val_if_fail (PN_IS_CONTAINER (container), FALSE);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
246 g_return_val_if_fail (actuator != NULL, FALSE);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
247 g_return_val_if_fail (PN_IS_ACTUATOR (actuator), FALSE);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
248 g_return_val_if_fail (position >= PN_POSITION_TAIL, FALSE);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
249
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
250 if (PN_CONTAINER_GET_CLASS (container)->add_actuator)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
251 return PN_CONTAINER_GET_CLASS (container)->add_actuator (container, actuator, position);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
252 else
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
253 return FALSE;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
254 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
255
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
256 /**
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
257 * pn_container_remove_actuator
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
258 * @container: a #PnContainer
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
259 * @actuator: the #PnActuator to remove
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
260 *
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
261 * Removes the first occurence of @actuator in @container's list
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
262 * of contained actuators.
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
263 */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
264 /* FIXME: what is the most convenient way to remove actuators? */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
265 /* Note: Only removes the first one in the array */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
266 void
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
267 pn_container_remove_actuator (PnContainer *container, PnActuator *actuator)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
268 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
269 guint i;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
270
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
271 g_return_if_fail (container != NULL);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
272 g_return_if_fail (PN_IS_CONTAINER (container));
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
273 g_return_if_fail (actuator != NULL);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
274 g_return_if_fail (PN_IS_ACTUATOR (actuator));
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
275
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
276 for (i=0; i<container->actuators->len; i++)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
277 if (g_array_index (container->actuators, PnActuator *, i) == actuator)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
278 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
279 g_array_remove_index (container->actuators, i);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
280 pn_object_unref (PN_OBJECT (actuator));
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
281 return;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
282 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
283 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
284
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
285 /**
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
286 * pn_container_remove_all_actuators
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
287 * @container: a #PnContainer
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
288 *
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
289 * Removes all actuators from @container's list of contained actuators.
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
290 */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
291 void
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
292 pn_container_remove_all_actuators (PnContainer *container)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
293 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
294 guint i;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
295
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
296 g_return_if_fail (container != NULL);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
297 g_return_if_fail (PN_IS_CONTAINER (container));
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
298
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
299 for (i=0; i<container->actuators->len; i++)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
300 pn_object_unref (g_array_index (container->actuators, PnObject *, i));
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
301
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
302 g_array_set_size (container->actuators, 0);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
303 }