Mercurial > pidgin.yaz
annotate src/pluginpref.c @ 14056:25fd9539c9cf
[gaim-migrate @ 16670]
Eliminated calls to bindtextdomain() and bind_textdomain_codeset(), which have already and more appropriately been called in gtkmain.c. Also removed the definition of LOCALEDIR, which is no longer needed.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Huetsch <markhuetsch> |
---|---|
date | Tue, 08 Aug 2006 01:02:56 +0000 |
parents | 8bda65b88e49 |
children |
rev | line source |
---|---|
8713 | 1 /** |
2 * gaim | |
3 * | |
4 * Gaim is the legal property of its developers, whose names are too numerous | |
5 * to list here. Please refer to the COPYRIGHT file distributed with this | |
6 * source distribution. | |
7 * | |
8 * This program is free software; you can redistribute it and/or modify | |
9 * it under the terms of the GNU General Public License as published by | |
10 * the Free Software Foundation; either version 2 of the License, or | |
11 * (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, | |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 * GNU General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU General Public License | |
19 * along with this program; if not, write to the Free Software | |
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 */ | |
22 #ifdef HAVE_CONFIG_H | |
23 # include <config.h> | |
24 #endif | |
25 | |
26 #include <glib.h> | |
27 | |
28 #include "debug.h" | |
29 #include "internal.h" | |
30 #include "pluginpref.h" | |
31 #include "prefs.h" | |
32 | |
14035 | 33 struct _GaimPluginPrefFrame |
34 { | |
8713 | 35 GList *prefs; |
36 }; | |
37 | |
14035 | 38 struct _GaimPluginPref |
39 { | |
8713 | 40 char *name; |
41 char *label; | |
42 | |
43 GaimPluginPrefType type; | |
44 | |
45 int min; | |
46 int max; | |
47 GList *choices; | |
48 unsigned int max_length; | |
9841 | 49 gboolean masked; |
12712
8ae981f2c9cb
[gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents:
10414
diff
changeset
|
50 GaimStringFormatType format; |
8713 | 51 }; |
52 | |
53 GaimPluginPrefFrame * | |
14035 | 54 gaim_plugin_pref_frame_new() |
55 { | |
8713 | 56 GaimPluginPrefFrame *frame; |
57 | |
58 frame = g_new0(GaimPluginPrefFrame, 1); | |
59 | |
60 return frame; | |
61 } | |
62 | |
63 void | |
14035 | 64 gaim_plugin_pref_frame_destroy(GaimPluginPrefFrame *frame) |
65 { | |
66 g_return_if_fail(frame != NULL); | |
8713 | 67 |
14035 | 68 g_list_foreach(frame->prefs, (GFunc)gaim_plugin_pref_destroy, NULL); |
8745 | 69 g_list_free(frame->prefs); |
70 g_free(frame); | |
8713 | 71 } |
72 | |
73 void | |
14035 | 74 gaim_plugin_pref_frame_add(GaimPluginPrefFrame *frame, GaimPluginPref *pref) |
75 { | |
76 g_return_if_fail(frame != NULL); | |
77 g_return_if_fail(pref != NULL); | |
8713 | 78 |
8745 | 79 frame->prefs = g_list_append(frame->prefs, pref); |
8713 | 80 } |
81 | |
82 GList * | |
14035 | 83 gaim_plugin_pref_frame_get_prefs(GaimPluginPrefFrame *frame) |
84 { | |
85 g_return_val_if_fail(frame != NULL, NULL); | |
86 g_return_val_if_fail(frame->prefs != NULL, NULL); | |
8745 | 87 |
8713 | 88 return frame->prefs; |
89 } | |
90 | |
91 GaimPluginPref * | |
14035 | 92 gaim_plugin_pref_new() |
93 { | |
8713 | 94 GaimPluginPref *pref; |
95 | |
96 pref = g_new0(GaimPluginPref, 1); | |
97 | |
98 return pref; | |
99 } | |
100 | |
101 GaimPluginPref * | |
14035 | 102 gaim_plugin_pref_new_with_name(const char *name) |
103 { | |
8713 | 104 GaimPluginPref *pref; |
105 | |
14035 | 106 g_return_val_if_fail(name != NULL, NULL); |
8713 | 107 |
108 pref = g_new0(GaimPluginPref, 1); | |
109 pref->name = g_strdup(name); | |
110 | |
111 return pref; | |
112 } | |
113 | |
114 GaimPluginPref * | |
14035 | 115 gaim_plugin_pref_new_with_label(const char *label) |
116 { | |
8713 | 117 GaimPluginPref *pref; |
118 | |
14035 | 119 g_return_val_if_fail(label != NULL, NULL); |
8713 | 120 |
121 pref = g_new0(GaimPluginPref, 1); | |
122 pref->label = g_strdup(label); | |
123 | |
124 return pref; | |
125 } | |
126 | |
127 GaimPluginPref * | |
14035 | 128 gaim_plugin_pref_new_with_name_and_label(const char *name, const char *label) |
129 { | |
8713 | 130 GaimPluginPref *pref; |
131 | |
14035 | 132 g_return_val_if_fail(name != NULL, NULL); |
133 g_return_val_if_fail(label != NULL, NULL); | |
8713 | 134 |
135 pref = g_new0(GaimPluginPref, 1); | |
136 pref->name = g_strdup(name); | |
137 pref->label = g_strdup(label); | |
138 | |
139 return pref; | |
140 } | |
141 | |
142 void | |
14035 | 143 gaim_plugin_pref_destroy(GaimPluginPref *pref) |
144 { | |
145 g_return_if_fail(pref != NULL); | |
8713 | 146 |
14035 | 147 g_free(pref->name); |
148 g_free(pref->label); | |
149 g_list_free(pref->choices); | |
8713 | 150 g_free(pref); |
151 } | |
152 | |
153 void | |
14035 | 154 gaim_plugin_pref_set_name(GaimPluginPref *pref, const char *name) |
155 { | |
156 g_return_if_fail(pref != NULL); | |
157 g_return_if_fail(name != NULL); | |
8713 | 158 |
14035 | 159 g_free(pref->name); |
8713 | 160 pref->name = g_strdup(name); |
161 } | |
162 | |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
12712
diff
changeset
|
163 const char * |
14035 | 164 gaim_plugin_pref_get_name(GaimPluginPref *pref) |
165 { | |
166 g_return_val_if_fail(pref != NULL, NULL); | |
8713 | 167 |
168 return pref->name; | |
169 } | |
170 | |
171 void | |
14035 | 172 gaim_plugin_pref_set_label(GaimPluginPref *pref, const char *label) |
173 { | |
174 g_return_if_fail(pref != NULL); | |
175 g_return_if_fail(label != NULL); | |
8713 | 176 |
14035 | 177 g_free(pref->label); |
8713 | 178 pref->label = g_strdup(label); |
179 } | |
180 | |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
12712
diff
changeset
|
181 const char * |
14035 | 182 gaim_plugin_pref_get_label(GaimPluginPref *pref) |
183 { | |
184 g_return_val_if_fail(pref != NULL, NULL); | |
8713 | 185 |
186 return pref->label; | |
187 } | |
188 | |
189 void | |
14035 | 190 gaim_plugin_pref_set_bounds(GaimPluginPref *pref, int min, int max) |
191 { | |
8713 | 192 int tmp; |
193 | |
14035 | 194 g_return_if_fail(pref != NULL); |
195 g_return_if_fail(pref->name != NULL); | |
8713 | 196 |
14035 | 197 if (gaim_prefs_get_type(pref->name) != GAIM_PREF_INT) |
198 { | |
199 gaim_debug_info("pluginpref", | |
8713 | 200 "gaim_plugin_pref_set_bounds: %s is not an integer pref\n", |
201 pref->name); | |
202 return; | |
203 } | |
10414 | 204 |
14035 | 205 if (min > max) |
206 { | |
8713 | 207 tmp = min; |
208 min = max; | |
209 max = tmp; | |
210 } | |
211 | |
212 pref->min = min; | |
213 pref->max = max; | |
214 } | |
215 | |
14035 | 216 void gaim_plugin_pref_get_bounds(GaimPluginPref *pref, int *min, int *max) |
217 { | |
218 g_return_if_fail(pref != NULL); | |
219 g_return_if_fail(pref->name != NULL); | |
8713 | 220 |
14035 | 221 if (gaim_prefs_get_type(pref->name) != GAIM_PREF_INT) |
222 { | |
8713 | 223 gaim_debug(GAIM_DEBUG_INFO, "pluginpref", |
224 "gaim_plugin_pref_get_bounds: %s is not an integer pref\n", | |
225 pref->name); | |
226 return; | |
227 } | |
228 | |
229 *min = pref->min; | |
230 *max = pref->max; | |
231 } | |
232 | |
233 void | |
14035 | 234 gaim_plugin_pref_set_type(GaimPluginPref *pref, GaimPluginPrefType type) |
235 { | |
236 g_return_if_fail(pref != NULL); | |
8713 | 237 |
238 pref->type = type; | |
239 } | |
240 | |
241 GaimPluginPrefType | |
14035 | 242 gaim_plugin_pref_get_type(GaimPluginPref *pref) |
243 { | |
244 g_return_val_if_fail(pref != NULL, GAIM_PLUGIN_PREF_NONE); | |
8713 | 245 |
246 return pref->type; | |
247 } | |
248 | |
249 void | |
14035 | 250 gaim_plugin_pref_add_choice(GaimPluginPref *pref, const char *label, gpointer choice) |
251 { | |
252 g_return_if_fail(pref != NULL); | |
253 g_return_if_fail(label != NULL); | |
13268
16f6d6f8afc7
[gaim-migrate @ 15634]
Richard Laager <rlaager@wiktel.com>
parents:
13106
diff
changeset
|
254 g_return_if_fail(choice || gaim_prefs_get_type(pref->name) == GAIM_PREF_INT); |
8713 | 255 |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
12712
diff
changeset
|
256 pref->choices = g_list_append(pref->choices, (gpointer)label); |
8713 | 257 pref->choices = g_list_append(pref->choices, choice); |
258 } | |
259 | |
260 GList * | |
14035 | 261 gaim_plugin_pref_get_choices(GaimPluginPref *pref) |
262 { | |
263 g_return_val_if_fail(pref != NULL, NULL); | |
8713 | 264 |
265 return pref->choices; | |
266 } | |
267 | |
268 void | |
14035 | 269 gaim_plugin_pref_set_max_length(GaimPluginPref *pref, unsigned int max_length) |
270 { | |
271 g_return_if_fail(pref != NULL); | |
8713 | 272 |
273 pref->max_length = max_length; | |
274 } | |
275 | |
276 unsigned int | |
14035 | 277 gaim_plugin_pref_get_max_length(GaimPluginPref *pref) |
278 { | |
279 g_return_val_if_fail(pref != NULL, 0); | |
8713 | 280 |
281 return pref->max_length; | |
282 } | |
9841 | 283 |
284 void | |
14035 | 285 gaim_plugin_pref_set_masked(GaimPluginPref *pref, gboolean masked) |
286 { | |
287 g_return_if_fail(pref != NULL); | |
9841 | 288 |
289 pref->masked = masked; | |
290 } | |
291 | |
292 gboolean | |
14035 | 293 gaim_plugin_pref_get_masked(GaimPluginPref *pref) |
294 { | |
295 g_return_val_if_fail(pref != NULL, FALSE); | |
9841 | 296 |
297 return pref->masked; | |
298 } | |
12712
8ae981f2c9cb
[gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents:
10414
diff
changeset
|
299 |
8ae981f2c9cb
[gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents:
10414
diff
changeset
|
300 void |
8ae981f2c9cb
[gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents:
10414
diff
changeset
|
301 gaim_plugin_pref_set_format_type(GaimPluginPref *pref, GaimStringFormatType format) |
8ae981f2c9cb
[gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents:
10414
diff
changeset
|
302 { |
14035 | 303 g_return_if_fail(pref != NULL); |
12712
8ae981f2c9cb
[gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents:
10414
diff
changeset
|
304 g_return_if_fail(pref->type == GAIM_PLUGIN_PREF_STRING_FORMAT); |
8ae981f2c9cb
[gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents:
10414
diff
changeset
|
305 |
8ae981f2c9cb
[gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents:
10414
diff
changeset
|
306 pref->format = format; |
8ae981f2c9cb
[gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents:
10414
diff
changeset
|
307 } |
8ae981f2c9cb
[gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents:
10414
diff
changeset
|
308 |
8ae981f2c9cb
[gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents:
10414
diff
changeset
|
309 GaimStringFormatType |
8ae981f2c9cb
[gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents:
10414
diff
changeset
|
310 gaim_plugin_pref_get_format_type(GaimPluginPref *pref) |
8ae981f2c9cb
[gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents:
10414
diff
changeset
|
311 { |
14035 | 312 g_return_val_if_fail(pref != NULL, 0); |
12712
8ae981f2c9cb
[gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents:
10414
diff
changeset
|
313 |
8ae981f2c9cb
[gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents:
10414
diff
changeset
|
314 if (pref->type != GAIM_PLUGIN_PREF_STRING_FORMAT) |
8ae981f2c9cb
[gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents:
10414
diff
changeset
|
315 return GAIM_STRING_FORMAT_TYPE_NONE; |
14035 | 316 |
12712
8ae981f2c9cb
[gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents:
10414
diff
changeset
|
317 return pref->format; |
8ae981f2c9cb
[gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents:
10414
diff
changeset
|
318 } |
8ae981f2c9cb
[gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents:
10414
diff
changeset
|
319 |