Mercurial > pidgin
comparison src/prefs.c @ 5533:b4c32b9a797d
[gaim-migrate @ 5933]
chip was right, setting a pref should create it if its not there.
I think I meant to do this like a week ago, but forgot about it.
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Mon, 26 May 2003 14:39:03 +0000 |
parents | e7747cae9710 |
children | 0aa4d089125c |
comparison
equal
deleted
inserted
replaced
5532:6f35b80c5ffa | 5533:b4c32b9a797d |
---|---|
269 } | 269 } |
270 | 270 |
271 void gaim_prefs_set_bool(const char *name, gboolean value) { | 271 void gaim_prefs_set_bool(const char *name, gboolean value) { |
272 struct gaim_pref *pref = find_pref(name); | 272 struct gaim_pref *pref = find_pref(name); |
273 | 273 |
274 g_return_if_fail(pref != NULL); | 274 if(pref) { |
275 g_return_if_fail(pref->type == GAIM_PREF_BOOLEAN); | 275 g_return_if_fail(pref->type == GAIM_PREF_BOOLEAN); |
276 | 276 |
277 if(pref->value.boolean != value) { | 277 if(pref->value.boolean != value) { |
278 pref->value.boolean = value; | 278 pref->value.boolean = value; |
279 do_callbacks(name, pref); | 279 do_callbacks(name, pref); |
280 } | |
281 } else { | |
282 gaim_prefs_add_bool(name, value); | |
280 } | 283 } |
281 } | 284 } |
282 | 285 |
283 void gaim_prefs_set_int(const char *name, int value) { | 286 void gaim_prefs_set_int(const char *name, int value) { |
284 struct gaim_pref *pref = find_pref(name); | 287 struct gaim_pref *pref = find_pref(name); |
285 | 288 |
286 g_return_if_fail(pref != NULL); | 289 if(pref) { |
287 g_return_if_fail(pref->type == GAIM_PREF_INT); | 290 g_return_if_fail(pref->type == GAIM_PREF_INT); |
288 | 291 |
289 if(pref->value.integer != value) { | 292 if(pref->value.integer != value) { |
290 pref->value.integer = value; | 293 pref->value.integer = value; |
291 do_callbacks(name, pref); | 294 do_callbacks(name, pref); |
295 } | |
296 } else { | |
297 gaim_prefs_add_int(name, value); | |
292 } | 298 } |
293 } | 299 } |
294 | 300 |
295 void gaim_prefs_set_string(const char *name, const char *value) { | 301 void gaim_prefs_set_string(const char *name, const char *value) { |
296 struct gaim_pref *pref = find_pref(name); | 302 struct gaim_pref *pref = find_pref(name); |
297 | 303 |
298 g_return_if_fail(pref != NULL); | 304 if(pref) { |
299 g_return_if_fail(pref->type == GAIM_PREF_STRING); | 305 g_return_if_fail(pref->type == GAIM_PREF_STRING); |
300 | 306 |
301 if(strcmp(pref->value.string, value)) { | 307 if(strcmp(pref->value.string, value)) { |
302 g_free(pref->value.string); | 308 g_free(pref->value.string); |
303 pref->value.string = g_strdup(value); | 309 pref->value.string = g_strdup(value); |
304 do_callbacks(name, pref); | 310 do_callbacks(name, pref); |
311 } | |
312 } else { | |
313 gaim_prefs_add_string(name, value); | |
305 } | 314 } |
306 } | 315 } |
307 | 316 |
308 gpointer gaim_prefs_get_generic(const char *name) { | 317 gpointer gaim_prefs_get_generic(const char *name) { |
309 struct gaim_pref *pref = find_pref(name); | 318 struct gaim_pref *pref = find_pref(name); |
519 pref_name_full = g_string_prepend(pref_name_full, tmp->data); | 528 pref_name_full = g_string_prepend(pref_name_full, tmp->data); |
520 } | 529 } |
521 | 530 |
522 pref_name_full = g_string_prepend_c(pref_name_full, '/'); | 531 pref_name_full = g_string_prepend_c(pref_name_full, '/'); |
523 | 532 |
524 if(!find_pref(pref_name_full->str)) { | 533 switch(pref_type) { |
525 switch(pref_type) { | 534 case GAIM_PREF_NONE: |
526 case GAIM_PREF_NONE: | 535 break; |
527 gaim_prefs_add_none(pref_name_full->str); | 536 case GAIM_PREF_BOOLEAN: |
528 break; | 537 gaim_prefs_set_bool(pref_name_full->str, atoi(pref_value)); |
529 case GAIM_PREF_BOOLEAN: | 538 break; |
530 gaim_prefs_add_bool(pref_name_full->str, atoi(pref_value)); | 539 case GAIM_PREF_INT: |
531 break; | 540 gaim_prefs_set_int(pref_name_full->str, atoi(pref_value)); |
532 case GAIM_PREF_INT: | 541 break; |
533 gaim_prefs_add_int(pref_name_full->str, atoi(pref_value)); | 542 case GAIM_PREF_STRING: |
534 break; | 543 gaim_prefs_set_string(pref_name_full->str, pref_value); |
535 case GAIM_PREF_STRING: | 544 break; |
536 gaim_prefs_add_string(pref_name_full->str, pref_value); | |
537 break; | |
538 } | |
539 } else { | |
540 switch(pref_type) { | |
541 case GAIM_PREF_NONE: | |
542 break; | |
543 case GAIM_PREF_BOOLEAN: | |
544 gaim_prefs_set_bool(pref_name_full->str, atoi(pref_value)); | |
545 break; | |
546 case GAIM_PREF_INT: | |
547 gaim_prefs_set_int(pref_name_full->str, atoi(pref_value)); | |
548 break; | |
549 case GAIM_PREF_STRING: | |
550 gaim_prefs_set_string(pref_name_full->str, pref_value); | |
551 break; | |
552 } | |
553 } | 545 } |
554 | 546 |
555 prefs_stack = g_list_prepend(prefs_stack, g_strdup(pref_name)); | 547 prefs_stack = g_list_prepend(prefs_stack, g_strdup(pref_name)); |
556 g_string_free(pref_name_full, TRUE); | 548 g_string_free(pref_name_full, TRUE); |
557 } | 549 } |