# HG changeset patch # User Nathan Walp # Date 1176937027 0 # Node ID 017405933589abb67272ba2aba2ba2d2e4029fff # Parent 50e1b269598e424e45feed8e442971a02ca7abcc# Parent 28b52d87392e40b82eef83be7d1f237673a794b5 merge of '8fd567043fa0c33cc2d373ee5f6451b4b40331b4' and 'aaa701a323aaa390e0b0b64480dd7522d132d323' diff -r 50e1b269598e -r 017405933589 libpurple/prefs.c --- a/libpurple/prefs.c Wed Apr 18 22:57:03 2007 +0000 +++ b/libpurple/prefs.c Wed Apr 18 22:57:07 2007 +0000 @@ -1090,30 +1090,30 @@ return ret; } -void -purple_prefs_rename(const char *oldname, const char *newname) +static void +purple_prefs_rename_node(struct purple_pref *oldpref, struct purple_pref *newpref) { - struct purple_pref *oldpref, *newpref; - - oldpref = find_pref(oldname); - - /* it's already been renamed, call off the dogs */ - if(!oldpref) - return; + struct purple_pref *child; + char *oldname, *newname; - if (oldpref->first_child != NULL) /* can't rename parents */ + /* if we're a parent, rename the kids first */ + for(child = oldpref->first_child; child != NULL; child = child->sibling) { - purple_debug_error("prefs", "Unable to rename %s to %s: can't rename parents\n", oldname, newname); - return; - } - - - newpref = find_pref(newname); - - if (newpref == NULL) - { - purple_debug_error("prefs", "Unable to rename %s to %s: new pref not created\n", oldname, newname); - return; + struct purple_pref *newchild; + for(newchild = newpref->first_child; newchild != NULL; newchild = newchild->sibling) + { + if(!strcmp(child->name, newchild->name)) + { + purple_prefs_rename_node(child, newchild); + break; + } + } + if(newchild == NULL) { + /* no rename happened, we weren't able to find the new pref */ + char *tmpname = pref_full_name(child); + gaim_debug_error("prefs", "Unable to find rename pref for %s", tmpname); + g_free(tmpname); + } } if (oldpref->type != newpref->type) @@ -1122,7 +1122,11 @@ return; } + oldname = pref_full_name(oldpref); + newname = pref_full_name(newpref); purple_debug_info("prefs", "Renaming %s to %s\n", oldname, newname); + g_free(oldname); + g_free(newname); switch(oldpref->type) { case PURPLE_PREF_NONE: @@ -1151,6 +1155,28 @@ } void +purple_prefs_rename(const char *oldname, const char *newname) +{ + struct purple_pref *oldpref, *newpref; + + oldpref = find_pref(oldname); + + /* it's already been renamed, call off the dogs */ + if(!oldpref) + return; + + newpref = find_pref(newname); + + if (newpref == NULL) + { + purple_debug_error("prefs", "Unable to rename %s to %s: new pref not created\n", oldname, newname); + return; + } + + purple_prefs_rename_node(oldpref, newpref); +} + +void purple_prefs_rename_boolean_toggle(const char *oldname, const char *newname) { struct purple_pref *oldpref, *newpref;