static void subtitle_add_to_settings(GValue *settings, GValue *subsettings) { // Add the current subtitle settings to the list. GValue *subtitle_list; gint count; gboolean burned, forced, def; gint source; subtitle_list = ghb_settings_get_value(settings, "subtitle_list"); if (subtitle_list == NULL) { subtitle_list = ghb_array_value_new(8); ghb_settings_set_value(settings, "subtitle_list", subtitle_list); } // Validate some settings const char *mux_id; const hb_container_t *mux; mux_id = ghb_settings_get_const_string(settings, "FileFormat"); mux = ghb_lookup_container_by_name(mux_id); source = ghb_settings_get_int(subsettings, "SubtitleSource"); burned = ghb_settings_get_boolean(subsettings, "SubtitleBurned"); if (burned && !hb_subtitle_can_burn(source)) { burned = FALSE; ghb_settings_set_boolean(subsettings, "SubtitleBurned", burned); } if (!burned && !hb_subtitle_can_pass(source, mux->format)) { burned = TRUE; ghb_settings_set_boolean(subsettings, "SubtitleBurned", burned); ghb_settings_set_boolean(subsettings, "SubtitleDefaultTrack", FALSE); } def = ghb_settings_get_boolean(subsettings, "SubtitleDefaultTrack"); forced = ghb_settings_get_boolean(subsettings, "SubtitleForced"); if (forced && !hb_subtitle_can_force(source)) { forced = FALSE; ghb_settings_set_boolean(subsettings, "SubtitleForced", forced); } ghb_array_append(subtitle_list, subsettings); // Check consistancy of exclusive flags count = ghb_array_len(subtitle_list); if (burned) ghb_subtitle_exclusive_burn_settings(settings, count-1); if (def) ghb_subtitle_exclusive_default_settings(settings, count-1); }
void ghb_subtitle_prune(signal_user_data_t *ud) { GValue *subtitle_list; GValue *subsettings; gint ii; gboolean one_burned = FALSE; subtitle_list = ghb_settings_get_value(ud->settings, "subtitle_list"); if (subtitle_list == NULL) return; const char *mux_id; const hb_container_t *mux; mux_id = ghb_settings_get_const_string(ud->settings, "FileFormat"); mux = ghb_lookup_container_by_name(mux_id); for (ii = 0; ii < ghb_array_len(subtitle_list); ) { gboolean burned; int source; subsettings = ghb_array_get_nth(subtitle_list, ii); burned = ghb_settings_get_boolean(subsettings, "SubtitleBurned"); source = ghb_settings_get_boolean(subsettings, "SubtitleSource"); burned = burned || !hb_subtitle_can_pass(source, mux->format); if (burned && one_burned) { GValue *gsub = ghb_array_get_nth(subtitle_list, ii); ghb_array_remove(subtitle_list, ii); ghb_value_free(gsub); continue; } one_burned = one_burned || burned; ghb_settings_set_boolean(subsettings, "SubtitleBurned", burned); ii++; } subsettings = subtitle_get_selected_settings(ud, NULL); if (subsettings != NULL) { subtitle_update_dialog_widgets(ud, subsettings); } }
static void subtitle_update_dialog_widgets(signal_user_data_t *ud, GValue *subsettings) { GtkWidget *widget; if (subsettings != NULL) { // Update widgets with subsettings gboolean burn, force, def; const char *mux_id; const hb_container_t *mux; mux_id = ghb_settings_get_const_string(ud->settings, "FileFormat"); mux = ghb_lookup_container_by_name(mux_id); int source = ghb_settings_get_int(subsettings, "SubtitleSource"); ghb_ui_update_from_settings(ud, "SubtitleTrack", subsettings); ghb_ui_update_from_settings(ud, "SrtLanguage", subsettings); ghb_ui_update_from_settings(ud, "SrtCodeset", subsettings); ghb_ui_update_from_settings(ud, "SrtFile", subsettings); ghb_ui_update_from_settings(ud, "SrtOffset", subsettings); if (source == SRTSUB) { ghb_ui_update(ud, "SubtitleSrtEnable", ghb_boolean_value(TRUE)); } else { ghb_ui_update(ud, "SubtitleSrtDisable", ghb_boolean_value(TRUE)); } widget = GHB_WIDGET(ud->builder, "SubtitleBurned"); gtk_widget_set_sensitive(widget, hb_subtitle_can_burn(source) && hb_subtitle_can_pass(source, mux->format)); widget = GHB_WIDGET(ud->builder, "SubtitleForced"); gtk_widget_set_sensitive(widget, hb_subtitle_can_force(source)); widget = GHB_WIDGET(ud->builder, "SubtitleDefaultTrack"); gtk_widget_set_sensitive(widget, hb_subtitle_can_pass(source, mux->format)); burn = ghb_settings_get_int(subsettings, "SubtitleBurned"); force = ghb_settings_get_int(subsettings, "SubtitleForced"); def = ghb_settings_get_int(subsettings, "SubtitleDefaultTrack"); if (!hb_subtitle_can_burn(source)) { burn = FALSE; } if (!hb_subtitle_can_force(source)) { force = FALSE; } if (!hb_subtitle_can_pass(source, mux->format)) { def = FALSE; burn = TRUE; } ghb_settings_set_boolean(subsettings, "SubtitleBurned", burn); ghb_ui_update(ud, "SubtitleBurned", ghb_boolean_value(burn)); ghb_settings_set_boolean(subsettings, "SubtitleForced", force); ghb_ui_update(ud, "SubtitleForced", ghb_boolean_value(force)); ghb_settings_set_boolean(subsettings, "SubtitleDefaultTrack", def); ghb_ui_update(ud, "SubtitleDefaultTrack", ghb_boolean_value(def)); // Hide regular subtitle widgets widget = GHB_WIDGET(ud->builder, "subtitle_track_box"); gtk_widget_set_visible(widget, source != SRTSUB); // Show SRT subitle widgets widget = GHB_WIDGET(ud->builder, "subtitle_srt_grid"); gtk_widget_set_visible(widget, source == SRTSUB); } else { // Hide SRT subitle widgets widget = GHB_WIDGET(ud->builder, "subtitle_srt_grid"); gtk_widget_set_visible(widget, FALSE); // Show regular subtitle widgets widget = GHB_WIDGET(ud->builder, "subtitle_track_box"); gtk_widget_set_visible(widget, TRUE); } }
static GValue* subtitle_add_track( signal_user_data_t *ud, GValue *settings, const hb_title_t *title, int track, int mux, gboolean default_track, gboolean srt, gboolean *burned) { int source = 0; if (track >= 0 && !srt) { hb_subtitle_t *subtitle = hb_list_item(title->list_subtitle, track); source = subtitle->source; } else if (srt) { source = SRTSUB; } if (*burned && !hb_subtitle_can_pass(source, mux)) { // Can only burn one. Skip others that must be burned. return NULL; } GValue *subsettings = ghb_dict_value_new(); ghb_settings_set_int(subsettings, "SubtitleTrack", track); ghb_settings_set_int(subsettings, "SubtitleSource", source); // Set default SRT settings gchar *pref_lang, *dir, *filename; pref_lang = ghb_settings_get_string(settings, "PreferredLanguage"); ghb_settings_set_string(subsettings, "SrtLanguage", pref_lang); g_free(pref_lang); ghb_settings_set_string(subsettings, "SrtCodeset", "UTF-8"); dir = ghb_settings_get_string(ud->prefs, "SrtDir"); filename = g_strdup_printf("%s/none", dir); ghb_settings_set_string(subsettings, "SrtFile", filename); g_free(dir); g_free(filename); ghb_settings_set_int(subsettings, "SrtOffset", 0); subtitle_set_track_description(settings, subsettings); if (!hb_subtitle_can_pass(source, mux)) { ghb_settings_set_boolean(subsettings, "SubtitleBurned", TRUE); *burned = TRUE; } else { ghb_settings_set_boolean(subsettings, "SubtitleBurned", FALSE); } if (track == -1) { // Foreign audio search "track" ghb_settings_set_boolean(subsettings, "SubtitleForced", TRUE); } else { ghb_settings_set_boolean(subsettings, "SubtitleForced", FALSE); } if (default_track) { ghb_settings_set_boolean(subsettings, "SubtitleDefaultTrack", TRUE); } else { ghb_settings_set_boolean(subsettings, "SubtitleDefaultTrack", FALSE); } subtitle_add_to_settings(settings, subsettings); return subsettings; }
static GhbValue* subtitle_add_track( signal_user_data_t *ud, GhbValue *settings, const hb_title_t *title, int track, int mux, gboolean default_track, gboolean srt, gboolean burn, gboolean *burned) { int source = 0; if (track >= 0 && !srt) { hb_subtitle_t *subtitle = hb_list_item(title->list_subtitle, track); source = subtitle->source; } else if (srt) { source = SRTSUB; } burn |= !hb_subtitle_can_pass(source, mux); if (*burned && burn) { // Can only burn one. Skip others that must be burned. return NULL; } GhbValue *subsettings = ghb_dict_new(); ghb_dict_set_int(subsettings, "SubtitleTrack", track); ghb_dict_set_int(subsettings, "SubtitleSource", source); // Set default SRT settings const gchar *pref_lang, *dir; gchar *filename; pref_lang = ghb_dict_get_string(settings, "PreferredLanguage"); ghb_dict_set_string(subsettings, "SrtLanguage", pref_lang); ghb_dict_set_string(subsettings, "SrtCodeset", "UTF-8"); dir = ghb_dict_get_string(ud->prefs, "SrtDir"); filename = g_strdup_printf("%s/none", dir); ghb_dict_set_string(subsettings, "SrtFile", filename); g_free(filename); ghb_dict_set_int(subsettings, "SrtOffset", 0); subtitle_set_track_description(settings, subsettings); if (burn) { ghb_dict_set_bool(subsettings, "SubtitleBurned", TRUE); if (track != -1) { // Allow 2 tracks to be marked burned when one is // foreign audio search. Extra burned track will be // sanitized away if foreign audio search actually finds // something. *burned = TRUE; } } else { ghb_dict_set_bool(subsettings, "SubtitleBurned", FALSE); } if (track == -1) { // Foreign audio search "track" ghb_dict_set_bool(subsettings, "SubtitleForced", TRUE); } else { ghb_dict_set_bool(subsettings, "SubtitleForced", FALSE); } if (default_track) { ghb_dict_set_bool(subsettings, "SubtitleDefaultTrack", TRUE); } else { ghb_dict_set_bool(subsettings, "SubtitleDefaultTrack", FALSE); } subtitle_add_to_settings(settings, subsettings); return subsettings; }