| 1975 | } |
| 1976 | |
| 1977 | void |
| 1978 | ghb_presets_load(signal_user_data_t *ud) |
| 1979 | { |
| 1980 | int result = presets_add_config_file("presets.json"); |
| 1981 | if (result == -2) |
| 1982 | { |
| 1983 | // The above can fail if the presets file was written by a |
| 1984 | // more recent version of HandBrake than is currently running. |
| 1985 | // Look for a backup version that matches the currently running |
| 1986 | // version. |
| 1987 | GtkWindow *hb_window = GTK_WINDOW(ghb_builder_widget("hb_window")); |
| 1988 | if (!ghb_question_dialog_run(hb_window, GHB_ACTION_DESTRUCTIVE, |
| 1989 | _("Load backup presets"), _("Get me out of here!"), |
| 1990 | _("Presets found are newer than what is supported by this version of HandBrake!\n\n" |
| 1991 | "Would you like to continue?"), NULL)) |
| 1992 | { |
| 1993 | exit(1); |
| 1994 | } |
| 1995 | |
| 1996 | gchar *name; |
| 1997 | int major, minor, micro; |
| 1998 | |
| 1999 | hb_presets_current_version(&major, &minor, µ); |
| 2000 | name = g_strdup_printf("presets.%d.%d.%d.json", major, minor, micro); |
| 2001 | ghb_log("Failed to read presets file, trying backup (%s)...", name); |
| 2002 | if (presets_add_config_file(name) < 0) |
| 2003 | { |
| 2004 | ghb_log("Failed to read backup presets, using defaults..."); |
| 2005 | hb_presets_builtin_update(); |
| 2006 | // Don't store defaults unless the user explicitly saves |
| 2007 | // a new preset. This would overwrite the presets file |
| 2008 | // that was generated by a newer version of HandBrake. |
| 2009 | } |
| 2010 | g_free(name); |
| 2011 | } |
| 2012 | else if (result < 0) |
| 2013 | { |
| 2014 | if (presets_add_config_file("presets") < 0) |
| 2015 | { |
| 2016 | ghb_log("Failed to read presets file, initializing new presets..."); |
| 2017 | hb_presets_builtin_update(); |
| 2018 | store_presets(); |
| 2019 | } |
| 2020 | } |
| 2021 | ghb_update_ui_combo_box(ud, "PresetCategory", NULL, FALSE); |
| 2022 | } |
| 2023 | |
| 2024 | static hb_preset_index_t * |
| 2025 | preset_get_folder (signal_user_data_t *ud, const char *name, int type) |
no test coverage detected