Mercurial > pidgin.yaz
changeset 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 | 429db0c1dcd8 |
children | 2d2f04c5c7d2 |
files | src/main.c src/prefs.c src/prefs.h |
diffstat | 3 files changed, 62 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main.c Tue Sep 02 03:19:31 2003 +0000 +++ b/src/main.c Tue Sep 02 03:29:53 2003 +0000 @@ -827,6 +827,8 @@ gaim_prefs_sync(); } + gaim_prefs_rename_old(); + /* load plugins we had when we quit */ gaim_plugins_load_saved("/gaim/gtk/plugins/loaded");
--- 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);
--- a/src/prefs.h Tue Sep 02 03:19:31 2003 +0000 +++ b/src/prefs.h Tue Sep 02 03:29:53 2003 +0000 @@ -107,6 +107,14 @@ void gaim_prefs_remove(const char *name); /** + * Rename a pref + * + * @param oldname The old name of the pref + * @param newname The new name for the pref + */ +void gaim_prefs_rename(const char *oldname, const char *newname); + +/** * Remove all prefs. */ void gaim_prefs_destroy(); @@ -217,6 +225,11 @@ */ void gaim_prefs_sync(); +/** + * Rename legacy prefs + */ +void gaim_prefs_rename_old(); + /*@}*/ #ifdef __cplusplus