| 1184 | } |
| 1185 | |
| 1186 | G_MODULE_EXPORT void |
| 1187 | subtitle_add_cb (GSimpleAction *action, GVariant *param, gpointer data) |
| 1188 | { |
| 1189 | // Add the current subtitle settings to the list. |
| 1190 | GhbValue *subsettings, *backup; |
| 1191 | gboolean one_burned; |
| 1192 | gint track; |
| 1193 | signal_user_data_t *ud = ghb_ud(); |
| 1194 | |
| 1195 | int title_id, titleindex; |
| 1196 | const hb_title_t *title; |
| 1197 | |
| 1198 | title_id = ghb_dict_get_int(ud->settings, "title"); |
| 1199 | title = ghb_lookup_title(title_id, &titleindex); |
| 1200 | if (title == NULL) |
| 1201 | { |
| 1202 | return; |
| 1203 | } |
| 1204 | |
| 1205 | // Back up settings in case we need to revert. |
| 1206 | backup = ghb_value_dup(ghb_get_job_subtitle_settings(ud->settings)); |
| 1207 | one_burned = subtitle_is_one_burned(ud->settings); |
| 1208 | |
| 1209 | const char *mux_id; |
| 1210 | const hb_container_t *mux; |
| 1211 | |
| 1212 | mux_id = ghb_dict_get_string(ud->settings, "FileFormat"); |
| 1213 | mux = ghb_lookup_container_by_name(mux_id); |
| 1214 | |
| 1215 | int count = hb_list_count(title->list_subtitle); |
| 1216 | for (subsettings = NULL, track = 0; |
| 1217 | subsettings == NULL && track < count; track++) |
| 1218 | { |
| 1219 | subsettings = subtitle_add_track(ud, ud->settings, track, |
| 1220 | mux->format, FALSE, FALSE, VOBSUB, |
| 1221 | FALSE, &one_burned); |
| 1222 | } |
| 1223 | if (subsettings == NULL) |
| 1224 | { |
| 1225 | subsettings = subtitle_add_track(ud, ud->settings, 0, |
| 1226 | mux->format, FALSE, TRUE, IMPORTSRT, |
| 1227 | FALSE, &one_burned); |
| 1228 | } |
| 1229 | if (subsettings != NULL) |
| 1230 | { |
| 1231 | add_subtitle_to_ui(ud, subsettings); |
| 1232 | |
| 1233 | // Pop up the edit dialog |
| 1234 | GtkWidget *dialog = ghb_builder_widget("subtitle_dialog"); |
| 1235 | gtk_window_set_title(GTK_WINDOW(dialog), _("Add Subtitles")); |
| 1236 | g_signal_connect(dialog, "response", G_CALLBACK(subtitle_add_response), backup); |
| 1237 | gtk_widget_set_visible(dialog, TRUE); |
| 1238 | } |
| 1239 | } |
| 1240 | |
| 1241 | static void |
| 1242 | subtitle_add_response (GtkWidget *dialog, int response, GhbValue *backup) |
nothing calls this directly
no test coverage detected