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

Function preset_export_action_cb

gtk/src/presets.c:2338–2401  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2336}
2337
2338G_MODULE_EXPORT void
2339preset_export_action_cb(GSimpleAction *action, GVariant *param,
2340 signal_user_data_t *ud)
2341{
2342 hb_preset_index_t *path;
2343 GtkWindow *hb_window;
2344 GtkFileChooser *chooser;
2345 const gchar *exportDir;
2346 gchar *filename;
2347 GhbValue *dict;
2348 char *preset_name;
2349
2350 path = get_selected_path(ud);
2351 if (path == NULL || path->depth <= 0)
2352 {
2353 const gchar *name;
2354 char * new_name;
2355
2356 free(path);
2357 dict = ghb_settings_to_preset(ud->settings);
2358 name = ghb_dict_get_string(dict, "PresetName");
2359 new_name = g_strdup_printf("%s (modified)", name);
2360 ghb_dict_set_string(dict, "PresetName", new_name);
2361 free(new_name);
2362 }
2363 else
2364 {
2365 dict = hb_value_dup(hb_preset_get(path));
2366 free(path);
2367 }
2368
2369 if (dict == NULL)
2370 {
2371 return;
2372 }
2373 preset_name = g_strdup(ghb_dict_get_string(dict, "PresetName"));
2374
2375 hb_window = GTK_WINDOW(ghb_builder_widget("hb_window"));
2376 chooser = ghb_file_chooser_new(_("Export Preset"), hb_window,
2377 GTK_FILE_CHOOSER_ACTION_SAVE,
2378 _("_Save"),
2379 _("_Cancel"));
2380
2381 exportDir = ghb_dict_get_string(ud->prefs, "ExportDirectory");
2382 if (exportDir == NULL || exportDir[0] == '\0')
2383 {
2384 exportDir = ".";
2385 }
2386
2387 // Clean up preset name for use as a filename. Removing leading
2388 // and trailing whitespace and filename illegal characters.
2389 g_strstrip(preset_name);
2390 g_strdelimit(preset_name, GHB_UNSAFE_FILENAME_CHARS, '_');
2391 filename = g_strdup_printf("%s.json", preset_name);
2392 ghb_file_chooser_set_initial_file(chooser, exportDir);
2393 gtk_file_chooser_set_current_name(chooser, filename);
2394 g_free(filename);
2395 g_free(preset_name);

Callers

nothing calls this directly

Calls 12

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_builder_widgetFunction · 0.85
ghb_file_chooser_newFunction · 0.85
hb_value_freeFunction · 0.85
ghb_file_chooser_showFunction · 0.85

Tested by

no test coverage detected