diff options
author | John Stebbins <[email protected]> | 2016-05-27 09:24:02 -0600 |
---|---|---|
committer | John Stebbins <[email protected]> | 2016-05-27 09:24:02 -0600 |
commit | 9ec150b5461cc59eda93c5d3b3199fd97809972d (patch) | |
tree | d38148b0ebddfde283eaf090132920da3eeb01b0 | |
parent | a34b503a4adcdaa500cc92d5e06efcbb3c2a4104 (diff) |
LinGui: add source title dict to queue
By adding the title to the queue entry, all necessary information for
displaying queued job is present in the queue entry. So I no longer
need hackish "Description" key in job audio and subtitle lists.
-rw-r--r-- | gtk/src/audiohandler.c | 56 | ||||
-rw-r--r-- | gtk/src/callbacks.c | 1 | ||||
-rw-r--r-- | gtk/src/hb-backend.c | 6 | ||||
-rw-r--r-- | gtk/src/hb-backend.h | 1 | ||||
-rw-r--r-- | gtk/src/queuehandler.c | 153 | ||||
-rw-r--r-- | gtk/src/settings.c | 21 | ||||
-rw-r--r-- | gtk/src/settings.h | 16 | ||||
-rw-r--r-- | gtk/src/subtitlehandler.c | 53 | ||||
-rw-r--r-- | gtk/src/subtitlehandler.h | 1 |
9 files changed, 159 insertions, 149 deletions
diff --git a/gtk/src/audiohandler.c b/gtk/src/audiohandler.c index 9cf879871..8e434964f 100644 --- a/gtk/src/audiohandler.c +++ b/gtk/src/audiohandler.c @@ -69,26 +69,6 @@ ghb_sanitize_audio_settings(GhbValue *settings, GhbValue *asettings) bitrate = ghb_dict_get_int(asettings, "Bitrate"); quality = ghb_dict_get_double(asettings, "Quality"); sr = ghb_dict_get_int(asettings, "Samplerate"); - val = ghb_dict_get(asettings, "Description"); - if (val == NULL) - { - int title_id, track; - const hb_title_t *title; - hb_audio_config_t *aconfig; - - title_id = ghb_dict_get_int(settings, "title"); - title = ghb_lookup_title(title_id, NULL); - track = ghb_dict_get_int(asettings, "Track"); - aconfig = ghb_get_audio_info(title, track); - if (aconfig != NULL) - { - char *desc; - desc = g_strdup_printf("%d - %s", track + 1, - aconfig->lang.description); - ghb_dict_set_string(asettings, "Description", desc); - g_free(desc); - } - } val = ghb_dict_get(asettings, "QualityEnable"); if (val == NULL) { @@ -1090,25 +1070,6 @@ audio_track_changed_cb(GtkWidget *widget, signal_user_data_t *ud) audio_deps(ud, asettings, widget); ghb_audio_list_refresh_selected(ud); ghb_live_reset(ud); - - // Update the track description used by the queue - int title_id, titleindex; - const hb_title_t *title; - int track; - hb_audio_config_t *aconfig; - - title_id = ghb_dict_get_int(ud->settings, "title"); - title = ghb_lookup_title(title_id, &titleindex); - track = ghb_dict_get_int(ud->settings, "AudioTrack"); - aconfig = ghb_get_audio_info(title, track); - if (aconfig != NULL) - { - char *desc; - desc = g_strdup_printf("%d - %s", track + 1, - aconfig->lang.description); - ghb_dict_set_string(asettings, "Description", desc); - g_free(desc); - } } } @@ -1393,25 +1354,8 @@ static void audio_add_to_settings(GhbValue *settings, GhbValue *asettings) { GhbValue *audio_list; - int title_id; - const hb_title_t *title; - gint titleindex; - hb_audio_config_t *aconfig; - title_id = ghb_dict_get_int(settings, "title"); - title = ghb_lookup_title(title_id, &titleindex); audio_list = ghb_get_job_audio_list(settings); - - int track = ghb_dict_get_int(asettings, "Track"); - aconfig = ghb_get_audio_info(title, track); - if (aconfig != NULL) - { - char *desc; - desc = g_strdup_printf("%d - %s", track + 1, aconfig->lang.description); - ghb_dict_set_string(asettings, "Description", desc); - g_free(desc); - } - ghb_array_append(audio_list, asettings); } diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c index c73820a41..e55441996 100644 --- a/gtk/src/callbacks.c +++ b/gtk/src/callbacks.c @@ -1937,7 +1937,6 @@ set_title_settings(signal_user_data_t *ud, GhbValue *settings) title->metadata->long_description); } ghb_sanitize_audio_track_settings(settings); - ghb_sanitize_subtitle_track_settings(settings); } set_destination_settings(ud, settings); diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c index d7437a3bd..3afd41a83 100644 --- a/gtk/src/hb-backend.c +++ b/gtk/src/hb-backend.c @@ -2080,6 +2080,12 @@ ghb_lookup_title(int title_id, int *index) return lookup_title(h_scan, title_id, index); } +GhbValue* +ghb_get_title_dict(int title_id) +{ + return hb_title_to_dict(h_scan, title_id); +} + int ghb_lookup_queue_title_index(int title_id) { diff --git a/gtk/src/hb-backend.h b/gtk/src/hb-backend.h index 359d5a7d2..4c321e823 100644 --- a/gtk/src/hb-backend.h +++ b/gtk/src/hb-backend.h @@ -180,6 +180,7 @@ gchar* ghb_create_title_label(const hb_title_t *title); // libhb lookup helpers const hb_title_t* ghb_lookup_title(int title_id, int *index); +GhbValue* ghb_get_title_dict(int title_id); const hb_container_t* ghb_lookup_container_by_name(const gchar *name); const hb_encoder_t* ghb_lookup_audio_encoder(const char *name); int ghb_lookup_audio_encoder_codec(const char *name); diff --git a/gtk/src/queuehandler.c b/gtk/src/queuehandler.c index 951b59fb2..ffb9016fd 100644 --- a/gtk/src/queuehandler.c +++ b/gtk/src/queuehandler.c @@ -78,6 +78,62 @@ queue_list_selection_changed_cb(GtkTreeSelection *selection, signal_user_data_t } } +static char * +subtitle_get_track_description(const GhbValue *subsource, + const GhbValue *subsettings) +{ + GhbValue *srt; + char *desc = NULL; + + srt = ghb_dict_get(subsettings, "SRT"); + if (srt != NULL) + { + const gchar *filename, *code; + const gchar *lang; + const iso639_lang_t *iso; + + lang = ghb_dict_get_string(srt, "Language"); + code = ghb_dict_get_string(srt, "Codeset"); + filename = ghb_dict_get_string(srt, "Filename"); + + iso = lang_lookup(lang); + if (iso != NULL) + { + if (iso->native_name != NULL) + lang = iso->native_name; + else + lang = iso->eng_name; + } + + if (g_file_test(filename, G_FILE_TEST_IS_REGULAR)) + { + gchar *basename; + + basename = g_path_get_basename(filename); + desc = g_strdup_printf("%s (%s)(SRT)(%s)", lang, code, basename); + g_free(basename); + } + else + { + desc = g_strdup_printf("%s (%s)(SRT)", lang, code); + } + } + else if (subsource == NULL) + { + desc = g_strdup(_("Foreign Audio Search")); + } + else + { + int track = ghb_dict_get_int(subsettings, "Track"); + int source = ghb_dict_get_int(subsource, "Source"); + const char * lang = ghb_dict_get_string(subsource, "Language"); + desc = g_strdup_printf("%d - %s (%s)", track + 1, + lang, hb_subsource_name(source)); + } + + return desc; +} + static void add_to_queue_list(signal_user_data_t *ud, GhbValue *queueDict, GtkTreeIter *piter) { @@ -553,10 +609,12 @@ add_to_queue_list(signal_user_data_t *ud, GhbValue *queueDict, GtkTreeIter *pite // Source description, Encoder, Mix, Samplerate, Bitrate // ... gint count, ii; - const GhbValue *audio_list; + const GhbValue * jobAudioList; + const GhbValue * titleAudioList; - audio_list = ghb_get_job_audio_list(queueDict); - count = ghb_array_len(audio_list); + jobAudioList = ghb_get_job_audio_list(queueDict); + titleAudioList = ghb_get_title_audio_list(queueDict); + count = ghb_array_len(jobAudioList); if (count == 1) { XPRINT(_("<b>Audio:</b> <small>")); @@ -567,12 +625,13 @@ add_to_queue_list(signal_user_data_t *ud, GhbValue *queueDict, GtkTreeIter *pite } for (ii = 0; ii < count; ii++) { - const gchar *track; - gchar *quality = NULL; - GhbValue *asettings; - const hb_encoder_t *audio_encoder; + int track; + gchar * quality = NULL; + GhbValue * asettings; + GhbValue * asource; + const hb_encoder_t * audio_encoder; - asettings = ghb_array_get(audio_list, ii); + asettings = ghb_array_get(jobAudioList, ii); audio_encoder = ghb_settings_audio_encoder(asettings, "Encoder"); double q = ghb_dict_get_double(asettings, "Quality"); @@ -592,7 +651,9 @@ add_to_queue_list(signal_user_data_t *ud, GhbValue *queueDict, GtkTreeIter *pite if (sr_name == NULL) sr_name = "Auto"; - track = ghb_dict_get_string(asettings, "Description"); + track = ghb_dict_get_int(asettings, "Track"); + asource = ghb_array_get(titleAudioList, track); + const char * desc = ghb_dict_get_string(asource, "Description"); const hb_mixdown_t *mix; mix = ghb_settings_mixdown(asettings, "Mixdown"); if (count > 1) @@ -600,12 +661,13 @@ add_to_queue_list(signal_user_data_t *ud, GhbValue *queueDict, GtkTreeIter *pite if (audio_encoder->codec & HB_ACODEC_PASS_FLAG) { - XPRINT(_("%s --> Encoder: %s"), track, audio_encoder->name); + XPRINT(_("%d - %s --> Encoder: %s"), + track + 1, desc, audio_encoder->name); } else { - XPRINT(_("%s --> Encoder: %s, Mixdown: %s, SampleRate: %s, %s"), - track, audio_encoder->name, mix->name, sr_name, quality); + XPRINT(_("%d - %s --> Encoder: %s, Mixdown: %s, SampleRate: %s, %s"), + track + 1, desc, audio_encoder->name, mix->name, sr_name, quality); } g_free(quality); } @@ -618,14 +680,16 @@ add_to_queue_list(signal_user_data_t *ud, GhbValue *queueDict, GtkTreeIter *pite // Subtitle Tracks: count // Subtitle description(Subtitle options) // ... - const GhbValue *sub_dict, *sub_list, *sub_search; + const GhbValue *jobSubtitleDict, *jobSubtitleList, *subtitleSearchDict; + const GhbValue *titleSubtitleList; gboolean search; - sub_dict = ghb_get_job_subtitle_settings(queueDict); - sub_list = ghb_dict_get(sub_dict, "SubtitleList"); - sub_search = ghb_dict_get(sub_dict, "Search"); - search = ghb_dict_get_bool(sub_search, "Enable"); - count = ghb_array_len(sub_list); + titleSubtitleList = ghb_get_title_subtitle_list(queueDict); + jobSubtitleDict = ghb_get_job_subtitle_settings(queueDict); + jobSubtitleList = ghb_dict_get(jobSubtitleDict, "SubtitleList"); + subtitleSearchDict = ghb_dict_get(jobSubtitleDict, "Search"); + search = ghb_dict_get_bool(subtitleSearchDict, "Enable"); + count = ghb_array_len(jobSubtitleList); if (count + search == 1) { XPRINT(_("<b>Subtitle:</b> ")); @@ -636,39 +700,43 @@ add_to_queue_list(signal_user_data_t *ud, GhbValue *queueDict, GtkTreeIter *pite } if (search) { - const gchar *track; gboolean force, burn, def; + char * desc; - track = ghb_dict_get_string(sub_search, "Description"); - force = ghb_dict_get_bool(sub_search, "Forced"); - burn = ghb_dict_get_bool(sub_search, "Burn"); - def = ghb_dict_get_bool(sub_search, "Default"); + desc = subtitle_get_track_description(NULL, subtitleSearchDict); + force = ghb_dict_get_bool(subtitleSearchDict, "Forced"); + burn = ghb_dict_get_bool(subtitleSearchDict, "Burn"); + def = ghb_dict_get_bool(subtitleSearchDict, "Default"); if (count + search > 1) XPRINT("\t"); - XPRINT("<small>%s%s%s%s</small>\n", track, + XPRINT("<small>%s%s%s%s</small>\n", desc, force ? _(" (Forced Only)") : "", burn ? _(" (Burn)") : "", def ? _(" (Default)") : "" ); + g_free(desc); } for (ii = 0; ii < count; ii++) { - GhbValue *subsettings, *srt; - const gchar *track; + GhbValue *subsettings, *subsource, *srt; + int track; gboolean force, burn, def; - - subsettings = ghb_array_get(sub_list, ii); - track = ghb_dict_get_string(subsettings, "Description"); - srt = ghb_dict_get(subsettings, "SRT"); - force = ghb_dict_get_bool(subsettings, "Forced"); - burn = ghb_dict_get_bool(subsettings, "Burn"); - def = ghb_dict_get_bool(subsettings, "Default"); + char * desc; + + subsettings = ghb_array_get(jobSubtitleList, ii); + track = ghb_dict_get_int(subsettings, "Track"); + subsource = ghb_array_get(titleSubtitleList, track); + desc = subtitle_get_track_description(subsource, subsettings); + srt = ghb_dict_get(subsettings, "SRT"); + force = ghb_dict_get_bool(subsettings, "Forced"); + burn = ghb_dict_get_bool(subsettings, "Burn"); + def = ghb_dict_get_bool(subsettings, "Default"); if (count + search > 1) XPRINT("\t"); if (srt == NULL) { - XPRINT("<small>%s%s%s%s</small>\n", track, + XPRINT("<small>%s%s%s%s</small>\n", desc, force ? _(" (Forced Only)") : "", burn ? _(" (Burn)") : "", def ? _(" (Default)") : "" @@ -679,8 +747,9 @@ add_to_queue_list(signal_user_data_t *ud, GhbValue *queueDict, GtkTreeIter *pite int offset = ghb_dict_get_int(subsettings, "Offset"); XPRINT(_("<small> %s, Offset (ms) %d%s</small>\n"), - track, offset, def ? " (Default)" : ""); + desc, offset, def ? " (Default)" : ""); } + g_free(desc); } // Remove the final newline in the string @@ -1123,12 +1192,16 @@ queue_add(signal_user_data_t *ud, GhbValue *settings, gint batch) ghb_finalize_job(settings); - GhbValue *queueDict = ghb_dict_new(); - GhbValue *uiDict = ghb_value_dup(settings); + GhbValue *jobDict = ghb_get_job_settings(settings); + GhbValue *sourceDict = ghb_get_job_source_settings(settings); + GhbValue *queueDict = ghb_dict_new(); + GhbValue *uiDict = ghb_value_dup(settings); ghb_dict_remove(uiDict, "Job"); + int title_id = ghb_dict_get_int(sourceDict, "Title"); + GhbValue *titleDict = ghb_get_title_dict(title_id); ghb_dict_set(queueDict, "uiSettings", uiDict); - ghb_dict_set(queueDict, "Job", - ghb_value_dup(ghb_dict_get(settings, "Job"))); + ghb_dict_set(queueDict, "Job", ghb_value_dup(jobDict)); + ghb_dict_set(queueDict, "Title", titleDict); // Copy current prefs into settings // The job should run with the preferences that existed @@ -1426,7 +1499,7 @@ add_multiple_titles(signal_user_data_t *ud) settings = ghb_array_get(ud->settings_array, ii); if (ghb_dict_get_bool(settings, "title_selected")) { - queue_add(ud, settings, ii); + queue_add(ud, settings, 1); } } } diff --git a/gtk/src/settings.c b/gtk/src/settings.c index 876a94aaa..f8733ceb1 100644 --- a/gtk/src/settings.c +++ b/gtk/src/settings.c @@ -60,6 +60,27 @@ ghb_settings_combo_option(const GhbValue *settings, const gchar *key) return ghb_lookup_combo_option(key, ghb_dict_get_value(settings, key)); } +GhbValue *ghb_get_title_settings(GhbValue *settings) +{ + GhbValue *title; + title = ghb_dict_get(settings, "Title"); + return title; +} + +GhbValue *ghb_get_title_audio_list(GhbValue *settings) +{ + GhbValue *title_dict = ghb_get_title_settings(settings); + GhbValue *audio_list = ghb_dict_get(title_dict, "AudioList"); + return audio_list; +} + +GhbValue *ghb_get_title_subtitle_list(GhbValue *settings) +{ + GhbValue *title_dict = ghb_get_title_settings(settings); + GhbValue *subtitle_list = ghb_dict_get(title_dict, "SubtitleList"); + return subtitle_list; +} + GhbValue *ghb_get_job_settings(GhbValue *settings) { GhbValue *job; diff --git a/gtk/src/settings.h b/gtk/src/settings.h index 5548fe4b2..f1d59f2f6 100644 --- a/gtk/src/settings.h +++ b/gtk/src/settings.h @@ -87,7 +87,11 @@ enum GHB_QUEUE_DONE, }; -GhbValue *ghb_get_job_settings(GhbValue *settings); +GhbValue* ghb_get_title_settings(GhbValue *settings); +GhbValue* ghb_get_title_audio_list(GhbValue *settings); +GhbValue* ghb_get_title_subtitle_list(GhbValue *settings); + +GhbValue* ghb_get_job_settings(GhbValue *settings); GhbValue* ghb_get_job_source_settings(GhbValue *settings); GhbValue* ghb_get_job_range_settings(GhbValue *settings); GhbValue* ghb_get_job_par_settings(GhbValue *settings); @@ -96,11 +100,11 @@ GhbValue* ghb_get_job_video_settings(GhbValue *settings); GhbValue* ghb_get_job_metadata_settings(GhbValue *settings); GhbValue* ghb_get_job_chapter_list(GhbValue *settings); GhbValue* ghb_get_job_mp4_settings(GhbValue *settings); -GhbValue *ghb_get_job_audio_settings(GhbValue *settings); -GhbValue *ghb_get_job_audio_list(GhbValue *settings); -GhbValue *ghb_get_job_subtitle_settings(GhbValue *settings); -GhbValue *ghb_get_job_subtitle_list(GhbValue *settings); -GhbValue *ghb_get_job_subtitle_search(GhbValue *settings); +GhbValue* ghb_get_job_audio_settings(GhbValue *settings); +GhbValue* ghb_get_job_audio_list(GhbValue *settings); +GhbValue* ghb_get_job_subtitle_settings(GhbValue *settings); +GhbValue* ghb_get_job_subtitle_list(GhbValue *settings); +GhbValue* ghb_get_job_subtitle_search(GhbValue *settings); GhbValue* ghb_get_job_filter_settings(GhbValue *settings); GhbValue* ghb_get_job_filter_list(GhbValue *settings); diff --git a/gtk/src/subtitlehandler.c b/gtk/src/subtitlehandler.c index c012d4a65..ba68bf9d9 100644 --- a/gtk/src/subtitlehandler.c +++ b/gtk/src/subtitlehandler.c @@ -34,8 +34,8 @@ #include "audiohandler.h" #include "subtitlehandler.h" -static void subtitle_set_track_description(GhbValue *settings, - GhbValue *subsettings); +static char * subtitle_get_track_description(GhbValue *settings, + GhbValue *subsettings); static void subtitle_list_refresh_selected(signal_user_data_t *ud, GhbValue *subsettings); static void subtitle_add_to_settings(GhbValue *settings, GhbValue *subsettings); @@ -79,7 +79,7 @@ subtitle_refresh_list_row_ui( gboolean forced, burned, def; char *info_src, *info_src_2; char *info_dst, *info_dst_2; - const char *desc; + char *desc; info_src_2 = NULL; @@ -88,13 +88,9 @@ subtitle_refresh_list_row_ui( forced = ghb_dict_get_bool(subsettings, "Forced"); burned = ghb_dict_get_bool(subsettings, "Burn"); def = ghb_dict_get_bool(subsettings, "Default"); - desc = ghb_dict_get_string(subsettings, "Description"); - if (desc == NULL) - { - subtitle_set_track_description(settings, subsettings); - desc = ghb_dict_get_string(subsettings, "Description"); - } + desc = subtitle_get_track_description(settings, subsettings); info_src = g_strdup_printf("<small>%s</small>", desc); + g_free(desc); if (ghb_dict_get(subsettings, "SRT") != NULL) { gint offset; @@ -330,8 +326,8 @@ subtitle_add_to_settings(GhbValue *settings, GhbValue *subsettings) subtitle_exclusive_default_settings(settings, count-1); } -static void -subtitle_set_track_description(GhbValue *settings, GhbValue *subsettings) +static char * +subtitle_get_track_description(GhbValue *settings, GhbValue *subsettings) { GhbValue *srt; char *desc = NULL; @@ -397,34 +393,9 @@ subtitle_set_track_description(GhbValue *settings, GhbValue *subsettings) } } - if (desc != NULL) - { - ghb_dict_set_string(subsettings, "Description", desc); - } - else - { - ghb_dict_set_string(subsettings, "Description", "Error!"); - } - - g_free(desc); + return desc; } -void ghb_sanitize_subtitle_track_settings(GhbValue *settings) -{ - int ii; - GhbValue *slist = ghb_get_job_subtitle_list(settings); - int count = ghb_array_len(slist); - - GhbValue *subtitle_search = ghb_get_job_subtitle_search(settings); - subtitle_set_track_description(settings, subtitle_search); - for (ii = 0; ii < count; ii++) - { - GhbValue *subsettings = ghb_array_get(slist, ii); - subtitle_set_track_description(settings, subsettings); - } -} - - static GhbValue* subtitle_add_track( signal_user_data_t *ud, GhbValue *settings, @@ -491,8 +462,6 @@ static GhbValue* subtitle_add_track( *burned = TRUE; } - subtitle_set_track_description(settings, subsettings); - subtitle_add_to_settings(settings, subsettings); return subsettings; @@ -749,7 +718,6 @@ subtitle_update_setting(GhbValue *val, const char *name, signal_user_data_t *ud) if (subsettings != NULL) { ghb_dict_set(subsettings, name, val); - subtitle_set_track_description(ud->settings, subsettings); subtitle_list_refresh_selected(ud, subsettings); ghb_live_reset(ud); } @@ -768,7 +736,6 @@ subtitle_track_changed_cb(GtkWidget *widget, signal_user_data_t *ud) "Track", ud); if (subsettings != NULL) { - subtitle_set_track_description(ud->settings, subsettings); subtitle_update_dialog_widgets(ud, subsettings); } } @@ -850,7 +817,6 @@ subtitle_srt_radio_toggled_cb(GtkWidget *widget, signal_user_data_t *ud) { ghb_dict_remove(subsettings, "SRT"); } - subtitle_set_track_description(ud->settings, subsettings); subtitle_update_dialog_widgets(ud, subsettings); subtitle_list_refresh_selected(ud, subsettings); ghb_live_reset(ud); @@ -891,7 +857,6 @@ srt_setting_update(GhbValue *val, const char *name, signal_user_data_t *ud) if (srt != NULL) { ghb_dict_set(srt, name, val); - subtitle_set_track_description(ud->settings, subsettings); subtitle_list_refresh_selected(ud, subsettings); ghb_live_reset(ud); } @@ -1144,8 +1109,6 @@ subtitle_add_fas_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) ghb_dict_set_bool(subtitle_search, "Default", 1); ghb_dict_set_bool(subtitle_search, "Burn", 0); - subtitle_set_track_description(ud->settings, subtitle_search); - GtkTreeView *tv; GtkTreeIter ti; GtkTreeModel *tm; diff --git a/gtk/src/subtitlehandler.h b/gtk/src/subtitlehandler.h index 7f723a024..7c6e84b00 100644 --- a/gtk/src/subtitlehandler.h +++ b/gtk/src/subtitlehandler.h @@ -36,7 +36,6 @@ void ghb_subtitle_defaults_to_ui(signal_user_data_t *ud); void ghb_subtitle_title_change(signal_user_data_t *ud, gboolean show); void ghb_subtitle_set_pref_lang(GhbValue *settings); void ghb_clear_subtitle_selection(GtkBuilder *builder); -void ghb_sanitize_subtitle_track_settings(GhbValue *settings); GhbValue *ghb_get_subtitle_list(GhbValue *settings); GhbValue *ghb_get_subtitle_settings(GhbValue *settings); |