comparison pidgin/gtkprefs.c @ 32736:cc361e897c41

Correctly save the conversation theme pref when re-choosing the Default.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Sun, 04 Mar 2012 03:32:07 +0000
parents e53eb11ff985
children 2efee7ca90be
comparison
equal deleted inserted replaced
32735:01741f87cc1e 32736:cc361e897c41
1099 1099
1100 /* sets the current conversation theme */ 1100 /* sets the current conversation theme */
1101 static void 1101 static void
1102 prefs_set_conv_theme_cb(GtkComboBox *combo_box, gpointer user_data) 1102 prefs_set_conv_theme_cb(GtkComboBox *combo_box, gpointer user_data)
1103 { 1103 {
1104 PidginConvTheme *theme = NULL;
1105 GtkTreeIter iter; 1104 GtkTreeIter iter;
1106 gchar *name = NULL;
1107 1105
1108 if (gtk_combo_box_get_active_iter(combo_box, &iter)) { 1106 if (gtk_combo_box_get_active_iter(combo_box, &iter)) {
1109 const GList *variants; 1107 gchar *name = NULL;
1110 const char *current_variant;
1111 gboolean unset = TRUE;
1112 1108
1113 gtk_tree_model_get(GTK_TREE_MODEL(prefs_conv_themes), &iter, 2, &name, -1); 1109 gtk_tree_model_get(GTK_TREE_MODEL(prefs_conv_themes), &iter, 2, &name, -1);
1114 if (!name || !*name) {
1115 g_free(name);
1116 return;
1117 }
1118 1110
1119 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/theme", name); 1111 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/theme", name);
1120 1112
1121 /* Update list of variants */ 1113 /* Update list of variants */
1122 gtk_list_store_clear(prefs_conv_variants); 1114 gtk_list_store_clear(prefs_conv_variants);
1123 1115
1124 theme = PIDGIN_CONV_THEME(purple_theme_manager_find_theme(name, "conversation")); 1116 if (name && *name) {
1125 current_variant = pidgin_conversation_theme_get_variant(theme); 1117 PidginConvTheme *theme;
1126 1118 const char *current_variant;
1127 variants = pidgin_conversation_theme_get_variants(theme); 1119 const GList *variants;
1128 for (; variants && current_variant; variants = g_list_next(variants)) { 1120 gboolean unset = TRUE;
1129 gtk_list_store_append(prefs_conv_variants, &iter); 1121
1130 gtk_list_store_set(prefs_conv_variants, &iter, 0, variants->data, -1); 1122 theme = PIDGIN_CONV_THEME(purple_theme_manager_find_theme(name, "conversation"));
1131 1123 current_variant = pidgin_conversation_theme_get_variant(theme);
1132 if (g_str_equal(variants->data, current_variant)) { 1124
1133 gtk_combo_box_set_active_iter(GTK_COMBO_BOX(prefs_conv_variants_combo_box), &iter); 1125 variants = pidgin_conversation_theme_get_variants(theme);
1134 unset = FALSE; 1126 for (; variants && current_variant; variants = g_list_next(variants)) {
1127 gtk_list_store_append(prefs_conv_variants, &iter);
1128 gtk_list_store_set(prefs_conv_variants, &iter, 0, variants->data, -1);
1129
1130 if (g_str_equal(variants->data, current_variant)) {
1131 gtk_combo_box_set_active_iter(GTK_COMBO_BOX(prefs_conv_variants_combo_box), &iter);
1132 unset = FALSE;
1133 }
1135 } 1134 }
1135
1136 if (unset)
1137 gtk_combo_box_set_active(GTK_COMBO_BOX(prefs_conv_variants_combo_box), 0);
1136 } 1138 }
1137
1138 if (unset)
1139 gtk_combo_box_set_active(GTK_COMBO_BOX(prefs_conv_variants_combo_box), 0);
1140 1139
1141 g_free(name); 1140 g_free(name);
1142 } 1141 }
1143 } 1142 }
1144 1143