summaryrefslogtreecommitdiffstats
path: root/gtk
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2009-05-19 22:27:11 +0000
committerjstebbins <[email protected]>2009-05-19 22:27:11 +0000
commit0ac869507784e807357b06b61fbb4b69f4191278 (patch)
treea02e240d25553da68c349850db28472b7b16b3e9 /gtk
parent568bd4e88feaee724e71cc8cd5bd9e93dd549de0 (diff)
mkv soft subtitle support
- new libmkv 0.6.4 with subtitle track support - muxmkv supports vobsub and closed caption subtitles - added subtitle format, source, and dest initialization to dvdnav - moved subtitle_force flag into hb_subtitle_t struct as it needs to be settable per subtitle - gtk ui added subtitle tab which allows selection of multiple subtitles - reorgainize subtitle sync code to prevent dropping of subtitles when multiple subtitles are enabled git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2428 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'gtk')
-rw-r--r--gtk/src/Makefile.am2
-rw-r--r--gtk/src/callbacks.c10
-rw-r--r--gtk/src/ghb.ui178
-rw-r--r--gtk/src/hb-backend.c472
-rw-r--r--gtk/src/hb-backend.h19
-rw-r--r--gtk/src/internal_defaults.xml18
-rw-r--r--gtk/src/main.c64
-rw-r--r--gtk/src/presets.c139
-rw-r--r--gtk/src/queuehandler.c4
-rw-r--r--gtk/src/settings.c6
-rw-r--r--gtk/src/settings.h1
11 files changed, 721 insertions, 192 deletions
diff --git a/gtk/src/Makefile.am b/gtk/src/Makefile.am
index 71b3ac363..b435cd1c2 100644
--- a/gtk/src/Makefile.am
+++ b/gtk/src/Makefile.am
@@ -68,6 +68,8 @@ ghb_SOURCES = \
queuehandler.h \
audiohandler.c \
audiohandler.h \
+ subtitlehandler.c \
+ subtitlehandler.h \
x264handler.c \
x264handler.h \
main.c \
diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c
index f2d964290..e2140d7d5 100644
--- a/gtk/src/callbacks.c
+++ b/gtk/src/callbacks.c
@@ -44,6 +44,7 @@
#include "callbacks.h"
#include "queuehandler.h"
#include "audiohandler.h"
+#include "subtitlehandler.h"
#include "resources.h"
#include "settings.h"
#include "presets.h"
@@ -1118,6 +1119,7 @@ container_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
}
g_free(container);
}
+ ghb_subtitle_adjust_burn(ud);
}
static gchar*
@@ -1254,10 +1256,10 @@ title_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
ghb_check_dependency(ud, widget);
titleindex = ghb_settings_combo_int(ud->settings, "title");
- ghb_update_ui_combo_box (ud->builder, "AudioTrack", titleindex, FALSE);
- ghb_update_ui_combo_box (ud->builder, "Subtitles", titleindex, FALSE);
+ ghb_update_ui_combo_box (ud, "AudioTrack", titleindex, FALSE);
+ ghb_update_ui_combo_box (ud, "SubtitleTrack", titleindex, FALSE);
- ghb_update_from_preset(ud, "Subtitles");
+ ghb_set_pref_subtitle(titleindex, ud);
if (ghb_get_title_info (&tinfo, titleindex))
{
show_title_info(ud, &tinfo);
@@ -2019,7 +2021,7 @@ ghb_backend_events(signal_user_data_t *ud)
ghb_title_info_t tinfo;
- ghb_update_ui_combo_box(ud->builder, "title", 0, FALSE);
+ ghb_update_ui_combo_box(ud, "title", 0, FALSE);
titleindex = ghb_longest_title();
ghb_ui_update(ud, "title", ghb_int64_value(titleindex));
diff --git a/gtk/src/ghb.ui b/gtk/src/ghb.ui
index 8d52e299b..57a941f7e 100644
--- a/gtk/src/ghb.ui
+++ b/gtk/src/ghb.ui
@@ -2153,7 +2153,7 @@
</object>
</child>
<child type="label">
- <object class="GtkLabel" id="label74">
+ <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="label" translatable="yes">&lt;b&gt;Preferred Audio Language&lt;/b&gt;</property>
@@ -2162,80 +2162,164 @@
</child>
</object>
</child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="label48">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Audio</property>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVBox" id="subtitle_tab">
+ <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="GtkFrame" id="frame20">
+ <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>
<child>
- <object class="GtkFrame" id="frame19">
+ <object class="GtkAlignment" id="alignment23">
<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="top_padding">6</property>
+ <property name="bottom_padding">2</property>
+ <property name="left_padding">12</property>
+ <property name="right_padding">2</property>
<child>
- <object class="GtkAlignment" id="alignment58">
+ <object class="GtkVBox" id="vbox12">
<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="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">2</property>
<child>
- <object class="GtkHBox" id="hbox65">
+ <object class="GtkHBox" id="hbox45">
<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>
-
<child>
- <object class="GtkComboBox" id="Subtitles">
- <property name="width_request">150</property>
+ <object class="GtkButton" id="subtitle_add">
<property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <signal handler="subtitle_changed_cb" name="changed"/>
+ <property name="tooltip-text" translatable="yes">Add new audio settings to the list</property>
+ <property name="relief">GTK_RELIEF_NONE</property>
+ <signal handler="subtitle_add_clicked_cb" name="clicked"/>
+ <child>
+ <object class="GtkImage" id="image9">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="stock">gtk-add</property>
+ </object>
+ </child>
</object>
+ <packing>
+ <property name="expand">False</property>
+ </packing>
</child>
<child>
- <object class="GtkCheckButton" id="SubtitlesForced">
+ <object class="GtkButton" id="subtitle_remove">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="has_tooltip">True</property>
- <property name="tooltip-text" translatable="yes">These are subtitles that a regular DVD player would automatically show.</property>
- <property name="label" translatable="yes">Allow only forced subtitles</property>
- <property name="draw_indicator">True</property>
- <signal handler="setting_widget_changed_cb" name="toggled"/>
+ <property name="receives_default">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="tooltip-text" translatable="yes">Remove the selected audio settings</property>
+ <property name="relief">GTK_RELIEF_NONE</property>
+ <signal handler="subtitle_remove_clicked_cb" name="clicked"/>
+ <child>
+ <object class="GtkImage" id="image2">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="stock">gtk-remove</property>
+ </object>
+ </child>
</object>
<packing>
+ <property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
+ <child>
+ <object class="GtkAlignment" id="alignment44">
+ <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">1</property>
+ <property name="xscale">0</property>
+ <property name="yscale">0</property>
+ <child>
+ <object class="GtkHBox" id="hbox21">
+ <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>
+ <child>
+ <object class="GtkLabel" id="label24">
+ <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">Subtitle:</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="SubtitleTrack">
+ <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="subtitle_track_changed_cb" name="changed"/>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ <property name="expand">False</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
</object>
+ <packing>
+ <property name="expand">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkTreeView" id="subtitle_list">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="headers_clickable">True</property>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
</child>
- </object>
- </child>
- <child type="label">
- <object class="GtkLabel" id="label75">
- <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;Subtitles&lt;/b&gt;</property>
- <property name="use_markup">True</property>
</object>
</child>
</object>
- <packing>
- <property name="position">1</property>
- </packing>
</child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="position">3</property>
- </packing>
</child>
</object>
</child>
<child type="tab">
- <object class="GtkLabel" id="label48">
+ <object class="GtkLabel" id="label9">
<property name="visible">True</property>
- <property name="label" translatable="yes">Audio/Subtitles</property>
+ <property name="label" translatable="yes">Subtitles</property>
</object>
<packing>
- <property name="position">2</property>
+ <property name="position">3</property>
<property name="tab_fill">False</property>
</packing>
</child>
@@ -3053,7 +3137,7 @@ no-dct-decimate=0:cabac=1</property>
<property name="label" translatable="yes">H.264</property>
</object>
<packing>
- <property name="position">3</property>
+ <property name="position">4</property>
<property name="tab_fill">False</property>
</packing>
</child>
@@ -3118,7 +3202,7 @@ no-dct-decimate=0:cabac=1</property>
<property name="label" translatable="yes">Chapters</property>
</object>
<packing>
- <property name="position">4</property>
+ <property name="position">5</property>
<property name="tab_fill">False</property>
</packing>
</child>
@@ -4597,7 +4681,7 @@ the required multiple.</property>
</object>
</child>
<child type="label">
- <object class="GtkLabel" id="label29">
+ <object class="GtkLabel" id="label25">
<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;Storage&lt;/b&gt;</property>
@@ -4862,7 +4946,7 @@ the required multiple.</property>
</packing>
</child>
<child>
- <object class="GtkAlignment" id="alignment2">
+ <object class="GtkAlignment" id="alignment27">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="xscale">0</property>
@@ -4875,7 +4959,7 @@ the required multiple.</property>
<property name="column_spacing">5</property>
<child>
- <object class="GtkLabel" id="label56">
+ <object class="GtkLabel" id="label41">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Deblock:</property>
@@ -4974,7 +5058,7 @@ the required multiple.</property>
<property name="column_spacing">5</property>
<child>
- <object class="GtkLabel" id="label56">
+ <object class="GtkLabel" id="label86">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Detelecine:</property>
@@ -5627,7 +5711,7 @@ libxvidcore authors:
<property name="visible_window">False</property>
<property name="above_child">True</property>
<child>
- <object class="GtkImage" id="image3">
+ <object class="GtkImage" id="image10">
<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="icon_name">hb-icon</property>
@@ -5685,7 +5769,7 @@ libxvidcore authors:
<property name="label_xalign">0</property>
<property name="shadow_type">etched-out</property>
<child>
- <object class="GtkAlignment" id="alignment2">
+ <object class="GtkAlignment" id="alignment28">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
@@ -5793,7 +5877,7 @@ libxvidcore authors:
</packing>
</child>
<child>
- <object class="GtkAlignment" id="alignment1">
+ <object class="GtkAlignment" id="alignment24">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="xscale">0</property>
diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c
index 0b7633da6..bb30d2c28 100644
--- a/gtk/src/hb-backend.c
+++ b/gtk/src/hb-backend.c
@@ -30,6 +30,7 @@
#include "hb-backend.h"
#include "settings.h"
#include "callbacks.h"
+#include "subtitlehandler.h"
#include "preview.h"
#include "values.h"
#include "lang.h"
@@ -48,20 +49,24 @@ typedef struct
options_map_t *map;
} combo_opts_t;
-static const gchar *index_str[] =
-{
- "0",
- "1",
- "2",
- "3",
- "4",
- "5",
- "6",
- "7",
- "8",
- "9",
- "10",
-};
+static gchar **index_str = NULL;
+static gint index_str_size = 0;
+
+static void
+index_str_init(gint max_index)
+{
+ int ii;
+
+ if (max_index+1 > index_str_size)
+ {
+ index_str = realloc(index_str, (max_index+1) * sizeof(char*));
+ for (ii = index_str_size; ii <= max_index; ii++)
+ {
+ index_str[ii] = g_strdup_printf("%d", ii);
+ }
+ index_str_size = max_index + 1;
+ }
+}
static options_map_t d_par_opts[] =
{
@@ -330,7 +335,7 @@ combo_name_map_t combo_name_map[] =
{"x264_subme", &subme_opts},
{"x264_analyse", &analyse_opts},
{"x264_trellis", &trellis_opts},
- {"Subtitles", &subtitle_opts},
+ {"SubtitleTrack", &subtitle_opts},
{"title", &title_opts},
{"AudioTrack", &audio_track_opts},
{NULL, NULL}
@@ -629,6 +634,26 @@ ghb_vquality_range(
}
}
+static const gchar*
+lookup_generic_string(combo_opts_t *opts, const GValue *gval)
+{
+ gint ii;
+ gchar *str;
+ const gchar *result = "";
+
+ str = ghb_value_string(gval);
+ for (ii = 0; ii < opts->count; ii++)
+ {
+ if (strcmp(opts->map[ii].shortOpt, str) == 0)
+ {
+ result = opts->map[ii].svalue;
+ break;
+ }
+ }
+ g_free(str);
+ return result;
+}
+
static gint
lookup_generic_int(combo_opts_t *opts, const GValue *gval)
{
@@ -964,6 +989,92 @@ ghb_hb_cleanup(gboolean partial)
}
gint
+ghb_subtitle_track_source(signal_user_data_t *ud, gint track)
+{
+ gint titleindex;
+
+ if (track == -2)
+ return CC608SUB;
+ if (track < 0)
+ return VOBSUB;
+ titleindex = ghb_settings_combo_int(ud->settings, "title");
+ if (titleindex < 0)
+ return VOBSUB;
+
+ hb_list_t * list;
+ hb_title_t * title;
+ hb_subtitle_t * sub;
+
+ if (h_scan == NULL) return VOBSUB;
+ list = hb_get_titles( h_scan );
+ if( !hb_list_count( list ) )
+ {
+ /* No valid title, stop right there */
+ return VOBSUB;
+ }
+ title = hb_list_item( list, titleindex );
+ if (title == NULL) return VOBSUB; // Bad titleindex
+ sub = hb_list_item( title->list_subtitle, track);
+ if (sub != NULL)
+ return sub->source;
+ else
+ return VOBSUB;
+}
+
+const char*
+ghb_subtitle_track_source_name(signal_user_data_t *ud, gint track)
+{
+ gint titleindex;
+ const gchar * name = "Unknown";
+
+ if (track == -2)
+ return CC608SUB;
+ if (track < 0)
+ return VOBSUB;
+ if (track < 0)
+ goto done;
+
+ titleindex = ghb_settings_combo_int(ud->settings, "title");
+ if (titleindex < 0)
+ goto done;
+
+ hb_list_t * list;
+ hb_title_t * title;
+ hb_subtitle_t * sub;
+
+ if (h_scan == NULL) return VOBSUB;
+ list = hb_get_titles( h_scan );
+ if( !hb_list_count( list ) )
+ goto done;
+
+ title = hb_list_item( list, titleindex );
+ if (title == NULL)
+ goto done;
+
+ sub = hb_list_item( title->list_subtitle, track);
+ if (sub != NULL)
+ {
+ switch (sub->source)
+ {
+ case VOBSUB:
+ name = "Bitmap";
+ break;
+ case CC708SUB:
+ case CC608SUB:
+ case SRTSUB:
+ name = "Text";
+ break;
+ default:
+ break;
+ }
+ }
+
+done:
+ return name;
+}
+
+
+gint
ghb_get_title_number(gint titleindex)
{
hb_list_t * list;
@@ -1544,6 +1655,7 @@ audio_track_opts_set(GtkBuilder *builder, const gchar *name, gint titleindex)
audio_track_opts.map[0].svalue = "none";
return;
}
+ index_str_init(count-1);
for (ii = 0; ii < count; ii++)
{
audio = (hb_audio_config_t *) hb_list_audio_config_item( title->list_audio, ii );
@@ -1562,20 +1674,18 @@ audio_track_opts_set(GtkBuilder *builder, const gchar *name, gint titleindex)
}
}
-
void
-subtitle_opts_set(GtkBuilder *builder, const gchar *name, gint titleindex)
+subtitle_opts_set(signal_user_data_t *ud, const gchar *name, gint titleindex)
{
GtkTreeIter iter;
GtkListStore *store;
hb_list_t * list = NULL;
hb_title_t * title = NULL;
- hb_subtitle_t * subtitle;
- gint ii;
- gint count = 0;
+ hb_subtitle_t * subtitle;
+ gint ii, count = 0;
g_debug("subtitle_opts_set () %s\n", name);
- store = get_combo_box_store(builder, name);
+ store = get_combo_box_store(ud->builder, name);
gtk_list_store_clear(store);
if (h_scan != NULL)
{
@@ -1590,74 +1700,77 @@ subtitle_opts_set(GtkBuilder *builder, const gchar *name, gint titleindex)
if (subtitle_opts.map) g_free(subtitle_opts.map);
if (count > 0)
{
- subtitle_opts.count = count+2;
- subtitle_opts.map = g_malloc((count+2)*sizeof(options_map_t));
+ subtitle_opts.count = count+1;
+ subtitle_opts.map = g_malloc((count+1)*sizeof(options_map_t));
}
else
{
subtitle_opts.count = LANG_TABLE_SIZE+2;
subtitle_opts.map = g_malloc((LANG_TABLE_SIZE+2)*sizeof(options_map_t));
}
- // Add options for "none" and "autoselect"
- gtk_list_store_append(store, &iter);
- gtk_list_store_set(store, &iter,
- 0, "None",
- 1, TRUE,
- 2, "none",
- 3, -2.0,
- 4, "none",
- -1);
- subtitle_opts.map[0].option = "None";
- subtitle_opts.map[0].shortOpt = "none";
- subtitle_opts.map[0].ivalue = -2;
- subtitle_opts.map[0].svalue = "none";
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter,
0, "Autoselect",
1, TRUE,
- 2, "auto",
+ 2, "-1",
3, -1.0,
4, "auto",
-1);
- subtitle_opts.map[1].option = "Same as audio";
- subtitle_opts.map[1].shortOpt = "auto";
- subtitle_opts.map[1].ivalue = -1;
- subtitle_opts.map[1].svalue = "auto";
+ subtitle_opts.map[0].option = "Same as audio";
+ subtitle_opts.map[0].shortOpt = "-1";
+ subtitle_opts.map[0].ivalue = -1;
+ subtitle_opts.map[0].svalue = "auto";
if (count > 0)
{
+ index_str_init(count-1);
for (ii = 0; ii < count; ii++)
{
subtitle = (hb_subtitle_t *)hb_list_item(title->list_subtitle, ii);
+ // Skip subtitles that must be burned if there is already
+ // a burned subtitle in the list
+ subtitle_opts.map[ii+1].option = subtitle->lang;
+ subtitle_opts.map[ii+1].shortOpt = index_str[ii];
+ subtitle_opts.map[ii+1].ivalue = ii;
+ subtitle_opts.map[ii+1].svalue = subtitle->iso639_2;
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter,
0, subtitle->lang,
1, TRUE,
- 2, subtitle->iso639_2,
+ 2, index_str[ii],
3, (gdouble)ii,
4, subtitle->iso639_2,
-1);
- subtitle_opts.map[ii+2].option = subtitle->lang;
- subtitle_opts.map[ii+2].shortOpt = subtitle->iso639_2;
- subtitle_opts.map[ii+2].ivalue = ii;
- subtitle_opts.map[ii+2].svalue = subtitle->iso639_2;
}
}
else
{
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter,
+ 0, "Closed Captions",
+ 1, TRUE,
+ 2, "-2",
+ 3, -2.0,
+ 4, "und",
+ -1);
+ subtitle_opts.map[1].option = "Closed Captions";
+ subtitle_opts.map[1].shortOpt = "-2";
+ subtitle_opts.map[1].ivalue = -2;
+ subtitle_opts.map[1].svalue = "und";
+ index_str_init(LANG_TABLE_SIZE-1);
for (ii = 0; ii < LANG_TABLE_SIZE; ii++)
{
- gtk_list_store_append(store, &iter);
- gtk_list_store_set(store, &iter,
- 0, ghb_language_table[ii].eng_name,
- 1, TRUE,
- 2, ghb_language_table[ii].iso639_2,
- 3, (gdouble)ii,
- 4, ghb_language_table[ii].iso639_2,
- -1);
subtitle_opts.map[ii+2].option = ghb_language_table[ii].eng_name;
- subtitle_opts.map[ii+2].shortOpt = ghb_language_table[ii].iso639_2;
+ subtitle_opts.map[ii+2].shortOpt = index_str[ii];
subtitle_opts.map[ii+2].ivalue = ii;
subtitle_opts.map[ii+2].svalue = ghb_language_table[ii].iso639_2;
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter,
+ 0, ghb_language_table[ii].eng_name,
+ 1, TRUE,
+ 2, index_str[ii],
+ 3, (gdouble)ii,
+ 4, ghb_language_table[ii].iso639_2,
+ -1);
}
}
}
@@ -1846,6 +1959,96 @@ ghb_find_audio_track(
return track;
}
+gint
+ghb_find_subtitle_track(
+ gint titleindex,
+ const gchar *lang,
+ GHashTable *track_indices)
+{
+ hb_list_t * list;
+ hb_title_t * title;
+ hb_subtitle_t * subtitle;
+ gint ii;
+ gint count = 0;
+ gboolean *used;
+
+ g_debug("find_subtitle_track ()\n");
+ if (strcmp(lang, "auto") == 0)
+ return -1;
+ if (h_scan == NULL) return -1;
+ list = hb_get_titles( h_scan );
+ title = (hb_title_t*)hb_list_item( list, titleindex );
+ if (title != NULL)
+ {
+ count = hb_list_count( title->list_subtitle );
+ used = g_hash_table_lookup(track_indices, lang);
+ if (used == NULL)
+ {
+ used = g_malloc0(count * sizeof(gboolean));
+ g_hash_table_insert(track_indices, g_strdup(lang), used);
+ }
+ // Try to find an item that matches the preferred language
+ for (ii = 0; ii < count; ii++)
+ {
+ if (used[ii])
+ continue;
+
+ subtitle = (hb_subtitle_t*)hb_list_item( title->list_subtitle, ii );
+ if ((strcmp(lang, subtitle->iso639_2) == 0) ||
+ (strcmp(lang, "und") == 0))
+ {
+ used[ii] = TRUE;
+ return ii;
+ }
+ }
+ return -1;
+ }
+ else
+ {
+ count = subtitle_opts.count;
+ for (ii = 0; ii < count; ii++)
+ {
+ if (strcmp(lang, subtitle_opts.map[ii].svalue) == 0)
+ {
+ return subtitle_opts.map[ii].ivalue;
+ }
+ }
+ return -1;
+ }
+}
+
+gint
+ghb_pick_subtitle_track(signal_user_data_t *ud)
+{
+ gint ii, count, track, candidate, first;
+ GValue *settings, *subtitle_list;
+
+ first = candidate = ghb_settings_combo_int(ud->settings, "SubtitleTrack");
+ subtitle_list = ghb_settings_get_value(ud->settings, "subtitle_list");
+ count = ghb_array_len(subtitle_list);
+ for (ii = 0; ii < count; ii++)
+ {
+ settings = ghb_array_get_nth(subtitle_list, ii);
+ track = ghb_settings_combo_int(settings, "SubtitleTrack");
+ if (candidate == track)
+ {
+ // Already in use, pick another
+ candidate++;
+ if (candidate >= subtitle_opts.count)
+ {
+ candidate = 0;
+ }
+ if (candidate == first)
+ {
+ candidate = -1;
+ break;
+ }
+ ii = -1;
+ }
+ }
+ return candidate;
+}
+
static void
generic_opts_set(GtkBuilder *builder, const gchar *name, combo_opts_t *opts)
{
@@ -1888,6 +2091,8 @@ find_combo_table(const gchar *name)
gint
ghb_lookup_combo_int(const gchar *name, const GValue *gval)
{
+ if (gval == NULL)
+ return 0;
if (strcmp(name, "AudioBitrate") == 0)
return lookup_audio_bitrate_int(gval);
else if (strcmp(name, "AudioSamplerate") == 0)
@@ -1909,6 +2114,8 @@ ghb_lookup_combo_int(const gchar *name, const GValue *gval)
gdouble
ghb_lookup_combo_double(const gchar *name, const GValue *gval)
{
+ if (gval == NULL)
+ return 0;
if (strcmp(name, "AudioBitrate") == 0)
return lookup_audio_bitrate_int(gval);
else if (strcmp(name, "AudioSamplerate") == 0)
@@ -1930,6 +2137,8 @@ ghb_lookup_combo_double(const gchar *name, const GValue *gval)
const gchar*
ghb_lookup_combo_option(const gchar *name, const GValue *gval)
{
+ if (gval == NULL)
+ return NULL;
if (strcmp(name, "AudioBitrate") == 0)
return lookup_audio_bitrate_option(gval);
else if (strcmp(name, "AudioSamplerate") == 0)
@@ -1945,11 +2154,38 @@ ghb_lookup_combo_option(const gchar *name, const GValue *gval)
return lookup_generic_option(find_combo_table(name), gval);
}
g_warning("ghb_lookup_combo_int() couldn't find %s", name);
- return 0;
+ return NULL;
+}
+
+const gchar*
+ghb_lookup_combo_string(const gchar *name, const GValue *gval)
+{
+ if (gval == NULL)
+ return NULL;
+ if (strcmp(name, "AudioBitrate") == 0)
+ return lookup_audio_bitrate_option(gval);
+ else if (strcmp(name, "AudioSamplerate") == 0)
+ return lookup_audio_rate_option(gval);
+ else if (strcmp(name, "VideoFramerate") == 0)
+ return lookup_video_rate_option(gval);
+ else if (strcmp(name, "AudioMixdown") == 0)
+ return lookup_mix_option(gval);
+ else if (strcmp(name, "SourceAudioLang") == 0)
+ return lookup_audio_lang_option(gval);
+ else
+ {
+ return lookup_generic_string(find_combo_table(name), gval);
+ }
+ g_warning("ghb_lookup_combo_int() couldn't find %s", name);
+ return NULL;
}
void
-ghb_update_ui_combo_box(GtkBuilder *builder, const gchar *name, gint user_data, gboolean all)
+ghb_update_ui_combo_box(
+ signal_user_data_t *ud,
+ const gchar *name,
+ gint user_data,
+ gboolean all)
{
GtkComboBox *combo = NULL;
gint signal_id;
@@ -1961,7 +2197,7 @@ ghb_update_ui_combo_box(GtkBuilder *builder, const gchar *name, gint user_data,
// Clearing a combo box causes a rash of "changed" events, even when
// the active item is -1 (inactive). To control things, I'm disabling
// the event till things are settled down.
- combo = GTK_COMBO_BOX(GHB_WIDGET(builder, name));
+ combo = GTK_COMBO_BOX(GHB_WIDGET(ud->builder, name));
signal_id = g_signal_lookup("changed", GTK_TYPE_COMBO_BOX);
if (signal_id > 0)
{
@@ -1977,52 +2213,52 @@ ghb_update_ui_combo_box(GtkBuilder *builder, const gchar *name, gint user_data,
}
if (all)
{
- audio_bitrate_opts_set(builder, "AudioBitrate");
- audio_samplerate_opts_set(builder, "AudioSamplerate", hb_audio_rates, hb_audio_rates_count);
- video_rate_opts_set(builder, "VideoFramerate", hb_video_rates, hb_video_rates_count);
- mix_opts_set(builder, "AudioMixdown");
- language_opts_set(builder, "SourceAudioLang");
- subtitle_opts_set(builder, "Subtitles", user_data);
- title_opts_set(builder, "title");
- audio_track_opts_set(builder, "AudioTrack", user_data);
- generic_opts_set(builder, "VideoQualityGranularity", &vqual_granularity_opts);
- generic_opts_set(builder, "PicturePAR", &par_opts);
- generic_opts_set(builder, "PictureModulus", &alignment_opts);
- generic_opts_set(builder, "LoggingLevel", &logging_opts);
- generic_opts_set(builder, "FileFormat", &container_opts);
- generic_opts_set(builder, "PictureDeinterlace", &deint_opts);
- generic_opts_set(builder, "PictureDetelecine", &detel_opts);
- generic_opts_set(builder, "PictureDecomb", &decomb_opts);
- generic_opts_set(builder, "PictureDenoise", &denoise_opts);
- generic_opts_set(builder, "VideoEncoder", &vcodec_opts);
- generic_opts_set(builder, "AudioEncoder", &acodec_opts);
- generic_opts_set(builder, "x264_direct", &direct_opts);
- generic_opts_set(builder, "x264_b_adapt", &badapt_opts);
- generic_opts_set(builder, "x264_me", &me_opts);
- generic_opts_set(builder, "x264_subme", &subme_opts);
- generic_opts_set(builder, "x264_analyse", &analyse_opts);
- generic_opts_set(builder, "x264_trellis", &trellis_opts);
+ audio_bitrate_opts_set(ud->builder, "AudioBitrate");
+ audio_samplerate_opts_set(ud->builder, "AudioSamplerate", hb_audio_rates, hb_audio_rates_count);
+ video_rate_opts_set(ud->builder, "VideoFramerate", hb_video_rates, hb_video_rates_count);
+ mix_opts_set(ud->builder, "AudioMixdown");
+ language_opts_set(ud->builder, "SourceAudioLang");
+ subtitle_opts_set(ud, "SubtitleTrack", user_data);
+ title_opts_set(ud->builder, "title");
+ audio_track_opts_set(ud->builder, "AudioTrack", user_data);
+ generic_opts_set(ud->builder, "VideoQualityGranularity", &vqual_granularity_opts);
+ generic_opts_set(ud->builder, "PicturePAR", &par_opts);
+ generic_opts_set(ud->builder, "PictureModulus", &alignment_opts);
+ generic_opts_set(ud->builder, "LoggingLevel", &logging_opts);
+ generic_opts_set(ud->builder, "FileFormat", &container_opts);
+ generic_opts_set(ud->builder, "PictureDeinterlace", &deint_opts);
+ generic_opts_set(ud->builder, "PictureDetelecine", &detel_opts);
+ generic_opts_set(ud->builder, "PictureDecomb", &decomb_opts);
+ generic_opts_set(ud->builder, "PictureDenoise", &denoise_opts);
+ generic_opts_set(ud->builder, "VideoEncoder", &vcodec_opts);
+ generic_opts_set(ud->builder, "AudioEncoder", &acodec_opts);
+ generic_opts_set(ud->builder, "x264_direct", &direct_opts);
+ generic_opts_set(ud->builder, "x264_b_adapt", &badapt_opts);
+ generic_opts_set(ud->builder, "x264_me", &me_opts);
+ generic_opts_set(ud->builder, "x264_subme", &subme_opts);
+ generic_opts_set(ud->builder, "x264_analyse", &analyse_opts);
+ generic_opts_set(ud->builder, "x264_trellis", &trellis_opts);
}
else
{
if (strcmp(name, "AudioBitrate") == 0)
- audio_bitrate_opts_set(builder, "AudioBitrate");
+ audio_bitrate_opts_set(ud->builder, "AudioBitrate");
else if (strcmp(name, "AudioSamplerate") == 0)
- audio_samplerate_opts_set(builder, "AudioSamplerate", hb_audio_rates, hb_audio_rates_count);
+ audio_samplerate_opts_set(ud->builder, "AudioSamplerate", hb_audio_rates, hb_audio_rates_count);
else if (strcmp(name, "VideoFramerate") == 0)
- video_rate_opts_set(builder, "VideoFramerate", hb_video_rates, hb_video_rates_count);
+ video_rate_opts_set(ud->builder, "VideoFramerate", hb_video_rates, hb_video_rates_count);
else if (strcmp(name, "AudioMixdown") == 0)
- mix_opts_set(builder, "AudioMixdown");
+ mix_opts_set(ud->builder, "AudioMixdown");
else if (strcmp(name, "SourceAudioLang") == 0)
- language_opts_set(builder, "SourceAudioLang");
- else if (strcmp(name, "Subtitles") == 0)
- subtitle_opts_set(builder, "Subtitles", user_data);
+ language_opts_set(ud->builder, "SourceAudioLang");
+ else if (strcmp(name, "SubtitleTrack") == 0)
+ subtitle_opts_set(ud, "SubtitleTrack", user_data);
else if (strcmp(name, "title") == 0)
- title_opts_set(builder, "title");
+ title_opts_set(ud->builder, "title");
else if (strcmp(name, "AudioTrack") == 0)
- audio_track_opts_set(builder, "AudioTrack", user_data);
+ audio_track_opts_set(ud->builder, "AudioTrack", user_data);
else
- generic_opts_set(builder, name, find_combo_table(name));
+ generic_opts_set(ud->builder, name, find_combo_table(name));
}
if (handler_id > 0)
{
@@ -2040,7 +2276,7 @@ init_ui_combo_boxes(GtkBuilder *builder)
init_combo_box(builder, "VideoFramerate");
init_combo_box(builder, "AudioMixdown");
init_combo_box(builder, "SourceAudioLang");
- init_combo_box(builder, "Subtitles");
+ init_combo_box(builder, "SubtitleTrack");
init_combo_box(builder, "title");
init_combo_box(builder, "AudioTrack");
for (ii = 0; combo_name_map[ii].name != NULL; ii++)
@@ -2248,12 +2484,12 @@ ghb_set_default_bitrate_opts(GtkBuilder *builder, gint last_rate)
static ghb_status_t hb_status;
void
-ghb_combo_init(GtkBuilder *builder)
+ghb_combo_init(signal_user_data_t *ud)
{
// Set up the list model for the combos
- init_ui_combo_boxes(builder);
+ init_ui_combo_boxes(ud->builder);
// Populate all the combos
- ghb_update_ui_combo_box(builder, NULL, 0, TRUE);
+ ghb_update_ui_combo_box(ud, NULL, 0, TRUE);
}
void
@@ -3699,24 +3935,42 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex)
{
job->x264opts = NULL;
}
+
+ const GValue *subtitle_list;
gint subtitle;
- subtitle = ghb_settings_get_int(js, "subtitle_index");
- if (subtitle == -1)
- {
- job->indepth_scan = 1;
- }
- else if (subtitle >= 0)
+
+ subtitle_list = ghb_settings_get_value(js, "subtitle_list");
+ count = ghb_array_len(subtitle_list);
+ for (ii = 0; ii < count; ii++)
{
- hb_subtitle_t * subt;
+ GValue *ssettings;
+ gboolean burned;
- subt = (hb_subtitle_t *)hb_list_item(title->list_subtitle, subtitle);
- if (subt != NULL)
+ ssettings = ghb_array_get_nth(subtitle_list, ii);
+
+ subtitle = ghb_settings_get_int(ssettings, "SubtitleTrack");
+ burned = ghb_settings_get_boolean(ssettings, "SubtitleBurned");
+ if (subtitle == -1)
+ {
+ job->indepth_scan = 1;
+ }
+ else if (subtitle >= 0)
{
- hb_list_add(job->list_subtitle, subt);
+ hb_subtitle_t * subt;
+
+ subt = (hb_subtitle_t *)hb_list_item(title->list_subtitle, subtitle);
+ if (subt != NULL)
+ {
+ if (!burned && job->mux == HB_MUX_MKV &&
+ subt->format == PICTURESUB)
+ {
+ subt->dest = PASSTHRUSUB;
+ }
+ subt->force = ghb_settings_get_boolean(ssettings, "SubtitleForced");
+ hb_list_add(job->list_subtitle, subt);
+ }
}
}
- gboolean forced_subtitles = ghb_settings_get_boolean(js, "SubtitlesForced");
- job->subtitle_force = forced_subtitles;
if (job->indepth_scan == 1)
{
diff --git a/gtk/src/hb-backend.h b/gtk/src/hb-backend.h
index d946b9224..4517f44f0 100644
--- a/gtk/src/hb-backend.h
+++ b/gtk/src/hb-backend.h
@@ -98,7 +98,7 @@ void ghb_vquality_range(
gint *digits,
gboolean *inverted);
//const gchar* ghb_get_rate_string(gint rate, gint type);
-void ghb_combo_init(GtkBuilder *builder);
+void ghb_combo_init(signal_user_data_t *ud);
void ghb_backend_init(gint debug);
void ghb_backend_close(void);
void ghb_add_job(GValue *js, gint unique_id);
@@ -136,10 +136,12 @@ void ghb_set_passthru_bitrate_opts(GtkBuilder *builder, gint bitrate);
void ghb_set_default_bitrate_opts(GtkBuilder *builder, gint last_rate);
void ghb_grey_combo_options(GtkBuilder *builder);
void ghb_update_ui_combo_box(
- GtkBuilder *builder, const gchar *name, gint user_data, gboolean all);
+ signal_user_data_t *ud, const gchar *name, gint user_data, gboolean all);
gint ghb_find_audio_track(
- gint titleindex, const gchar *lang,
- gint acodec, GHashTable *track_indices);
+ gint titleindex, const gchar *lang, gint acodec, GHashTable *track_indices);
+gint ghb_find_subtitle_track(
+ gint titleindex, const gchar *lang, GHashTable *track_indices);
+gint ghb_pick_subtitle_track(signal_user_data_t *ud);
gint ghb_longest_title(void);
gchar* ghb_build_x264opts_string(GValue *settings);
GdkPixbuf* ghb_get_preview_image(
@@ -148,6 +150,8 @@ GdkPixbuf* ghb_get_preview_image(
gint ghb_calculate_target_bitrate(GValue *settings, gint titleindex);
gchar* ghb_dvd_volname(const gchar *device);
gint ghb_get_title_number(gint titleindex);
+gint ghb_subtitle_track_source(signal_user_data_t *ud, gint track);
+const char* ghb_subtitle_track_source_name(signal_user_data_t *ud, gint track);
gboolean ghb_validate_vquality(GValue *settings);
gboolean ghb_validate_audio(signal_user_data_t *ud);
@@ -155,9 +159,10 @@ gboolean ghb_validate_video(signal_user_data_t *ud);
gboolean ghb_validate_filters(signal_user_data_t *ud);
gboolean ghb_validate_filter_string(const gchar *str, gint max_fields);
void ghb_hb_cleanup(gboolean partial);
-gint ghb_lookup_combo_int(const gchar *name, const GValue *acodec);
-gdouble ghb_lookup_combo_double(const gchar *name, const GValue *acodec);
-const gchar* ghb_lookup_combo_option(const gchar *name, const GValue *acodec);
+gint ghb_lookup_combo_int(const gchar *name, const GValue *gval);
+gdouble ghb_lookup_combo_double(const gchar *name, const GValue *gval);
+const gchar* ghb_lookup_combo_option(const gchar *name, const GValue *gval);
+const gchar* ghb_lookup_combo_string(const gchar *name, const GValue *gval);
gchar* ghb_get_tmp_dir();
#endif // _HBBACKEND_H_
diff --git a/gtk/src/internal_defaults.xml b/gtk/src/internal_defaults.xml
index eb858d019..be58588e0 100644
--- a/gtk/src/internal_defaults.xml
+++ b/gtk/src/internal_defaults.xml
@@ -89,6 +89,9 @@
<key>audio_list</key>
<array>
</array>
+ <key>subtitle_list</key>
+ <array>
+ </array>
<key>vquality_type_bitrate</key>
<false />
<key>vquality_type_constant</key>
@@ -222,8 +225,6 @@
<integer>0</integer>
<key>PictureWidth</key>
<integer>0</integer>
- <key>SubtitlesForced</key>
- <true />
<key>VideoFramerate</key>
<string>source</string>
<key>VideoGrayScale</key>
@@ -263,8 +264,17 @@
<integer>1</integer>
<key>SourceAudioLang</key>
<string>und</string>
- <key>Subtitles</key>
- <string>none</string>
+ <key>SubtitleList</key>
+ <array>
+ <dict>
+ <key>SubtitleLanguage</key>
+ <string>und</string>
+ <key>SubtitleForced</key>
+ <false />
+ <key>SubtitleBurned</key>
+ <true />
+ </dict>
+ </array>
<key>VideoTurboTwoPass</key>
<false />
<key>UsesPictureFilters</key>
diff --git a/gtk/src/main.c b/gtk/src/main.c
index 505142be5..d7a15c1b1 100644
--- a/gtk/src/main.c
+++ b/gtk/src/main.c
@@ -376,6 +376,67 @@ bind_audio_tree_model (signal_user_data_t *ud)
g_debug("Done\n");
}
+extern G_MODULE_EXPORT void subtitle_list_selection_changed_cb(void);
+extern G_MODULE_EXPORT void subtitle_forced_toggled_cb(void);
+extern G_MODULE_EXPORT void subtitle_burned_toggled_cb(void);
+
+// Create and bind the tree model to the tree view for the subtitle track list
+// Also, connect up the signal that lets us know the selection has changed
+static void
+bind_subtitle_tree_model (signal_user_data_t *ud)
+{
+ GtkCellRenderer *cell;
+ GtkTreeViewColumn *column;
+ GtkListStore *treestore;
+ GtkTreeView *treeview;
+ GtkTreeSelection *selection;
+ GtkWidget *widget;
+
+ g_debug("bind_subtitle_tree_model ()\n");
+ treeview = GTK_TREE_VIEW(GHB_WIDGET (ud->builder, "subtitle_list"));
+ selection = gtk_tree_view_get_selection (treeview);
+ // 5 columns in model. 4 are visible, the other 1 is for storing
+ // values that I need
+ treestore = gtk_list_store_new(5,
+ G_TYPE_STRING,
+ G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
+ G_TYPE_STRING, G_TYPE_STRING);
+ gtk_tree_view_set_model(treeview, GTK_TREE_MODEL(treestore));
+
+ cell = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(
+ _("Track"), cell, "text", 0, NULL);
+ gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column));
+
+ cell = gtk_cell_renderer_toggle_new();
+ column = gtk_tree_view_column_new_with_attributes(
+ _("Forced Only"), cell, "active", 1, NULL);
+ gtk_tree_view_column_set_max_width (column, 50);
+ gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column));
+ g_signal_connect(cell, "toggled", subtitle_forced_toggled_cb, ud);
+
+ cell = gtk_cell_renderer_toggle_new();
+ gtk_cell_renderer_toggle_set_radio(GTK_CELL_RENDERER_TOGGLE(cell), TRUE);
+ column = gtk_tree_view_column_new_with_attributes(
+ _("Burned In"), cell, "active", 2, NULL);
+ gtk_tree_view_column_set_max_width (column, 50);
+ gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column));
+ g_signal_connect(cell, "toggled", subtitle_burned_toggled_cb, ud);
+
+ cell = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(
+ _("Type"), cell, "text", 3, NULL);
+ gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column));
+
+
+ g_signal_connect(selection, "changed", subtitle_list_selection_changed_cb, ud);
+ // Need to disable remove and update buttons since there are initially
+ // no selections
+ widget = GHB_WIDGET (ud->builder, "subtitle_remove");
+ gtk_widget_set_sensitive(widget, FALSE);
+ g_debug("Done\n");
+}
+
extern G_MODULE_EXPORT void presets_list_selection_changed_cb(void);
extern G_MODULE_EXPORT void presets_drag_cb(void);
extern G_MODULE_EXPORT void presets_drag_motion_cb(void);
@@ -642,12 +703,13 @@ main (int argc, char *argv[])
buffer = gtk_text_view_get_buffer (textview);
g_signal_connect(buffer, "changed", (GCallback)x264_entry_changed_cb, ud);
- ghb_combo_init(ud->builder);
+ ghb_combo_init(ud);
g_debug("ud %p\n", ud);
g_debug("ud->builder %p\n", ud->builder);
bind_audio_tree_model(ud);
+ bind_subtitle_tree_model(ud);
bind_presets_tree_model(ud);
bind_queue_tree_model(ud);
bind_chapter_tree_model(ud);
diff --git a/gtk/src/presets.c b/gtk/src/presets.c
index 25a5e96ce..35f7b9c4b 100644
--- a/gtk/src/presets.c
+++ b/gtk/src/presets.c
@@ -20,6 +20,7 @@
#include "settings.h"
#include "callbacks.h"
#include "audiohandler.h"
+#include "subtitlehandler.h"
#include "hb-backend.h"
#include "plist.h"
#include "resources.h"
@@ -2057,15 +2058,25 @@ export_value_xlat(GValue *dict)
gval = export_value_xlat2(denoise_xlat, lin_val, G_TYPE_INT);
if (gval)
ghb_dict_insert(dict, g_strdup(key), gval);
- key = "Subtitles";
- lin_val = ghb_dict_lookup(dict, key);
- gval = export_subtitle_xlat2(lin_val);
- if (gval)
- ghb_dict_insert(dict, g_strdup(key), gval);
+
+ GValue *slist;
+ GValue *sdict;
+ gint count, ii;
+
+ slist = ghb_dict_lookup(dict, "SubtitleList");
+ count = ghb_array_len(slist);
+ for (ii = 0; ii < count; ii++)
+ {
+ sdict = ghb_array_get_nth(slist, ii);
+ key = "SubtitleLanguage";
+ lin_val = ghb_dict_lookup(sdict, key);
+ gval = export_subtitle_xlat2(lin_val);
+ if (gval)
+ ghb_dict_insert(sdict, g_strdup(key), gval);
+ }
GValue *alist;
GValue *adict;
- gint count, ii;
alist = ghb_dict_lookup(dict, "AudioList");
count = ghb_array_len(alist);
@@ -2132,13 +2143,34 @@ import_value_xlat2(
return gval;
}
}
- //g_warning("Can't map value: (%s)", str);
g_free(str);
}
else
{
- g_warning("Bad key: (%s)", key);
- return NULL;
+ gint ii;
+ gchar *str;
+ GValue *sval;
+
+ str = ghb_value_string(mac_val);
+ for (ii = 0; value_map[ii].mac_val; ii++)
+ {
+ if (strcmp(str, value_map[ii].mac_val) == 0)
+ {
+ sval = ghb_string_value_new(value_map[ii].lin_val);
+ g_free(str);
+ gval = ghb_value_new(G_VALUE_TYPE(mac_val));
+ if (!g_value_transform(sval, gval))
+ {
+ g_warning("can't transform");
+ ghb_value_free(gval);
+ ghb_value_free(sval);
+ return NULL;
+ }
+ ghb_value_free(sval);
+ return gval;
+ }
+ }
+ g_free(str);
}
return NULL;
}
@@ -2185,19 +2217,82 @@ import_value_xlat(GValue *dict)
gval = import_value_xlat2(defaults, denoise_xlat, key, mac_val);
if (gval)
ghb_dict_insert(dict, g_strdup(key), gval);
- key = "Subtitles";
- mac_val = ghb_dict_lookup(dict, key);
- gval = import_subtitle_xlat2(mac_val);
- if (gval)
- ghb_dict_insert(dict, g_strdup(key), gval);
+
+ GValue *sdeflist;
+ GValue *sdefaults;
+ GValue *slist;
+ GValue *sdict;
+ gint count, ii;
+
+ sdeflist = ghb_dict_lookup(defaults, "SubtitleList");
+ if (sdeflist)
+ {
+ slist = ghb_dict_lookup(dict, "SubtitleList");
+ if (slist)
+ {
+ sdefaults = ghb_array_get_nth(sdeflist, 0);
+ count = ghb_array_len(slist);
+ for (ii = 0; ii < count; ii++)
+ {
+ sdict = ghb_array_get_nth(slist, ii);
+ key = "SubtitleLanguage";
+ mac_val = ghb_dict_lookup(sdict, key);
+ gval = import_subtitle_xlat2(mac_val);
+ if (gval)
+ ghb_dict_insert(sdict, g_strdup(key), gval);
+ }
+
+ }
+ else
+ {
+ key = "Subtitles";
+ mac_val = ghb_dict_lookup(dict, key);
+ if (mac_val)
+ {
+ gchar *lang;
+
+ gval = import_subtitle_xlat2(mac_val);
+ lang = ghb_value_string(gval);
+ if (lang && strcmp(lang, "none") != 0 && !slist)
+ {
+ slist = ghb_array_value_new(8);
+ sdict = ghb_dict_value_new();
+ ghb_dict_insert(dict, g_strdup("SubtitleList"), slist);
+ ghb_array_append(slist, sdict);
+ ghb_dict_insert(sdict, g_strdup("SubtitleLanguage"), gval);
+ gval = ghb_dict_lookup(dict, "SubtitlesForced");
+ if (gval != NULL)
+ {
+ ghb_dict_insert(sdict, g_strdup("SubtitleForced"),
+ ghb_value_dup(gval));
+ }
+ else
+ {
+ ghb_dict_insert(sdict, g_strdup("SubtitleForced"),
+ ghb_boolean_value_new(FALSE));
+ }
+ ghb_dict_insert(sdict, g_strdup("SubtitleBurned"),
+ ghb_boolean_value_new(TRUE));
+ }
+ else
+ {
+ ghb_value_free(gval);
+ }
+ if (lang)
+ g_free(lang);
+ }
+ }
+ }
+ ghb_dict_remove(dict, "Subtitles");
+ ghb_dict_remove(dict, "SubtitlesForced");
+
GValue *alist;
GValue *adict;
GValue *adefaults;
GValue *adeflist;
- gint count, ii;
- adeflist = ghb_dict_lookup(dict, "AudioList");
+ adeflist = ghb_dict_lookup(defaults, "AudioList");
if (adeflist)
{
adefaults = ghb_array_get_nth(adeflist, 0);
@@ -2847,6 +2942,16 @@ update_audio_presets(signal_user_data_t *ud)
ghb_settings_set_value(ud->settings, "AudioList", audio_list);
}
+static void
+update_subtitle_presets(signal_user_data_t *ud)
+{
+ g_debug("update_subtitle_presets");
+ const GValue *subtitle_list;
+
+ subtitle_list = ghb_settings_get_value(ud->settings, "subtitle_list");
+ ghb_settings_set_value(ud->settings, "SubtitleList", subtitle_list);
+}
+
void
enforce_preset_type(signal_user_data_t *ud, const GValue *path)
{
@@ -2940,6 +3045,7 @@ presets_save_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
{
// Construct the audio settings presets from the current audio list
update_audio_presets(ud);
+ update_subtitle_presets(ud);
settings_save(ud, dest);
}
ghb_value_free(dest);
@@ -3435,6 +3541,7 @@ presets_list_selection_changed_cb(GtkTreeSelection *selection, signal_user_data_
gint titleindex;
titleindex = ghb_settings_combo_int(ud->settings, "title");
ghb_set_pref_audio(titleindex, ud);
+ ghb_set_pref_subtitle(titleindex, ud);
ghb_settings_set_boolean(ud->settings, "preset_modified", FALSE);
if (ghb_get_title_info (&tinfo, titleindex))
{
diff --git a/gtk/src/queuehandler.c b/gtk/src/queuehandler.c
index 8ff54419a..1ac36ca89 100644
--- a/gtk/src/queuehandler.c
+++ b/gtk/src/queuehandler.c
@@ -646,7 +646,6 @@ queue_add(signal_user_data_t *ud)
GValue *settings;
gint titleindex;
gint titlenum;
- gint sub;
g_debug("queue_add ()");
if (!validate_settings(ud))
@@ -663,9 +662,6 @@ queue_add(signal_user_data_t *ud)
ud->queue = ghb_array_value_new(32);
// Make a copy of current settings to be used for the new job
settings = ghb_value_dup(ud->settings);
- sub = ghb_settings_combo_int(settings, "Subtitles");
- ghb_settings_set_int(settings, "subtitle_index", sub);
-
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");
diff --git a/gtk/src/settings.c b/gtk/src/settings.c
index c6657707f..41dd26ba2 100644
--- a/gtk/src/settings.c
+++ b/gtk/src/settings.c
@@ -170,6 +170,12 @@ ghb_settings_combo_option(const GValue *settings, const gchar *key)
return ghb_lookup_combo_option(key, ghb_settings_get_value(settings, key));
}
+const gchar*
+ghb_settings_combo_string(const GValue *settings, const gchar *key)
+{
+ return ghb_lookup_combo_string(key, ghb_settings_get_value(settings, key));
+}
+
// Map widget names to setting keys
// Widgets that map to settings have names
// of this format: s_<setting key>
diff --git a/gtk/src/settings.h b/gtk/src/settings.h
index 8c2cac821..072baf07a 100644
--- a/gtk/src/settings.h
+++ b/gtk/src/settings.h
@@ -86,6 +86,7 @@ gchar* ghb_settings_get_string(const GValue *settings, const gchar *key);
gint ghb_settings_combo_int(const GValue *settings, const gchar *key);
gdouble ghb_settings_combo_double(const GValue *settings, const gchar *key);
const gchar* ghb_settings_combo_option(const GValue *settings, const gchar *key);
+const gchar* ghb_settings_combo_string(const GValue *settings, const gchar *key);
GValue* ghb_widget_value(GtkWidget *widget);
gchar* ghb_widget_string(GtkWidget *widget);