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

Function settings_save

gtk/src/presets.c:2052–2122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2050}
2051
2052static void
2053settings_save(signal_user_data_t *ud, const char * category,
2054 const char *name, const char * desc, gboolean set_def)
2055{
2056 GhbValue * preset, * new_preset;
2057 hb_preset_index_t * folder_path, * path;
2058 char * fullname;
2059
2060 folder_path = preset_get_folder(ud, category, HB_PRESET_TYPE_CUSTOM);
2061 if (!folder_path) return;
2062
2063 new_preset = ghb_settings_to_preset(ud->settings);
2064 ghb_dict_set_int(new_preset, "Type", HB_PRESET_TYPE_CUSTOM);
2065 ghb_dict_set_string(new_preset, "PresetName", name);
2066 if (desc != NULL)
2067 ghb_dict_set_string(new_preset, "PresetDescription", desc);
2068
2069 fullname = g_strdup_printf("/%s/%s", category, name);
2070 path = hb_preset_search_index(fullname, 0, HB_PRESET_TYPE_CUSTOM);
2071 preset = hb_preset_get(path);
2072 if (preset != NULL)
2073 {
2074 // Replacing an existing preset
2075 gboolean def = ghb_dict_get_bool(preset, "Default");
2076
2077 // If we are replacing the default preset, re-mark it as default
2078 ghb_dict_set_bool(new_preset, "Default", def);
2079 // Already exists, update its description
2080 if (hb_preset_set(path, new_preset) >= 0)
2081 {
2082 presets_list_update_item(ud, path, FALSE);
2083 }
2084 }
2085 else
2086 {
2087 // Check if the new preset is also the new default preset
2088 if (set_def)
2089 {
2090 ghb_dict_set_bool(new_preset, "Default", set_def);
2091 presets_list_clear_default(ud);
2092 hb_presets_clear_default();
2093 }
2094
2095 // Adding a new preset
2096 // Append to the folder
2097 int index = hb_preset_append(folder_path, new_preset);
2098 if (index >= 0)
2099 {
2100 folder_path->index[folder_path->depth++] = index;
2101 presets_list_append(ud, folder_path);
2102 }
2103 *path = *folder_path;
2104 }
2105
2106
2107 free(fullname);
2108 ghb_value_free(&new_preset);
2109

Callers 2

preset_save_as_write_cbFunction · 0.85
preset_save_action_cbFunction · 0.85

Calls 15

preset_get_folderFunction · 0.85
ghb_settings_to_presetFunction · 0.85
ghb_dict_set_intFunction · 0.85
ghb_dict_set_stringFunction · 0.85
hb_preset_search_indexFunction · 0.85
hb_preset_getFunction · 0.85
ghb_dict_get_boolFunction · 0.85
ghb_dict_set_boolFunction · 0.85
hb_preset_setFunction · 0.85
presets_list_update_itemFunction · 0.85
hb_presets_clear_defaultFunction · 0.85

Tested by

no test coverage detected