diff options
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/src/Makefile.am | 6 | ||||
-rw-r--r-- | gtk/src/audiohandler.c | 100 | ||||
-rw-r--r-- | gtk/src/audiohandler.h | 4 | ||||
-rw-r--r-- | gtk/src/callbacks.c | 150 | ||||
-rw-r--r-- | gtk/src/create_resources.py | 2 | ||||
-rw-r--r-- | gtk/src/hb-backend.c | 439 | ||||
-rw-r--r-- | gtk/src/hb-backend.h | 31 | ||||
-rw-r--r-- | gtk/src/makedeps.py | 2 | ||||
-rw-r--r-- | gtk/src/presets.c | 2 | ||||
-rw-r--r-- | gtk/src/preview.c | 19 | ||||
-rw-r--r-- | gtk/src/queuehandler.c | 33 | ||||
-rw-r--r-- | gtk/src/subtitlehandler.c | 39 | ||||
-rw-r--r-- | gtk/src/subtitlehandler.h | 3 |
13 files changed, 469 insertions, 361 deletions
diff --git a/gtk/src/Makefile.am b/gtk/src/Makefile.am index 10ce7377a..c9bf53f9e 100644 --- a/gtk/src/Makefile.am +++ b/gtk/src/Makefile.am @@ -55,7 +55,7 @@ AM_CPPFLAGS = \ AM_CFLAGS = -Wall -g -bin_PROGRAMS = ghb +bin_PROGRAMS = ghb # Dummy file, not built. Forces g++ linking nodist_EXTRA_ghb_SOURCES = dummy.cpp @@ -129,13 +129,13 @@ resources.plist: create_resources resources.list $(icons_dep) internal_defaults. CREATE_RES.c = \ create_resources.c \ plist.c \ - values.c + values.c CREATE_RES.c.o = $(patsubst %.c,%-native.o,$(CREATE_RES.c)) create_resources: $(CREATE_RES.c.o) $(CC_FOR_BUILD) -o $@ $^ $(GHB_TOOLS_LIBS) - + $(CREATE_RES.c.o): %-native.o: %.c $(CC_FOR_BUILD) $(GHB_TOOLS_CFLAGS) -c -o $@ $< diff --git a/gtk/src/audiohandler.c b/gtk/src/audiohandler.c index ec889a013..49fb770d3 100644 --- a/gtk/src/audiohandler.c +++ b/gtk/src/audiohandler.c @@ -56,13 +56,18 @@ static void audio_deps(signal_user_data_t *ud, GValue *asettings, GtkWidget *wid gint track = -1, encoder = 0; hb_audio_config_t *aconfig = NULL; - gint titleindex = ghb_settings_combo_int(ud->settings, "title"); + int title_id; + gint titleindex; + const hb_title_t *title; + + title_id = ghb_settings_get_int(ud->settings, "title"); + title = ghb_lookup_title(title_id, &titleindex); if (asettings != NULL) { track = ghb_settings_get_int(asettings, "AudioTrack"); encoder = ghb_settings_combo_int(asettings, "AudioEncoder"); - aconfig = ghb_get_scan_audio_info(titleindex, track); + aconfig = ghb_get_audio_info(title, track); } gboolean is_passthru = (encoder & HB_ACODEC_PASS_FLAG); @@ -196,7 +201,9 @@ int ghb_select_fallback(GValue *settings, int acodec) void audio_sanitize_settings(GValue *settings, GValue *asettings) { + int title_id; gint titleindex, track, acodec, select_acodec, mix; + const hb_title_t *title; hb_audio_config_t *aconfig; gint mux; gint bitrate; @@ -204,14 +211,15 @@ audio_sanitize_settings(GValue *settings, GValue *asettings) g_debug("ghb_santiize_audio ()"); mux = ghb_settings_combo_int(settings, "FileFormat"); - titleindex = ghb_settings_get_int(settings, "title_no"); + title_id = ghb_settings_get_int(settings, "title"); + title = ghb_lookup_title(title_id, &titleindex); track = ghb_settings_get_int(asettings, "AudioTrack"); acodec = ghb_settings_combo_int(asettings, "AudioEncoder"); mix = ghb_settings_combo_int(asettings, "AudioMixdown"); bitrate = ghb_settings_combo_int(asettings, "AudioBitrate"); sr = ghb_settings_combo_int(asettings, "AudioSamplerate"); - aconfig = ghb_get_scan_audio_info(titleindex, track); + aconfig = ghb_get_audio_info(title, track); if (sr == 0) { sr = aconfig ? aconfig->in.samplerate : 48000; @@ -263,7 +271,9 @@ audio_sanitize_settings(GValue *settings, GValue *asettings) void ghb_adjust_audio_rate_combos(signal_user_data_t *ud) { - gint titleindex, track, acodec, select_acodec, mix; + int title_id, titleindex; + const hb_title_t *title; + gint track, acodec, select_acodec, mix; hb_audio_config_t *aconfig; GtkWidget *widget; GValue *gval; @@ -273,7 +283,8 @@ ghb_adjust_audio_rate_combos(signal_user_data_t *ud) g_debug("ghb_adjust_audio_rate_combos ()"); mux = ghb_settings_combo_int(ud->settings, "FileFormat"); - titleindex = ghb_settings_combo_int(ud->settings, "title"); + title_id = ghb_settings_get_int(ud->settings, "title"); + title = ghb_lookup_title(title_id, &titleindex); widget = GHB_WIDGET(ud->builder, "AudioTrack"); gval = ghb_widget_value(widget); @@ -300,7 +311,7 @@ ghb_adjust_audio_rate_combos(signal_user_data_t *ud) sr = ghb_lookup_combo_int("AudioSamplerate", gval); ghb_value_free(gval); - aconfig = ghb_get_scan_audio_info(titleindex, track); + aconfig = ghb_get_audio_info(title, track); if (sr == 0) { sr = aconfig ? aconfig->in.samplerate : 48000; @@ -397,7 +408,7 @@ free_audio_hash_key_value(gpointer data) } const gchar* -ghb_get_user_audio_lang(GValue *settings, hb_title_t *title, gint track) +ghb_get_user_audio_lang(GValue *settings, const hb_title_t *title, gint track) { GValue *audio_list, *asettings; const gchar *lang; @@ -432,7 +443,7 @@ get_track_used(gint settings, GHashTable *track_indices, gint count) static GValue* audio_add_track( GValue *settings, - hb_title_t *title, + const hb_title_t *title, int track, int encoder, gboolean enable_quality, @@ -446,11 +457,7 @@ audio_add_track( GValue *asettings; hb_audio_config_t *aconfig = NULL; - if (title != NULL) - { - aconfig = hb_list_audio_config_item(title->list_audio, track); - } - + aconfig = ghb_get_audio_info(title, track); asettings = ghb_dict_value_new(); ghb_settings_set_int(asettings, "AudioTrack", track); @@ -487,7 +494,7 @@ audio_add_track( static GValue* audio_select_and_add_track( - hb_title_t *title, + const hb_title_t *title, GValue *settings, GValue *pref_audio, const char *lang, @@ -538,7 +545,7 @@ audio_select_and_add_track( } static void set_pref_audio_with_lang( - hb_title_t *title, + const hb_title_t *title, GValue *settings, const char *lang, int behavior, @@ -626,10 +633,11 @@ void ghb_audio_title_change(signal_user_data_t *ud, gboolean title_valid) } void -ghb_set_pref_audio_settings(gint titleindex, GValue *settings) +ghb_set_pref_audio_settings(GValue *settings) { GHashTable *track_used; - hb_title_t *title; + int title_id, titleindex; + const hb_title_t *title; const GValue *lang_list; gint behavior; @@ -641,7 +649,8 @@ ghb_set_pref_audio_settings(gint titleindex, GValue *settings) // Clear the audio list ghb_clear_audio_list_settings(settings); - title = ghb_get_title_info(titleindex); + title_id = ghb_settings_get_int(settings, "title"); + title = ghb_lookup_title(title_id, &titleindex); if (behavior == 0 || title == NULL) { // None or no source title @@ -736,10 +745,13 @@ audio_refresh_list_row_ui( gdouble drc, gain; hb_audio_config_t *aconfig; int titleindex, track, sr, codec; + int title_id; + const hb_title_t *title; - titleindex = ghb_settings_combo_int(ud->settings, "title"); + title_id = ghb_settings_get_int(ud->settings, "title"); + title = ghb_lookup_title(title_id, &titleindex); track = ghb_settings_get_int(settings, "AudioTrack"); - aconfig = ghb_get_scan_audio_info(titleindex, track); + aconfig = ghb_get_audio_info(title, track); if (aconfig == NULL) { return; @@ -954,10 +966,15 @@ audio_codec_changed_cb(GtkWidget *widget, signal_user_data_t *ud) { // Transition from passthru to not, put some audio settings back to // pref settings + int title_id; + const hb_title_t *title; gint titleindex; gint track; gint br, sr, mix_code; + title_id = ghb_settings_get_int(ud->settings, "title"); + title = ghb_lookup_title(title_id, &titleindex); + if (asettings != NULL) { br = ghb_settings_get_int(asettings, "AudioBitrate"); @@ -971,7 +988,6 @@ audio_codec_changed_cb(GtkWidget *widget, signal_user_data_t *ud) mix_code = 0; } - titleindex = ghb_settings_combo_int(ud->settings, "title"); track = ghb_settings_get_int(ud->settings, "AudioTrack"); if (sr) { @@ -980,7 +996,7 @@ audio_codec_changed_cb(GtkWidget *widget, signal_user_data_t *ud) ghb_ui_update(ud, "AudioSamplerate", ghb_int64_value(sr)); hb_audio_config_t *aconfig; - aconfig = ghb_get_scan_audio_info(titleindex, track); + aconfig = ghb_get_audio_info(title, track); if (sr == 0) { sr = aconfig ? aconfig->in.samplerate : 48000; @@ -1332,8 +1348,13 @@ static void audio_add_to_settings(GValue *settings, GValue *asettings) { GValue *audio_list; - const gchar * track; + int title_id; + const hb_title_t *title; + gint titleindex; + hb_audio_config_t *aconfig; + title_id = ghb_settings_get_int(settings, "title"); + title = ghb_lookup_title(title_id, &titleindex); audio_list = ghb_settings_get_value(settings, "audio_list"); if (audio_list == NULL) { @@ -1341,10 +1362,13 @@ audio_add_to_settings(GValue *settings, GValue *asettings) ghb_settings_set_value(settings, "audio_list", audio_list); } - int title_no = ghb_settings_get_int(settings, "title_no"); - int track_no = ghb_settings_get_int(asettings, "AudioTrack"); - track = ghb_audio_track_description(track_no, title_no); - ghb_settings_set_string(asettings, "AudioTrackDescription", track); + int track = ghb_settings_get_int(asettings, "AudioTrack"); + aconfig = ghb_get_audio_info(title, track); + if (aconfig != NULL) + { + ghb_settings_set_string(asettings, "AudioTrackDescription", + aconfig->lang.description); + } GValue *aname; aname = ghb_dict_lookup(asettings, "AudioTrackName"); @@ -1360,15 +1384,16 @@ audio_add_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) { // Add the current audio settings to the list. GValue *asettings, *backup; + int title_id, titleindex; + const hb_title_t *title; + + title_id = ghb_settings_get_int(ud->settings, "title"); + title = ghb_lookup_title(title_id, &titleindex); // Back up settings in case we need to revert. backup = ghb_value_dup( ghb_settings_get_value(ud->settings, "audio_list")); - - int titleindex = ghb_settings_combo_int(ud->settings, "title"); - hb_title_t *title = ghb_get_title_info(titleindex); GValue *pref_audio = ghb_settings_get_value(ud->settings, "AudioList"); - asettings = audio_select_and_add_track(title, ud->settings, pref_audio, "und", 0, 0); ghb_add_audio_to_ui(ud, asettings); @@ -1400,13 +1425,15 @@ audio_add_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) G_MODULE_EXPORT void audio_add_all_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) { - // Add the current audio settings to the list. + int title_id, titleindex; + const hb_title_t *title; + // Add the current audio settings to the list. ghb_clear_audio_list_settings(ud->settings); ghb_clear_audio_list_ui(ud->builder); - int titleindex = ghb_settings_combo_int(ud->settings, "title"); - hb_title_t *title = ghb_get_title_info(titleindex); + title_id = ghb_settings_get_int(ud->settings, "title"); + title = ghb_lookup_title(title_id, &titleindex); GValue *pref_audio = ghb_settings_get_value(ud->settings, "AudioList"); int pref_count = ghb_array_len(pref_audio); @@ -1541,8 +1568,7 @@ audio_remove_clicked_cb(GtkWidget *widget, gchar *path, signal_user_data_t *ud) G_MODULE_EXPORT void audio_reset_clicked_cb(GtkWidget *widget, signal_user_data_t *ud) { - int titleindex = ghb_settings_combo_int(ud->settings, "title"); - ghb_set_pref_audio_settings(titleindex, ud->settings); + ghb_set_pref_audio_settings(ud->settings); audio_refresh_list_ui(ud); } diff --git a/gtk/src/audiohandler.h b/gtk/src/audiohandler.h index 8af2e2497..51f1840a6 100644 --- a/gtk/src/audiohandler.h +++ b/gtk/src/audiohandler.h @@ -28,8 +28,8 @@ #include "settings.h" void ghb_adjust_audio_rate_combos(signal_user_data_t *ud); -void ghb_set_pref_audio_settings(gint titleindex, GValue *settings); -const gchar* ghb_get_user_audio_lang(GValue *settings, hb_title_t *title, gint track); +void ghb_set_pref_audio_settings(GValue *settings); +const gchar* ghb_get_user_audio_lang(GValue *settings, const hb_title_t *title, gint track); void ghb_audio_list_refresh_selected(signal_user_data_t *ud); gint ghb_select_audio_codec(gint mux, hb_audio_config_t *aconfig, gint acodec, gint fallback_acodec, gint copy_mask); int ghb_select_fallback( GValue *settings, int acodec ); diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c index e288db2d8..061e10bbc 100644 --- a/gtk/src/callbacks.c +++ b/gtk/src/callbacks.c @@ -870,19 +870,21 @@ static void break_duration(gint64 duration, gint *hh, gint *mm, gint *ss) static void update_title_duration(signal_user_data_t *ud) { - gint ti; gint hh, mm, ss, start, end; gchar *text; GtkWidget *widget; + int title_id, titleindex; + const hb_title_t *title; - ti = ghb_settings_combo_int(ud->settings, "title"); + title_id = ghb_settings_get_int(ud->settings, "title"); + title = ghb_lookup_title(title_id, &titleindex); widget = GHB_WIDGET (ud->builder, "title_duration"); if (ghb_settings_combo_int(ud->settings, "PtoPType") == 0) { start = ghb_settings_get_int(ud->settings, "start_point"); end = ghb_settings_get_int(ud->settings, "end_point"); - ghb_part_duration(ti, start, end, &hh, &mm, &ss); + ghb_part_duration(title, start, end, &hh, &mm, &ss); } else if (ghb_settings_combo_int(ud->settings, "PtoPType") == 1) { @@ -895,7 +897,6 @@ update_title_duration(signal_user_data_t *ud) } else if (ghb_settings_combo_int(ud->settings, "PtoPType") == 2) { - hb_title_t * title = ghb_get_title_info (ti); if (title != NULL) { gint64 frames; @@ -985,13 +986,16 @@ scale_configure( void ghb_set_widget_ranges(signal_user_data_t *ud, GValue *settings) { - int titleindex = ghb_settings_combo_int(settings, "title"); - hb_title_t * title = ghb_get_title_info(titleindex); + int title_id, titleindex; + const hb_title_t * title; double val; + title_id = ghb_settings_get_int(settings, "title"); + title = ghb_lookup_title(title_id, &titleindex); + // Reconfigure the UI combo boxes - ghb_update_ui_combo_box(ud, "AudioTrack", titleindex, FALSE); - ghb_update_ui_combo_box(ud, "SubtitleTrack", titleindex, FALSE); + ghb_update_ui_combo_box(ud, "AudioTrack", title, FALSE); + ghb_update_ui_combo_box(ud, "SubtitleTrack", title, FALSE); if (title != NULL) { @@ -1155,7 +1159,7 @@ static void start_scan( signal_user_data_t *ud, const gchar *path, - gint titlenum, + gint title_id, gint preview_count) { GtkWidget *widget; @@ -1174,7 +1178,7 @@ start_scan( gtk_widget_set_sensitive(widget, FALSE); widget = GHB_WIDGET(ud->builder, "source_title_open"); gtk_widget_set_sensitive(widget, FALSE); - ghb_backend_scan(path, titlenum, preview_count, + ghb_backend_scan(path, title_id, preview_count, 90000L * ghb_settings_get_int64(ud->prefs, "MinTitleDuration")); } @@ -1195,24 +1199,31 @@ void ghb_do_scan( signal_user_data_t *ud, const gchar *filename, - gint titlenum, + gint title_id, gboolean force) { + int titleindex; + const hb_title_t *title; + + (void)title; // Silence "unused variable" warning + g_debug("ghb_do_scan()"); if (!force && last_scan_file != NULL && strcmp(last_scan_file, filename) == 0) { if (ghb_queue_edit_settings != NULL) { - int titleindex = ghb_settings_get_int(ghb_queue_edit_settings, "title_no"); - ghb_array_replace(ud->settings_array, titleindex, ghb_queue_edit_settings); + title_id = ghb_settings_get_int(ghb_queue_edit_settings, "title"); + title = ghb_lookup_title(title_id, &titleindex); + ghb_array_replace(ud->settings_array, titleindex, + ghb_queue_edit_settings); ud->settings = ghb_queue_edit_settings; ghb_load_settings(ud); ghb_queue_edit_settings = NULL; } else { - int titleindex = ghb_settings_get_int(ud->settings, "title_no"); + title = ghb_lookup_title(title_id, &titleindex); load_all_titles(ud, titleindex); } return; @@ -1234,7 +1245,7 @@ ghb_do_scan( prune_logs(ud); preview_count = ghb_settings_get_int(ud->prefs, "preview_count"); - start_scan(ud, path, titlenum, preview_count); + start_scan(ud, path, title_id, preview_count); g_free(path); } else @@ -1286,13 +1297,13 @@ do_source_dialog(GtkButton *button, gboolean single, signal_user_data_t *ud) filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); if (filename != NULL) { - gint titlenum; + gint title_id; if (single) - titlenum = ghb_settings_get_int(ud->settings, "single_title"); + title_id = ghb_settings_get_int(ud->settings, "single_title"); else - titlenum = 0; - ghb_do_scan(ud, filename, titlenum, TRUE); + title_id = 0; + ghb_do_scan(ud, filename, title_id, TRUE); if (strcmp(sourcename, filename) != 0) { ghb_settings_set_string(ud->prefs, "default_source", filename); @@ -1632,11 +1643,11 @@ update_crop_info(signal_user_data_t *ud) GtkWidget *widget; gchar *text; gint width, height, crop[4] = {0,}; - gint titleindex; - hb_title_t *title; + gint title_id, titleindex; + const hb_title_t *title; - titleindex = ghb_settings_combo_int(ud->settings, "title"); - title = ghb_get_title_info(titleindex); + title_id = ghb_settings_get_int(ud->settings, "title"); + title = ghb_lookup_title(title_id, &titleindex); if (title != NULL) { crop[0] = ghb_settings_get_int(ud->settings, "PictureTopCrop"); @@ -1678,8 +1689,11 @@ ghb_update_title_info(signal_user_data_t *ud) GtkWidget *widget; gchar *text; - int titleindex = ghb_settings_get_int(ud->settings, "title_no"); - hb_title_t * title = ghb_get_title_info(titleindex); + int title_id, titleindex; + const hb_title_t * title; + + title_id = ghb_settings_get_int(ud->settings, "title"); + title = ghb_lookup_title(title_id, &titleindex); if (title == NULL) return; @@ -1721,12 +1735,14 @@ ghb_update_title_info(signal_user_data_t *ud) } void -set_title_settings(signal_user_data_t *ud, GValue *settings, gint titleindex) +set_title_settings(signal_user_data_t *ud, GValue *settings) { - ghb_settings_set_int(settings, "title", titleindex); - ghb_settings_set_int(settings, "title_no", titleindex); + int title_id, titleindex; + const hb_title_t * title; + + title_id = ghb_settings_get_int(settings, "title"); + title = ghb_lookup_title(title_id, &titleindex); - hb_title_t * title = ghb_get_title_info(titleindex); if (title != NULL) { gint num_chapters = hb_list_count(title->list_chapter); @@ -1804,7 +1820,7 @@ set_title_settings(signal_user_data_t *ud, GValue *settings, gint titleindex) ghb_set_pref_subtitle_settings(ud, title, settings); } update_chapter_list_settings(settings); - ghb_set_pref_audio_settings(titleindex, settings); + ghb_set_pref_audio_settings(settings); set_destination_settings(ud, settings); ghb_settings_set_value(settings, "dest_dir", @@ -1825,8 +1841,7 @@ set_title_settings(signal_user_data_t *ud, GValue *settings, gint titleindex) void ghb_set_current_title_settings(signal_user_data_t *ud) { - int titleindex = ghb_settings_get_int(ud->settings, "title_no"); - set_title_settings(ud, ud->settings, titleindex); + set_title_settings(ud, ud->settings); } static void @@ -1835,6 +1850,7 @@ load_all_titles(signal_user_data_t *ud, int titleindex) gint ii, count; GValue *preset, *preset_path; GValue *settings_array; + const hb_title_t *title; hb_list_t *list = ghb_get_title_list(); count = hb_list_count(list); @@ -1848,12 +1864,17 @@ load_all_titles(signal_user_data_t *ud, int titleindex) preset_path = ghb_get_current_preset_path(ud); for (ii = 0; ii < count; ii++) { + int index; GValue *settings = ghb_settings_new(); + title = hb_list_item(list, ii); + index = (title != NULL) ? title->index : -1; + ghb_settings_init(settings, "Initialization"); ghb_preset_to_settings(settings, preset); ghb_settings_set_value(settings, "preset", preset_path); - set_title_settings(ud, settings, ii); + ghb_settings_set_int(settings, "title", index); + set_title_settings(ud, settings); ghb_array_append(settings_array, settings); } ghb_value_free(preset_path); @@ -1871,21 +1892,18 @@ static gboolean update_preview = FALSE; G_MODULE_EXPORT void title_changed_cb(GtkWidget *widget, signal_user_data_t *ud) { - gint titleindex, count; - GValue *wval; + gint title_id, titleindex, count; + const hb_title_t * title; g_debug("title_changed_cb ()"); - - wval = ghb_widget_value(widget); - titleindex = ghb_lookup_combo_int("title", wval); - ghb_value_free(wval); + title_id = ghb_widget_int(widget); + title = ghb_lookup_title(title_id, &titleindex); count = ghb_array_len(ud->settings_array); int idx = (titleindex >= 0 && titleindex < count) ? titleindex : 0; ud->settings = ghb_array_get_nth(ud->settings_array, idx); ghb_load_settings(ud); - hb_title_t * title = ghb_get_title_info(titleindex); ghb_audio_title_change(ud, title != NULL); ghb_subtitle_title_change(ud, title != NULL); ghb_grey_combo_options(ud); @@ -1900,15 +1918,15 @@ title_changed_cb(GtkWidget *widget, signal_user_data_t *ud) G_MODULE_EXPORT void ptop_widget_changed_cb(GtkWidget *widget, signal_user_data_t *ud) { - gint ti; - hb_title_t * title; + gint title_id, titleindex; + const hb_title_t * title; ghb_widget_to_setting(ud->settings, widget); ghb_check_dependency(ud, widget, NULL); ghb_live_reset(ud); - ti = ghb_settings_combo_int(ud->settings, "title"); - title = ghb_get_title_info(ti); + title_id = ghb_settings_get_int(ud->settings, "title"); + title = ghb_lookup_title(title_id, &titleindex); if (title == NULL) return; @@ -2571,7 +2589,7 @@ static void queue_scan(signal_user_data_t *ud, GValue *js) { gchar *path; - gint titlenum; + gint title_id; time_t _now; struct tm *now; gchar *log_path, *pos, *destname, *basename, *dest_dir; @@ -2617,8 +2635,8 @@ queue_scan(signal_user_data_t *ud, GValue *js) g_free(log_path); path = ghb_settings_get_string( js, "source"); - titlenum = ghb_settings_get_int(js, "titlenum"); - ghb_backend_queue_scan(path, titlenum); + title_id = ghb_settings_get_int(js, "title"); + ghb_backend_queue_scan(path, title_id); g_free(path); } @@ -2886,7 +2904,6 @@ ghb_backend_events(signal_user_data_t *ud) gchar *status_str; GtkProgressBar *progress; GtkLabel *work_status; - gint titleindex; GValue *js; gint index; GtkTreeView *treeview; @@ -2976,21 +2993,23 @@ ghb_backend_events(signal_user_data_t *ud) gtk_progress_bar_set_fraction (scan_prog, 1.0); gtk_widget_hide(GTK_WIDGET(scan_prog)); - ghb_update_ui_combo_box(ud, "title", 0, FALSE); - - titleindex = ghb_longest_title(); + int title_id, titleindex; + const hb_title_t *title; + title_id = ghb_longest_title(); + title = ghb_lookup_title(title_id, &titleindex); + ghb_update_ui_combo_box(ud, "title", NULL, FALSE); load_all_titles(ud, titleindex); label = GTK_LABEL(GHB_WIDGET (ud->builder, "volume_label")); + // Are there really any titles. - hb_title_t * title = ghb_get_title_info(titleindex); if (title == NULL) { gtk_label_set_text(label, _("No Title Found")); } ghb_clear_scan_state(GHB_STATE_SCANDONE); - ghb_ui_update(ud, "title", ghb_int64_value(titleindex)); + ghb_ui_update(ud, "title", ghb_int64_value(title->index)); if (ghb_queue_edit_settings != NULL) { @@ -2999,7 +3018,8 @@ ghb_backend_events(signal_user_data_t *ud) ghb_settings_get_value(ghb_queue_edit_settings, "title")); // The above should cause the current title index to update - int titleindex = ghb_settings_get_int(ud->settings, "title_no"); + title_id = ghb_settings_get_int(ud->settings, "title"); + title = ghb_lookup_title(title_id, &titleindex); ghb_array_replace(ud->settings_array, titleindex, ghb_queue_edit_settings); ud->settings = ghb_queue_edit_settings; @@ -3613,7 +3633,7 @@ chapter_refresh_list_row_ui( GtkTreeModel *tm, GtkTreeIter *ti, GValue *chapter_list, - int titleindex, + const hb_title_t *title, int index) { gchar *chapter, *s_duration, *s_start; @@ -3623,10 +3643,10 @@ chapter_refresh_list_row_ui( // Update row with settings data g_debug("Updating chapter row ui"); chapter = ghb_value_string(ghb_array_get_nth(chapter_list, index)); - duration = ghb_get_chapter_duration(titleindex, index) / 90000; + duration = ghb_get_chapter_duration(title, index) / 90000; break_duration(duration, &hh, &mm, &ss); s_duration = g_strdup_printf("%02d:%02d:%02d", hh, mm, ss); - start = ghb_get_chapter_start(titleindex, index) / 90000; + start = ghb_get_chapter_start(title, index) / 90000; break_duration(start, &hh, &mm, &ss); s_start = g_strdup_printf("%02d:%02d:%02d", hh, mm, ss); gtk_list_store_set(GTK_LIST_STORE(tm), ti, @@ -3660,14 +3680,16 @@ chapter_refresh_list_ui(signal_user_data_t *ud) GtkTreeView *tv; GtkTreeModel *tm; GtkTreeIter ti; - int titleindex; + int title_id, titleindex; + const hb_title_t *title; tv = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "chapters_list")); tm = gtk_tree_view_get_model(tv); tm_count = gtk_tree_model_iter_n_children(tm, NULL); - titleindex = ghb_settings_combo_int(ud->settings, "title"); + title_id = ghb_settings_get_int(ud->settings, "title"); + title = ghb_lookup_title(title_id, &titleindex); chapter_list = ghb_settings_get_value(ud->settings, "chapter_list"); count = ghb_array_len(chapter_list); if (count != tm_count) @@ -3681,7 +3703,7 @@ chapter_refresh_list_ui(signal_user_data_t *ud) for (ii = 0; ii < count; ii++) { gtk_tree_model_iter_nth_child(tm, &ti, NULL, ii); - chapter_refresh_list_row_ui(tm, &ti, chapter_list, titleindex, ii); + chapter_refresh_list_row_ui(tm, &ti, chapter_list, title, ii); } } @@ -3695,11 +3717,13 @@ static void update_chapter_list_settings(GValue *settings) { GValue *chapters; - gint titleindex; + gint title_id, titleindex; + const hb_title_t *title; g_debug("update_chapter_list_settings ()"); - titleindex = ghb_settings_get_int(settings, "title_no"); - chapters = ghb_get_chapters(titleindex); + title_id = ghb_settings_get_int(settings, "title"); + title = ghb_lookup_title(title_id, &titleindex); + chapters = ghb_get_chapters(title); if (chapters) ghb_settings_take_value(settings, "chapter_list", chapters); } diff --git a/gtk/src/create_resources.py b/gtk/src/create_resources.py index ba5526361..0767513aa 100644 --- a/gtk/src/create_resources.py +++ b/gtk/src/create_resources.py @@ -74,7 +74,7 @@ def start_element_handler(tag, attr): elif fname == None: print >> sys.stderr, ( "Error: No such string file %s" % fbase ) sys.exit(1) - + if val != None: if type(current) == types.DictType: current[key] = val diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c index afcc5ae9f..be3dede7c 100644 --- a/gtk/src/hb-backend.c +++ b/gtk/src/hb-backend.c @@ -369,12 +369,6 @@ combo_opts_t subtitle_opts = NULL }; -combo_opts_t title_opts = -{ - 0, - NULL -}; - combo_opts_t audio_track_opts = { 0, @@ -412,7 +406,6 @@ combo_name_map_t combo_name_map[] = {"x264_analyse", &analyse_opts}, {"x264_trellis", &trellis_opts}, {"SubtitleTrack", &subtitle_opts}, - {"title", &title_opts}, {"AudioTrack", &audio_track_opts}, {NULL, NULL} }; @@ -1422,22 +1415,19 @@ ghb_hb_cleanup(gboolean partial) gint ghb_subtitle_track_source(GValue *settings, gint track) { - gint titleindex; + gint title_id, titleindex; + const hb_title_t *title; if (track == -2) return SRTSUB; if (track < 0) return VOBSUB; - titleindex = ghb_settings_combo_int(settings, "title"); - if (titleindex < 0) + title_id = ghb_settings_get_int(settings, "title"); + title = ghb_lookup_title(title_id, &titleindex); + if (title == NULL) return VOBSUB; - hb_title_t * title; hb_subtitle_t * sub; - - if (h_scan == NULL) return VOBSUB; - title = ghb_get_title_info( titleindex ); - if (title == NULL) return VOBSUB; // Bad titleindex sub = hb_list_item( title->list_subtitle, track); if (sub != NULL) return sub->source; @@ -1448,13 +1438,11 @@ ghb_subtitle_track_source(GValue *settings, gint track) const gchar* ghb_subtitle_track_lang(GValue *settings, gint track) { - gint titleindex; - hb_title_t * title; + gint title_id, titleindex; + const hb_title_t * title; - titleindex = ghb_settings_combo_int(settings, "title"); - if (titleindex < 0) - goto fail; - title = ghb_get_title_info(titleindex); + title_id = ghb_settings_get_int(settings, "title"); + title = ghb_lookup_title(title_id, &titleindex); if (title == NULL) // Bad titleindex goto fail; if (track == -1) @@ -1471,40 +1459,6 @@ fail: return "und"; } -gint -ghb_get_title_number(gint titleindex) -{ - hb_title_t * title; - - title = ghb_get_title_info( titleindex ); - if (title == NULL) return 1; // Bad titleindex - return title->index; -} - -static hb_audio_config_t* -get_hb_audio(hb_handle_t *h, gint titleindex, gint track) -{ - hb_list_t * list; - hb_title_t * title; - hb_audio_config_t *audio = NULL; - - if (h == NULL) return NULL; - list = hb_get_titles( h ); - if( !hb_list_count( list ) ) - { - /* No valid title, stop right there */ - return NULL; - } - title = hb_list_item( list, titleindex ); - if (title == NULL) return NULL; // Bad titleindex - if (!hb_list_count(title->list_audio)) - { - return NULL; - } - audio = (hb_audio_config_t *)hb_list_audio_config_item(title->list_audio, track); - return audio; -} - static gint search_audio_bitrates(gint rate) { @@ -1574,19 +1528,21 @@ void ghb_grey_combo_options(signal_user_data_t *ud) { GtkWidget *widget; - gint mux, track, titleindex, acodec, fallback; + gint mux, track, title_id, titleindex, acodec, fallback; + const hb_title_t *title; hb_audio_config_t *aconfig = NULL; GValue *gval; + title_id = ghb_settings_get_int(ud->settings, "title"); + title = ghb_lookup_title(title_id, &titleindex); widget = GHB_WIDGET (ud->builder, "title"); gval = ghb_widget_value(widget); - titleindex = ghb_lookup_combo_int("title", gval); ghb_value_free(gval); widget = GHB_WIDGET (ud->builder, "AudioTrack"); gval = ghb_widget_value(widget); track = ghb_lookup_combo_int("AudioTrack", gval); ghb_value_free(gval); - aconfig = get_hb_audio(h_scan, titleindex, track); + aconfig = ghb_get_audio_info(title, track); widget = GHB_WIDGET (ud->builder, "FileFormat"); gval = ghb_widget_value(widget); mux = ghb_lookup_combo_int("FileFormat", gval); @@ -1759,6 +1715,19 @@ ghb_audio_samplerate_opts_set(GtkComboBox *combo) } } +const hb_rate_t* +ghb_lookup_samplerate(const char *name) +{ + const hb_rate_t *rate; + for (rate = hb_audio_samplerate_get_next(NULL); rate != NULL; + rate = hb_audio_samplerate_get_next(rate)) + { + if (!strncmp(name, rate->name, 80)) + return rate; + } + return NULL; +} + static void audio_samplerate_opts_set(GtkBuilder *builder, const gchar *name) { @@ -1818,6 +1787,19 @@ video_framerate_opts_set(GtkBuilder *builder, const gchar *name) } } +const hb_rate_t* +ghb_lookup_framerte(const char *name) +{ + const hb_rate_t *rate; + for (rate = hb_video_framerate_get_next(NULL); rate != NULL; + rate = hb_video_framerate_get_next(rate)) + { + if (!strncmp(name, rate->name, 80)) + return rate; + } + return NULL; +} + static void video_encoder_opts_set( GtkBuilder *builder, @@ -1849,6 +1831,22 @@ video_encoder_opts_set( } } +const hb_encoder_t* +ghb_lookup_video_encoder(const char *name) +{ + const hb_encoder_t *enc; + for (enc = hb_video_encoder_get_next(NULL); enc != NULL; + enc = hb_video_encoder_get_next(enc)) + { + if (!strncmp(name, enc->short_name, 80) || + !strncmp(name, enc->name, 80)) + { + return enc; + } + } + return NULL; +} + void ghb_audio_encoder_opts_set_with_mask( GtkComboBox *combo, @@ -1883,6 +1881,22 @@ ghb_audio_encoder_opts_set_with_mask( } } +const hb_encoder_t* +ghb_lookup_audio_encoder(const char *name) +{ + const hb_encoder_t *enc; + for (enc = hb_audio_encoder_get_next(NULL); enc != NULL; + enc = hb_audio_encoder_get_next(enc)) + { + if (!strncmp(name, enc->short_name, 80) || + !strncmp(name, enc->name, 80)) + { + return enc; + } + } + return NULL; +} + static void audio_encoder_opts_set_with_mask( GtkBuilder *builder, @@ -1968,6 +1982,22 @@ ghb_mix_opts_set(GtkComboBox *combo) } } +const hb_mixdown_t* +ghb_lookup_mix(const char *name) +{ + const hb_mixdown_t *mix; + for (mix = hb_mixdown_get_next(NULL); mix != NULL; + mix = hb_mixdown_get_next(mix)) + { + if (!strncmp(name, mix->short_name, 80) || + !strncmp(name, mix->name, 80)) + { + return mix; + } + } + return NULL; +} + static void mix_opts_set(GtkBuilder *builder, const gchar *name) { @@ -2007,6 +2037,22 @@ container_opts_set( } } +const hb_container_t * +ghb_lookup_container(const gchar *name) +{ + const hb_container_t *mux; + for (mux = hb_container_get_next(NULL); mux != NULL; + mux = hb_container_get_next(mux)) + { + if (!strncmp(mux->short_name, name, 80) || + !strncmp(mux->name, name, 80)) + { + return mux; + } + } + return NULL; +} + static void srt_codeset_opts_set(GtkBuilder *builder, const gchar *name) { @@ -2062,10 +2108,26 @@ language_opts_set(GtkBuilder *builder, const gchar *name) } } -static gchar **titles = NULL; +const iso639_lang_t* +ghb_lookup_lang(const char *name) +{ + int ii; + for (ii = 0; ii < LANG_TABLE_SIZE; ii++) + { + if (!strncmp(name, ghb_language_table[ii].iso639_2, 4) || + !strncmp(name, ghb_language_table[ii].iso639_1, 4) || + !strncmp(name, ghb_language_table[ii].iso639_2b, 4) || + !strncmp(name, ghb_language_table[ii].native_name, 4) || + !strncmp(name, ghb_language_table[ii].eng_name, 4)) + { + return &ghb_language_table[ii]; + } + } + return NULL; +} gchar* -ghb_create_title_label(hb_title_t *title) +ghb_create_title_label(const hb_title_t *title) { gchar *label; @@ -2125,10 +2187,11 @@ title_opts_set(GtkBuilder *builder, const gchar *name) GtkTreeIter iter; GtkListStore *store; hb_list_t * list = NULL; - hb_title_t * title = NULL; + const hb_title_t * title = NULL; gint ii; gint count = 0; + g_debug("title_opts_set ()\n"); GtkComboBox *combo = GTK_COMBO_BOX(GHB_WIDGET(builder, name)); store = GTK_LIST_STORE(gtk_combo_box_get_model (combo)); @@ -2138,20 +2201,6 @@ title_opts_set(GtkBuilder *builder, const gchar *name) list = hb_get_titles( h_scan ); count = hb_list_count( list ); } - if (titles) g_strfreev(titles); - if (title_opts.map) g_free(title_opts.map); - if (count > 0) - { - title_opts.count = count; - title_opts.map = g_malloc(count*sizeof(options_map_t)); - titles = g_malloc((count+1) * sizeof(gchar*)); - } - else - { - title_opts.count = 1; - title_opts.map = g_malloc(sizeof(options_map_t)); - titles = NULL; - } if( count <= 0 ) { // No titles. Fill in a default. @@ -2163,31 +2212,89 @@ title_opts_set(GtkBuilder *builder, const gchar *name) 3, -1.0, 4, "none", -1); - title_opts.map[0].option = "No Titles"; - title_opts.map[0].shortOpt = "none"; - title_opts.map[0].ivalue = -1; - title_opts.map[0].svalue = "none"; return; } for (ii = 0; ii < count; ii++) { - title = (hb_title_t*)hb_list_item(list, ii); - titles[ii] = ghb_create_title_label(title); + char *title_opt, *title_index; + + title = hb_list_item(list, ii); + title_opt = ghb_create_title_label(title); + title_index = g_strdup_printf("%d", title->index); gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, - 0, titles[ii], + 0, title_opt, 1, TRUE, - 2, titles[ii], - 3, (gdouble)ii, - 4, titles[ii], + 2, title_index, + 3, (gdouble)title->index, + 4, title_index, -1); - title_opts.map[ii].option = titles[ii]; - title_opts.map[ii].shortOpt = titles[ii]; - title_opts.map[ii].ivalue = ii; - title_opts.map[ii].svalue = titles[ii]; + g_free(title_opt); + g_free(title_index); + } +} + +static int +lookup_title_index(hb_handle_t *h, int title_id) +{ + if (h == NULL) + return -1; + + hb_list_t *list; + const hb_title_t *title; + int count, ii; + + list = hb_get_titles(h); + count = hb_list_count(list); + for (ii = 0; ii < count; ii++) + { + title = hb_list_item(list, ii); + if (title_id == title->index) + { + return ii; + } } - titles[ii] = NULL; + return -1; +} + +const hb_title_t* +lookup_title(hb_handle_t *h, int title_id, int *index) +{ + int ii = lookup_title_index(h, title_id); + + if (index != NULL) + *index = ii; + if (ii < 0) + return NULL; + + hb_list_t *list; + list = hb_get_titles(h); + return hb_list_item(list, ii); +} + +int +ghb_lookup_title_index(int title_id) +{ + return lookup_title_index(h_scan, title_id); +} + +const hb_title_t* +ghb_lookup_title(int title_id, int *index) +{ + return lookup_title(h_scan, title_id, index); +} + +int +ghb_lookup_queue_title_index(int title_id) +{ + return lookup_title_index(h_queue, title_id); +} + +const hb_title_t* +ghb_lookup_queue_title(int title_id, int *index) +{ + return lookup_title(h_queue, title_id, index); } static void @@ -2289,12 +2396,6 @@ h264_level_opts_set(GtkBuilder *builder, const gchar *name) } } -int -ghb_get_title_count() -{ - return title_opts.count; -} - static gboolean find_combo_item_by_int(GtkTreeModel *store, gint value, GtkTreeIter *iter) { @@ -2317,11 +2418,10 @@ find_combo_item_by_int(GtkTreeModel *store, gint value, GtkTreeIter *iter) } void -audio_track_opts_set(GtkBuilder *builder, const gchar *name, gint titleindex) +audio_track_opts_set(GtkBuilder *builder, const gchar *name, const hb_title_t *title) { GtkTreeIter iter; GtkListStore *store; - hb_title_t * title = NULL; hb_audio_config_t * audio; gint ii; gint count = 0; @@ -2331,7 +2431,6 @@ audio_track_opts_set(GtkBuilder *builder, const gchar *name, gint titleindex) GtkComboBox *combo = GTK_COMBO_BOX(GHB_WIDGET(builder, name)); store = GTK_LIST_STORE(gtk_combo_box_get_model (combo)); gtk_list_store_clear(store); - title = ghb_get_title_info(titleindex); if (title != NULL) { count = hb_list_count( title->list_audio ); @@ -2399,30 +2498,11 @@ audio_track_opts_set(GtkBuilder *builder, const gchar *name, gint titleindex) gtk_combo_box_set_active (combo, 0); } -const gchar* -ghb_audio_track_description(gint track, int titleindex) -{ - hb_title_t * title = NULL; - hb_audio_config_t * audio; - gchar * desc = "Unknown"; - - g_debug("ghb_audio_track_description ()\n"); - - title = ghb_get_title_info( titleindex ); - if (title == NULL) return desc; - if (track >= hb_list_count( title->list_audio )) return desc; - - audio = hb_list_audio_config_item(title->list_audio, track); - if (audio == NULL) return desc; - return audio->lang.description; -} - void -subtitle_track_opts_set(GtkBuilder *builder, const gchar *name, gint titleindex) +subtitle_track_opts_set(GtkBuilder *builder, const gchar *name, const hb_title_t *title) { GtkTreeIter iter; GtkListStore *store; - hb_title_t * title = NULL; hb_subtitle_t * subtitle; gint ii, count = 0; static char ** options = NULL; @@ -2431,7 +2511,6 @@ subtitle_track_opts_set(GtkBuilder *builder, const gchar *name, gint titleindex) GtkComboBox *combo = GTK_COMBO_BOX(GHB_WIDGET(builder, name)); store = GTK_LIST_STORE(gtk_combo_box_get_model (combo)); gtk_list_store_clear(store); - title = ghb_get_title_info(titleindex); if (title != NULL) { count = hb_list_count( title->list_subtitle ); @@ -2499,35 +2578,26 @@ subtitle_track_opts_set(GtkBuilder *builder, const gchar *name, gint titleindex) gtk_combo_box_set_active (combo, 0); } +// Get title id of feature or longest title gint ghb_longest_title() { hb_title_set_t * title_set; - hb_title_t * title; - gint ii; + const hb_title_t * title; gint count = 0; - gint feature; g_debug("ghb_longest_title ()\n"); if (h_scan == NULL) return 0; title_set = hb_get_title_set( h_scan ); count = hb_list_count( title_set->list_title ); if (count < 1) return 0; - title = (hb_title_t*)hb_list_item(title_set->list_title, 0); - feature = title_set->feature; - for (ii = 0; ii < count; ii++) - { - title = (hb_title_t*)hb_list_item(title_set->list_title, ii); - if (title->index == feature) - { - return ii; - } - } - return 0; + title = hb_list_item(title_set->list_title, 0); + (void)title; // Silence "unused variable" warning + return title_set->feature; } const gchar* -ghb_get_source_audio_lang(hb_title_t *title, gint track) +ghb_get_source_audio_lang(const hb_title_t *title, gint track) { hb_audio_config_t * audio; const gchar *lang = "und"; @@ -2547,7 +2617,7 @@ ghb_get_source_audio_lang(hb_title_t *title, gint track) } gint -ghb_find_audio_track(hb_title_t *title, const gchar *lang, int start) +ghb_find_audio_track(const hb_title_t *title, const gchar *lang, int start) { hb_audio_config_t * audio; gint ii, count = 0; @@ -2584,7 +2654,7 @@ ghb_find_pref_subtitle_track(const gchar *lang) } gint -ghb_find_subtitle_track(hb_title_t * title, const gchar * lang, int start) +ghb_find_subtitle_track(const hb_title_t * title, const gchar * lang, int start) { hb_subtitle_t * subtitle; gint count, ii; @@ -2872,7 +2942,7 @@ void ghb_update_ui_combo_box( signal_user_data_t *ud, const gchar *name, - gint user_data, + const void *user_data, gboolean all) { GtkComboBox *combo = NULL; @@ -3105,15 +3175,13 @@ void ghb_set_video_encoder_opts(hb_job_t *job, GValue *js) } void -ghb_part_duration(gint tt, gint sc, gint ec, gint *hh, gint *mm, gint *ss) +ghb_part_duration(const hb_title_t *title, gint sc, gint ec, gint *hh, gint *mm, gint *ss) { - hb_title_t * title; hb_chapter_t * chapter; gint count, c; gint64 duration; *hh = *mm = *ss = 0; - title = ghb_get_title_info( tt ); if (title == NULL) return; *hh = title->hours; @@ -3140,14 +3208,11 @@ ghb_part_duration(gint tt, gint sc, gint ec, gint *hh, gint *mm, gint *ss) } gint64 -ghb_get_chapter_duration(gint ti, gint chap) +ghb_get_chapter_duration(const hb_title_t *title, gint chap) { - hb_title_t * title; hb_chapter_t * chapter; gint count; - g_debug("ghb_get_chapter_duration (title = %d)\n", ti); - title = ghb_get_title_info( ti ); if (title == NULL) return 0; count = hb_list_count( title->list_chapter ); if (chap >= count) return 0; @@ -3157,15 +3222,12 @@ ghb_get_chapter_duration(gint ti, gint chap) } gint64 -ghb_get_chapter_start(gint ti, gint chap) +ghb_get_chapter_start(const hb_title_t *title, gint chap) { - hb_title_t * title; hb_chapter_t * chapter; gint count, ii; gint64 start = 0; - g_debug("ghb_get_chapter_start (title = %d)\n", ti); - title = ghb_get_title_info( ti ); if (title == NULL) return 0; count = hb_list_count( title->list_chapter ); if (chap > count) return chap = count; @@ -3178,17 +3240,14 @@ ghb_get_chapter_start(gint ti, gint chap) } GValue* -ghb_get_chapters(gint titleindex) +ghb_get_chapters(const hb_title_t *title) { - hb_title_t * title; hb_chapter_t * chapter; gint count, ii; GValue *chapters = NULL; - g_debug("ghb_get_chapters (title = %d)\n", titleindex); chapters = ghb_array_value_new(0); - title = ghb_get_title_info( titleindex ); if (title == NULL) return chapters; count = hb_list_count( title->list_chapter ); for (ii = 0; ii < count; ii++) @@ -3413,7 +3472,7 @@ ghb_combo_init(signal_user_data_t *ud) // Set up the list model for the combos init_ui_combo_boxes(ud->builder); // Populate all the combos - ghb_update_ui_combo_box(ud, NULL, 0, TRUE); + ghb_update_ui_combo_box(ud, NULL, NULL, TRUE); } void @@ -3681,15 +3740,15 @@ ghb_track_status() } } -hb_title_t * -ghb_get_title_info(gint titleindex) +hb_audio_config_t* +ghb_get_audio_info(const hb_title_t *title, gint track) { - hb_list_t * list; - - if (h_scan == NULL) return NULL; - list = hb_get_titles( h_scan ); - if (list == NULL) return NULL; - return hb_list_item( list, titleindex ); + if (title == NULL) return NULL; + if (!hb_list_count(title->list_audio)) + { + return NULL; + } + return hb_list_audio_config_item(title->list_audio, track); } hb_list_t * @@ -3699,15 +3758,6 @@ ghb_get_title_list() return hb_get_titles( h_scan ); } -hb_audio_config_t* -ghb_get_scan_audio_info(gint titleindex, gint audioindex) -{ - hb_audio_config_t *aconfig; - - aconfig = get_hb_audio(h_scan, titleindex, audioindex); - return aconfig; -} - gboolean ghb_audio_is_passthru(gint acodec) { @@ -3793,7 +3843,6 @@ ghb_limit_rational( gint *num, gint *den, gint limit ) void ghb_set_scale_settings(GValue *settings, gint mode) { - hb_title_t * title; hb_job_t * job; gboolean keep_aspect; gint pic_par; @@ -3822,13 +3871,14 @@ ghb_set_scale_settings(GValue *settings, gint mode) ghb_settings_set_boolean(settings, "PictureKeepRatio", TRUE); } - gint titleindex; + int title_id, titleindex; + const hb_title_t * title; - titleindex = ghb_settings_combo_int(settings, "title"); - title = ghb_get_title_info (titleindex); + title_id = ghb_settings_get_int(settings, "title"); + title = ghb_lookup_title(title_id, &titleindex); if (title == NULL) return; - job = hb_job_init( title ); + job = hb_job_init( (hb_title_t*)title ); if (job == NULL) return; // First configure widgets @@ -4342,13 +4392,12 @@ ghb_validate_video(GValue *settings) gboolean ghb_validate_subtitles(GValue *settings) { - hb_title_t * title; + gint title_id, titleindex; + const hb_title_t * title; gchar *message; - gint titleindex; - - titleindex = ghb_settings_combo_int(settings, "title"); - title = ghb_get_title_info(titleindex); + title_id = ghb_settings_get_int(settings, "title"); + title = ghb_lookup_title(title_id, &titleindex); if (title == NULL) { /* No valid title, stop right there */ @@ -4415,14 +4464,13 @@ ghb_validate_subtitles(GValue *settings) gboolean ghb_validate_audio(GValue *settings) { - hb_title_t * title; + gint title_id, titleindex; + const hb_title_t * title; gchar *message; GValue *value; - gint titleindex; - - titleindex = ghb_settings_combo_int(settings, "title"); - title = ghb_get_title_info( titleindex ); + title_id = ghb_settings_get_int(settings, "title"); + title = ghb_lookup_title(title_id, &titleindex); if (title == NULL) { /* No valid title, stop right there */ @@ -4613,10 +4661,10 @@ ghb_validate_vquality(GValue *settings) } static void -add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex) +add_job(hb_handle_t *h, GValue *js, gint unique_id, int titleindex) { hb_list_t * list; - hb_title_t * title; + const hb_title_t * title; hb_job_t * job; gint sub_id = 0; hb_filter_object_t * filter; @@ -4637,7 +4685,7 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex) if (title == NULL) return; /* Set job settings */ - job = hb_job_init( title ); + job = hb_job_init( (hb_title_t*)title ); if (job == NULL) return; prefs = ghb_settings_get_value(js, "Preferences"); @@ -5228,7 +5276,12 @@ ghb_add_job(GValue *js, gint unique_id) void ghb_add_live_job(GValue *js, gint unique_id) { - gint titleindex = ghb_settings_combo_int(js, "title"); + int title_id, titleindex; + const hb_title_t *title; + + title_id = ghb_settings_get_int(js, "title"); + title = ghb_lookup_title(title_id, &titleindex); + (void)title; // Silence "unused variable" warning add_job(h_scan, js, unique_id, titleindex); } @@ -5391,19 +5444,17 @@ hash_pixbuf( GdkPixbuf* ghb_get_preview_image( - gint titleindex, + const hb_title_t *title, gint index, signal_user_data_t *ud, gint *out_width, gint *out_height) { - hb_title_t *title; hb_job_t *job; - title = ghb_get_title_info( titleindex ); if( title == NULL ) return NULL; - job = hb_job_init( title ); + job = hb_job_init( (hb_title_t*)title ); if (job == NULL) return NULL; set_preview_job_settings(ud, job, ud->settings); diff --git a/gtk/src/hb-backend.h b/gtk/src/hb-backend.h index 0f15d4070..3ee1e5a1d 100644 --- a/gtk/src/hb-backend.h +++ b/gtk/src/hb-backend.h @@ -104,42 +104,40 @@ void ghb_track_status(void); void ghb_backend_scan(const gchar *path, gint titleindex, gint preview_count, guint64 min_duration); void ghb_backend_scan_stop(); void ghb_backend_queue_scan(const gchar *path, gint titleindex); -hb_title_t* ghb_get_title_info(gint titleindex); hb_list_t * ghb_get_title_list(); void ghb_par_init(signal_user_data_t *ud); void ghb_set_scale(signal_user_data_t *ud, gint mode); void ghb_set_scale_settings(GValue *settings, gint mode); void ghb_picture_settings_deps(signal_user_data_t *ud); -GValue* ghb_get_chapters(gint titleindex); -gint64 ghb_get_chapter_duration(gint ti, gint chap); -gint64 ghb_get_chapter_start(gint ti, gint chap); -void ghb_part_duration(gint tt, gint sc, gint ec, gint *hh, gint *mm, gint *ss); +GValue* ghb_get_chapters(const hb_title_t *title); +gint64 ghb_get_chapter_duration(const hb_title_t *title, gint chap); +gint64 ghb_get_chapter_start(const hb_title_t *title, gint chap); +void ghb_part_duration( + const hb_title_t *title, gint sc, gint ec, gint *hh, gint *mm, gint *ss); +hb_audio_config_t* ghb_get_audio_info(const hb_title_t *title, gint track); gint ghb_get_best_mix(hb_audio_config_t *aconfig, gint acodec, gint mix); gboolean ghb_ac3_in_audio_list(const GValue *audio_list); gboolean ghb_audio_is_passthru(gint acodec); gboolean ghb_audio_can_passthru(gint acodec); gint ghb_get_default_acodec(void); -hb_audio_config_t* ghb_get_scan_audio_info(gint titleindex, gint audioindex); void ghb_set_bitrate_opts( GtkBuilder *builder, gint first_rate, gint last_rate, gint extra_rate); void ghb_grey_combo_options(signal_user_data_t *ud); void ghb_update_ui_combo_box( - signal_user_data_t *ud, const gchar *name, gint user_data, gboolean all); -const gchar* ghb_get_source_audio_lang(hb_title_t *title, gint track); -gint ghb_find_audio_track(hb_title_t *title, const gchar *lang, int start); -const gchar* ghb_audio_track_description(gint track, int titleindex); + signal_user_data_t *ud, const gchar *name, + const void *user_data, gboolean all); +const gchar* ghb_get_source_audio_lang(const hb_title_t *title, gint track); +gint ghb_find_audio_track(const hb_title_t *title, const gchar *lang, int start); void ghb_add_all_subtitles(signal_user_data_t *ud, gint titleindex); gint ghb_find_pref_subtitle_track(const gchar *lang); -gint ghb_find_subtitle_track(hb_title_t * title, const gchar * lang, int start); +gint ghb_find_subtitle_track(const hb_title_t * title, const gchar * lang, int start); gint ghb_pick_subtitle_track(signal_user_data_t *ud); gint ghb_longest_title(void); gchar* ghb_build_advanced_opts_string(GValue *settings); GdkPixbuf* ghb_get_preview_image( - gint titleindex, gint index, signal_user_data_t *ud, - gint *width, gint *height); + const hb_title_t *title, gint index, signal_user_data_t *ud, + gint *out_width, gint *out_height); gchar* ghb_dvd_volname(const gchar *device); -gint ghb_get_title_number(gint titleindex); -int ghb_get_title_count(); gint ghb_subtitle_track_source(GValue *settings, gint track); const gchar* ghb_subtitle_track_lang(GValue *settings, gint track); @@ -171,6 +169,7 @@ void ghb_audio_samplerate_opts_set(GtkComboBox *combo); int ghb_lookup_audio_lang(const GValue *glang); const iso639_lang_t* ghb_iso639_lookup_by_int(int idx); void ghb_update_display_aspect_label(signal_user_data_t *ud); -gchar* ghb_create_title_label(hb_title_t *title); +gchar* ghb_create_title_label(const hb_title_t *title); +const hb_title_t* ghb_lookup_title(int title_id, int *index); #endif // _HBBACKEND_H_ diff --git a/gtk/src/makedeps.py b/gtk/src/makedeps.py index aa2111cea..331e0cf77 100644 --- a/gtk/src/makedeps.py +++ b/gtk/src/makedeps.py @@ -111,6 +111,6 @@ def main(): deps.append(rec) top[ii.dep] = deps plistlib.writePlist(top, revfile) - + main() diff --git a/gtk/src/presets.c b/gtk/src/presets.c index 560eec832..940cadaaa 100644 --- a/gtk/src/presets.c +++ b/gtk/src/presets.c @@ -956,7 +956,7 @@ ghb_preset_to_settings(GValue *settings, GValue *preset) init_settings_from_dict(settings, preset, NULL, TRUE); // Fix up all the internal settings that are derived from preset values. - ghb_settings_set_boolean(settings, "PictureDeinterlaceDecomb", + ghb_settings_set_boolean(settings, "PictureDeinterlaceDecomb", !ghb_settings_get_boolean(settings, "PictureDecombDeinterlace")); ghb_settings_set_value(settings, "scale_height", diff --git a/gtk/src/preview.c b/gtk/src/preview.c index cf046f24a..a77c7e018 100644 --- a/gtk/src/preview.c +++ b/gtk/src/preview.c @@ -919,12 +919,14 @@ ghb_set_preview_image(signal_user_data_t *ud) gint preview_width, preview_height, target_height, width, height; g_debug("set_preview_button_image ()"); - gint titleindex; + gint title_id, titleindex; + const hb_title_t *title; live_preview_stop(ud); - titleindex = ghb_settings_combo_int(ud->settings, "title"); - if (titleindex < 0) return; + title_id = ghb_settings_get_int(ud->settings, "title"); + title = ghb_lookup_title(title_id, &titleindex); + if (title == NULL) return; widget = GHB_WIDGET (ud->builder, "preview_frame"); ud->preview->frame = ghb_widget_int(widget) - 1; if (ud->preview->encoded[ud->preview->frame]) @@ -948,8 +950,7 @@ ghb_set_preview_image(signal_user_data_t *ud) g_object_unref(ud->preview->pix); ud->preview->pix = - ghb_get_preview_image(titleindex, ud->preview->frame, - ud, &width, &height); + ghb_get_preview_image(title, ud->preview->frame, ud, &width, &height); if (ud->preview->pix == NULL) return; preview_width = gdk_pixbuf_get_width(ud->preview->pix); preview_height = gdk_pixbuf_get_height(ud->preview->pix); @@ -1149,14 +1150,16 @@ preview_button_size_allocate_cb(GtkWidget *widget, GtkAllocation *allocation, si void ghb_preview_set_visible(signal_user_data_t *ud) { - gint titleindex; + gint title_id, titleindex; + const hb_title_t *title; GtkWidget *widget; gboolean settings_active; + title_id = ghb_settings_get_int(ud->settings, "title"); + title = ghb_lookup_title(title_id, &titleindex); settings_active = ghb_settings_get_boolean(ud->globals, "show_picture"); widget = GHB_WIDGET(ud->builder, "preview_window"); - titleindex = ghb_settings_combo_int(ud->settings, "title"); - if (settings_active && titleindex >= 0) + if (settings_active && title != NULL) { gint x, y; x = ghb_settings_get_int(ud->prefs, "preview_x"); diff --git a/gtk/src/queuehandler.c b/gtk/src/queuehandler.c index cdc783245..11980dc2c 100644 --- a/gtk/src/queuehandler.c +++ b/gtk/src/queuehandler.c @@ -84,7 +84,7 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter) // Collect information for first line in the display // Volume (Title X, Chapters Y through Z, N Video Passes) --> Destination - title = ghb_settings_get_int(settings, "titlenum"); + title = ghb_settings_get_int(settings, "title"); start_point = ghb_settings_get_int(settings, "start_point"); end_point = ghb_settings_get_int(settings, "end_point"); vol_name = ghb_settings_get_const_string(settings, "volume_label"); @@ -656,10 +656,12 @@ validate_settings(signal_user_data_t *ud, GValue *settings, gint batch) // already in the queue gchar *message, *dest; gint count, ii; - gint titleindex; + gint title_id, titleindex; + const hb_title_t *title; - titleindex = ghb_settings_combo_int(settings, "title"); - if (titleindex < 0) return FALSE; + title_id = ghb_settings_get_int(settings, "title"); + title = ghb_lookup_title(title_id, &titleindex); + if (title == NULL) return FALSE; dest = ghb_settings_get_string(settings, "destination"); count = ghb_array_len(ud->queue); for (ii = 0; ii < count; ii++) @@ -804,9 +806,6 @@ static gboolean queue_add(signal_user_data_t *ud, GValue *settings, gint batch) { // Add settings to the queue - gint titleindex; - gint titlenum; - g_debug("queue_add ()"); if (!validate_settings(ud, settings, batch)) { @@ -824,9 +823,7 @@ queue_add(signal_user_data_t *ud, GValue *settings, gint batch) // Make a copy of current settings to be used for the new job ghb_settings_set_int(settings, "job_status", GHB_QUEUE_PENDING); ghb_settings_set_int(settings, "job_unique_id", 0); - titleindex = ghb_settings_combo_int(settings, "title"); - titlenum = ghb_get_title_number(titleindex); - ghb_settings_set_int(settings, "titlenum", titlenum); + ghb_array_append(ud->queue, settings); add_to_queue_list(ud, settings, NULL); ghb_save_queue(ud->queue); @@ -1314,8 +1311,8 @@ queue_add_multiple_clicked_cb(GtkWidget *widget, signal_user_data_t *ud) GtkEntry *entry; GtkFileChooser *chooser; gchar *title_label, *dest_dir, *dest_file; - int titleindex; - hb_title_t *title; + int title_id, titleindex; + const hb_title_t *title; row = title_create_row(ud); label = GTK_LABEL(find_widget(row, "title_label")); @@ -1323,8 +1320,8 @@ queue_add_multiple_clicked_cb(GtkWidget *widget, signal_user_data_t *ud) chooser = GTK_FILE_CHOOSER(find_widget(row, "title_dir")); settings = ghb_array_get_nth(ud->settings_array, ii); - titleindex = ghb_settings_get_int(settings, "title_no"); - title = ghb_get_title_info(titleindex); + title_id = ghb_settings_get_int(settings, "title"); + title = ghb_lookup_title(title_id, &titleindex); if (title != NULL) { int len; @@ -1666,12 +1663,14 @@ ghb_queue_buttons_grey(signal_user_data_t *ud) { GtkWidget *widget; gint queue_count; - gint titleindex; + gint title_id, titleindex; + const hb_title_t *title; gint queue_state, scan_state; gboolean show_start, show_stop, paused; queue_count = ghb_array_len(ud->queue); - titleindex = ghb_settings_combo_int(ud->settings, "title"); + title_id = ghb_settings_get_int(ud->settings, "title"); + title = ghb_lookup_title(title_id, &titleindex); queue_state = ghb_get_queue_state(); scan_state = ghb_get_scan_state(); @@ -1680,7 +1679,7 @@ ghb_queue_buttons_grey(signal_user_data_t *ud) (GHB_STATE_WORKING | GHB_STATE_SEARCHING | GHB_STATE_SCANNING | GHB_STATE_MUXING); show_start = !(scan_state & GHB_STATE_SCANNING) && - (titleindex >= 0 || queue_count > 0); + (title !=NULL || queue_count > 0); paused = queue_state & GHB_STATE_PAUSED; diff --git a/gtk/src/subtitlehandler.c b/gtk/src/subtitlehandler.c index 6065f5a4a..cba0cbf54 100644 --- a/gtk/src/subtitlehandler.c +++ b/gtk/src/subtitlehandler.c @@ -309,7 +309,7 @@ subtitle_set_track_description(GValue *subsettings) static GValue* subtitle_add_track( signal_user_data_t *ud, GValue *settings, - hb_title_t *title, + const hb_title_t *title, int track, int mux, gboolean default_track, @@ -400,7 +400,7 @@ ghb_subtitle_title_change(signal_user_data_t *ud, gboolean show) } void -ghb_set_pref_subtitle_settings(signal_user_data_t *ud, hb_title_t *title, GValue *settings) +ghb_set_pref_subtitle_settings(signal_user_data_t *ud, const hb_title_t *title, GValue *settings) { gint track; gboolean *used; @@ -532,14 +532,12 @@ ghb_set_pref_subtitle_settings(signal_user_data_t *ud, hb_title_t *title, GValue } void -ghb_set_pref_subtitle(gint titleindex, signal_user_data_t *ud) +ghb_set_pref_subtitle(const hb_title_t *title, signal_user_data_t *ud) { - hb_title_t *title; int sub_count; GtkWidget *widget; ghb_clear_subtitle_list_ui(ud->builder); - title = ghb_get_title_info(titleindex); if (title == NULL) { return; @@ -1050,9 +1048,11 @@ subtitle_add_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) gboolean one_burned; gint track, mux; - hb_title_t *title; - int titleindex = ghb_settings_combo_int(ud->settings, "title"); - title = ghb_get_title_info(titleindex); + int title_id, titleindex; + const hb_title_t *title; + + title_id = ghb_settings_get_int(ud->settings, "title"); + title = ghb_lookup_title(title_id, &titleindex); if (title == NULL) { return; @@ -1110,9 +1110,10 @@ subtitle_add_all_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) gboolean one_burned = FALSE; gint track, mux; - hb_title_t *title; - int titleindex = ghb_settings_combo_int(ud->settings, "title"); - title = ghb_get_title_info(titleindex); + const hb_title_t *title; + int title_id, titleindex; + title_id = ghb_settings_get_int(ud->settings, "title"); + title = ghb_lookup_title(title_id, &titleindex); if (title == NULL) { return; @@ -1136,8 +1137,12 @@ subtitle_add_all_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) G_MODULE_EXPORT void subtitle_reset_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) { - int titleindex = ghb_settings_combo_int(ud->settings, "title"); - ghb_set_pref_subtitle(titleindex, ud); + int title_id, titleindex; + const hb_title_t *title; + + title_id = ghb_settings_get_int(ud->settings, "title"); + title = ghb_lookup_title(title_id, &titleindex); + ghb_set_pref_subtitle(title, ud); } void @@ -1187,13 +1192,15 @@ ghb_reset_subtitles(signal_user_data_t *ud, GValue *settings) GValue *slist; GValue *subtitle; gint count, ii; - gint titleindex; + gint title_id, titleindex; + const hb_title_t *title; g_debug("ghb_reset_subtitles"); ghb_clear_subtitle_list_settings(ud->settings); ghb_clear_subtitle_list_ui(ud->builder); - titleindex = ghb_settings_combo_int(ud->settings, "title"); - if (titleindex < 0) + title_id = ghb_settings_get_int(ud->settings, "title"); + title = ghb_lookup_title(title_id, &titleindex); + if (title == NULL) return; slist = ghb_settings_get_value(settings, "subtitle_list"); diff --git a/gtk/src/subtitlehandler.h b/gtk/src/subtitlehandler.h index 5e09d4f6c..0569be89e 100644 --- a/gtk/src/subtitlehandler.h +++ b/gtk/src/subtitlehandler.h @@ -27,8 +27,7 @@ #include "settings.h" -void ghb_set_pref_subtitle(gint titleindex, signal_user_data_t *ud); -void ghb_set_pref_subtitle_settings(signal_user_data_t *ud, hb_title_t *title, GValue *settings); +void ghb_set_pref_subtitle_settings(signal_user_data_t *ud, const hb_title_t *title, GValue *settings); void ghb_set_subtitle(signal_user_data_t *ud, gint track, GValue *settings); void ghb_reset_subtitles(signal_user_data_t *ud, GValue *settings); void ghb_subtitle_prune(signal_user_data_t *ud); |