Mercurial > pidgin.yaz
diff src/prefs.c @ 6693:8c1b5dd87fbf
[gaim-migrate @ 7219]
sean might think this is contact support, but it isn't. this will be useful
when we figure out where prefs should have been in the first place
committer: Tailor Script <tailor@pidgin.im>
| author | Nathan Walp <nwalp@pidgin.im> |
|---|---|
| date | Tue, 02 Sep 2003 03:29:53 +0000 |
| parents | 4bc050b1af34 |
| children | 0c5637b5462e |
line wrap: on
line diff
--- a/src/prefs.c Tue Sep 02 03:19:31 2003 +0000 +++ b/src/prefs.c Tue Sep 02 03:29:53 2003 +0000 @@ -163,6 +163,8 @@ static char *pref_full_name(struct gaim_pref *pref) { GString *name; struct gaim_pref *parent; + char *ret; + if(!pref) return NULL; @@ -176,8 +178,9 @@ name = g_string_prepend_c(name, '/'); name = g_string_prepend(name, parent->name); } + ret = name->str; g_string_free(name, FALSE); - return name->str; + return ret; } static struct gaim_pref *find_pref(const char *name) @@ -316,6 +319,9 @@ if(!pref || pref == &prefs) return; + while(pref->first_child) + remove_pref(pref->first_child); + if(pref->parent->first_child == pref) { pref->parent->first_child = pref->sibling; } else { @@ -327,6 +333,8 @@ name = pref_full_name(pref); + gaim_debug(GAIM_DEBUG_INFO, "prefs", "removing pref %s\n", name); + g_hash_table_remove(prefs_hash, name); g_free(name); @@ -339,16 +347,9 @@ void gaim_prefs_remove(const char *name) { struct gaim_pref *pref = find_pref(name); - struct gaim_pref *child, *child2; if(!pref) return; - child = pref->first_child; - while(child) { - child2 = child; - child = child->sibling; - remove_pref(child2); - } remove_pref(pref); } @@ -571,6 +572,44 @@ return ret; } +void gaim_prefs_rename(const char *oldname, const char *newname) { + struct gaim_pref *oldpref, *newpref; + + oldpref = find_pref(oldname); + newpref = find_pref(newname); + + /* it's already been renamed, call off the dogs */ + if(!oldpref) + return; + + g_return_if_fail(newpref != NULL); /* the new one needs to be created */ + g_return_if_fail(oldpref->type == newpref->type); + g_return_if_fail(oldpref->first_child == NULL); /* can't rename parents */ + + switch(oldpref->type) { + case GAIM_PREF_NONE: + break; + case GAIM_PREF_BOOLEAN: + gaim_prefs_set_bool(newname, oldpref->value.boolean); + break; + case GAIM_PREF_INT: + gaim_prefs_set_int(newname, oldpref->value.integer); + break; + case GAIM_PREF_STRING: + gaim_prefs_set_string(newname, oldpref->value.string); + break; + case GAIM_PREF_STRING_LIST: + gaim_prefs_set_string_list(newname, oldpref->value.stringlist); + break; + } + + remove_pref(oldpref); +} + +void gaim_prefs_rename_old() { + /* This doesn't actually do anything yet, but it will */ +} + guint gaim_prefs_connect_callback(const char *name, GaimPrefCallback func, gpointer data) { struct gaim_pref *pref = find_pref(name);
