| 1122 | #endif |
| 1123 | |
| 1124 | void |
| 1125 | ghb_prefs_load(signal_user_data_t *ud) |
| 1126 | { |
| 1127 | GhbValue *dict, *internal; |
| 1128 | GhbValue *internalDict; |
| 1129 | |
| 1130 | internalDict = ghb_resource_get("internal-defaults"); |
| 1131 | prefsDict = read_config_file("preferences.json"); |
| 1132 | if (prefsDict == NULL) |
| 1133 | prefsDict = read_config_file("preferences"); |
| 1134 | if (prefsDict == NULL) |
| 1135 | prefsDict = ghb_dict_new(); |
| 1136 | dict = ghb_dict_get(prefsDict, "Preferences"); |
| 1137 | internal = ghb_dict_get(internalDict, "Preferences"); |
| 1138 | if (dict == NULL && internal != NULL) |
| 1139 | { |
| 1140 | dict = ghb_value_dup(internal); |
| 1141 | ghb_dict_set(prefsDict, "Preferences", dict); |
| 1142 | |
| 1143 | const char *dir = g_get_user_special_dir(G_USER_DIRECTORY_DOCUMENTS); |
| 1144 | if (dir == NULL) |
| 1145 | { |
| 1146 | dir = "."; |
| 1147 | } |
| 1148 | ghb_dict_set_string(dict, "ExportDirectory", dir); |
| 1149 | |
| 1150 | dir = g_get_user_special_dir(G_USER_DIRECTORY_VIDEOS); |
| 1151 | if (dir == NULL) |
| 1152 | { |
| 1153 | dir = "."; |
| 1154 | } |
| 1155 | ghb_dict_set_string(dict, "destination_dir", dir); |
| 1156 | |
| 1157 | ghb_dict_set_string(dict, "SrtDir", dir); |
| 1158 | #if defined(_WIN32) |
| 1159 | gchar *source; |
| 1160 | |
| 1161 | source = FindFirstCDROM(); |
| 1162 | if (source == NULL) |
| 1163 | { |
| 1164 | source = g_strdup("C:" G_DIR_SEPARATOR_S); |
| 1165 | } |
| 1166 | ghb_dict_set_string(dict, "default_source", source); |
| 1167 | g_free(source); |
| 1168 | #endif |
| 1169 | store_prefs(); |
| 1170 | } |
| 1171 | // Migrate from legacy preferences |
| 1172 | if (ghb_dict_get_int(dict, "DiskFreeLimit")) |
| 1173 | { |
| 1174 | int limit_gb = ghb_dict_get_int(dict, "DiskFreeLimit") / 1000; |
| 1175 | if (limit_gb <= 0) limit_gb = 1; |
| 1176 | ghb_dict_set_int(dict, "DiskFreeLimitGB", limit_gb); |
| 1177 | ghb_dict_remove(dict, "DiskFreeLimit"); |
| 1178 | } |
| 1179 | ghb_dict_remove(dict, "show_presets"); |
| 1180 | } |
| 1181 |
no test coverage detected