summaryrefslogtreecommitdiffstats
path: root/gtk
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2014-02-24 03:42:58 +0000
committerjstebbins <[email protected]>2014-02-24 03:42:58 +0000
commit888fa38b6f36f092afe189624604b1b347195cee (patch)
tree20f8f7c0b11fc82085ae48675689da483c17ff9e /gtk
parent5b29b62a484f50fd0e0afdc6d0639822ac4b2ecb (diff)
LinGui: simplify subtitle track refrencing
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6079 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'gtk')
-rw-r--r--gtk/src/hb-backend.c126
-rw-r--r--gtk/src/hb-backend.h4
-rw-r--r--gtk/src/queuehandler.c11
-rw-r--r--gtk/src/subtitlehandler.c44
4 files changed, 78 insertions, 107 deletions
diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c
index 69847365e..aca268e89 100644
--- a/gtk/src/hb-backend.c
+++ b/gtk/src/hb-backend.c
@@ -52,25 +52,6 @@ typedef struct
options_map_t *map;
} combo_opts_t;
-static gchar **index_str = NULL;
-static gint index_str_size = 0;
-
-static void
-index_str_init(gint max_index)
-{
- gint 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_subtitle_track_sel_opts[] =
{
{N_("None"), "none", 0, "0"},
@@ -363,12 +344,6 @@ combo_opts_t trellis_opts =
d_trellis_opts
};
-combo_opts_t subtitle_opts =
-{
- 0,
- NULL
-};
-
typedef struct
{
const gchar *name;
@@ -399,7 +374,6 @@ combo_name_map_t combo_name_map[] =
{"x264_subme", &subme_opts},
{"x264_analyse", &analyse_opts},
{"x264_trellis", &trellis_opts},
- {"SubtitleTrack", &subtitle_opts},
{NULL, NULL}
};
@@ -2129,7 +2103,7 @@ audio_track_opts_set(GtkBuilder *builder, const gchar *name, const hb_title_t *t
hb_audio_config_t * audio;
gint ii;
gint count = 0;
- gchar *str;
+ gchar *opt;
g_debug("audio_track_opts_set ()\n");
GtkComboBox *combo = GTK_COMBO_BOX(GHB_WIDGET(builder, name));
@@ -2142,62 +2116,59 @@ audio_track_opts_set(GtkBuilder *builder, const gchar *name, const hb_title_t *t
if( count <= 0 )
{
// No audio. set some default
- gtk_list_store_append(store, &iter);
+ opt = g_strdup_printf("<small>%s</small>", _("No Audio"));
- str = g_strdup_printf("<small>%s</small>", _("No Audio"));
+ gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter,
- 0, str,
+ 0, opt,
1, TRUE,
2, "none",
3, -1.0,
4, "none",
-1);
- g_free(str);
+ g_free(opt);
return;
}
for (ii = 0; ii < count; ii++)
{
- gtk_list_store_append(store, &iter);
-
char idx[4];
audio = hb_list_audio_config_item(title->list_audio, ii);
- str = g_strdup_printf("<small>%d - %s</small>",
+ opt = g_strdup_printf("<small>%d - %s</small>",
ii + 1, audio->lang.description);
snprintf(idx, 4, "%d", ii);
+
+ gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter,
- 0, str,
+ 0, opt,
1, TRUE,
2, idx,
3, (gdouble)ii,
4, idx,
-1);
- g_free(str);
+ g_free(opt);
}
gtk_combo_box_set_active (combo, 0);
}
void
-subtitle_track_opts_set(GtkBuilder *builder, const gchar *name, const hb_title_t *title)
+subtitle_track_opts_set(
+ GtkBuilder *builder,
+ const gchar *name,
+ const hb_title_t *title)
{
GtkTreeIter iter;
GtkListStore *store;
hb_subtitle_t * subtitle;
gint ii, count = 0;
- static char ** options = NULL;
- g_debug("subtitle_track_opts_set ()\n");
GtkComboBox *combo = GTK_COMBO_BOX(GHB_WIDGET(builder, name));
store = GTK_LIST_STORE(gtk_combo_box_get_model (combo));
gtk_list_store_clear(store);
+
if (title != NULL)
{
count = hb_list_count( title->list_subtitle );
}
- if (subtitle_opts.map) g_free(subtitle_opts.map);
-
- subtitle_opts.count = count+1;
- subtitle_opts.map = g_malloc((subtitle_opts.count)*sizeof(options_map_t));
-
if (count > 0)
{
gtk_list_store_append(store, &iter);
@@ -2208,35 +2179,27 @@ subtitle_track_opts_set(GtkBuilder *builder, const gchar *name, const hb_title_t
3, -1.0,
4, "auto",
-1);
- subtitle_opts.map[0].option = "Foreign Audio Search";
- subtitle_opts.map[0].shortOpt = "-1";
- subtitle_opts.map[0].ivalue = -1;
- subtitle_opts.map[0].svalue = "auto";
-
- if (options != NULL)
- g_strfreev(options);
- options = g_malloc((count+1)*sizeof(gchar*));
- index_str_init(count-1);
+
for (ii = 0; ii < count; ii++)
{
- subtitle = (hb_subtitle_t *)hb_list_item(title->list_subtitle, ii);
- options[ii] = g_strdup_printf("%d - %s (%s)", ii+1,
- subtitle->lang,
- hb_subsource_name(subtitle->source));
- subtitle_opts.map[ii+1].option = options[ii];
- 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;
+ gchar *opt;
+ char idx[4];
+
+ subtitle = hb_list_item(title->list_subtitle, ii);
+ opt = g_strdup_printf("%d - %s (%s)", ii+1, subtitle->lang,
+ hb_subsource_name(subtitle->source));
+ snprintf(idx, 4, "%d", ii);
+
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter,
- 0, options[ii],
+ 0, opt,
1, TRUE,
- 2, index_str[ii],
+ 2, idx,
3, (gdouble)ii,
- 4, subtitle->iso639_2,
+ 4, idx,
-1);
+ g_free(opt);
}
- options[count] = NULL;
}
else
{
@@ -2248,10 +2211,6 @@ subtitle_track_opts_set(GtkBuilder *builder, const gchar *name, const hb_title_t
3, 0.0,
4, "none",
-1);
- subtitle_opts.map[0].option = "None";
- subtitle_opts.map[0].shortOpt = "0";
- subtitle_opts.map[0].ivalue = 0;
- subtitle_opts.map[0].svalue = "none";
}
gtk_combo_box_set_active (combo, 0);
}
@@ -2327,21 +2286,6 @@ ghb_find_audio_track(const hb_title_t *title, const gchar *lang, int start)
}
gint
-ghb_find_pref_subtitle_track(const gchar *lang)
-{
- gint ii, count;
- 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 -2;
-}
-
-gint
ghb_find_subtitle_track(const hb_title_t * title, const gchar * lang, int start)
{
hb_subtitle_t * subtitle;
@@ -2642,6 +2586,7 @@ init_ui_combo_boxes(GtkBuilder *builder)
init_combo_box(builder, "SrtCodeset");
init_combo_box(builder, "title");
init_combo_box(builder, "AudioTrack");
+ init_combo_box(builder, "SubtitleTrack");
init_combo_box(builder, "VideoEncoder");
init_combo_box(builder, "AudioEncoder");
init_combo_box(builder, "AudioEncoderFallback");
@@ -3387,6 +3332,17 @@ ghb_get_audio_info(const hb_title_t *title, gint track)
return hb_list_audio_config_item(title->list_audio, track);
}
+hb_subtitle_t*
+ghb_get_subtitle_info(const hb_title_t *title, gint track)
+{
+ if (title == NULL) return NULL;
+ if (!hb_list_count(title->list_subtitle))
+ {
+ return NULL;
+ }
+ return hb_list_item(title->list_subtitle, track);
+}
+
hb_list_t *
ghb_get_title_list()
{
@@ -4765,7 +4721,7 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, int titleindex)
hb_subtitle_t * subt;
hb_subtitle_config_t sub_config;
- subt = (hb_subtitle_t *)hb_list_item(title->list_subtitle, subtitle);
+ subt = hb_list_item(title->list_subtitle, subtitle);
if (subt != NULL)
{
sub_config = subt->config;
diff --git a/gtk/src/hb-backend.h b/gtk/src/hb-backend.h
index a17e5c818..823edb5d8 100644
--- a/gtk/src/hb-backend.h
+++ b/gtk/src/hb-backend.h
@@ -114,7 +114,6 @@ gint64 ghb_get_chapter_duration(const hb_title_t *title, gint chap);
gint64 ghb_get_chapter_start(const hb_title_t *title, gint chap);
void ghb_part_duration(
const hb_title_t *title, gint sc, gint ec, gint *hh, gint *mm, gint *ss);
-hb_audio_config_t* ghb_get_audio_info(const hb_title_t *title, gint track);
gint ghb_get_best_mix(hb_audio_config_t *aconfig, gint acodec, gint mix);
gboolean ghb_ac3_in_audio_list(const GValue *audio_list);
gboolean ghb_audio_is_passthru(gint acodec);
@@ -129,7 +128,6 @@ void ghb_update_ui_combo_box(
const gchar* ghb_get_source_audio_lang(const hb_title_t *title, gint track);
gint ghb_find_audio_track(const hb_title_t *title, const gchar *lang, int start);
void ghb_add_all_subtitles(signal_user_data_t *ud, gint titleindex);
-gint ghb_find_pref_subtitle_track(const gchar *lang);
gint ghb_find_subtitle_track(const hb_title_t * title, const gchar * lang, int start);
gint ghb_pick_subtitle_track(signal_user_data_t *ud);
gint ghb_longest_title(void);
@@ -206,5 +204,7 @@ int ghb_settings_audio_bitrate_rate(const GValue *settings, const char *name);
const hb_rate_t* ghb_settings_audio_bitrate(
const GValue *settings, const char *name);
const char* ghb_audio_bitrate_get_short_name(int rate);
+hb_audio_config_t* ghb_get_audio_info(const hb_title_t *title, gint track);
+hb_subtitle_t* ghb_get_subtitle_info(const hb_title_t *title, gint track);
#endif // _HBBACKEND_H_
diff --git a/gtk/src/queuehandler.c b/gtk/src/queuehandler.c
index 2c5000891..385160e06 100644
--- a/gtk/src/queuehandler.c
+++ b/gtk/src/queuehandler.c
@@ -538,11 +538,11 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter)
count = ghb_array_len(audio_list);
if (count == 1)
{
- XPRINT("<b>Audio:</b> ");
+ XPRINT("<b>Audio:</b> <small>");
}
else if (count > 1)
{
- XPRINT("<b>Audio Tracks: %d</b>\n", count);
+ XPRINT("<b>Audio Tracks: %d</b><small>\n", count);
}
for (ii = 0; ii < count; ii++)
{
@@ -574,18 +574,17 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter)
if (audio_encoder->codec & HB_ACODEC_PASS_FLAG)
{
- XPRINT("<small>%s --> Encoder: %s</small>\n",
- track, audio_encoder->name);
+ XPRINT("%s --> Encoder: %s\n", track, audio_encoder->name);
}
else
{
- XPRINT(
- "<small>%s, Encoder: %s, Mixdown: %s, SampleRate: %s, %s</small>\n",
+ XPRINT("%s --> Encoder: %s, Mixdown: %s, SampleRate: %s, %s\n",
track, audio_encoder->name, mix->name, sr->name, quality);
}
g_free(track);
g_free(quality);
}
+ XPRINT("</small>");
// Next line in the display (Subtitle)
// Subtitle Tracks: count
diff --git a/gtk/src/subtitlehandler.c b/gtk/src/subtitlehandler.c
index cc792d7dd..4d7861acb 100644
--- a/gtk/src/subtitlehandler.c
+++ b/gtk/src/subtitlehandler.c
@@ -272,9 +272,9 @@ subtitle_add_to_settings(GValue *settings, GValue *subsettings)
}
static void
-subtitle_set_track_description(GValue *subsettings)
+subtitle_set_track_description(GValue *settings, GValue *subsettings)
{
- char *track;
+ char *desc;
if (ghb_settings_get_int(subsettings, "SubtitleSource") == SRTSUB)
{
@@ -290,25 +290,41 @@ subtitle_set_track_description(GValue *subsettings)
gchar *basename;
basename = g_path_get_basename(filename);
- track = g_strdup_printf("%s (%s)(SRT)(%s)", lang, code, basename);
+ desc = g_strdup_printf("%s (%s)(SRT)(%s)", lang, code, basename);
g_free(basename);
}
else
{
- track = g_strdup_printf("%s (%s)(SRT)", lang, code);
+ desc = g_strdup_printf("%s (%s)(SRT)", lang, code);
}
g_free(code);
}
else
{
- track = g_strdup(
- ghb_settings_combo_option(subsettings, "SubtitleTrack"));
+ int title_id, titleindex;
+ const hb_title_t *title;
+ int track;
+ hb_subtitle_t *subtitle;
+
+ title_id = ghb_settings_get_int(settings, "title");
+ title = ghb_lookup_title(title_id, &titleindex);
+ track = ghb_settings_get_int(subsettings, "SubtitleTrack");
+ if (track < 0)
+ {
+ desc = g_strdup(_("Foreign Audio Search"));
+ }
+ else
+ {
+ subtitle = ghb_get_subtitle_info(title, track);
+ desc = g_strdup_printf("%d - %s (%s)", track + 1, subtitle->lang,
+ hb_subsource_name(subtitle->source));
+ }
}
ghb_settings_set_string(
- subsettings, "SubtitleTrackDescription", track);
+ subsettings, "SubtitleTrackDescription", desc);
- g_free(track);
+ g_free(desc);
}
static GValue* subtitle_add_track(
@@ -360,7 +376,7 @@ static GValue* subtitle_add_track(
ghb_settings_set_int(subsettings, "SrtOffset", 0);
- subtitle_set_track_description(subsettings);
+ subtitle_set_track_description(settings, subsettings);
if (!hb_subtitle_can_pass(source, mux))
{
@@ -746,7 +762,7 @@ subtitle_track_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
track = ghb_settings_get_int(subsettings, "SubtitleTrack");
source = ghb_subtitle_track_source(ud->settings, track);
ghb_settings_set_int(subsettings, "SubtitleSource", source);
- subtitle_set_track_description(subsettings);
+ subtitle_set_track_description(ud->settings, subsettings);
subtitle_update_dialog_widgets(ud, subsettings);
ghb_subtitle_list_refresh_selected(ud);
ghb_live_reset(ud);
@@ -822,7 +838,7 @@ subtitle_srt_radio_toggled_cb(GtkWidget *widget, signal_user_data_t *ud)
source = ghb_subtitle_track_source(ud->settings, track);
ghb_settings_set_int(subsettings, "SubtitleSource", source);
}
- subtitle_set_track_description(subsettings);
+ subtitle_set_track_description(ud->settings, subsettings);
subtitle_update_dialog_widgets(ud, subsettings);
ghb_subtitle_list_refresh_selected(ud);
ghb_live_reset(ud);
@@ -881,7 +897,7 @@ srt_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
if (subsettings != NULL)
{
ghb_widget_to_setting(subsettings, widget);
- subtitle_set_track_description(subsettings);
+ subtitle_set_track_description(ud->settings, subsettings);
ghb_subtitle_list_refresh_selected(ud);
ghb_live_reset(ud);
}
@@ -901,7 +917,7 @@ srt_file_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
gchar *filename, *dirname;
ghb_widget_to_setting(subsettings, widget);
- subtitle_set_track_description(subsettings);
+ subtitle_set_track_description(ud->settings, subsettings);
ghb_subtitle_list_refresh_selected(ud);
ghb_live_reset(ud);
@@ -934,7 +950,7 @@ srt_lang_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
if (subsettings != NULL)
{
ghb_widget_to_setting(subsettings, widget);
- subtitle_set_track_description(subsettings);
+ subtitle_set_track_description(ud->settings, subsettings);
ghb_subtitle_list_refresh_selected(ud);
ghb_live_reset(ud);
}