Customize external subtitles font

This commit is contained in:
Rafostar
2020-11-24 17:54:53 +01:00
parent 3fcd612e6e
commit 9ad1a11452
5 changed files with 32 additions and 12 deletions

View File

@@ -193,12 +193,10 @@ class ClapperPrefsDialog extends Gtk.Dialog
title: 'Audio',
widget: Prefs.AudioPage,
},
/*
{
title: 'Subtitles',
widget: Prefs.SubtitlesPage,
}
*/
]
},
{

View File

@@ -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 = [];

View File

@@ -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');
}
});

View File

@@ -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)

View File

@@ -48,6 +48,10 @@
<default>0</default>
<summary>Offset time for subtitle tracks relative to video (milliseconds)</summary>
</key>
<key name="subtitle-font" type="s">
<default>"Sans 12"</default>
<summary>The subtitles font description</summary>
</key>
<!-- Tweaks -->
<key name="render-shadows" type="b">