diff options
author | jstebbins <[email protected]> | 2009-06-30 17:22:43 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2009-06-30 17:22:43 +0000 |
commit | b5526f35fe83ede6affbdeb9eed3e4e6d9c8f6b1 (patch) | |
tree | 8be97016c13fbe13023381a5bf979ad5625835c8 /gtk | |
parent | e7a1a9f47c475028b6e73f36ed704bc65ca6c77d (diff) |
LinGui: SRT support
- there are now two buttons to add subtitles
one button adds normal subtitles from the source.
the second adds SRT subtitles.
- when an SRT subtitle is selected in the list, the available controls change
SRT controls are: Language, Character Codeset, File, and Time Offset (ms)
- A combo entry box is used for character code. A subset of the most common
character codes is available in the popup. Other codes can be manually
entered in the entry box.
- The last used SRT file directory is remembered.
- Remove the debug printf eddyg left in decsrtsub.c
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2648 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/src/callbacks.c | 11 | ||||
-rw-r--r-- | gtk/src/ghb.ui | 224 | ||||
-rw-r--r-- | gtk/src/hb-backend.c | 148 | ||||
-rw-r--r-- | gtk/src/internal_defaults.xml | 10 | ||||
-rw-r--r-- | gtk/src/main.c | 20 | ||||
-rw-r--r-- | gtk/src/presets.c | 14 | ||||
-rw-r--r-- | gtk/src/queuehandler.c | 18 | ||||
-rw-r--r-- | gtk/src/settings.c | 25 | ||||
-rw-r--r-- | gtk/src/subtitlehandler.c | 446 |
9 files changed, 845 insertions, 71 deletions
diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c index 0b3e0cc12..4d02add03 100644 --- a/gtk/src/callbacks.c +++ b/gtk/src/callbacks.c @@ -742,7 +742,7 @@ update_source_label(signal_user_data_t *ud, const gchar *source) G_MODULE_EXPORT void chooser_file_selected_cb(GtkFileChooser *dialog, signal_user_data_t *ud) { - const gchar *name = gtk_file_chooser_get_filename (dialog); + gchar *name = gtk_file_chooser_get_filename (dialog); GtkTreeModel *store; GtkTreeIter iter; const gchar *device; @@ -768,6 +768,8 @@ chooser_file_selected_cb(GtkFileChooser *dialog, signal_user_data_t *ud) gtk_combo_box_set_active_iter (combo, &iter); else gtk_combo_box_set_active (combo, 0); + + g_free(name); } G_MODULE_EXPORT void @@ -779,13 +781,16 @@ dvd_device_changed_cb(GtkComboBox *combo, signal_user_data_t *ud) ii = gtk_combo_box_get_active (combo); if (ii > 0) { - const gchar *device, *name; + const gchar *device; + gchar *name; dialog = GHB_WIDGET(ud->builder, "source_dialog"); device = gtk_combo_box_get_active_text (combo); name = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(dialog)); if (name == NULL || strcmp(name, device) != 0) gtk_file_chooser_select_filename (GTK_FILE_CHOOSER(dialog), device); + if (name != NULL) + g_free(name); } } @@ -959,7 +964,7 @@ do_source_dialog(GtkButton *button, gboolean single, signal_user_data_t *ud) gtk_widget_hide(dialog); if (response == GTK_RESPONSE_ACCEPT) { - char *filename; + gchar *filename; filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); if (filename != NULL) diff --git a/gtk/src/ghb.ui b/gtk/src/ghb.ui index 72da56549..6e1e34db1 100644 --- a/gtk/src/ghb.ui +++ b/gtk/src/ghb.ui @@ -241,6 +241,14 @@ <property name="page_size">0</property> <property name="value">0</property> </object> + <object class="GtkAdjustment" id="adjustment31"> + <property name="upper">30000</property> + <property name="lower">-30000</property> + <property name="page_increment">100</property> + <property name="step_increment">10</property> + <property name="page_size">0</property> + <property name="value">0</property> + </object> <object class="GtkAdjustment" id="preview_progress_adj"> <property name="upper">100</property> <property name="lower">0</property> @@ -256,6 +264,16 @@ <property name="page_size">0</property> <property name="value">10</property> </object> + <object class="GtkImage" id="subtitle_add_image"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="stock">gtk-add</property> + </object> + <object class="GtkImage" id="srt_add_image"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="stock">gtk-add</property> + </object> <object class="GtkUIManager" id="uimanager1"> <child> <object class="GtkActionGroup" id="actiongroup1"> @@ -2157,20 +2175,32 @@ audio-volume-medium</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="tooltip-text" translatable="yes">Add new audio settings to the list</property> <property name="relief">GTK_RELIEF_NONE</property> + <property name="label">Subtitle</property> + <property name="image">subtitle_add_image</property> <signal handler="subtitle_add_clicked_cb" name="clicked"/> - <child> - <object class="GtkImage" id="image9"> - <property name="visible">True</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="stock">gtk-add</property> - </object> - </child> </object> <packing> <property name="expand">False</property> </packing> </child> <child> + <object class="GtkButton" id="srt_add"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="tooltip-text" translatable="yes">Add new audio settings to the list</property> + <property name="relief">GTK_RELIEF_NONE</property> + <property name="label">External SRT</property> + <property name="image">srt_add_image</property> + <signal handler="srt_add_clicked_cb" name="clicked"/> + </object> + <packing> + <property name="expand">False</property> + <property name="position">1</property> + </packing> + </child> + <child> <object class="GtkButton" id="subtitle_remove"> <property name="visible">True</property> <property name="can_focus">True</property> @@ -2189,33 +2219,181 @@ audio-volume-medium</property> </object> <packing> <property name="expand">False</property> - <property name="position">1</property> + <property name="position">2</property> </packing> </child> + </object> + <packing> + <property name="expand">False</property> + </packing> + </child> + <child> + <object class="GtkTable" id="table5"> + <property name="height_request">45</property> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="n_rows">2</property> + <property name="n_columns">5</property> + <property name="column-spacing">4</property> <child> - <object class="GtkAlignment" id="alignment48"> + <object class="GtkLabel" id="subtitle_track_label"> <property name="visible">True</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="xscale">0</property> - <property name="yscale">0</property> - <property name="xalign">1</property> - <child> - <object class="GtkComboBox" id="SubtitleTrack"> - <property name="width_request">215</property> - <property name="visible">True</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <signal handler="subtitle_track_changed_cb" name="changed"/> - </object> - </child> + <property name="label" translatable="yes">Track</property> </object> <packing> - <property name="expand">True</property> - <property name="position">2</property> + <property name="x_options">GTK_FILL</property> + <property name="y_options">GTK_FILL</property> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">0</property> + <property name="bottom_attach">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="srt_lang_label"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="label" translatable="yes">Language</property> + </object> + <packing> + <property name="x_options">GTK_FILL</property> + <property name="y_options">GTK_FILL</property> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">0</property> + <property name="bottom_attach">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="srt_code_label"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="label" translatable="yes">Character Code</property> + </object> + <packing> + <property name="x_options">GTK_FILL</property> + <property name="y_options">GTK_FILL</property> + <property name="left_attach">2</property> + <property name="right_attach">3</property> + <property name="top_attach">0</property> + <property name="bottom_attach">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="srt_file_label"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="label" translatable="yes">File</property> + </object> + <packing> + <property name="x_options">GTK_FILL</property> + <property name="y_options">GTK_FILL</property> + <property name="left_attach">3</property> + <property name="right_attach">4</property> + <property name="top_attach">0</property> + <property name="bottom_attach">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="srt_offset_label"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="label" translatable="yes">Offset (ms)</property> + </object> + <packing> + <property name="x_options">GTK_FILL</property> + <property name="y_options">GTK_FILL</property> + <property name="left_attach">4</property> + <property name="right_attach">5</property> + <property name="top_attach">0</property> + <property name="bottom_attach">1</property> + </packing> + </child> + <child> + <object class="GtkComboBox" id="SubtitleTrack"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <signal handler="subtitle_track_changed_cb" name="changed"/> + </object> + <packing> + <property name="x_options">GTK_FILL</property> + <property name="y_options"></property> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + </packing> + </child> + <child> + <object class="GtkComboBox" id="SrtLanguage"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <signal handler="srt_lang_changed_cb" name="changed"/> + </object> + <packing> + <property name="x_options">GTK_FILL</property> + <property name="y_options"></property> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + </packing> + </child> + <child> + <object class="GtkComboBoxEntry" id="SrtCodeset"> + <property name="width_request">150</property> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <signal handler="srt_changed_cb" name="changed"/> + </object> + <packing> + <property name="x_options">GTK_FILL</property> + <property name="y_options"></property> + <property name="left_attach">2</property> + <property name="right_attach">3</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + </packing> + </child> + <child> + <object class="GtkFileChooserButton" id="SrtFile"> + <property name="visible">True</property> + <property name="action">GTK_FILE_CHOOSER_ACTION_OPEN</property> + <property name="title" translatable="yes">Srt File</property> + <signal name="selection_changed" handler="srt_file_changed_cb"/> + </object> + <packing> + <property name="x_options">GTK_FILL|GTK_EXPAND</property> + <property name="y_options"></property> + <property name="left_attach">3</property> + <property name="right_attach">4</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + </packing> + </child> + <child> + <object class="GtkSpinButton" id="SrtOffset"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="tooltip-text" translatable="yes">Adjust the offset in milliseconds between video and SRT timestamps</property> + <property name="adjustment">adjustment31</property> + <signal handler="srt_changed_cb" name="value_changed"/> + </object> + <packing> + <property name="x_options">GTK_FILL</property> + <property name="y_options"></property> + <property name="left_attach">4</property> + <property name="right_attach">5</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> </packing> </child> </object> <packing> <property name="expand">False</property> + <property name="position">1</property> </packing> </child> <child> @@ -2235,7 +2413,7 @@ audio-volume-medium</property> </child> </object> <packing> - <property name="position">1</property> + <property name="position">2</property> </packing> </child> </object> diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c index 50978f0ad..1edabda50 100644 --- a/gtk/src/hb-backend.c +++ b/gtk/src/hb-backend.c @@ -383,6 +383,43 @@ combo_name_map_t combo_name_map[] = {NULL, NULL} }; +const gchar *srt_codeset_table[] = +{ + "ANSI_X3.4-1968", + "ANSI_X3.4-1986", + "ANSI_X3.4", + "ANSI_X3.110-1983", + "ANSI_X3.110", + "ASCII", + "ECMA-114", + "ECMA-118", + "ECMA-128", + "ECMA-CYRILLIC", + "IEC_P27-1", + "ISO-8859-1", + "ISO-8859-2", + "ISO-8859-3", + "ISO-8859-4", + "ISO-8859-5", + "ISO-8859-6", + "ISO-8859-7", + "ISO-8859-8", + "ISO-8859-9", + "ISO-8859-9E", + "ISO-8859-10", + "ISO-8859-11", + "ISO-8859-13", + "ISO-8859-14", + "ISO-8859-15", + "ISO-8859-16", + "UTF-7", + "UTF-8", + "UTF-16", + "UTF-32", + NULL +}; +#define SRT_TABLE_SIZE (sizeof(srt_codeset_table)/ sizeof(char*)-1) + #if 0 typedef struct iso639_lang_t { @@ -1035,7 +1072,7 @@ ghb_subtitle_track_source(signal_user_data_t *ud, gint track) gint titleindex; if (track == -2) - return CC608SUB; + return SRTSUB; if (track < 0) return VOBSUB; titleindex = ghb_settings_combo_int(ud->settings, "title"); @@ -1070,7 +1107,7 @@ ghb_subtitle_track_source_name(signal_user_data_t *ud, gint track) if (track == -2) { - name = "Text"; + name = "SRT"; goto done; } if (track == -1) @@ -1107,9 +1144,11 @@ ghb_subtitle_track_source_name(signal_user_data_t *ud, gint track) break; case CC708SUB: case CC608SUB: - case SRTSUB: name = "Text"; break; + case SRTSUB: + name = "SRT"; + break; default: break; } @@ -1528,6 +1567,33 @@ mix_opts_set(GtkBuilder *builder, const gchar *name) } static void +srt_codeset_opts_set(GtkBuilder *builder, const gchar *name) +{ + GtkTreeIter iter; + GtkListStore *store; + gint ii; + + g_debug("srt_codeset_opts_set ()\n"); + store = get_combo_box_store(builder, name); + gtk_list_store_clear(store); + for (ii = 0; ii < SRT_TABLE_SIZE; ii++) + { + gtk_list_store_append(store, &iter); + gtk_list_store_set(store, &iter, + 0, srt_codeset_table[ii], + 1, TRUE, + 2, srt_codeset_table[ii], + 3, (gdouble)ii, + 4, srt_codeset_table[ii], + -1); + } + GtkComboBoxEntry *cbe; + + cbe = GTK_COMBO_BOX_ENTRY(GHB_WIDGET(builder, name)); + //gtk_combo_box_entry_set_text_column(cbe, 0); +} + +static void language_opts_set(GtkBuilder *builder, const gchar *name) { GtkTreeIter iter; @@ -2139,6 +2205,8 @@ ghb_lookup_combo_int(const gchar *name, const GValue *gval) return lookup_video_rate_int(gval); else if (strcmp(name, "AudioMixdown") == 0) return lookup_mix_int(gval); + else if (strcmp(name, "SrtLanguage") == 0) + return lookup_audio_lang_int(gval); else if (strcmp(name, "PreferredLanguage") == 0) return lookup_audio_lang_int(gval); else @@ -2162,6 +2230,8 @@ ghb_lookup_combo_double(const gchar *name, const GValue *gval) return lookup_video_rate_int(gval); else if (strcmp(name, "AudioMixdown") == 0) return lookup_mix_int(gval); + else if (strcmp(name, "SrtLanguage") == 0) + return lookup_audio_lang_int(gval); else if (strcmp(name, "PreferredLanguage") == 0) return lookup_audio_lang_int(gval); else @@ -2185,6 +2255,8 @@ ghb_lookup_combo_option(const gchar *name, const GValue *gval) return lookup_video_rate_option(gval); else if (strcmp(name, "AudioMixdown") == 0) return lookup_mix_option(gval); + else if (strcmp(name, "SrtLanguage") == 0) + return lookup_audio_lang_option(gval); else if (strcmp(name, "PreferredLanguage") == 0) return lookup_audio_lang_option(gval); else @@ -2208,6 +2280,8 @@ ghb_lookup_combo_string(const gchar *name, const GValue *gval) return lookup_video_rate_option(gval); else if (strcmp(name, "AudioMixdown") == 0) return lookup_mix_option(gval); + else if (strcmp(name, "SrtLanguage") == 0) + return lookup_audio_lang_option(gval); else if (strcmp(name, "PreferredLanguage") == 0) return lookup_audio_lang_option(gval); else @@ -2255,7 +2329,9 @@ ghb_update_ui_combo_box( audio_samplerate_opts_set(ud->builder, "AudioSamplerate", hb_audio_rates, hb_audio_rates_count); video_rate_opts_set(ud->builder, "VideoFramerate", hb_video_rates, hb_video_rates_count); mix_opts_set(ud->builder, "AudioMixdown"); + language_opts_set(ud->builder, "SrtLanguage"); language_opts_set(ud->builder, "PreferredLanguage"); + srt_codeset_opts_set(ud->builder, "SrtCodeset"); title_opts_set(ud->builder, "title"); audio_track_opts_set(ud->builder, "AudioTrack", user_data); subtitle_track_opts_set(ud->builder, "SubtitleTrack", user_data); @@ -2290,8 +2366,12 @@ ghb_update_ui_combo_box( video_rate_opts_set(ud->builder, "VideoFramerate", hb_video_rates, hb_video_rates_count); else if (strcmp(name, "AudioMixdown") == 0) mix_opts_set(ud->builder, "AudioMixdown"); + else if (strcmp(name, "SrtLanguage") == 0) + language_opts_set(ud->builder, "SrtLanguage"); else if (strcmp(name, "PreferredLanguage") == 0) language_opts_set(ud->builder, "PreferredLanguage"); + else if (strcmp(name, "SrtCodeset") == 0) + srt_codeset_opts_set(ud->builder, "SrtCodeset"); else if (strcmp(name, "title") == 0) title_opts_set(ud->builder, "title"); else if (strcmp(name, "SubtitleTrack") == 0) @@ -2316,7 +2396,9 @@ init_ui_combo_boxes(GtkBuilder *builder) init_combo_box(builder, "AudioSamplerate"); init_combo_box(builder, "VideoFramerate"); init_combo_box(builder, "AudioMixdown"); + init_combo_box(builder, "SrtLanguage"); init_combo_box(builder, "PreferredLanguage"); + init_combo_box(builder, "SrtCodeset"); init_combo_box(builder, "title"); init_combo_box(builder, "AudioTrack"); for (ii = 0; combo_name_map[ii].name != NULL; ii++) @@ -3423,7 +3505,7 @@ ghb_validate_subtitles(signal_user_data_t *ud) gint mux = ghb_settings_combo_int(ud->settings, "FileFormat"); const GValue *slist, *settings; - gint count, ii, track, source; + gint count, ii, source; gboolean burned, one_burned = FALSE; slist = ghb_settings_get_value(ud->settings, "subtitle_list"); @@ -3431,9 +3513,8 @@ ghb_validate_subtitles(signal_user_data_t *ud) for (ii = 0; ii < count; ii++) { settings = ghb_array_get_nth(slist, ii); - track = ghb_settings_combo_int(settings, "SubtitleTrack"); + source = ghb_settings_get_int(settings, "SubtitleSource"); burned = ghb_settings_get_boolean(settings, "SubtitleBurned"); - source = ghb_subtitle_track_source(ud, track); if (burned && one_burned) { // MP4 can only handle burned vobsubs. make sure there isn't @@ -3462,7 +3543,8 @@ ghb_validate_subtitles(signal_user_data_t *ud) "Your chosen container does not support soft bitmap subtitles.\n\n" "You should change your subtitle selections.\n" "If you continue, some subtitles will be lost."); - if (!ghb_message_dialog(GTK_MESSAGE_WARNING, message, "Cancel", "Continue")) + if (!ghb_message_dialog(GTK_MESSAGE_WARNING, message, + "Cancel", "Continue")) { g_free(message); return FALSE; @@ -3470,6 +3552,27 @@ ghb_validate_subtitles(signal_user_data_t *ud) g_free(message); break; } + if (source == SRTSUB) + { + gchar *filename; + + filename = ghb_settings_get_string(settings, "SrtFile"); + if (!g_file_test(filename, G_FILE_TEST_IS_REGULAR)) + { + message = g_strdup_printf( + "Srt file does not exist or not a regular file.\n\n" + "You should choose a valid file.\n" + "If you continue, this subtitle will be ignored."); + if (!ghb_message_dialog(GTK_MESSAGE_WARNING, message, + "Cancel", "Continue")) + { + g_free(message); + return FALSE; + } + g_free(message); + break; + } + } } return TRUE; } @@ -4089,14 +4192,43 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex) for (ii = 0; ii < count; ii++) { GValue *ssettings; + gint source; ssettings = ghb_array_get_nth(subtitle_list, ii); - subtitle = ghb_settings_get_int(ssettings, "SubtitleTrack"); force = ghb_settings_get_boolean(ssettings, "SubtitleForced"); burned = ghb_settings_get_boolean(ssettings, "SubtitleBurned"); def = ghb_settings_get_boolean(ssettings, "SubtitleDefaultTrack"); + source = ghb_settings_get_int(ssettings, "SubtitleSource"); + + if (source == SRTSUB) + { + hb_subtitle_config_t sub_config; + gchar *filename, *lang, *code; + + filename = ghb_settings_get_string(ssettings, "SrtFile"); + if (!g_file_test(filename, G_FILE_TEST_IS_REGULAR)) + { + continue; + } + sub_config.offset = ghb_settings_get_int(ssettings, "SrtOffset"); + lang = ghb_settings_get_string(ssettings, "SrtLanguage"); + code = ghb_settings_get_string(ssettings, "SrtCodeset"); + strncpy(sub_config.src_filename, filename, 128); + strncpy(sub_config.src_codeset, code, 40); + sub_config.force = 0; + sub_config.dest = PASSTHRUSUB; + sub_config.default_track = def; + + hb_srt_add( job, &sub_config, lang); + + g_free(filename); + g_free(lang); + g_free(code); + continue; + } + subtitle = ghb_settings_get_int(ssettings, "SubtitleTrack"); if (subtitle == -1) { if (!burned && job->mux == HB_MUX_MKV) diff --git a/gtk/src/internal_defaults.xml b/gtk/src/internal_defaults.xml index fac8c31ff..86fe2b654 100644 --- a/gtk/src/internal_defaults.xml +++ b/gtk/src/internal_defaults.xml @@ -98,6 +98,14 @@ <false /> <key>vquality_type_target</key> <false /> + <key>SrtLanguage</key> + <string>und</string> + <key>SrtCodeset</key> + <string>ISO-8859-1</string> + <key>SrtFile</key> + <string></string> + <key>SrtOffset</key> + <integer>0</integer> </dict> <key>Preferences</key> <dict> @@ -171,6 +179,8 @@ <true /> <key>WhenComplete</key> <string>notify</string> + <key>SrtDir</key> + <string></string> </dict> <key>XlatPresets</key> <dict> diff --git a/gtk/src/main.c b/gtk/src/main.c index 34d3c149d..48a8e8d0d 100644 --- a/gtk/src/main.c +++ b/gtk/src/main.c @@ -404,12 +404,16 @@ bind_subtitle_tree_model (signal_user_data_t *ud) selection = gtk_tree_view_get_selection (treeview); // 6 columns in model. 5 are visible, the other 1 is for storing // values that I need - // Track, force, burn, default, type, track short - treestore = gtk_list_store_new(6, + // Track, force, burn, default, type, srt offset, track short, source + // force visible, burn visible, offset visible + treestore = gtk_list_store_new(11, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_STRING, - G_TYPE_STRING); + G_TYPE_INT, G_TYPE_STRING, + G_TYPE_INT, + G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, + G_TYPE_BOOLEAN); gtk_tree_view_set_model(treeview, GTK_TREE_MODEL(treestore)); cell = gtk_cell_renderer_text_new(); @@ -421,14 +425,14 @@ bind_subtitle_tree_model (signal_user_data_t *ud) cell = gtk_cell_renderer_toggle_new(); column = gtk_tree_view_column_new_with_attributes( - _("Forced Only"), cell, "active", 1, NULL); + _("Forced Only"), cell, "active", 1, "visible", 8, NULL); gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column)); g_signal_connect(cell, "toggled", subtitle_forced_toggled_cb, ud); cell = gtk_cell_renderer_toggle_new(); gtk_cell_renderer_toggle_set_radio(GTK_CELL_RENDERER_TOGGLE(cell), TRUE); column = gtk_tree_view_column_new_with_attributes( - _("Burned In"), cell, "active", 2, NULL); + _("Burned In"), cell, "active", 2, "visible", 9, NULL); gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column)); g_signal_connect(cell, "toggled", subtitle_burned_toggled_cb, ud); @@ -443,6 +447,12 @@ bind_subtitle_tree_model (signal_user_data_t *ud) column = gtk_tree_view_column_new_with_attributes( _("Type"), cell, "text", 4, NULL); gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column)); + gtk_tree_view_column_set_min_width (column, 240); + + cell = gtk_cell_renderer_text_new(); + column = gtk_tree_view_column_new_with_attributes( + _("Srt Offset"), cell, "text", 5, "visible", 10, NULL); + gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column)); g_signal_connect(selection, "changed", subtitle_list_selection_changed_cb, ud); diff --git a/gtk/src/presets.c b/gtk/src/presets.c index 01183d1a6..c17a902d4 100644 --- a/gtk/src/presets.c +++ b/gtk/src/presets.c @@ -1392,6 +1392,8 @@ ghb_prefs_load(signal_user_data_t *ud) } ghb_dict_insert(dict, g_strdup("destination_dir"), ghb_value_dup(ghb_string_value(dir))); + ghb_dict_insert(dict, + g_strdup("SrtDir"), ghb_value_dup(ghb_string_value(dir))); #if defined(_WIN32) gchar *source; @@ -3064,7 +3066,7 @@ update_subtitle_presets(signal_user_data_t *ud) g_debug("update_subtitle_presets"); const GValue *subtitle_list, *subtitle; GValue *slist, *dict; - gint count, ii; + gint count, ii, source; subtitle_list = ghb_settings_get_value(ud->settings, "subtitle_list"); slist = ghb_array_value_new(8); @@ -3072,10 +3074,14 @@ update_subtitle_presets(signal_user_data_t *ud) for (ii = 0; ii < count; ii++) { subtitle = ghb_array_get_nth(subtitle_list, ii); - dict = ghb_value_dup(subtitle); - ghb_array_append(slist, dict); + source = ghb_settings_get_int(subtitle, "SubtitleSource"); + if (source != SRTSUB) + { + dict = ghb_value_dup(subtitle); + ghb_array_append(slist, dict); + } } - ghb_settings_set_value(ud->settings, "SubtitleList", slist); + ghb_settings_take_value(ud->settings, "SubtitleList", slist); } void diff --git a/gtk/src/queuehandler.c b/gtk/src/queuehandler.c index d47a2aa66..d32cbcf2f 100644 --- a/gtk/src/queuehandler.c +++ b/gtk/src/queuehandler.c @@ -456,6 +456,24 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter) def ? " (Default)":"" ); } + else + { + gint offset; + gchar *filename, *basename, *code; + + offset = ghb_settings_get_int(settings, "SrtOffset"); + filename = ghb_settings_get_string(settings, "SrtFile"); + basename = g_path_get_basename(filename); + code = ghb_settings_get_string(settings, "SrtCodeset"); + g_string_append_printf(str, + "<small> %s (%s), %s, Offset (ms) %d%s</small>", + track, code, basename, offset, + def ? " (Default)":"" + ); + g_free(filename); + g_free(basename); + g_free(code); + } if (ii < count-1) g_string_append_printf(str, "\n"); g_free(track); diff --git a/gtk/src/settings.c b/gtk/src/settings.c index f392bc281..f95b6a627 100644 --- a/gtk/src/settings.c +++ b/gtk/src/settings.c @@ -349,9 +349,13 @@ ghb_widget_value(GtkWidget *widget) } else if (type == GTK_TYPE_FILE_CHOOSER_BUTTON) { - const gchar *str; + gchar *str; str = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(widget)); + if (str == NULL) + str = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(widget)); value = ghb_string_value_new(str); + if (str != NULL) + g_free(str); } else { @@ -620,10 +624,27 @@ update_widget(GtkWidget *widget, const GValue *value) { gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(widget), str); } - else + else if (act == GTK_FILE_CHOOSER_ACTION_SAVE) { gtk_file_chooser_set_filename (GTK_FILE_CHOOSER(widget), str); } + else + { + if (!g_file_test(str, G_FILE_TEST_IS_DIR)) + { + gchar *dirname; + + dirname = g_path_get_dirname(str); + gtk_file_chooser_set_current_folder( + GTK_FILE_CHOOSER(widget), dirname); + g_free(dirname); + } + else + { + gtk_file_chooser_set_current_folder( + GTK_FILE_CHOOSER(widget), str); + } + } } else { diff --git a/gtk/src/subtitlehandler.c b/gtk/src/subtitlehandler.c index 34683b46e..938323ea4 100644 --- a/gtk/src/subtitlehandler.c +++ b/gtk/src/subtitlehandler.c @@ -23,6 +23,7 @@ #include "subtitlehandler.h" static void add_to_subtitle_list(signal_user_data_t *ud, GValue *settings); +static void add_to_srt_list(signal_user_data_t *ud, GValue *settings); static void free_subtitle_index_list(gpointer data) @@ -123,6 +124,53 @@ ghb_subtitle_exclusive_default(signal_user_data_t *ud, gint index) } void +ghb_add_srt(signal_user_data_t *ud, GValue *settings) +{ + // Add the current subtitle settings to the list. + GValue *subtitle_list; + gint count; + const gchar *lang; + + g_debug("ghb_add_srt ()"); + + // Add the long track description so the queue can access it + // when a different title is selected. + lang = ghb_settings_combo_option(settings, "SrtLanguage"); + ghb_settings_set_string(settings, "SubtitleTrackDescription", lang); + + ghb_settings_set_int(settings, "SubtitleSource", SRTSUB); + + subtitle_list = ghb_settings_get_value(ud->settings, "subtitle_list"); + if (subtitle_list == NULL) + { + subtitle_list = ghb_array_value_new(8); + ghb_settings_set_value(ud->settings, "subtitle_list", subtitle_list); + } + count = ghb_array_len(subtitle_list); + + // Don't allow more than 99 + // This is a had limit imposed by libhb/sync.c:GetFifoForId() + if (count >= 99) + { + ghb_value_free(settings); + return; + } + + ghb_array_append(subtitle_list, settings); + add_to_srt_list(ud, settings); + + if (count == 98) + { + GtkWidget *widget; + widget = GHB_WIDGET (ud->builder, "subtitle_add"); + gtk_widget_set_sensitive(widget, FALSE); + widget = GHB_WIDGET (ud->builder, "srt_add"); + gtk_widget_set_sensitive(widget, FALSE); + } + ghb_live_reset(ud); +} + +void ghb_add_subtitle(signal_user_data_t *ud, GValue *settings) { // Add the current subtitle settings to the list. @@ -174,6 +222,8 @@ ghb_add_subtitle(signal_user_data_t *ud, GValue *settings) GtkWidget *widget; widget = GHB_WIDGET (ud->builder, "subtitle_add"); gtk_widget_set_sensitive(widget, FALSE); + widget = GHB_WIDGET (ud->builder, "srt_add"); + gtk_widget_set_sensitive(widget, FALSE); } ghb_live_reset(ud); } @@ -398,7 +448,7 @@ subtitle_forced_toggled_cb( GtkTreePath *tp; gint *indices; GValue *subtitle_list, *settings; - gint source, track; + gint source; g_debug("forced toggled"); tp = gtk_tree_path_new_from_string (path); @@ -421,9 +471,8 @@ subtitle_forced_toggled_cb( return; settings = ghb_array_get_nth(subtitle_list, row); - track = ghb_settings_combo_int(settings, "SubtitleTrack"); - source = ghb_subtitle_track_source(ud, track); + source = ghb_settings_get_int(settings, "SubtitleSource"); if (source != VOBSUB) return; @@ -470,12 +519,12 @@ subtitle_burned_toggled_cb( return; settings = ghb_array_get_nth(subtitle_list, row); - track = ghb_settings_combo_int(settings, "SubtitleTrack"); - source = ghb_subtitle_track_source(ud, track); + source = ghb_settings_get_int(settings, "SubtitleSource"); if (source != VOBSUB) return; + track = ghb_settings_combo_int(settings, "SubtitleTrack"); if (!active && mustBurn(ud, track)) return; @@ -502,7 +551,7 @@ subtitle_default_toggled_cb( gint row; gint *indices; GValue *subtitle_list; - gint count, track; + gint count; GValue *settings; g_debug("default toggled"); @@ -526,7 +575,6 @@ subtitle_default_toggled_cb( return; settings = ghb_array_get_nth(subtitle_list, row); - track = ghb_settings_combo_int(settings, "SubtitleTrack"); ghb_settings_set_boolean(settings, "SubtitleDefaultTrack", active); @@ -536,6 +584,30 @@ subtitle_default_toggled_cb( ghb_live_reset(ud); } +static const char* +subtitle_source_name(gint source) +{ + const gchar * name; + + switch (source) + { + case VOBSUB: + name = "Bitmap"; + break; + case CC708SUB: + case CC608SUB: + name = "Text"; + break; + case SRTSUB: + name = "SRT"; + break; + default: + name = "Unknown"; + break; + } + return name; +} + static void subtitle_list_refresh_selected(signal_user_data_t *ud) { @@ -554,10 +626,10 @@ subtitle_list_refresh_selected(signal_user_data_t *ud) selection = gtk_tree_view_get_selection (treeview); if (gtk_tree_selection_get_selected(selection, &store, &iter)) { - const gchar *track, *source; + gchar *track, *source; gboolean forced, burned, def; gchar *s_track; - gint i_track; + gint offset = 0; // Get the row number treepath = gtk_tree_model_get_path (store, &iter); @@ -571,17 +643,10 @@ subtitle_list_refresh_selected(signal_user_data_t *ud) return; settings = ghb_array_get_nth(subtitle_list, row); - track = ghb_settings_combo_option(settings, "SubtitleTrack"); - forced = ghb_settings_get_boolean(settings, "SubtitleForced"); - burned = ghb_settings_get_boolean(settings, "SubtitleBurned"); def = ghb_settings_get_boolean(settings, "SubtitleDefaultTrack"); - s_track = ghb_settings_get_string(settings, "SubtitleTrack"); - i_track = ghb_settings_get_int(settings, "SubtitleTrack"); - source = ghb_subtitle_track_source_name(ud, i_track); - gint i_source; - i_source = ghb_subtitle_track_source(ud, i_track); + i_source = ghb_settings_get_int(settings, "SubtitleSource"); if (i_source != VOBSUB) { // Force and burn only apply to VOBSUBS @@ -591,6 +656,45 @@ subtitle_list_refresh_selected(signal_user_data_t *ud) ghb_settings_set_boolean(settings, "SubtitleBurned", burned); } + if (i_source == SRTSUB) + { + const gchar *lang; + gchar *code; + + lang = ghb_settings_combo_option(settings, "SrtLanguage"); + code = ghb_settings_get_string(settings, "SrtCodeset"); + track = g_strdup_printf("%s (%s)", lang, code); + g_free(code); + + s_track = ghb_settings_get_string(settings, "SrtFile"); + if (g_file_test(s_track, G_FILE_TEST_IS_REGULAR)) + { + gchar *basename; + + basename = g_path_get_basename(s_track); + source = g_strdup_printf("SRT (%s)", basename); + g_free(basename); + } + else + { + source = g_strdup_printf("SRT (none)"); + } + offset = ghb_settings_get_int(settings, "SrtOffset"); + + forced = FALSE; + burned = FALSE; + } + else + { + track = g_strdup( + ghb_settings_combo_option(settings, "SubtitleTrack")); + source = g_strdup(subtitle_source_name(i_source)); + s_track = ghb_settings_get_string(settings, "SubtitleTrack"); + + forced = ghb_settings_get_boolean(settings, "SubtitleForced"); + burned = ghb_settings_get_boolean(settings, "SubtitleBurned"); + } + gtk_list_store_set(GTK_LIST_STORE(store), &iter, // These are displayed in list 0, track, @@ -598,9 +702,13 @@ subtitle_list_refresh_selected(signal_user_data_t *ud) 2, burned, 3, def, 4, source, + 5, offset, // These are used to set combo box values when a list item is selected - 5, s_track, + 6, s_track, + 7, i_source, -1); + g_free(track); + g_free(source); g_free(s_track); if (burned) ghb_subtitle_exclusive_burn(ud, row); @@ -618,7 +726,7 @@ subtitle_track_changed_cb(GtkWidget *widget, signal_user_data_t *ud) settings = ghb_selected_subtitle_settings(ud); if (settings != NULL) { - const gchar *track; + const gchar *track, *lang; gint tt, source; ghb_widget_to_setting(settings, widget); @@ -628,11 +736,88 @@ subtitle_track_changed_cb(GtkWidget *widget, signal_user_data_t *ud) tt = ghb_settings_get_int(settings, "SubtitleTrack"); source = ghb_subtitle_track_source(ud, tt); ghb_settings_set_int(settings, "SubtitleSource", source); + lang = ghb_settings_combo_string(settings, "SubtitleTrack"); + ghb_settings_set_string(settings, "SubtitleLanguage", lang); ghb_live_reset(ud); } ghb_live_reset(ud); } +G_MODULE_EXPORT void +srt_changed_cb(GtkWidget *widget, signal_user_data_t *ud) +{ + GValue *settings; + + g_debug("srt_changed_cb ()"); + ghb_check_dependency(ud, widget); + ghb_widget_to_setting(ud->settings, widget); + settings = ghb_selected_subtitle_settings(ud); + if (settings != NULL) + { + ghb_widget_to_setting(settings, widget); + subtitle_list_refresh_selected(ud); + + ghb_live_reset(ud); + } +} + +G_MODULE_EXPORT void +srt_file_changed_cb(GtkWidget *widget, signal_user_data_t *ud) +{ + GValue *settings; + + g_debug("srt_changed_cb ()"); + ghb_check_dependency(ud, widget); + ghb_widget_to_setting(ud->settings, widget); + settings = ghb_selected_subtitle_settings(ud); + if (settings != NULL) + { + gchar *filename, *dirname; + + ghb_widget_to_setting(settings, widget); + subtitle_list_refresh_selected(ud); + + ghb_live_reset(ud); + + filename = ghb_settings_get_string(settings, "SrtFile"); + if (g_file_test(filename, G_FILE_TEST_IS_DIR)) + { + ghb_settings_set_string(ud->settings, "SrtDir", filename); + } + else + { + dirname = g_path_get_dirname(filename); + ghb_settings_set_string(ud->settings, "SrtDir", dirname); + g_free(dirname); + } + ghb_pref_save(ud->settings, "SrtDir"); + g_free(filename); + } +} + +G_MODULE_EXPORT void +srt_lang_changed_cb(GtkWidget *widget, signal_user_data_t *ud) +{ + GValue *settings; + + g_debug("srt_lang_changed_cb ()"); + ghb_check_dependency(ud, widget); + ghb_widget_to_setting(ud->settings, widget); + settings = ghb_selected_subtitle_settings(ud); + if (settings != NULL) + { + const gchar *lang; + + ghb_widget_to_setting(settings, widget); + subtitle_list_refresh_selected(ud); + + ghb_live_reset(ud); + + lang = ghb_settings_combo_option(settings, "SrtLanguage"); + ghb_settings_set_string(settings, "SubtitleTrackDescription", lang); + } +} + void ghb_clear_subtitle_list(signal_user_data_t *ud) { @@ -666,7 +851,7 @@ add_to_subtitle_list( const gchar *track, *source; gboolean forced, burned, def; gchar *s_track; - gint i_track; + gint i_source; g_debug("add_to_subtitle_list ()"); treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "subtitle_list")); @@ -679,8 +864,8 @@ add_to_subtitle_list( def = ghb_settings_get_boolean(settings, "SubtitleDefaultTrack"); s_track = ghb_settings_get_string(settings, "SubtitleTrack"); - i_track = ghb_settings_get_int(settings, "SubtitleTrack"); - source = ghb_subtitle_track_source_name(ud, i_track); + i_source = ghb_settings_get_int(settings, "SubtitleSource"); + source = subtitle_source_name(i_source); gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, @@ -691,12 +876,81 @@ add_to_subtitle_list( 3, def, 4, source, // These are used to set combo box values when a list item is selected - 5, s_track, + 6, s_track, + 7, i_source, + 8, TRUE, + 9, TRUE, + 10, FALSE, -1); gtk_tree_selection_select_iter(selection, &iter); g_free(s_track); } +static void +add_to_srt_list( + signal_user_data_t *ud, + GValue *settings) +{ + GtkTreeView *treeview; + GtkTreeIter iter; + GtkListStore *store; + GtkTreeSelection *selection; + const gchar *lang; + gboolean forced, burned, def; + gchar *filename, *code, *track, *source; + gint i_source, offset; + + g_debug("add_to_srt_list ()"); + treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "subtitle_list")); + selection = gtk_tree_view_get_selection (treeview); + store = GTK_LIST_STORE(gtk_tree_view_get_model(treeview)); + + lang = ghb_settings_combo_option(settings, "SrtLanguage"); + code = ghb_settings_get_string(settings, "SrtCodeset"); + track = g_strdup_printf("%s (%s)", lang, code); + forced = FALSE; + burned = FALSE; + def = ghb_settings_get_boolean(settings, "SubtitleDefaultTrack"); + + filename = ghb_settings_get_string(settings, "SrtFile"); + if (g_file_test(filename, G_FILE_TEST_IS_REGULAR)) + { + gchar *basename; + + basename = g_path_get_basename(filename); + source = g_strdup_printf("SRT (%s)", basename); + g_free(basename); + } + else + { + source = g_strdup_printf("SRT (none)"); + } + i_source = SRTSUB; + offset = ghb_settings_get_int(settings, "SrtOffset"); + + gtk_list_store_append(store, &iter); + gtk_list_store_set(store, &iter, + // These are displayed in list + 0, track, + 1, forced, + 2, burned, + 3, def, + 4, source, + 5, offset, + // These are used to set combo box values when a list item is selected + 6, filename, + 7, i_source, + 8, FALSE, + 9, FALSE, + 10, TRUE, + -1); + gtk_tree_selection_select_iter(selection, &iter); + g_free(code); + g_free(track); + g_free(filename); + g_free(source); +} + G_MODULE_EXPORT void subtitle_list_selection_changed_cb(GtkTreeSelection *selection, signal_user_data_t *ud) { @@ -707,14 +961,152 @@ subtitle_list_selection_changed_cb(GtkTreeSelection *selection, signal_user_data g_debug("subtitle_list_selection_changed_cb ()"); if (gtk_tree_selection_get_selected(selection, &store, &iter)) { - const gchar *track; + gint source; + GtkTreePath *treepath; + gint *indices, row; + GValue *subtitle_list, *settings; + + treepath = gtk_tree_model_get_path (store, &iter); + indices = gtk_tree_path_get_indices (treepath); + row = indices[0]; + gtk_tree_path_free(treepath); - gtk_tree_model_get(store, &iter, 5, &track, -1); - ghb_ui_update(ud, "SubtitleTrack", ghb_string_value(track)); + subtitle_list = ghb_settings_get_value(ud->settings, "subtitle_list"); + if (row >= ghb_array_len(subtitle_list)) + return; + settings = ghb_array_get_nth(subtitle_list, row); + + source = ghb_settings_get_int(settings, "SubtitleSource"); + if (source == SRTSUB) + { + gchar *str; + gint offset; + + str = ghb_settings_get_string(settings, "SrtLanguage"); + ghb_ui_update(ud, "SrtLanguage", ghb_string_value(str)); + g_free(str); + + str = ghb_settings_get_string(settings, "SrtCodeset"); + ghb_ui_update(ud, "SrtCodeset", ghb_string_value(str)); + g_free(str); + + str = ghb_settings_get_string(settings, "SrtFile"); + ghb_ui_update(ud, "SrtFile", ghb_string_value(str)); + g_free(str); + + offset = ghb_settings_get_int(settings, "SrtOffset"); + ghb_ui_update(ud, "SrtOffset", ghb_int_value(offset)); + + widget = GHB_WIDGET(ud->builder, "subtitle_track_label"); + gtk_widget_hide(widget); + widget = GHB_WIDGET(ud->builder, "SubtitleTrack"); + gtk_widget_hide(widget); + widget = GHB_WIDGET(ud->builder, "srt_lang_label"); + gtk_widget_show(widget); + widget = GHB_WIDGET(ud->builder, "srt_code_label"); + gtk_widget_show(widget); + widget = GHB_WIDGET(ud->builder, "srt_file_label"); + gtk_widget_show(widget); + widget = GHB_WIDGET(ud->builder, "srt_offset_label"); + gtk_widget_show(widget); + widget = GHB_WIDGET(ud->builder, "SrtLanguage"); + gtk_widget_show(widget); + widget = GHB_WIDGET(ud->builder, "SrtCodeset"); + gtk_widget_show(widget); + widget = GHB_WIDGET(ud->builder, "SrtFile"); + gtk_widget_show(widget); + widget = GHB_WIDGET(ud->builder, "SrtOffset"); + gtk_widget_show(widget); + } + else + { + gchar *track; + + track = ghb_settings_get_string(settings, "SubtitleTrack"); + ghb_ui_update(ud, "SubtitleTrack", ghb_string_value(track)); + g_free(track); + + widget = GHB_WIDGET(ud->builder, "srt_lang_label"); + gtk_widget_hide(widget); + widget = GHB_WIDGET(ud->builder, "srt_code_label"); + gtk_widget_hide(widget); + widget = GHB_WIDGET(ud->builder, "srt_file_label"); + gtk_widget_hide(widget); + widget = GHB_WIDGET(ud->builder, "srt_offset_label"); + gtk_widget_hide(widget); + widget = GHB_WIDGET(ud->builder, "SrtLanguage"); + gtk_widget_hide(widget); + widget = GHB_WIDGET(ud->builder, "SrtCodeset"); + gtk_widget_hide(widget); + widget = GHB_WIDGET(ud->builder, "SrtFile"); + gtk_widget_hide(widget); + widget = GHB_WIDGET(ud->builder, "SrtOffset"); + gtk_widget_hide(widget); + widget = GHB_WIDGET(ud->builder, "subtitle_track_label"); + gtk_widget_show(widget); + widget = GHB_WIDGET(ud->builder, "SubtitleTrack"); + gtk_widget_show(widget); + } widget = GHB_WIDGET (ud->builder, "subtitle_remove"); gtk_widget_set_sensitive(widget, TRUE); } + else + { + widget = GHB_WIDGET(ud->builder, "srt_lang_label"); + gtk_widget_hide(widget); + widget = GHB_WIDGET(ud->builder, "srt_code_label"); + gtk_widget_hide(widget); + widget = GHB_WIDGET(ud->builder, "srt_file_label"); + gtk_widget_hide(widget); + widget = GHB_WIDGET(ud->builder, "srt_offset_label"); + gtk_widget_hide(widget); + widget = GHB_WIDGET(ud->builder, "SrtLanguage"); + gtk_widget_hide(widget); + widget = GHB_WIDGET(ud->builder, "SrtCodeset"); + gtk_widget_hide(widget); + widget = GHB_WIDGET(ud->builder, "SrtFile"); + gtk_widget_hide(widget); + widget = GHB_WIDGET(ud->builder, "SrtOffset"); + gtk_widget_hide(widget); + widget = GHB_WIDGET(ud->builder, "subtitle_track_label"); + gtk_widget_show(widget); + widget = GHB_WIDGET(ud->builder, "SubtitleTrack"); + gtk_widget_show(widget); + } +} + +G_MODULE_EXPORT void +srt_add_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) +{ + // Add the current subtitle settings to the list. + GValue *settings; + gboolean burned = FALSE; + gint track; + gchar *dir, *filename; + + g_debug("subtitle_add_clicked_cb ()"); + + track = ghb_settings_get_int(ud->settings, "SubtitleTrack"); + if (mustBurn(ud, track)) + { + burned = TRUE; + } + settings = ghb_dict_value_new(); + ghb_settings_set_string(settings, "SrtLanguage", "und"); + ghb_settings_set_string(settings, "SrtCodeset", "UTF-8"); + + dir = ghb_settings_get_string(ud->settings, "SrtDir"); + filename = g_strdup_printf("%s/none", dir); + ghb_settings_set_string(settings, "SrtFile", filename); + g_free(dir); + g_free(filename); + + ghb_settings_set_int(settings, "SrtOffset", 0); + ghb_settings_take_value(settings, "SubtitleDefaultTrack", + ghb_boolean_value_new(FALSE)); + + ghb_add_srt(ud, settings); } G_MODULE_EXPORT void @@ -785,6 +1177,8 @@ subtitle_remove_clicked_cb(GtkWidget *widget, signal_user_data_t *ud) if (row < 0) return; widget = GHB_WIDGET (ud->builder, "subtitle_add"); gtk_widget_set_sensitive(widget, TRUE); + widget = GHB_WIDGET (ud->builder, "srt_add"); + gtk_widget_set_sensitive(widget, TRUE); subtitle_list = ghb_settings_get_value(ud->settings, "subtitle_list"); if (row >= ghb_array_len(subtitle_list)) return; |