MCPcopy Create free account
hub / github.com/HandBrake/HandBrake / preset_export_response_cb

Function preset_export_response_cb

gtk/src/presets.c:2282–2336  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2280}
2281
2282static void
2283preset_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
2338G_MODULE_EXPORT void
2339preset_export_action_cb(GSimpleAction *action, GVariant *param,

Callers

nothing calls this directly

Calls 11

get_selected_pathFunction · 0.85
ghb_settings_to_presetFunction · 0.85
ghb_dict_get_stringFunction · 0.85
ghb_dict_set_stringFunction · 0.85
hb_value_dupFunction · 0.85
hb_preset_getFunction · 0.85
ghb_file_chooser_destroyFunction · 0.85
hb_presets_write_jsonFunction · 0.85
ghb_pref_saveFunction · 0.85
hb_value_freeFunction · 0.85

Tested by

no test coverage detected