From 9ad1a11452bf4d90f06ae50aa1046a3085ebbd06 Mon Sep 17 00:00:00 2001
From: Rafostar <40623528+Rafostar@users.noreply.github.com>
Date: Tue, 24 Nov 2020 17:54:53 +0100
Subject: [PATCH] Customize external subtitles font
---
clapper_src/dialogs.js | 2 --
clapper_src/playerBase.js | 10 ++--------
clapper_src/prefs.js | 9 +++++++--
clapper_src/prefsBase.js | 19 +++++++++++++++++++
data/com.github.rafostar.Clapper.gschema.xml | 4 ++++
5 files changed, 32 insertions(+), 12 deletions(-)
diff --git a/clapper_src/dialogs.js b/clapper_src/dialogs.js
index b9d59670..80cbc7e2 100644
--- a/clapper_src/dialogs.js
+++ b/clapper_src/dialogs.js
@@ -193,12 +193,10 @@ class ClapperPrefsDialog extends Gtk.Dialog
title: 'Audio',
widget: Prefs.AudioPage,
},
-/*
{
title: 'Subtitles',
widget: Prefs.SubtitlesPage,
}
-*/
]
},
{
diff --git a/clapper_src/playerBase.js b/clapper_src/playerBase.js
index a0c4dc0f..96036fb5 100644
--- a/clapper_src/playerBase.js
+++ b/clapper_src/playerBase.js
@@ -89,7 +89,8 @@ class ClapperPlayerBase extends GstPlayer.Player
for(let key of settingsToSet)
this._onSettingsKeyChanged(settings, key);
- //let flag = Gio.SettingsBindFlags.GET;
+ let flag = Gio.SettingsBindFlags.GET;
+ settings.bind('subtitle-font', this.pipeline, 'subtitle_font_desc', flag);
}
set_initial_config()
@@ -123,13 +124,6 @@ class ClapperPlayerBase extends GstPlayer.Player
debug(`could not change option: ${option}`);
}
- /* FIXME: add in prefs and move to bind_settings() */
- set_subtitle_font_desc(desc)
- {
- let pipeline = this.get_pipeline();
- pipeline.subtitle_font_desc = desc;
- }
-
set_all_plugins_ranks()
{
let data = [];
diff --git a/clapper_src/prefs.js b/clapper_src/prefs.js
index f43572be..53545d2d 100644
--- a/clapper_src/prefs.js
+++ b/clapper_src/prefs.js
@@ -84,8 +84,13 @@ class ClapperSubtitlesPage extends PrefsBase.Grid
{
super._init();
- this.addTitle('Synchronization');
- this.addSpinButton('Offset (milliseconds)', -5000, 5000, 'subtitle-offset', 25);
+ /* FIXME: This should be moved to subtitles popup and displayed only when
+ external subtitles were added for easier customization per video. */
+ //this.addTitle('Synchronization');
+ //this.addSpinButton('Offset (milliseconds)', -5000, 5000, 'subtitle-offset', 25);
+
+ this.addTitle('External Subtitles');
+ this.addFontButton('Default font', 'subtitle-font');
}
});
diff --git a/clapper_src/prefsBase.js b/clapper_src/prefsBase.js
index 5fac2c07..baf7c252 100644
--- a/clapper_src/prefsBase.js
+++ b/clapper_src/prefsBase.js
@@ -127,6 +127,14 @@ class ClapperPrefsGrid extends Gtk.Grid
return this.addToGrid(widget);
}
+ addFontButton(text, setting)
+ {
+ let label = this.getLabel(text + ':');
+ let widget = this.getFontButton(setting);
+
+ return this.addToGrid(label, widget);
+ }
+
getLabel(text, isTitle)
{
let marginLR = 0;
@@ -185,6 +193,17 @@ class ClapperPrefsGrid extends Gtk.Grid
return checkButton;
}
+ getFontButton(setting)
+ {
+ let fontButton = new Gtk.FontButton({
+ use_font: true,
+ use_size: true,
+ });
+ settings.bind(setting, fontButton, 'font', this.flag);
+
+ return fontButton;
+ }
+
_onClose(name)
{
if(name)
diff --git a/data/com.github.rafostar.Clapper.gschema.xml b/data/com.github.rafostar.Clapper.gschema.xml
index ef7dd038..124748bd 100644
--- a/data/com.github.rafostar.Clapper.gschema.xml
+++ b/data/com.github.rafostar.Clapper.gschema.xml
@@ -48,6 +48,10 @@
0
Offset time for subtitle tracks relative to video (milliseconds)
+
+ "Sans 12"
+ The subtitles font description
+