changeset 8705:543b19a96ac5

[gaim-migrate @ 9458] " All preferences in gaim, except for "No sounds when you log in", are "positive" preferences. For consistency and to make it a bit easier to understand the preference I think they should all be "positive" preferences (there's probably something about this in some HIG somewhere too) This patch: 1. changes "No sounds when you log in" to "Sounds when you log in" 2. adds a helper function for renaming old boolean prefs and inverting their meaning (gaim_prefs_rename_boolean_toggle) 3. Moves existing renames from prefs.c to gtkprefs.c because they all reference gtk preferences. Default behaviour for new users remains the same (no sounds during log in), and existing user's preferences are migrated correctly." --Stu Tomlinson at one point possitive preferences were policy, i think we should maintain that policy. committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Sun, 18 Apr 2004 19:30:19 +0000
parents 581c94348984
children afa05986603a
files src/gaimrc.c src/gtkprefs.c src/gtkprefs.h src/gtksound.c src/main.c src/prefs.c src/prefs.h
diffstat 7 files changed, 51 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/src/gaimrc.c	Sun Apr 18 19:26:33 2004 +0000
+++ b/src/gaimrc.c	Sun Apr 18 19:30:19 2004 +0000
@@ -1125,8 +1125,8 @@
 					sound_options & OPT_SOUND_FIRST_RCV);
 			gaim_prefs_set_bool("/core/sound/when_away",
 					sound_options & OPT_SOUND_WHEN_AWAY);
-			gaim_prefs_set_bool("/gaim/gtk/sound/silent_signon",
-					sound_options & OPT_SOUND_SILENT_SIGNON);
+			gaim_prefs_set_bool("/gaim/gtk/sound/signon",
+					!(sound_options & OPT_SOUND_SILENT_SIGNON));
 			gaim_prefs_set_bool("/gaim/gtk/sound/enabled/join_chat",
 					sound_options & OPT_SOUND_CHAT_JOIN);
 			gaim_prefs_set_bool("/gaim/gtk/sound/enabled/chat_msg_recv",
--- a/src/gtkprefs.c	Sun Apr 18 19:26:33 2004 +0000
+++ b/src/gtkprefs.c	Sun Apr 18 19:30:19 2004 +0000
@@ -1534,8 +1534,8 @@
 	sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
 
 	vbox = gaim_gtk_make_frame (ret, _("Sound Options"));
-	gaim_gtk_prefs_checkbox(_("_No sounds when you log in"),
-				   "/gaim/gtk/sound/silent_signon", vbox);
+	gaim_gtk_prefs_checkbox(_("Sounds when you _log in"),
+				   "/gaim/gtk/sound/signon", vbox);
 	gaim_gtk_prefs_checkbox(_("Sounds when conversation has _focus"),
 				   "/gaim/gtk/sound/conv_focus", vbox);
 	gaim_gtk_prefs_checkbox(_("_Sounds while away"),
@@ -3014,3 +3014,13 @@
 	gaim_prefs_connect_callback("/gaim/gtk/smileys/theme",
 								smiley_theme_pref_cb, NULL);
 }
+
+void gaim_gtk_prefs_rename_old() {
+	gaim_prefs_rename("/gaim/gtk/logging/log_ims", "/core/logging/log_ims");
+	gaim_prefs_rename("/gaim/gtk/logging/log_chats", "/core/logging/log_chats");
+	gaim_prefs_rename("/core/conversations/placement",
+					  "/gaim/gtk/conversations/placement");
+	gaim_prefs_rename_boolean_toggle("/gaim/gtk/sound/silent_signon",
+									 "/gaim/gtk/sound/signon");
+}
+
--- a/src/gtkprefs.h	Sun Apr 18 19:26:33 2004 +0000
+++ b/src/gtkprefs.h	Sun Apr 18 19:30:19 2004 +0000
@@ -105,4 +105,9 @@
 		const gchar * title, GaimPrefType type, const char *key,
 		GList *menuitems);
 
+/**
+ * Rename legacy prefs
+ */
+void gaim_gtk_prefs_rename_old();
+
 #endif /* _GAIM_GTK_PREFS_H_ */
--- a/src/gtksound.c	Sun Apr 18 19:26:33 2004 +0000
+++ b/src/gtksound.c	Sun Apr 18 19:30:19 2004 +0000
@@ -107,7 +107,7 @@
 	gaim_prefs_add_string("/gaim/gtk/sound/file/nick_said", "");
 	gaim_prefs_add_bool("/gaim/gtk/sound/enabled/pounce_default", TRUE);
 	gaim_prefs_add_string("/gaim/gtk/sound/file/pounce_default", "");
-	gaim_prefs_add_bool("/gaim/gtk/sound/silent_signon", TRUE);
+	gaim_prefs_add_bool("/gaim/gtk/sound/signon", FALSE);
 	gaim_prefs_add_bool("/gaim/gtk/sound/conv_focus", TRUE);
 	gaim_prefs_add_string("/gaim/gtk/sound/command", "");
 	gaim_prefs_add_string("/gaim/gtk/sound/method", "automatic");
--- a/src/main.c	Sun Apr 18 19:26:33 2004 +0000
+++ b/src/main.c	Sun Apr 18 19:30:19 2004 +0000
@@ -124,7 +124,7 @@
 void gaim_setup(GaimConnection *gc)
 {
 	if (gaim_prefs_get_bool("/gaim/gtk/sound/enabled/login")
-			&& gaim_prefs_get_bool("/gaim/gtk/sound/silent_signon")) {
+			&& !gaim_prefs_get_bool("/gaim/gtk/sound/signon")) {
 		if(snd_tmout) {
 			g_source_remove(snd_tmout);
 		}
@@ -851,7 +851,7 @@
 		gaim_prefs_sync();
 	}
 
-	gaim_prefs_rename_old();
+	gaim_gtk_prefs_rename_old();
 
 	/* load plugins we had when we quit */
 	gaim_plugins_load_saved("/gaim/gtk/plugins/loaded");
--- a/src/prefs.c	Sun Apr 18 19:26:33 2004 +0000
+++ b/src/prefs.c	Sun Apr 18 19:30:19 2004 +0000
@@ -626,11 +626,27 @@
 	remove_pref(oldpref);
 }
 
-void gaim_prefs_rename_old() {
-	gaim_prefs_rename("/gaim/gtk/logging/log_ims", "/core/logging/log_ims");
-	gaim_prefs_rename("/gaim/gtk/logging/log_chats", "/core/logging/log_chats");
-	gaim_prefs_rename("/core/conversations/placement",
-					  "/gaim/gtk/conversations/placement");
+void gaim_prefs_rename_boolean_toggle(const char *oldname, const char *newname) {
+		struct gaim_pref *oldpref, *newpref;
+		
+		gaim_debug_info("prefs", "Attempting to rename and toggle %s to %s\n", oldname, newname);
+
+		oldpref = find_pref(oldname);
+		newpref = find_pref(newname);
+
+		/* it's already been renamed, call off the cats */
+		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->type == GAIM_PREF_BOOLEAN);
+		g_return_if_fail(oldpref->first_child == NULL); /* can't rename parents */
+		
+		gaim_prefs_set_bool(newname, !(oldpref->value.boolean));
+
+		remove_pref(oldpref);
+
 }
 
 guint gaim_prefs_connect_callback(const char *name, GaimPrefCallback func, gpointer data)
--- a/src/prefs.h	Sun Apr 18 19:26:33 2004 +0000
+++ b/src/prefs.h	Sun Apr 18 19:30:19 2004 +0000
@@ -122,6 +122,14 @@
 void gaim_prefs_rename(const char *oldname, const char *newname);
 
 /**
+ * Rename a boolean pref, toggling it's value
+ *
+ * @param oldname The old name of the pref
+ * @param newname The new name for the pref
+ */
+void gaim_prefs_rename_boolean_toggle(const char *oldname, const char *newname);
+
+/**
  * Remove all prefs.
  */
 void gaim_prefs_destroy();
@@ -232,11 +240,6 @@
  */
 void gaim_prefs_sync();
 
-/**
- * Rename legacy prefs
- */
-void gaim_prefs_rename_old();
-
 /*@}*/
 
 #ifdef __cplusplus