summaryrefslogtreecommitdiffstats
path: root/gtk
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2009-06-22 20:25:15 +0000
committerjstebbins <[email protected]>2009-06-22 20:25:15 +0000
commit55394d4229f9fbcde3841f5b3d91467cbd10d7f5 (patch)
tree84ba60491e5d5754d2d8e6032fdccab7846c6928 /gtk
parent5f1d29efe1d78d2019899619440250e5e760d614 (diff)
LinGui: add audio-dub/add-subtitle radio buttons for preferred language control
- When Audio DUB is enabled, behavior is essentially unchanged - When Add Subtitle is enabled, a subtitle of the preferred language will be added to the subtitle list when the preferred language does not match the first audio track. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2600 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'gtk')
-rw-r--r--gtk/src/audiohandler.c24
-rw-r--r--gtk/src/audiohandler.h2
-rw-r--r--gtk/src/callbacks.c4
-rw-r--r--gtk/src/ghb.ui92
-rw-r--r--gtk/src/hb-backend.c26
-rw-r--r--gtk/src/hb-backend.h1
-rw-r--r--gtk/src/internal_defaults.xml2
-rw-r--r--gtk/src/main.c6
-rw-r--r--gtk/src/subtitlehandler.c79
9 files changed, 200 insertions, 36 deletions
diff --git a/gtk/src/audiohandler.c b/gtk/src/audiohandler.c
index 176f7d9cf..29700ca5d 100644
--- a/gtk/src/audiohandler.c
+++ b/gtk/src/audiohandler.c
@@ -89,11 +89,26 @@ free_audio_index_list(gpointer data)
g_free(data);
}
+gchar*
+ghb_get_user_audio_lang(signal_user_data_t *ud, gint titleindex, gint track)
+{
+ GValue *audio_list, *asettings;
+ gchar *lang = NULL;
+
+ audio_list = ghb_settings_get_value(ud->settings, "audio_list");
+ if (ghb_array_len(audio_list) <= track)
+ return NULL;
+ asettings = ghb_array_get_nth(audio_list, track);
+ track = ghb_settings_get_int(asettings, "AudioTrack");
+ lang = ghb_get_source_audio_lang(titleindex, track);
+ return lang;
+}
+
void
ghb_set_pref_audio(gint titleindex, signal_user_data_t *ud)
{
gint acodec_code, mix_code, track;
- gchar *source_lang;
+ gchar *source_lang = NULL;
GtkWidget *button;
ghb_audio_info_t ainfo;
GHashTable *track_indices;
@@ -109,7 +124,12 @@ ghb_set_pref_audio(gint titleindex, signal_user_data_t *ud)
ghb_clear_audio_list(ud);
// Find "best" audio based on audio preferences
button = GHB_WIDGET (ud->builder, "audio_add");
- source_lang = ghb_settings_get_string(ud->settings, "SourceAudioLang");
+ if (!ghb_settings_get_boolean(ud->settings, "AudioDUB"))
+ {
+ source_lang = ghb_get_source_audio_lang(titleindex, 0);
+ }
+ if (source_lang == NULL)
+ source_lang = ghb_settings_get_string(ud->settings, "SourceAudioLang");
pref_audio = ghb_settings_get_value(ud->settings, "AudioList");
diff --git a/gtk/src/audiohandler.h b/gtk/src/audiohandler.h
index 727a98bb3..b064ab2a3 100644
--- a/gtk/src/audiohandler.h
+++ b/gtk/src/audiohandler.h
@@ -31,5 +31,7 @@ void ghb_adjust_audio_rate_combos(signal_user_data_t *ud);
void ghb_set_pref_audio(gint titleindex, signal_user_data_t *ud);
void ghb_clear_audio_list(signal_user_data_t *ud);
void ghb_set_audio(signal_user_data_t *ud, GValue *settings);
+gchar* ghb_get_user_audio_lang(
+ signal_user_data_t *ud, gint titleindex, gint track);
#endif // _AUDIOHANDLER_H_
diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c
index b768fabb0..0267d2ef8 100644
--- a/gtk/src/callbacks.c
+++ b/gtk/src/callbacks.c
@@ -1338,7 +1338,6 @@ title_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
ghb_update_ui_combo_box (ud, "AudioTrack", titleindex, FALSE);
ghb_update_ui_combo_box (ud, "SubtitleTrack", titleindex, FALSE);
- ghb_set_pref_subtitle(titleindex, ud);
if (ghb_get_title_info (&tinfo, titleindex))
{
show_title_info(ud, &tinfo);
@@ -1346,6 +1345,7 @@ title_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
update_chapter_list (ud);
ghb_adjust_audio_rate_combos(ud);
ghb_set_pref_audio(titleindex, ud);
+ ghb_set_pref_subtitle(titleindex, ud);
if (ghb_settings_get_boolean(ud->settings, "vquality_type_target"))
{
gint bitrate = ghb_calculate_target_bitrate (ud->settings, titleindex);
@@ -2551,7 +2551,7 @@ ghb_log(gchar *log, ...)
_now = time(NULL);
now = localtime( &_now );
- snprintf(fmt, 362, "[%02d:%02d:%02d] lingui: %s\n",
+ snprintf(fmt, 362, "[%02d:%02d:%02d] gtkgui: %s\n",
now->tm_hour, now->tm_min, now->tm_sec, log);
va_start(args, log);
vfprintf(stderr, fmt, args);
diff --git a/gtk/src/ghb.ui b/gtk/src/ghb.ui
index 428e388f2..1627fb3fa 100644
--- a/gtk/src/ghb.ui
+++ b/gtk/src/ghb.ui
@@ -2159,55 +2159,93 @@ audio-volume-medium</property>
<object class="GtkHBox" id="hbox63">
<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="spacing">5</property>
+ <property name="spacing">4</property>
<child>
- <object class="GtkFrame" id="frame18">
+ <object class="GtkAlignment" id="alignment61">
<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_xalign">0</property>
- <property name="shadow_type">none</property>
+ <property name="left_padding">12</property>
+ <property name="right_padding">2</property>
+ <property name="yscale">0</property>
<child>
- <object class="GtkAlignment" id="alignment57">
+ <object class="GtkHBox" id="hbox81">
<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="xalign">0</property>
- <property name="xscale">0</property>
- <property name="top_padding">6</property>
- <property name="bottom_padding">2</property>
- <property name="left_padding">12</property>
- <property name="right_padding">2</property>
+ <property name="spacing">4</property>
+
<child>
- <object class="GtkHBox" id="hbox64">
+ <object class="GtkLabel" id="label87">
<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="spacing">5</property>
+ <property name="label" translatable="yes">Preferred Language:</property>
+ <property name="use_markup">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ </packing>
+ </child>
- <child>
- <object class="GtkComboBox" id="SourceAudioLang">
- <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="setting_widget_changed_cb" name="changed"/>
- </object>
- </child>
+ <child>
+ <object class="GtkComboBox" id="SourceAudioLang">
+ <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="setting_widget_changed_cb" name="changed"/>
</object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
</child>
</object>
</child>
- <child type="label">
- <object class="GtkLabel" id="label87">
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVBox" id="vbox49">
+ <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>
+ <child>
+ <object class="GtkRadioButton" id="AudioDUB">
<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">&lt;b&gt;Preferred Audio Language&lt;/b&gt;</property>
- <property name="use_markup">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">DUB Audio</property>
+ <property name="tooltip-text" translatable="yes">DUB Audio of foreign language films with "Preferred Language"</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="setting_widget_changed_cb"/>
</object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="not_dub_audio">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Add Subtitles</property>
+ <property name="tooltip-text" translatable="yes">Add "Preferred Language" subtitles to foreign language films</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">AudioDUB</property>
+ <signal name="toggled" handler="setting_widget_changed_cb"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
- <property name="position">3</property>
+ <property name="position">2</property>
</packing>
</child>
</object>
diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c
index 7dc568af7..f15fe0081 100644
--- a/gtk/src/hb-backend.c
+++ b/gtk/src/hb-backend.c
@@ -1817,6 +1817,32 @@ ghb_longest_title()
return titleindex;
}
+gchar*
+ghb_get_source_audio_lang(gint titleindex, gint track)
+{
+ hb_list_t * list;
+ hb_title_t * title;
+ hb_audio_config_t * audio;
+ gchar *lang = NULL;
+
+ g_debug("ghb_lookup_1st_audio_lang ()\n");
+ if (h_scan == NULL)
+ return NULL;
+ list = hb_get_titles( h_scan );
+ title = (hb_title_t*)hb_list_item( list, titleindex );
+ if (title == NULL)
+ return NULL;
+ if (hb_list_count( title->list_audio ) <= track)
+ return NULL;
+
+ audio = hb_list_audio_config_item(title->list_audio, track);
+ if (audio == NULL)
+ return NULL;
+
+ lang = g_strdup(audio->lang.iso639_2);
+ return lang;
+}
+
gint
ghb_find_audio_track(
gint titleindex,
diff --git a/gtk/src/hb-backend.h b/gtk/src/hb-backend.h
index 23d09639a..f46b64175 100644
--- a/gtk/src/hb-backend.h
+++ b/gtk/src/hb-backend.h
@@ -137,6 +137,7 @@ void ghb_set_default_bitrate_opts(GtkBuilder *builder, gint last_rate);
void ghb_grey_combo_options(GtkBuilder *builder);
void ghb_update_ui_combo_box(
signal_user_data_t *ud, const gchar *name, gint user_data, gboolean all);
+gchar* ghb_get_source_audio_lang(gint titleindex, gint track);
gint ghb_find_audio_track(
gint titleindex, const gchar *lang, gint acodec, GHashTable *track_indices);
void ghb_add_all_subtitles(signal_user_data_t *ud, gint titleindex);
diff --git a/gtk/src/internal_defaults.xml b/gtk/src/internal_defaults.xml
index c68874dc2..e49f5b7a7 100644
--- a/gtk/src/internal_defaults.xml
+++ b/gtk/src/internal_defaults.xml
@@ -268,6 +268,8 @@
<string>Name Missing</string>
<key>Type</key>
<integer>1</integer>
+ <key>AudioDUB</key>
+ <false />
<key>SourceAudioLang</key>
<string>und</string>
<key>SubtitleList</key>
diff --git a/gtk/src/main.c b/gtk/src/main.c
index edd5fecf1..2a3ee18f8 100644
--- a/gtk/src/main.c
+++ b/gtk/src/main.c
@@ -349,23 +349,25 @@ bind_audio_tree_model (signal_user_data_t *ud)
column = gtk_tree_view_column_new_with_attributes(
_("Codec"), cell, "text", 1, NULL);
gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column));
+ gtk_tree_view_column_set_min_width (column, 130);
cell = gtk_cell_renderer_text_new();
column = gtk_tree_view_column_new_with_attributes(
_("Bitrate"), cell, "text", 2, NULL);
gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column));
+ gtk_tree_view_column_set_min_width (column, 60);
cell = gtk_cell_renderer_text_new();
column = gtk_tree_view_column_new_with_attributes(
_("Sample Rate"), cell, "text", 3, NULL);
gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column));
- gtk_tree_view_column_set_min_width (column, 120);
+ gtk_tree_view_column_set_min_width (column, 130);
cell = gtk_cell_renderer_text_new();
column = gtk_tree_view_column_new_with_attributes(
_("Mix"), cell, "text", 4, NULL);
gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column));
- gtk_tree_view_column_set_min_width (column, 120);
+ gtk_tree_view_column_set_min_width (column, 140);
cell = gtk_cell_renderer_text_new();
column = gtk_tree_view_column_new_with_attributes(
diff --git a/gtk/src/subtitlehandler.c b/gtk/src/subtitlehandler.c
index c5d44eb12..fd7c52c6b 100644
--- a/gtk/src/subtitlehandler.c
+++ b/gtk/src/subtitlehandler.c
@@ -19,6 +19,7 @@
#include "callbacks.h"
#include "preview.h"
#include "presets.h"
+#include "audiohandler.h"
#include "subtitlehandler.h"
static void add_to_subtitle_list(signal_user_data_t *ud, GValue *settings);
@@ -180,13 +181,32 @@ ghb_set_pref_subtitle(gint titleindex, signal_user_data_t *ud)
{
gint track;
GHashTable *track_indices;
- char *lang;
+ gchar *lang, *pref_lang = NULL;
+ gchar *audio_lang;
+ gint foreign_lang_index = -1;
const GValue *pref_subtitle;
GValue *subtitle;
- gint count, ii;
+ gint count, ii, jj;
g_debug("ghb_set_pref_subtitle %d", titleindex);
+
+ // Check to see if we need to add a subtitle track for foreign audio
+ // language films. A subtitle track will be added if:
+ //
+ // The first (default) audio track language does NOT match the users
+ // chosen Preferred Language AND the Preferred Language is NOT Any (und).
+ //
+ audio_lang = ghb_get_user_audio_lang(ud, titleindex, 0);
+ pref_lang = ghb_settings_get_string(ud->settings, "SourceAudioLang");
+
+ if (audio_lang != NULL && pref_lang != NULL &&
+ (strcmp(audio_lang, pref_lang) == 0 || strcmp("und", pref_lang) == 0))
+ {
+ g_free(pref_lang);
+ pref_lang = NULL;
+ }
+
track_indices = g_hash_table_new_full(g_str_hash, g_str_equal,
free_subtitle_key, free_subtitle_index_list);
@@ -204,6 +224,7 @@ ghb_set_pref_subtitle(gint titleindex, signal_user_data_t *ud)
pref_subtitle = ghb_settings_get_value(ud->settings, "SubtitleList");
count = ghb_array_len(pref_subtitle);
+ jj = 0;
for (ii = 0; ii < count; ii++)
{
subtitle = ghb_array_get_nth(pref_subtitle, ii);
@@ -212,14 +233,66 @@ ghb_set_pref_subtitle(gint titleindex, signal_user_data_t *ud)
// select sequential tracks for each. The hash keeps track
// of the tracks used for each language.
track = ghb_find_subtitle_track(titleindex, lang, track_indices);
- g_free(lang);
if (track >= -1)
{
GValue *dup = ghb_value_dup(subtitle);
ghb_settings_set_int(dup, "SubtitleTrack", track);
+ if (foreign_lang_index < 0 && pref_lang != NULL &&
+ strcmp(lang, pref_lang) == 0)
+ {
+ foreign_lang_index = jj;
+ ghb_settings_take_value(dup, "SubtitleForced",
+ ghb_boolean_value_new(FALSE));
+ ghb_settings_take_value(dup, "SubtitleDefaultTrack",
+ ghb_boolean_value_new(TRUE));
+ }
ghb_add_subtitle(ud, dup);
+ jj++;
+ }
+ g_free(lang);
+ }
+ if (foreign_lang_index < 0 && pref_lang != NULL)
+ {
+ GValue *settings;
+ gboolean burn;
+
+ track = ghb_find_subtitle_track(titleindex, pref_lang, track_indices);
+ if (track >= -1)
+ {
+ burn = mustBurn(ud, track);
+ settings = ghb_dict_value_new();
+ ghb_settings_set_int(settings, "SubtitleTrack", track);
+ ghb_settings_take_value(settings, "SubtitleForced",
+ ghb_boolean_value_new(FALSE));
+ ghb_settings_take_value(settings, "SubtitleBurned",
+ ghb_boolean_value_new(burn));
+ ghb_settings_take_value(settings, "SubtitleDefaultTrack",
+ ghb_boolean_value_new(TRUE));
+
+ ghb_add_subtitle(ud, settings);
+ foreign_lang_index = jj;
}
}
+ if (foreign_lang_index >= 0)
+ {
+ GValue *subtitle_list;
+ gboolean burn, def;
+
+ subtitle_list = ghb_settings_get_value(ud->settings, "subtitle_list");
+ subtitle = ghb_array_get_nth(subtitle_list, foreign_lang_index);
+
+ burn = ghb_settings_get_boolean(subtitle, "SubtitleBurned");
+ def = ghb_settings_get_boolean(subtitle, "SubtitleDefaultTrack");
+ if (burn)
+ ghb_subtitle_exclusive_burn(ud, foreign_lang_index);
+ if (def)
+ ghb_subtitle_exclusive_default(ud, foreign_lang_index);
+ ghb_log("adding subtitle for foreign language audio: %s", audio_lang);
+ }
+ if (pref_lang != NULL)
+ g_free(pref_lang);
+ if (audio_lang != NULL)
+ g_free(audio_lang);
g_hash_table_destroy(track_indices);
}