changeset 16251:017405933589

merge of '8fd567043fa0c33cc2d373ee5f6451b4b40331b4' and 'aaa701a323aaa390e0b0b64480dd7522d132d323'
author Nathan Walp <nwalp@pidgin.im>
date Wed, 18 Apr 2007 22:57:07 +0000
parents 50e1b269598e (current diff) 28b52d87392e (diff)
children c25b815c29e3 c3052de39110
files README.SVN README.dbus doc/FAQ pidgin/pixmaps/tb_drag_arrow_down.xpm pidgin/pixmaps/tb_drag_arrow_left.xpm pidgin/pixmaps/tb_drag_arrow_right.xpm pidgin/pixmaps/tb_drag_arrow_up.xpm pidgin/plugins/crazychat/configure.ac
diffstat 1 files changed, 47 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- 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;