annotate Plugins/Visualization/paranormal/pn/pnfloatoption.c @ 1717:837983bac90f trunk

[svn] Fixed a lot of warnings that only showed up on *BSD.
author js
date Sat, 16 Sep 2006 16:26:54 -0700
parents 6647d5cc717c
children
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 <config.h>
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
20
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
21 #include <stdlib.h>
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
22 #include <limits.h>
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
23 #include <glib.h>
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
24 #include "pnfloatoption.h"
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
25 #include "pnxml.h"
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
26 #include "pnerror.h"
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
27
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
28 static void pn_float_option_class_init (PnFloatOptionClass *class);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
29 static void pn_float_option_init (PnFloatOption *float_option,
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
30 PnFloatOptionClass *class);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
31
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
32 /* PnUserObject methods */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
33 static void pn_float_option_save_thyself (PnUserObject *user_object,
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
34 xmlNodePtr node);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
35 static void pn_float_option_load_thyself (PnUserObject *user_object,
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
36 xmlNodePtr node);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
37
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
38 static PnUserObjectClass *parent_class = NULL;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
39
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
40 GType
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
41 pn_float_option_get_type (void)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
42 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
43 static GType float_option_type = 0;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
44
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
45 if (! float_option_type)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
46 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
47 static const GTypeInfo float_option_info =
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
48 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
49 sizeof (PnFloatOptionClass),
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
50 NULL, /* base_init */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
51 NULL, /* base_finalize */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
52 (GClassInitFunc) pn_float_option_class_init,
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
53 NULL, /* class_finalize */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
54 NULL, /* class_data */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
55 sizeof (PnFloatOption),
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
56 0, /* n_preallocs */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
57 (GInstanceInitFunc) pn_float_option_init
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
58 };
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
59
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
60 /* FIXME: should this be dynamic? */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
61 float_option_type = g_type_register_static (PN_TYPE_OPTION,
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
62 "PnFloatOption",
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
63 &float_option_info,
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
64 0);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
65 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
66 return float_option_type;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
67 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
68
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
69 static void
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
70 pn_float_option_class_init (PnFloatOptionClass *class)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
71 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
72 PnObjectClass *object_class;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
73 PnUserObjectClass *user_object_class;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
74 PnOptionClass *option_class;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
75
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
76 parent_class = g_type_class_peek_parent (class);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
77
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
78 object_class = (PnObjectClass *) class;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
79 user_object_class = (PnUserObjectClass *) class;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
80 option_class = (PnOptionClass *) class;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
81
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
82 /* PnUserObject methods */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
83 user_object_class->save_thyself = pn_float_option_save_thyself;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
84 user_object_class->load_thyself = pn_float_option_load_thyself;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
85
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
86 /* PnOption methods */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
87 /* FIXME: this needs to be uncommented when the widget is done */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
88 /* option_class->widget_type = PN_TYPE_FLOAT_OPTION_WIDGET; */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
89 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
90
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
91 static void
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
92 pn_float_option_init (PnFloatOption *float_option,
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
93 PnFloatOptionClass *class)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
94 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
95 float_option->min = INT_MIN;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
96 float_option->max = INT_MAX;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
97 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
98
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
99 static void
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
100 pn_float_option_save_thyself (PnUserObject *user_object, xmlNodePtr node)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
101 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
102 PnFloatOption *float_option;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
103 xmlNodePtr value_node;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
104 gchar str[16];
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
105
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
106 g_return_if_fail (user_object != NULL);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
107 g_return_if_fail (PN_IS_FLOAT_OPTION (user_object));
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
108 g_return_if_fail (node != NULL);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
109
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
110 float_option = (PnFloatOption *) user_object;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
111
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: 1507
diff changeset
112 value_node = xmlNewChild (node, NULL, (xmlChar *) "Value", NULL);
1507
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
113 sprintf (str, "%f", float_option->value);
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: 1507
diff changeset
114 xmlNodeSetContent (value_node, (xmlChar *) str);
1507
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
115
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
116 if (parent_class->save_thyself)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
117 parent_class->save_thyself (user_object, node);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
118 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
119
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
120 static void
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
121 pn_float_option_load_thyself (PnUserObject *user_object, const xmlNodePtr node)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
122 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
123 PnFloatOption *float_option;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
124 xmlNodePtr float_option_node;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
125 gchar *val_str;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
126
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
127 g_return_if_fail (user_object != NULL);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
128 g_return_if_fail (PN_IS_FLOAT_OPTION (user_object));
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
129 g_return_if_fail (node != NULL);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
130
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
131 float_option = (PnFloatOption *) user_object;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
132
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
133 /* find the node for this class */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
134 for (float_option_node = node->xmlChildrenNode;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
135 float_option_node;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
136 float_option_node = float_option_node->next)
1592
752949e9aec4 [svn] Actually cast variables to glib types before feeding them into glib compare functions. Resolves another 16 signedness warnings on PPC.
chainsaw
parents: 1591
diff changeset
137 if (g_strcasecmp ((gchar *) float_option_node->name, "Value") == 0)
1507
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
138 break;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
139 if (! float_option_node)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
140 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
141 pn_error ("unable to load a PnFloatOption from xml node \"%s\"", node->name);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
142 return;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
143 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
144
1593
6647d5cc717c [svn] Additional (PPC?) warning squashing by Joseph Jezak from Gentoo.
chainsaw
parents: 1592
diff changeset
145 val_str = (gchar *)xmlNodeGetContent (float_option_node);
1507
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
146
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
147 if (val_str)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
148 pn_float_option_set_value (float_option, strtod (val_str, NULL));
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
149 else
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
150 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
151 pn_error ("invalid float option value encountered at xml node \"%s\"", node->name);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
152 return;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
153 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
154
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
155 if (parent_class->load_thyself)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
156 parent_class->load_thyself (user_object, node);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
157 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
158
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
159 PnFloatOption*
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
160 pn_float_option_new (const gchar *name, const gchar *desc)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
161 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
162 PnFloatOption *float_option;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
163
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
164 g_return_val_if_fail (name != NULL, NULL);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
165 g_return_val_if_fail (desc != NULL, NULL);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
166
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
167 float_option = (PnFloatOption *) g_object_new (PN_TYPE_FLOAT_OPTION, NULL);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
168
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
169 pn_user_object_set_name (PN_USER_OBJECT (float_option), name);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
170 pn_user_object_set_description (PN_USER_OBJECT (float_option), desc);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
171
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
172 return float_option;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
173 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
174
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
175 void
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
176 pn_float_option_set_value (PnFloatOption *float_option, gfloat value)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
177 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
178 g_return_if_fail (float_option != NULL);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
179 g_return_if_fail (PN_IS_FLOAT_OPTION (float_option));
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
180
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
181 float_option->value = CLAMP (value, float_option->min, float_option->max);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
182 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
183
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
184 gfloat
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
185 pn_float_option_get_value (PnFloatOption *float_option)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
186 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
187 g_return_val_if_fail (float_option != NULL, FALSE);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
188 g_return_val_if_fail (PN_IS_FLOAT_OPTION (float_option), FALSE);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
189
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
190 return float_option->value;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
191 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
192
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
193 void
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
194 pn_float_option_set_min (PnFloatOption *float_option, gfloat min)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
195 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
196 g_return_if_fail (float_option != NULL);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
197 g_return_if_fail (PN_IS_FLOAT_OPTION (float_option));
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
198
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
199 if (min > float_option->max)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
200 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
201 float_option->min = float_option->max;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
202 float_option->max = min;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
203 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
204 else
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
205 float_option->min = min;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
206
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
207 pn_float_option_set_value (float_option, float_option->value);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
208 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
209
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
210 gfloat
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
211 pn_float_option_get_min (PnFloatOption *float_option)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
212 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
213 g_return_val_if_fail (float_option != NULL, FALSE);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
214 g_return_val_if_fail (PN_IS_FLOAT_OPTION (float_option), FALSE);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
215
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
216 return float_option->min;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
217 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
218
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
219 void
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
220 pn_float_option_set_max (PnFloatOption *float_option, gfloat max)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
221 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
222 g_return_if_fail (float_option != NULL);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
223 g_return_if_fail (PN_IS_FLOAT_OPTION (float_option));
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
224
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
225 if (max < float_option->min)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
226 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
227 float_option->max = float_option->min;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
228 float_option->min = max;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
229 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
230 else
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
231 float_option->max = max;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
232
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
233 pn_float_option_set_value (float_option, float_option->value);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
234 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
235
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
236 gfloat
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
237 pn_float_option_get_max (PnFloatOption *float_option)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
238 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
239 g_return_val_if_fail (float_option != NULL, FALSE);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
240 g_return_val_if_fail (PN_IS_FLOAT_OPTION (float_option), FALSE);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
241
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
242 return float_option->max;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
243 }