summaryrefslogtreecommitdiffstats
path: root/gtk/src
diff options
context:
space:
mode:
authorJohn Stebbins <[email protected]>2019-01-06 10:33:11 -0700
committerJohn Stebbins <[email protected]>2019-01-14 13:36:08 -0800
commitef1e5ad9fd6ab564523660567a023ac57e3eeb6f (patch)
treef1fa9594ba98952dfab85f016ce48ae5776b104a /gtk/src
parente81aa4f4d29daad15a5117940a510f32557ae2d1 (diff)
LinGui: add SSA import
Diffstat (limited to 'gtk/src')
-rw-r--r--gtk/src/ghb.m420
-rw-r--r--gtk/src/queuehandler.c38
-rw-r--r--gtk/src/settings.c3
-rw-r--r--gtk/src/subtitlehandler.c66
4 files changed, 92 insertions, 35 deletions
diff --git a/gtk/src/ghb.m4 b/gtk/src/ghb.m4
index d1af69c13..53d97b579 100644
--- a/gtk/src/ghb.m4
+++ b/gtk/src/ghb.m4
@@ -8217,7 +8217,24 @@ filter_output([
</packing>
</child>
<child>
- <object class="GtkRadioButton" id="SubtitleSrtDisable">
+ <object class="GtkRadioButton" id="SubtitleSsaEnable">
+ <property name="label" translatable="yes">Import SSA</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</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">Enable settings to import an SSA subtitle file</property>
+ <property name="halign">start</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">SubtitleSrtEnable</property>
+ <signal name="toggled" handler="subtitle_import_radio_toggled_cb" swapped="no"/>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="SubtitleImportDisable">
<property name="label" translatable="yes">Embedded Subtitle List</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -8227,6 +8244,7 @@ filter_output([
<property name="halign">start</property>
<property name="draw_indicator">True</property>
<property name="group">SubtitleSrtEnable</property>
+ <signal name="toggled" handler="subtitle_import_radio_toggled_cb" swapped="no"/>
</object>
<packing>
<property name="position">1</property>
diff --git a/gtk/src/queuehandler.c b/gtk/src/queuehandler.c
index 488c4d195..95b79c51b 100644
--- a/gtk/src/queuehandler.c
+++ b/gtk/src/queuehandler.c
@@ -88,15 +88,20 @@ ghb_subtitle_short_description(const GhbValue *subsource,
import = ghb_dict_get(subsettings, "Import");
if (import != NULL)
{
- const gchar *format = "SRT";
- const gchar *code;
- const gchar *lang;
+ const gchar * format = "SRT";
+ const gchar * code;
+ const gchar * lang;
+ int source = IMPORTSRT;
const iso639_lang_t *iso;
format = ghb_dict_get_string(import, "Format");
- lang = ghb_dict_get_string(import, "Language");
- code = ghb_dict_get_string(import, "Codeset");
+ lang = ghb_dict_get_string(import, "Language");
+ code = ghb_dict_get_string(import, "Codeset");
+ if (format != NULL && !strcasecmp(format, "SSA"))
+ {
+ source = IMPORTSSA;
+ }
iso = lang_lookup(lang);
if (iso != NULL)
{
@@ -106,7 +111,7 @@ ghb_subtitle_short_description(const GhbValue *subsource,
lang = iso->eng_name;
}
- if (code != NULL)
+ if (source == IMPORTSRT)
{
desc = g_strdup_printf("%s (%s)(%s)", lang, code, format);
}
@@ -138,16 +143,21 @@ subtitle_get_track_description(const GhbValue *subsource,
import = ghb_dict_get(subsettings, "Import");
if (import != NULL)
{
- const gchar *format = "SRT";
- const gchar *filename, *code;
- const gchar *lang;
+ const gchar * format = "SRT";
+ const gchar * filename, *code;
+ const gchar * lang;
+ int source = IMPORTSRT;
const iso639_lang_t *iso;
- format = ghb_dict_get_string(import, "Format");
- lang = ghb_dict_get_string(import, "Language");
- code = ghb_dict_get_string(import, "Codeset");
+ format = ghb_dict_get_string(import, "Format");
+ lang = ghb_dict_get_string(import, "Language");
+ code = ghb_dict_get_string(import, "Codeset");
filename = ghb_dict_get_string(import, "Filename");
+ if (format != NULL && !strcasecmp(format, "SSA"))
+ {
+ source = IMPORTSSA;
+ }
iso = lang_lookup(lang);
if (iso != NULL)
{
@@ -162,7 +172,7 @@ subtitle_get_track_description(const GhbValue *subsource,
gchar *basename;
basename = g_path_get_basename(filename);
- if (code != NULL)
+ if (source == IMPORTSRT)
{
desc = g_strdup_printf("%s (%s)(%s)(%s)",
lang, code, format, basename);
@@ -175,7 +185,7 @@ subtitle_get_track_description(const GhbValue *subsource,
}
else
{
- if (code != NULL)
+ if (source == IMPORTSRT)
{
desc = g_strdup_printf("%s (%s)(%s)", lang, code, format);
}
diff --git a/gtk/src/settings.c b/gtk/src/settings.c
index 40c362437..856081c2a 100644
--- a/gtk/src/settings.c
+++ b/gtk/src/settings.c
@@ -699,11 +699,12 @@ ghb_update_widget(GtkWidget *widget, const GhbValue *value)
}
else
{
- gchar *dirname;
+ gchar * dirname;
dirname = g_path_get_dirname(str);
gtk_file_chooser_set_current_folder(
GTK_FILE_CHOOSER(widget), dirname);
+ gtk_file_chooser_unselect_all(GTK_FILE_CHOOSER(widget));
g_free(dirname);
}
}
diff --git a/gtk/src/subtitlehandler.c b/gtk/src/subtitlehandler.c
index a4fd3314b..dbf80c57b 100644
--- a/gtk/src/subtitlehandler.c
+++ b/gtk/src/subtitlehandler.c
@@ -346,6 +346,7 @@ subtitle_get_track_description(GhbValue *settings, GhbValue *subsettings)
const gchar * format = "SRT";
const gchar * filename, * code;
const gchar * lang;
+ int source = IMPORTSRT;
const iso639_lang_t * iso;
format = ghb_dict_get_string(import, "Format");
@@ -353,6 +354,10 @@ subtitle_get_track_description(GhbValue *settings, GhbValue *subsettings)
lang = ghb_dict_get_string(import, "Language");
code = ghb_dict_get_string(import, "Codeset");
+ if (format != NULL && !strcasecmp(format, "SSA"))
+ {
+ source = IMPORTSSA;
+ }
iso = lang_lookup(lang);
if (iso != NULL)
{
@@ -367,7 +372,7 @@ subtitle_get_track_description(GhbValue *settings, GhbValue *subsettings)
gchar *basename;
basename = g_path_get_basename(filename);
- if (code != NULL)
+ if (source == IMPORTSRT)
{
desc = g_strdup_printf("%s (%s)(%s)(%s)",
lang, code, format, basename);
@@ -380,7 +385,7 @@ subtitle_get_track_description(GhbValue *settings, GhbValue *subsettings)
}
else
{
- if (code != NULL)
+ if (source == IMPORTSRT)
{
desc = g_strdup_printf("%s (%s)(%s)", lang, code, format);
}
@@ -502,7 +507,7 @@ ghb_subtitle_title_change(signal_user_data_t *ud, gboolean show)
const hb_title_t *title = ghb_lookup_title(title_id, NULL);
if (title != NULL)
{
- w = GHB_WIDGET(ud->builder, "SubtitleSrtDisable");
+ w = GHB_WIDGET(ud->builder, "SubtitleImportDisable");
gtk_widget_set_sensitive(w, !!hb_list_count(title->list_subtitle));
}
}
@@ -528,12 +533,12 @@ ghb_set_pref_subtitle(signal_user_data_t *ud)
if (sub_count == 0)
{
// No source subtitles
- widget = GHB_WIDGET(ud->builder, "SubtitleSrtDisable");
- gtk_widget_set_sensitive(widget, FALSE);
+ widget = GHB_WIDGET(ud->builder, "SubtitleSrtEnable");
+ gtk_widget_set_sensitive(widget, TRUE);
}
else
{
- widget = GHB_WIDGET(ud->builder, "SubtitleSrtDisable");
+ widget = GHB_WIDGET(ud->builder, "SubtitleImportDisable");
gtk_widget_set_sensitive(widget, TRUE);
}
GhbValue *job = ghb_get_job_settings(ud->settings);
@@ -671,7 +676,14 @@ subtitle_update_dialog_widgets(signal_user_data_t *ud, GhbValue *subsettings)
if (import != NULL)
{
- ghb_ui_update(ud, "SubtitleSrtEnable", ghb_boolean_value(TRUE));
+ if (source == IMPORTSSA)
+ {
+ ghb_ui_update(ud, "SubtitleSsaEnable", ghb_boolean_value(TRUE));
+ }
+ else
+ {
+ ghb_ui_update(ud, "SubtitleSrtEnable", ghb_boolean_value(TRUE));
+ }
val = ghb_dict_get(import, "Language");
ghb_ui_update(ud, "ImportLanguage", val);
val = ghb_dict_get(import, "Codeset");
@@ -683,7 +695,7 @@ subtitle_update_dialog_widgets(signal_user_data_t *ud, GhbValue *subsettings)
}
else
{
- ghb_ui_update(ud, "SubtitleSrtDisable", ghb_boolean_value(TRUE));
+ ghb_ui_update(ud, "SubtitleImportDisable", ghb_boolean_value(TRUE));
}
widget = GHB_WIDGET(ud->builder, "SubtitleBurned");
@@ -825,24 +837,40 @@ subtitle_import_radio_toggled_cb(GtkWidget *widget, signal_user_data_t *ud)
GhbValue *subsettings;
ghb_widget_to_setting(ud->settings, widget);
+ if (!ghb_dict_get_bool(ud->settings, "SubtitleSrtEnable") &&
+ !ghb_dict_get_bool(ud->settings, "SubtitleSsaEnable") &&
+ !ghb_dict_get_bool(ud->settings, "SubtitleImportDisable"))
+ {
+ // Radio buttons are in an in-between state with none enabled.
+ // Wait for the next toggle when something gets enabled.
+ return;
+ }
subsettings = subtitle_get_selected_settings(ud, NULL);
if (subsettings != NULL)
{
- if (ghb_dict_get_bool(ud->settings, "SubtitleSrtEnable"))
+ if (ghb_dict_get_bool(ud->settings, "SubtitleSrtEnable") ||
+ ghb_dict_get_bool(ud->settings, "SubtitleSsaEnable"))
{
const gchar *pref_lang, *dir;
gchar *filename;
- GhbValue *srt = ghb_dict_new();
+ GhbValue *import = ghb_dict_get(subsettings, "Import");
- ghb_dict_set(subsettings, "Import", srt);
- pref_lang = ghb_dict_get_string(ud->settings, "PreferredLanguage");
- ghb_dict_set_string(srt, "Language", pref_lang);
- ghb_dict_set_string(srt, "Codeset", "UTF-8");
-
- dir = ghb_dict_get_string(ud->prefs, "SrtDir");
- filename = g_strdup_printf("%s/none", dir);
- ghb_dict_set_string(srt, "Filename", filename);
- g_free(filename);
+ if (import == NULL)
+ {
+ import = ghb_dict_new();
+ ghb_dict_set(subsettings, "Import", import);
+ pref_lang = ghb_dict_get_string(ud->settings, "PreferredLanguage");
+ ghb_dict_set_string(import, "Language", pref_lang);
+ ghb_dict_set_string(import, "Codeset", "UTF-8");
+
+ dir = ghb_dict_get_string(ud->prefs, "SrtDir");
+ filename = g_strdup_printf("%s/none", dir);
+ ghb_dict_set_string(import, "Filename", filename);
+ g_free(filename);
+ }
+ ghb_dict_set_string(import, "Format",
+ hb_dict_get_bool(ud->settings, "SubtitleSrtEnable") ?
+ "SRT" : "SSA");
}
else
{