summaryrefslogtreecommitdiffstats
path: root/gtk/src
diff options
context:
space:
mode:
Diffstat (limited to 'gtk/src')
-rw-r--r--gtk/src/callbacks.c2
-rw-r--r--gtk/src/ghb.ui37
-rw-r--r--gtk/src/hb-backend.c31
-rw-r--r--gtk/src/hb-backend.h1
-rw-r--r--gtk/src/main.c7
-rw-r--r--gtk/src/settings.h1
-rw-r--r--gtk/src/subtitlehandler.c217
7 files changed, 139 insertions, 157 deletions
diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c
index e2140d7d5..decc4579d 100644
--- a/gtk/src/callbacks.c
+++ b/gtk/src/callbacks.c
@@ -1257,7 +1257,7 @@ title_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
titleindex = ghb_settings_combo_int(ud->settings, "title");
ghb_update_ui_combo_box (ud, "AudioTrack", titleindex, FALSE);
- ghb_update_ui_combo_box (ud, "SubtitleTrack", titleindex, FALSE);
+ ghb_subtitle_track_model(ud, titleindex);
ghb_set_pref_subtitle(titleindex, ud);
if (ghb_get_title_info (&tinfo, titleindex))
diff --git a/gtk/src/ghb.ui b/gtk/src/ghb.ui
index 54e99eeda..f740a9054 100644
--- a/gtk/src/ghb.ui
+++ b/gtk/src/ghb.ui
@@ -2253,43 +2253,6 @@
<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="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>
diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c
index b4635d2a6..0fbd6919f 100644
--- a/gtk/src/hb-backend.c
+++ b/gtk/src/hb-backend.c
@@ -1349,6 +1349,8 @@ init_combo_box(GtkBuilder *builder, const gchar *name)
g_debug("init_combo_box() %s\n", name);
// First modify the combobox model to allow greying out of options
combo = GTK_COMBO_BOX(GHB_WIDGET(builder, name));
+ if (combo == NULL)
+ return;
// Store contains:
// 1 - String to display
// 2 - bool indicating whether the entry is selectable (grey or not)
@@ -1680,7 +1682,7 @@ audio_track_opts_set(GtkBuilder *builder, const gchar *name, gint titleindex)
}
void
-subtitle_opts_set(signal_user_data_t *ud, const gchar *name, gint titleindex)
+ghb_subtitle_track_model(signal_user_data_t *ud, gint titleindex)
{
GtkTreeIter iter;
GtkListStore *store;
@@ -1689,9 +1691,7 @@ subtitle_opts_set(signal_user_data_t *ud, const gchar *name, gint titleindex)
hb_subtitle_t * subtitle;
gint ii, count = 0;
- g_debug("subtitle_opts_set () %s\n", name);
- store = get_combo_box_store(ud->builder, name);
- gtk_list_store_clear(store);
+ g_debug("ghb_subtitle_track_model ()\n");
if (h_scan != NULL)
{
list = hb_get_titles( h_scan );
@@ -1713,6 +1713,23 @@ subtitle_opts_set(signal_user_data_t *ud, const gchar *name, gint titleindex)
subtitle_opts.count = LANG_TABLE_SIZE+2;
subtitle_opts.map = g_malloc((LANG_TABLE_SIZE+2)*sizeof(options_map_t));
}
+ if (ud->subtitle_track_model == NULL)
+ {
+ // Store contains:
+ // 1 - String to display
+ // 2 - bool indicating whether the entry is selectable (grey or not)
+ // 3 - String that is used for presets
+ // 4 - Int value determined by backend
+ // 5 - String value determined by backend
+ store = gtk_list_store_new(5, G_TYPE_STRING, G_TYPE_BOOLEAN,
+ G_TYPE_STRING, G_TYPE_DOUBLE, G_TYPE_STRING);
+ ud->subtitle_track_model = store;
+ }
+ else
+ {
+ store = ud->subtitle_track_model;
+ gtk_list_store_clear(store);
+ }
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter,
0, "Autoselect",
@@ -2039,7 +2056,7 @@ ghb_pick_subtitle_track(signal_user_data_t *ud)
{
// Already in use, pick another
candidate++;
- if (candidate >= subtitle_opts.count)
+ if (candidate >= subtitle_opts.count-1)
{
candidate = 0;
}
@@ -2223,7 +2240,6 @@ ghb_update_ui_combo_box(
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);
@@ -2256,8 +2272,6 @@ ghb_update_ui_combo_box(
mix_opts_set(ud->builder, "AudioMixdown");
else if (strcmp(name, "SourceAudioLang") == 0)
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(ud->builder, "title");
else if (strcmp(name, "AudioTrack") == 0)
@@ -2281,7 +2295,6 @@ 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, "SubtitleTrack");
init_combo_box(builder, "title");
init_combo_box(builder, "AudioTrack");
for (ii = 0; combo_name_map[ii].name != NULL; ii++)
diff --git a/gtk/src/hb-backend.h b/gtk/src/hb-backend.h
index 43ad920d1..0d98a8425 100644
--- a/gtk/src/hb-backend.h
+++ b/gtk/src/hb-backend.h
@@ -152,6 +152,7 @@ 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);
+void ghb_subtitle_track_model(signal_user_data_t *ud, gint titleindex);
gboolean ghb_validate_vquality(GValue *settings);
gboolean ghb_validate_audio(signal_user_data_t *ud);
diff --git a/gtk/src/main.c b/gtk/src/main.c
index a9c07fab2..74f7bf83a 100644
--- a/gtk/src/main.c
+++ b/gtk/src/main.c
@@ -379,6 +379,7 @@ bind_audio_tree_model (signal_user_data_t *ud)
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);
+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
// Also, connect up the signal that lets us know the selection has changed
@@ -405,10 +406,14 @@ bind_subtitle_tree_model (signal_user_data_t *ud)
G_TYPE_INT);
gtk_tree_view_set_model(treeview, GTK_TREE_MODEL(treestore));
- cell = gtk_cell_renderer_text_new();
+ cell = gtk_cell_renderer_combo_new();
+ ghb_subtitle_track_model(ud, -1);
+ g_object_set(G_OBJECT(cell), "model", ud->subtitle_track_model,
+ "text-column", 0, "editable", TRUE, "width", 200, "has-entry", FALSE, NULL);
column = gtk_tree_view_column_new_with_attributes( _("Track"), cell,
"text", 0, "foreground", 5, "weight", 6, "style", 7, NULL);
gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column));
+ g_signal_connect(cell, "changed", subtitle_track_changed_cb, ud);
cell = gtk_cell_renderer_toggle_new();
column = gtk_tree_view_column_new_with_attributes(
diff --git a/gtk/src/settings.h b/gtk/src/settings.h
index 072baf07a..0616426ff 100644
--- a/gtk/src/settings.h
+++ b/gtk/src/settings.h
@@ -53,6 +53,7 @@ typedef struct
preview_t *preview;
gchar *appcast;
gint appcast_len;
+ GtkListStore *subtitle_track_model;
} signal_user_data_t;
enum
diff --git a/gtk/src/subtitlehandler.c b/gtk/src/subtitlehandler.c
index 70f1a6075..06ed0ec0b 100644
--- a/gtk/src/subtitlehandler.c
+++ b/gtk/src/subtitlehandler.c
@@ -99,7 +99,6 @@ ghb_set_pref_subtitle(gint titleindex, signal_user_data_t *ud)
ghb_settings_set_int(subtitle, "SubtitleTrack", track);
// Add to subtitle list
add_pref(ud, subtitle);
- ghb_ui_update(ud, "SubtitleTrack", ghb_int64_value(track));
}
}
g_hash_table_destroy(track_indices);
@@ -184,78 +183,6 @@ ghb_selected_subtitle_settings(signal_user_data_t *ud)
return settings;
}
-static void
-subtitle_list_refresh_selected(signal_user_data_t *ud)
-{
- GtkTreeView *treeview;
- GtkTreePath *treepath;
- GtkTreeSelection *selection;
- GtkTreeModel *store;
- GtkTreeIter iter;
- gint *indices;
- gint row;
- GValue *settings = NULL;
- const GValue *subtitle_list;
-
- g_debug("subtitle_list_refresh_selected ()");
- treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "subtitle_list"));
- selection = gtk_tree_view_get_selection (treeview);
- if (gtk_tree_selection_get_selected(selection, &store, &iter))
- {
- const gchar *track, *source, *color;
- gboolean forced, burned;
- gchar *s_track;
- gint i_track, weight, style;
-
- // Get the row number
- treepath = gtk_tree_model_get_path (store, &iter);
- indices = gtk_tree_path_get_indices (treepath);
- row = indices[0];
- gtk_tree_path_free(treepath);
- // find subtitle settings
- if (row < 0) return;
- subtitle_list = ghb_settings_get_value(ud->settings, "subtitle_list");
- if (row >= ghb_array_len(subtitle_list))
- return;
- settings = ghb_array_get_nth(subtitle_list, row);
-
- track = ghb_settings_combo_option(settings, "SubtitleTrack");
- forced = ghb_settings_get_boolean(settings, "SubtitleForced");
- burned = ghb_settings_get_boolean(settings, "SubtitleBurned");
-
- s_track = ghb_settings_get_string(settings, "SubtitleTrack");
- i_track = ghb_settings_get_int(settings, "SubtitleTrack");
- source = ghb_subtitle_track_source_name(ud, i_track);
-
- if (!burned && mustBurn(ud, i_track))
- {
- weight = 800;
- style = 2;
- color = "red";
- }
- else
- {
- weight = 400;
- style = 0;
- color = NULL;
- }
-
- gtk_list_store_set(GTK_LIST_STORE(store), &iter,
- // These are displayed in list
- 0, track,
- 1, forced,
- 2, burned,
- 3, source,
- // These are used to set combo values when a list item is selected
- 4, s_track,
- 5, color,
- 6, weight,
- 7, style,
- -1);
- g_free(s_track);
- }
-}
-
G_MODULE_EXPORT void
subtitle_forced_toggled_cb(
GtkCellRendererToggle *cell,
@@ -279,7 +206,6 @@ subtitle_forced_toggled_cb(
gtk_tree_model_get_iter(tm, &ti, tp);
gtk_tree_model_get(tm, &ti, 1, &active, -1);
active ^= 1;
- gtk_list_store_set(GTK_LIST_STORE(tm), &ti, 1, active, -1);
// Get the row number
indices = gtk_tree_path_get_indices (tp);
@@ -288,15 +214,25 @@ subtitle_forced_toggled_cb(
if (row >= 0)
{
- GValue *subtitle_list;
+ GValue *subtitle_list, *settings;
+ gint source, track;
subtitle_list = ghb_settings_get_value(ud->settings, "subtitle_list");
+
+ settings = ghb_array_get_nth(subtitle_list, row);
+ track = ghb_settings_combo_int(settings, "SubtitleTrack");
+
+ source = ghb_subtitle_track_source(ud, track);
+ if (source != VOBSUB)
+ return;
+
if (row < ghb_array_len(subtitle_list))
{
GValue *settings;
settings = ghb_array_get_nth(subtitle_list, row);
ghb_settings_set_boolean(settings, "SubtitleForced", active);
+ gtk_list_store_set(GTK_LIST_STORE(tm), &ti, 1, active, -1);
}
}
}
@@ -359,7 +295,7 @@ subtitle_burned_toggled_cb(
gint row;
gint *indices;
GValue *subtitle_list;
- gint count, track;
+ gint count, track, source;
GValue *settings;
g_debug("burned toggled");
@@ -384,6 +320,11 @@ subtitle_burned_toggled_cb(
settings = ghb_array_get_nth(subtitle_list, row);
track = ghb_settings_combo_int(settings, "SubtitleTrack");
+
+ source = ghb_subtitle_track_source(ud, track);
+ if (source != VOBSUB)
+ return;
+
if (!active && mustBurn(ud, track))
return;
@@ -415,41 +356,99 @@ trackUsed(signal_user_data_t *ud, gint track)
}
G_MODULE_EXPORT void
-subtitle_track_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
+subtitle_track_changed_cb(
+ GtkCellRendererCombo *combo,
+ gchar *path,
+ GtkTreeIter *iter,
+ signal_user_data_t *ud)
{
- GValue *settings;
+ GtkTreeView *tv;
+ GtkTreeModel *tm;
+ GtkTreeIter ti;
+ GtkTreePath *tp;
+ gdouble dtrack;
+ gint *indices;
+ int tt, row;
+ GValue *subtitle_list, *settings;
+ const char *lang;
g_debug("subtitle_track_changed_cb ()");
- ghb_check_dependency(ud, widget);
- settings = ghb_selected_subtitle_settings(ud);
- if (settings != NULL)
+ gtk_tree_model_get(GTK_TREE_MODEL(ud->subtitle_track_model), iter,
+ 3, &dtrack, -1);
+ tt = (gint)dtrack;
+ if (trackUsed(ud, tt))
+ return;
+
+ 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);
+
+ // 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");
+ if (row >= ghb_array_len(subtitle_list))
+ return;
+ settings = ghb_array_get_nth(subtitle_list, row);
+
+ ghb_settings_set_int(settings, "SubtitleTrack", tt);
+ lang = ghb_settings_combo_string(settings, "SubtitleTrack");
+ if (mustBurn(ud, tt))
{
- const gchar *lang;
- GValue *gval;
- GtkWidget *widget;
- gint track;
-
- widget = GHB_WIDGET (ud->builder, "SubtitleTrack");
- gval = ghb_widget_value(widget);
- track = ghb_value_int(gval);
- ghb_value_free(gval);
- if (trackUsed(ud, track))
- return;
- ghb_widget_to_setting(settings, widget);
- track = ghb_settings_combo_int(settings, "SubtitleTrack");
- lang = ghb_settings_combo_string(settings, "SubtitleTrack");
- if (mustBurn(ud, track))
- {
- ghb_settings_set_boolean(settings, "SubtitleBurned", TRUE);
- }
- else
- {
- ghb_settings_set_boolean(settings, "SubtitleBurned", FALSE);
- }
- ghb_settings_set_string(settings, "SubtitleLanguage", lang);
- subtitle_list_refresh_selected(ud);
+ ghb_settings_set_boolean(settings, "SubtitleBurned", TRUE);
+ }
+ else
+ {
+ ghb_settings_set_boolean(settings, "SubtitleBurned", FALSE);
+ }
+ ghb_settings_set_string(settings, "SubtitleLanguage", lang);
+
+ const gchar *track, *source, *color;
+ gboolean forced, burned;
+ gchar *s_track;
+ gint i_track, weight, style;
+
+ track = ghb_settings_combo_option(settings, "SubtitleTrack");
+ forced = ghb_settings_get_boolean(settings, "SubtitleForced");
+ burned = ghb_settings_get_boolean(settings, "SubtitleBurned");
+
+ s_track = ghb_settings_get_string(settings, "SubtitleTrack");
+ i_track = ghb_settings_get_int(settings, "SubtitleTrack");
+ source = ghb_subtitle_track_source_name(ud, i_track);
+
+ if (!burned && mustBurn(ud, i_track))
+ {
+ weight = 800;
+ style = 2;
+ color = "red";
}
+ else
+ {
+ weight = 400;
+ style = 0;
+ color = NULL;
+ }
+
+ gtk_list_store_set(GTK_LIST_STORE(tm), &ti,
+ // These are displayed in list
+ 0, track,
+ 1, forced,
+ 2, burned,
+ 3, source,
+ // These are used to set combo values when a list item is selected
+ 4, s_track,
+ 5, color,
+ 6, weight,
+ 7, style,
+ -1);
+ g_free(s_track);
ghb_live_reset(ud);
+
}
void
@@ -581,7 +580,8 @@ add_to_subtitle_list(signal_user_data_t *ud, GValue *settings)
-1);
gtk_tree_selection_select_iter(selection, &iter);
g_free(s_track);
- ghb_subtitle_exclusive_burn(ud, i_track);
+ if (burned)
+ ghb_subtitle_exclusive_burn(ud, i_track);
}
G_MODULE_EXPORT void
@@ -597,7 +597,8 @@ subtitle_list_selection_changed_cb(GtkTreeSelection *selection, signal_user_data
const gchar *track;
gtk_tree_model_get(store, &iter, 4, &track, -1);
- ghb_ui_update(ud, "SubtitleTrack", ghb_string_value(track));
+ ghb_settings_set_string(ud->settings, "SubtitleTrack", track);
+
widget = GHB_WIDGET (ud->builder, "subtitle_remove");
gtk_widget_set_sensitive(widget, TRUE);
}
@@ -613,7 +614,6 @@ subtitle_add_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
{
// Add the current subtitle settings to the list.
GValue *settings;
- GtkWidget *widget;
gint count;
GValue *subtitle_list;
gboolean burned = FALSE;
@@ -630,7 +630,6 @@ subtitle_add_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
}
settings = ghb_dict_value_new();
// Only allow up to 8 subtitle entries
- widget = GHB_WIDGET(ud->builder, "SubtitleTrack");
ghb_settings_set_int(settings, "SubtitleTrack", track);
ghb_settings_take_value(settings, "SubtitleForced",
ghb_boolean_value_new(FALSE));