summaryrefslogtreecommitdiffstats
path: root/gtk
diff options
context:
space:
mode:
Diffstat (limited to 'gtk')
-rw-r--r--gtk/src/hb-backend.c62
-rw-r--r--gtk/src/internal_defaults.xml2
-rw-r--r--gtk/src/main.c19
-rw-r--r--gtk/src/presets.c2
-rw-r--r--gtk/src/subtitlehandler.c104
5 files changed, 155 insertions, 34 deletions
diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c
index 3fbc03ad3..fa38a20ce 100644
--- a/gtk/src/hb-backend.c
+++ b/gtk/src/hb-backend.c
@@ -1992,6 +1992,7 @@ ghb_add_all_subtitles(signal_user_data_t *ud, gint titleindex)
ghb_settings_set_int(subdict, "SubtitleTrack", -1);
ghb_settings_set_boolean(subdict, "SubtitleForced", FALSE);
ghb_settings_set_boolean(subdict, "SubtitleBurned", FALSE);
+ ghb_settings_set_boolean(subdict, "SubtitleDefaultTrack", FALSE);
ghb_settings_set_string(subdict, "SubtitleLanguage", "auto");
ghb_add_subtitle(ud, subdict, FALSE);
@@ -2004,6 +2005,7 @@ ghb_add_all_subtitles(signal_user_data_t *ud, gint titleindex)
ghb_settings_set_int(subdict, "SubtitleTrack", ii);
ghb_settings_set_boolean(subdict, "SubtitleForced", FALSE);
ghb_settings_set_boolean(subdict, "SubtitleBurned", FALSE);
+ ghb_settings_set_boolean(subdict, "SubtitleDefaultTrack", FALSE);
ghb_settings_set_string(subdict, "SubtitleLanguage",
subtitle->iso639_2);
ghb_add_subtitle(ud, subdict, FALSE);
@@ -3913,18 +3915,8 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex)
job->cfr = 1;
}
- // First remove any audios that are already in the list
- // This happens if you are encoding the same title a second time.
- gint num_audio_tracks = hb_list_count(job->list_audio);
- gint ii;
- for(ii = 0; ii < num_audio_tracks; ii++)
- {
- hb_audio_t *audio = (hb_audio_t*)hb_list_item(job->list_audio, 0);
- hb_list_rem(job->list_audio, audio);
- }
-
const GValue *audio_list;
- gint count;
+ gint count, ii;
gint tcount = 0;
audio_list = ghb_settings_get_value(js, "audio_list");
@@ -4043,12 +4035,13 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex)
const GValue *subtitle_list;
gint subtitle;
+ job->select_subtitle = NULL;
subtitle_list = ghb_settings_get_value(js, "subtitle_list");
count = ghb_array_len(subtitle_list);
for (ii = 0; ii < count; ii++)
{
GValue *ssettings;
- gboolean burned, enabled, one_burned = FALSE;
+ gboolean enabled, force, burned, def, one_burned = FALSE;
ssettings = ghb_array_get_nth(subtitle_list, ii);
@@ -4058,11 +4051,33 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex)
continue;
subtitle = ghb_settings_get_int(ssettings, "SubtitleTrack");
+ force = ghb_settings_get_boolean(ssettings, "SubtitleForced");
burned = ghb_settings_get_boolean(ssettings, "SubtitleBurned");
+ def = ghb_settings_get_boolean(ssettings, "SubtitleDefaultTrack");
if (subtitle == -1)
{
+ if (!burned && job->mux == HB_MUX_MKV)
+ {
+ job->select_subtitle_config.dest = PASSTHRUSUB;
+ }
+ else if (!burned && job->mux == HB_MUX_MP4)
+ {
+ // Skip any non-burned vobsubs when output is mp4
+ continue;
+ }
+ else
+ {
+ // Only allow one subtitle to be burned into the video
+ if (one_burned)
+ continue;
+ one_burned = TRUE;
+ }
+ job->select_subtitle_config.force = force;
+ job->select_subtitle_config.default_track = def;
job->indepth_scan = 1;
+ job->select_subtitle = malloc(sizeof(hb_subtitle_t*));
+ *job->select_subtitle = NULL;
}
else if (subtitle >= 0)
{
@@ -4074,7 +4089,7 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex)
if (!burned && job->mux == HB_MUX_MKV &&
subt->format == PICTURESUB)
{
- subt->dest = PASSTHRUSUB;
+ subt->config.dest = PASSTHRUSUB;
}
else if (!burned && job->mux == HB_MUX_MP4 &&
subt->format == PICTURESUB)
@@ -4089,7 +4104,8 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex)
continue;
one_burned = TRUE;
}
- subt->force = ghb_settings_get_boolean(ssettings, "SubtitleForced");
+ subt->config.force = force;
+ subt->config.default_track = def;
hb_list_add(job->list_subtitle, subt);
}
}
@@ -4110,8 +4126,6 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex)
x264opts_tmp = job->x264opts;
job->x264opts = NULL;
- job->select_subtitle = malloc(sizeof(hb_subtitle_t*));
- *(job->select_subtitle) = NULL;
/*
* Add the pre-scan job
@@ -4123,10 +4137,7 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex)
job->x264opts = x264opts_tmp;
}
- else
- {
- job->select_subtitle = NULL;
- }
+
if( ghb_settings_get_boolean(js, "VideoTwoPass") &&
!ghb_settings_get_boolean(js, "vquality_type_constant"))
{
@@ -4198,6 +4209,17 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex)
//if (job->x264opts != NULL)
// g_free(job->x264opts);
}
+
+ // First remove any audios that are already in the list
+ // This happens if you are encoding the same title a second time.
+ gint num_audio_tracks = hb_list_count(job->list_audio);
+ for(ii = 0; ii < num_audio_tracks; ii++)
+ {
+ hb_audio_t *audio = (hb_audio_t*)hb_list_item(job->list_audio, 0);
+ hb_list_rem(job->list_audio, audio);
+ free(audio);
+ }
+
if (detel_str) g_free(detel_str);
if (decomb_str) g_free(decomb_str);
if (deint_str) g_free(deint_str);
diff --git a/gtk/src/internal_defaults.xml b/gtk/src/internal_defaults.xml
index 3349c30c6..a216f73aa 100644
--- a/gtk/src/internal_defaults.xml
+++ b/gtk/src/internal_defaults.xml
@@ -277,6 +277,8 @@
<true />
<key>SubtitleBurned</key>
<true />
+ <key>SubtitleDefaultTrack</key>
+ <false />
</dict>
</array>
<key>VideoTurboTwoPass</key>
diff --git a/gtk/src/main.c b/gtk/src/main.c
index ef0dc18c2..7331c0b7e 100644
--- a/gtk/src/main.c
+++ b/gtk/src/main.c
@@ -384,6 +384,7 @@ extern G_MODULE_EXPORT void subtitle_list_selection_changed_cb(void);
extern G_MODULE_EXPORT void subtitle_enable_toggled_cb(void);
extern G_MODULE_EXPORT void subtitle_forced_toggled_cb(void);
extern G_MODULE_EXPORT void subtitle_burned_toggled_cb(void);
+extern G_MODULE_EXPORT void subtitle_default_toggled_cb(void);
extern G_MODULE_EXPORT void subtitle_track_changed_cb(void);
// Create and bind the tree model to the tree view for the subtitle track list
@@ -403,16 +404,17 @@ bind_subtitle_tree_model (signal_user_data_t *ud)
selection = gtk_tree_view_get_selection (treeview);
// 6 columns in model. 4 are visible, the other 2 is for storing
// values that I need
- treestore = gtk_list_store_new(7,
+ // Enable, Track, force, burn, default, type, track short, can delete
+ treestore = gtk_list_store_new(8,
G_TYPE_BOOLEAN, G_TYPE_STRING,
G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
- G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_BOOLEAN);
+ G_TYPE_BOOLEAN, G_TYPE_STRING,
+ G_TYPE_STRING, G_TYPE_BOOLEAN);
gtk_tree_view_set_model(treeview, GTK_TREE_MODEL(treestore));
cell = gtk_cell_renderer_toggle_new();
column = gtk_tree_view_column_new_with_attributes(
- _("On"), cell, "active", 0, NULL);
+ _("Enable"), cell, "active", 0, NULL);
gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column));
g_signal_connect(cell, "toggled", subtitle_enable_toggled_cb, ud);
@@ -438,9 +440,16 @@ bind_subtitle_tree_model (signal_user_data_t *ud)
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_toggle_new();
+ gtk_cell_renderer_toggle_set_radio(GTK_CELL_RENDERER_TOGGLE(cell), TRUE);
+ column = gtk_tree_view_column_new_with_attributes(
+ _("Default"), cell, "active", 4, NULL);
+ gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column));
+ g_signal_connect(cell, "toggled", subtitle_default_toggled_cb, ud);
+
cell = gtk_cell_renderer_text_new();
column = gtk_tree_view_column_new_with_attributes(
- _("Type"), cell, "text", 4, NULL);
+ _("Type"), cell, "text", 5, NULL);
gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column));
diff --git a/gtk/src/presets.c b/gtk/src/presets.c
index be028f6bc..505ce023e 100644
--- a/gtk/src/presets.c
+++ b/gtk/src/presets.c
@@ -2274,6 +2274,8 @@ import_value_xlat(GValue *dict)
}
ghb_dict_insert(sdict, g_strdup("SubtitleBurned"),
ghb_boolean_value_new(TRUE));
+ ghb_dict_insert(sdict, g_strdup("SubtitleDefaultTrack"),
+ ghb_boolean_value_new(FALSE));
}
else
{
diff --git a/gtk/src/subtitlehandler.c b/gtk/src/subtitlehandler.c
index 255da4744..c40e880e7 100644
--- a/gtk/src/subtitlehandler.c
+++ b/gtk/src/subtitlehandler.c
@@ -245,6 +245,40 @@ ghb_subtitle_exclusive_burn(signal_user_data_t *ud, gint track)
}
}
+void
+ghb_subtitle_exclusive_default(signal_user_data_t *ud, gint track)
+{
+ GValue *subtitle_list;
+ GValue *settings;
+ gint ii, count, tt;
+ GtkTreeView *tv;
+ GtkTreeModel *tm;
+ GtkTreeIter ti;
+ gboolean def;
+
+ g_debug("ghb_subtitle_exclusive_default");
+ 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);
+ tt = ghb_settings_combo_int(settings, "SubtitleTrack");
+ def = ghb_settings_get_boolean(settings, "SubtitleDefaultTrack");
+
+ tv = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "subtitle_list"));
+ g_return_if_fail(tv != NULL);
+ tm = gtk_tree_view_get_model(tv);
+ gtk_tree_model_iter_nth_child(tm, &ti, NULL, ii);
+ if (def && tt != track)
+ {
+
+ ghb_settings_set_boolean(settings, "SubtitleDefaultTrack", FALSE);
+ def = FALSE;
+ gtk_list_store_set(GTK_LIST_STORE(tm), &ti, 4, FALSE, -1);
+ }
+ }
+}
+
G_MODULE_EXPORT void
subtitle_enable_toggled_cb(
GtkCellRendererToggle *cell,
@@ -395,6 +429,53 @@ subtitle_burned_toggled_cb(
ghb_subtitle_exclusive_burn(ud, track);
}
+G_MODULE_EXPORT void
+subtitle_default_toggled_cb(
+ GtkCellRendererToggle *cell,
+ gchar *path,
+ signal_user_data_t *ud)
+{
+ GtkTreeView *tv;
+ GtkTreeModel *tm;
+ GtkTreeIter ti;
+ GtkTreePath *tp;
+ gboolean active;
+ gint row;
+ gint *indices;
+ GValue *subtitle_list;
+ gint count, track;
+ GValue *settings;
+
+ g_debug("default toggled");
+ tp = gtk_tree_path_new_from_string (path);
+ tv = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "subtitle_list"));
+ g_return_if_fail(tv != NULL);
+ tm = gtk_tree_view_get_model(tv);
+ g_return_if_fail(tm != NULL);
+ gtk_tree_model_get_iter(tm, &ti, tp);
+ gtk_tree_model_get(tm, &ti, 4, &active, -1);
+ active ^= 1;
+
+ // Get the row number
+ indices = gtk_tree_path_get_indices (tp);
+ row = indices[0];
+ gtk_tree_path_free(tp);
+
+ subtitle_list = ghb_settings_get_value(ud->settings, "subtitle_list");
+ count = ghb_array_len(subtitle_list);
+ if (row < 0 || row >= count)
+ return;
+
+ settings = ghb_array_get_nth(subtitle_list, row);
+ track = ghb_settings_combo_int(settings, "SubtitleTrack");
+
+ ghb_settings_set_boolean(settings, "SubtitleDefaultTrack", active);
+
+ gtk_list_store_set(GTK_LIST_STORE(tm), &ti, 4, active, -1);
+ // allow only one default
+ ghb_subtitle_exclusive_default(ud, track);
+}
+
static gboolean
trackUsed(signal_user_data_t *ud, gint track)
{
@@ -484,9 +565,9 @@ subtitle_track_changed_cb(
// These are displayed in list
1, track,
3, burned,
- 4, source,
+ 5, source,
// These are used to set combo values when a list item is selected
- 5, s_track,
+ 6, s_track,
-1);
g_free(s_track);
ghb_live_reset(ud);
@@ -586,7 +667,7 @@ add_to_subtitle_list(
GtkListStore *store;
GtkTreeSelection *selection;
const gchar *track, *source;
- gboolean forced, burned, enabled;
+ gboolean forced, burned, enabled, def;
gchar *s_track;
gint i_track;
@@ -599,6 +680,7 @@ add_to_subtitle_list(
enabled = ghb_settings_get_boolean(settings, "SubtitleEnabled");
forced = ghb_settings_get_boolean(settings, "SubtitleForced");
burned = ghb_settings_get_boolean(settings, "SubtitleBurned");
+ def = ghb_settings_get_boolean(settings, "SubtitleDefaultTrack");
s_track = ghb_settings_get_string(settings, "SubtitleTrack");
i_track = ghb_settings_get_int(settings, "SubtitleTrack");
@@ -611,10 +693,11 @@ add_to_subtitle_list(
1, track,
2, forced,
3, burned,
- 4, source,
+ 4, def,
+ 5, source,
// These are used to set combo box values when a list item is selected
- 5, s_track,
- 6, can_delete,
+ 6, s_track,
+ 7, can_delete,
-1);
gtk_tree_selection_select_iter(selection, &iter);
g_free(s_track);
@@ -635,7 +718,7 @@ subtitle_list_selection_changed_cb(GtkTreeSelection *selection, signal_user_data
const gchar *track;
gboolean can_delete;
- gtk_tree_model_get(store, &iter, 5, &track, 6, &can_delete, -1);
+ gtk_tree_model_get(store, &iter, 6, &track, 7, &can_delete, -1);
ghb_settings_set_string(ud->settings, "SubtitleTrack", track);
if (can_delete)
@@ -749,7 +832,7 @@ ghb_set_subtitle(signal_user_data_t *ud, gint track, GValue *settings)
GValue *slist;
GValue *subtitle;
gint count, ii, tt;
- gboolean forced, burned, enabled;
+ gboolean enabled, forced, burned, def;
g_debug("ghb_set_subtitle");
slist = ghb_settings_get_value(ud->settings, "subtitle_list");
@@ -765,6 +848,7 @@ ghb_set_subtitle(signal_user_data_t *ud, gint track, GValue *settings)
enabled = ghb_settings_get_boolean(settings, "SubtitleEnabled");
forced = ghb_settings_get_boolean(settings, "SubtitleForced");
burned = ghb_settings_get_boolean(settings, "SubtitleBurned");
+ def = ghb_settings_get_boolean(settings, "SubtitleDefaultTrack");
tv = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "subtitle_list"));
g_return_if_fail(tv != NULL);
@@ -774,11 +858,13 @@ ghb_set_subtitle(signal_user_data_t *ud, gint track, GValue *settings)
ghb_settings_set_boolean(subtitle, "SubtitleEnabled", enabled);
ghb_settings_set_boolean(subtitle, "SubtitleForced", forced);
ghb_settings_set_boolean(subtitle, "SubtitleBurned", burned);
+ ghb_settings_set_boolean(subtitle, "SubtitleDefaultTrack", def);
gtk_list_store_set(GTK_LIST_STORE(tm), &ti,
0, enabled,
2, forced,
3, burned,
- 6, FALSE,
+ 4, def,
+ 7, FALSE,
-1);
break;
}