| 2280 | } |
| 2281 | |
| 2282 | static void |
| 2283 | preset_export_response_cb(GtkFileChooser *chooser, |
| 2284 | GtkResponseType response, signal_user_data_t *ud) |
| 2285 | { |
| 2286 | hb_preset_index_t *path; |
| 2287 | const gchar *exportDir; |
| 2288 | gchar *filename; |
| 2289 | GhbValue *dict; |
| 2290 | |
| 2291 | if (response == GTK_RESPONSE_ACCEPT) |
| 2292 | { |
| 2293 | path = get_selected_path(ud); |
| 2294 | if (path == NULL || path->depth <= 0) |
| 2295 | { |
| 2296 | const gchar *name; |
| 2297 | char * new_name; |
| 2298 | |
| 2299 | free(path); |
| 2300 | dict = ghb_settings_to_preset(ud->settings); |
| 2301 | name = ghb_dict_get_string(dict, "PresetName"); |
| 2302 | new_name = g_strdup_printf("%s (modified)", name); |
| 2303 | ghb_dict_set_string(dict, "PresetName", new_name); |
| 2304 | free(new_name); |
| 2305 | } |
| 2306 | else |
| 2307 | { |
| 2308 | dict = hb_value_dup(hb_preset_get(path)); |
| 2309 | free(path); |
| 2310 | } |
| 2311 | |
| 2312 | if (dict == NULL) |
| 2313 | { |
| 2314 | ghb_file_chooser_destroy(chooser); |
| 2315 | return; |
| 2316 | } |
| 2317 | |
| 2318 | gchar *dir; |
| 2319 | |
| 2320 | filename = ghb_file_chooser_get_filename(chooser); |
| 2321 | |
| 2322 | // export the preset |
| 2323 | hb_presets_write_json(dict, filename); |
| 2324 | exportDir = ghb_dict_get_string(ud->prefs, "ExportDirectory"); |
| 2325 | dir = g_path_get_dirname(filename); |
| 2326 | if (strcmp(dir, exportDir) != 0) |
| 2327 | { |
| 2328 | ghb_dict_set_string(ud->prefs, "ExportDirectory", dir); |
| 2329 | ghb_pref_save(ud->prefs, "ExportDirectory"); |
| 2330 | } |
| 2331 | g_free(dir); |
| 2332 | g_free(filename); |
| 2333 | hb_value_free(&dict); |
| 2334 | } |
| 2335 | ghb_file_chooser_destroy(chooser); |
| 2336 | } |
| 2337 | |
| 2338 | G_MODULE_EXPORT void |
| 2339 | preset_export_action_cb(GSimpleAction *action, GVariant *param, |
nothing calls this directly
no test coverage detected