comparison libpurple/pluginpref.c @ 15822:32c366eeeb99

sed -ie 's/gaim/purple/g'
author Sean Egan <seanegan@gmail.com>
date Mon, 19 Mar 2007 07:01:17 +0000
parents 5fe8042783c1
children 44b4e8bd759b
comparison
equal deleted inserted replaced
15821:84b0f9b23ede 15822:32c366eeeb99
1 /** 1 /**
2 * gaim 2 * purple
3 * 3 *
4 * Gaim is the legal property of its developers, whose names are too numerous 4 * Purple 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 5 * to list here. Please refer to the COPYRIGHT file distributed with this
6 * source distribution. 6 * source distribution.
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 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 9 * it under the terms of the GNU General Public License as published by
28 #include "debug.h" 28 #include "debug.h"
29 #include "internal.h" 29 #include "internal.h"
30 #include "pluginpref.h" 30 #include "pluginpref.h"
31 #include "prefs.h" 31 #include "prefs.h"
32 32
33 struct _GaimPluginPrefFrame 33 struct _PurplePluginPrefFrame
34 { 34 {
35 GList *prefs; 35 GList *prefs;
36 }; 36 };
37 37
38 struct _GaimPluginPref 38 struct _PurplePluginPref
39 { 39 {
40 char *name; 40 char *name;
41 char *label; 41 char *label;
42 42
43 GaimPluginPrefType type; 43 PurplePluginPrefType type;
44 44
45 int min; 45 int min;
46 int max; 46 int max;
47 GList *choices; 47 GList *choices;
48 unsigned int max_length; 48 unsigned int max_length;
49 gboolean masked; 49 gboolean masked;
50 GaimStringFormatType format; 50 PurpleStringFormatType format;
51 }; 51 };
52 52
53 GaimPluginPrefFrame * 53 PurplePluginPrefFrame *
54 gaim_plugin_pref_frame_new() 54 purple_plugin_pref_frame_new()
55 { 55 {
56 GaimPluginPrefFrame *frame; 56 PurplePluginPrefFrame *frame;
57 57
58 frame = g_new0(GaimPluginPrefFrame, 1); 58 frame = g_new0(PurplePluginPrefFrame, 1);
59 59
60 return frame; 60 return frame;
61 } 61 }
62 62
63 void 63 void
64 gaim_plugin_pref_frame_destroy(GaimPluginPrefFrame *frame) 64 purple_plugin_pref_frame_destroy(PurplePluginPrefFrame *frame)
65 { 65 {
66 g_return_if_fail(frame != NULL); 66 g_return_if_fail(frame != NULL);
67 67
68 g_list_foreach(frame->prefs, (GFunc)gaim_plugin_pref_destroy, NULL); 68 g_list_foreach(frame->prefs, (GFunc)purple_plugin_pref_destroy, NULL);
69 g_list_free(frame->prefs); 69 g_list_free(frame->prefs);
70 g_free(frame); 70 g_free(frame);
71 } 71 }
72 72
73 void 73 void
74 gaim_plugin_pref_frame_add(GaimPluginPrefFrame *frame, GaimPluginPref *pref) 74 purple_plugin_pref_frame_add(PurplePluginPrefFrame *frame, PurplePluginPref *pref)
75 { 75 {
76 g_return_if_fail(frame != NULL); 76 g_return_if_fail(frame != NULL);
77 g_return_if_fail(pref != NULL); 77 g_return_if_fail(pref != NULL);
78 78
79 frame->prefs = g_list_append(frame->prefs, pref); 79 frame->prefs = g_list_append(frame->prefs, pref);
80 } 80 }
81 81
82 GList * 82 GList *
83 gaim_plugin_pref_frame_get_prefs(GaimPluginPrefFrame *frame) 83 purple_plugin_pref_frame_get_prefs(PurplePluginPrefFrame *frame)
84 { 84 {
85 g_return_val_if_fail(frame != NULL, NULL); 85 g_return_val_if_fail(frame != NULL, NULL);
86 g_return_val_if_fail(frame->prefs != NULL, NULL); 86 g_return_val_if_fail(frame->prefs != NULL, NULL);
87 87
88 return frame->prefs; 88 return frame->prefs;
89 } 89 }
90 90
91 GaimPluginPref * 91 PurplePluginPref *
92 gaim_plugin_pref_new() 92 purple_plugin_pref_new()
93 { 93 {
94 GaimPluginPref *pref; 94 PurplePluginPref *pref;
95 95
96 pref = g_new0(GaimPluginPref, 1); 96 pref = g_new0(PurplePluginPref, 1);
97 97
98 return pref; 98 return pref;
99 } 99 }
100 100
101 GaimPluginPref * 101 PurplePluginPref *
102 gaim_plugin_pref_new_with_name(const char *name) 102 purple_plugin_pref_new_with_name(const char *name)
103 { 103 {
104 GaimPluginPref *pref; 104 PurplePluginPref *pref;
105 105
106 g_return_val_if_fail(name != NULL, NULL); 106 g_return_val_if_fail(name != NULL, NULL);
107 107
108 pref = g_new0(GaimPluginPref, 1); 108 pref = g_new0(PurplePluginPref, 1);
109 pref->name = g_strdup(name); 109 pref->name = g_strdup(name);
110 110
111 return pref; 111 return pref;
112 } 112 }
113 113
114 GaimPluginPref * 114 PurplePluginPref *
115 gaim_plugin_pref_new_with_label(const char *label) 115 purple_plugin_pref_new_with_label(const char *label)
116 { 116 {
117 GaimPluginPref *pref; 117 PurplePluginPref *pref;
118 118
119 g_return_val_if_fail(label != NULL, NULL); 119 g_return_val_if_fail(label != NULL, NULL);
120 120
121 pref = g_new0(GaimPluginPref, 1); 121 pref = g_new0(PurplePluginPref, 1);
122 pref->label = g_strdup(label); 122 pref->label = g_strdup(label);
123 123
124 return pref; 124 return pref;
125 } 125 }
126 126
127 GaimPluginPref * 127 PurplePluginPref *
128 gaim_plugin_pref_new_with_name_and_label(const char *name, const char *label) 128 purple_plugin_pref_new_with_name_and_label(const char *name, const char *label)
129 { 129 {
130 GaimPluginPref *pref; 130 PurplePluginPref *pref;
131 131
132 g_return_val_if_fail(name != NULL, NULL); 132 g_return_val_if_fail(name != NULL, NULL);
133 g_return_val_if_fail(label != NULL, NULL); 133 g_return_val_if_fail(label != NULL, NULL);
134 134
135 pref = g_new0(GaimPluginPref, 1); 135 pref = g_new0(PurplePluginPref, 1);
136 pref->name = g_strdup(name); 136 pref->name = g_strdup(name);
137 pref->label = g_strdup(label); 137 pref->label = g_strdup(label);
138 138
139 return pref; 139 return pref;
140 } 140 }
141 141
142 void 142 void
143 gaim_plugin_pref_destroy(GaimPluginPref *pref) 143 purple_plugin_pref_destroy(PurplePluginPref *pref)
144 { 144 {
145 g_return_if_fail(pref != NULL); 145 g_return_if_fail(pref != NULL);
146 146
147 g_free(pref->name); 147 g_free(pref->name);
148 g_free(pref->label); 148 g_free(pref->label);
149 g_list_free(pref->choices); 149 g_list_free(pref->choices);
150 g_free(pref); 150 g_free(pref);
151 } 151 }
152 152
153 void 153 void
154 gaim_plugin_pref_set_name(GaimPluginPref *pref, const char *name) 154 purple_plugin_pref_set_name(PurplePluginPref *pref, const char *name)
155 { 155 {
156 g_return_if_fail(pref != NULL); 156 g_return_if_fail(pref != NULL);
157 g_return_if_fail(name != NULL); 157 g_return_if_fail(name != NULL);
158 158
159 g_free(pref->name); 159 g_free(pref->name);
160 pref->name = g_strdup(name); 160 pref->name = g_strdup(name);
161 } 161 }
162 162
163 const char * 163 const char *
164 gaim_plugin_pref_get_name(GaimPluginPref *pref) 164 purple_plugin_pref_get_name(PurplePluginPref *pref)
165 { 165 {
166 g_return_val_if_fail(pref != NULL, NULL); 166 g_return_val_if_fail(pref != NULL, NULL);
167 167
168 return pref->name; 168 return pref->name;
169 } 169 }
170 170
171 void 171 void
172 gaim_plugin_pref_set_label(GaimPluginPref *pref, const char *label) 172 purple_plugin_pref_set_label(PurplePluginPref *pref, const char *label)
173 { 173 {
174 g_return_if_fail(pref != NULL); 174 g_return_if_fail(pref != NULL);
175 g_return_if_fail(label != NULL); 175 g_return_if_fail(label != NULL);
176 176
177 g_free(pref->label); 177 g_free(pref->label);
178 pref->label = g_strdup(label); 178 pref->label = g_strdup(label);
179 } 179 }
180 180
181 const char * 181 const char *
182 gaim_plugin_pref_get_label(GaimPluginPref *pref) 182 purple_plugin_pref_get_label(PurplePluginPref *pref)
183 { 183 {
184 g_return_val_if_fail(pref != NULL, NULL); 184 g_return_val_if_fail(pref != NULL, NULL);
185 185
186 return pref->label; 186 return pref->label;
187 } 187 }
188 188
189 void 189 void
190 gaim_plugin_pref_set_bounds(GaimPluginPref *pref, int min, int max) 190 purple_plugin_pref_set_bounds(PurplePluginPref *pref, int min, int max)
191 { 191 {
192 int tmp; 192 int tmp;
193 193
194 g_return_if_fail(pref != NULL); 194 g_return_if_fail(pref != NULL);
195 g_return_if_fail(pref->name != NULL); 195 g_return_if_fail(pref->name != NULL);
196 196
197 if (gaim_prefs_get_type(pref->name) != GAIM_PREF_INT) 197 if (purple_prefs_get_type(pref->name) != PURPLE_PREF_INT)
198 { 198 {
199 gaim_debug_info("pluginpref", 199 purple_debug_info("pluginpref",
200 "gaim_plugin_pref_set_bounds: %s is not an integer pref\n", 200 "purple_plugin_pref_set_bounds: %s is not an integer pref\n",
201 pref->name); 201 pref->name);
202 return; 202 return;
203 } 203 }
204 204
205 if (min > max) 205 if (min > max)
211 211
212 pref->min = min; 212 pref->min = min;
213 pref->max = max; 213 pref->max = max;
214 } 214 }
215 215
216 void gaim_plugin_pref_get_bounds(GaimPluginPref *pref, int *min, int *max) 216 void purple_plugin_pref_get_bounds(PurplePluginPref *pref, int *min, int *max)
217 { 217 {
218 g_return_if_fail(pref != NULL); 218 g_return_if_fail(pref != NULL);
219 g_return_if_fail(pref->name != NULL); 219 g_return_if_fail(pref->name != NULL);
220 220
221 if (gaim_prefs_get_type(pref->name) != GAIM_PREF_INT) 221 if (purple_prefs_get_type(pref->name) != PURPLE_PREF_INT)
222 { 222 {
223 gaim_debug(GAIM_DEBUG_INFO, "pluginpref", 223 purple_debug(PURPLE_DEBUG_INFO, "pluginpref",
224 "gaim_plugin_pref_get_bounds: %s is not an integer pref\n", 224 "purple_plugin_pref_get_bounds: %s is not an integer pref\n",
225 pref->name); 225 pref->name);
226 return; 226 return;
227 } 227 }
228 228
229 *min = pref->min; 229 *min = pref->min;
230 *max = pref->max; 230 *max = pref->max;
231 } 231 }
232 232
233 void 233 void
234 gaim_plugin_pref_set_type(GaimPluginPref *pref, GaimPluginPrefType type) 234 purple_plugin_pref_set_type(PurplePluginPref *pref, PurplePluginPrefType type)
235 { 235 {
236 g_return_if_fail(pref != NULL); 236 g_return_if_fail(pref != NULL);
237 237
238 pref->type = type; 238 pref->type = type;
239 } 239 }
240 240
241 GaimPluginPrefType 241 PurplePluginPrefType
242 gaim_plugin_pref_get_type(GaimPluginPref *pref) 242 purple_plugin_pref_get_type(PurplePluginPref *pref)
243 { 243 {
244 g_return_val_if_fail(pref != NULL, GAIM_PLUGIN_PREF_NONE); 244 g_return_val_if_fail(pref != NULL, PURPLE_PLUGIN_PREF_NONE);
245 245
246 return pref->type; 246 return pref->type;
247 } 247 }
248 248
249 void 249 void
250 gaim_plugin_pref_add_choice(GaimPluginPref *pref, const char *label, gpointer choice) 250 purple_plugin_pref_add_choice(PurplePluginPref *pref, const char *label, gpointer choice)
251 { 251 {
252 g_return_if_fail(pref != NULL); 252 g_return_if_fail(pref != NULL);
253 g_return_if_fail(label != NULL); 253 g_return_if_fail(label != NULL);
254 g_return_if_fail(choice || gaim_prefs_get_type(pref->name) == GAIM_PREF_INT); 254 g_return_if_fail(choice || purple_prefs_get_type(pref->name) == PURPLE_PREF_INT);
255 255
256 pref->choices = g_list_append(pref->choices, (gpointer)label); 256 pref->choices = g_list_append(pref->choices, (gpointer)label);
257 pref->choices = g_list_append(pref->choices, choice); 257 pref->choices = g_list_append(pref->choices, choice);
258 } 258 }
259 259
260 GList * 260 GList *
261 gaim_plugin_pref_get_choices(GaimPluginPref *pref) 261 purple_plugin_pref_get_choices(PurplePluginPref *pref)
262 { 262 {
263 g_return_val_if_fail(pref != NULL, NULL); 263 g_return_val_if_fail(pref != NULL, NULL);
264 264
265 return pref->choices; 265 return pref->choices;
266 } 266 }
267 267
268 void 268 void
269 gaim_plugin_pref_set_max_length(GaimPluginPref *pref, unsigned int max_length) 269 purple_plugin_pref_set_max_length(PurplePluginPref *pref, unsigned int max_length)
270 { 270 {
271 g_return_if_fail(pref != NULL); 271 g_return_if_fail(pref != NULL);
272 272
273 pref->max_length = max_length; 273 pref->max_length = max_length;
274 } 274 }
275 275
276 unsigned int 276 unsigned int
277 gaim_plugin_pref_get_max_length(GaimPluginPref *pref) 277 purple_plugin_pref_get_max_length(PurplePluginPref *pref)
278 { 278 {
279 g_return_val_if_fail(pref != NULL, 0); 279 g_return_val_if_fail(pref != NULL, 0);
280 280
281 return pref->max_length; 281 return pref->max_length;
282 } 282 }
283 283
284 void 284 void
285 gaim_plugin_pref_set_masked(GaimPluginPref *pref, gboolean masked) 285 purple_plugin_pref_set_masked(PurplePluginPref *pref, gboolean masked)
286 { 286 {
287 g_return_if_fail(pref != NULL); 287 g_return_if_fail(pref != NULL);
288 288
289 pref->masked = masked; 289 pref->masked = masked;
290 } 290 }
291 291
292 gboolean 292 gboolean
293 gaim_plugin_pref_get_masked(GaimPluginPref *pref) 293 purple_plugin_pref_get_masked(PurplePluginPref *pref)
294 { 294 {
295 g_return_val_if_fail(pref != NULL, FALSE); 295 g_return_val_if_fail(pref != NULL, FALSE);
296 296
297 return pref->masked; 297 return pref->masked;
298 } 298 }
299 299
300 void 300 void
301 gaim_plugin_pref_set_format_type(GaimPluginPref *pref, GaimStringFormatType format) 301 purple_plugin_pref_set_format_type(PurplePluginPref *pref, PurpleStringFormatType format)
302 { 302 {
303 g_return_if_fail(pref != NULL); 303 g_return_if_fail(pref != NULL);
304 g_return_if_fail(pref->type == GAIM_PLUGIN_PREF_STRING_FORMAT); 304 g_return_if_fail(pref->type == PURPLE_PLUGIN_PREF_STRING_FORMAT);
305 305
306 pref->format = format; 306 pref->format = format;
307 } 307 }
308 308
309 GaimStringFormatType 309 PurpleStringFormatType
310 gaim_plugin_pref_get_format_type(GaimPluginPref *pref) 310 purple_plugin_pref_get_format_type(PurplePluginPref *pref)
311 { 311 {
312 g_return_val_if_fail(pref != NULL, 0); 312 g_return_val_if_fail(pref != NULL, 0);
313 313
314 if (pref->type != GAIM_PLUGIN_PREF_STRING_FORMAT) 314 if (pref->type != PURPLE_PLUGIN_PREF_STRING_FORMAT)
315 return GAIM_STRING_FORMAT_TYPE_NONE; 315 return PURPLE_STRING_FORMAT_TYPE_NONE;
316 316
317 return pref->format; 317 return pref->format;
318 } 318 }
319 319