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', title: 'Audio',
widget: Prefs.AudioPage, widget: Prefs.AudioPage,
}, },
/*
{ {
title: 'Subtitles', title: 'Subtitles',
widget: Prefs.SubtitlesPage, widget: Prefs.SubtitlesPage,
} }
*/
] ]
}, },
{ {

View File

@@ -89,7 +89,8 @@ class ClapperPlayerBase extends GstPlayer.Player
for(let key of settingsToSet) for(let key of settingsToSet)
this._onSettingsKeyChanged(settings, key); 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() set_initial_config()
@@ -123,13 +124,6 @@ class ClapperPlayerBase extends GstPlayer.Player
debug(`could not change option: ${option}`); 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() set_all_plugins_ranks()
{ {
let data = []; let data = [];

View File

@@ -84,8 +84,13 @@ class ClapperSubtitlesPage extends PrefsBase.Grid
{ {
super._init(); super._init();
this.addTitle('Synchronization'); /* FIXME: This should be moved to subtitles popup and displayed only when
this.addSpinButton('Offset (milliseconds)', -5000, 5000, 'subtitle-offset', 25); 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); 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) getLabel(text, isTitle)
{ {
let marginLR = 0; let marginLR = 0;
@@ -185,6 +193,17 @@ class ClapperPrefsGrid extends Gtk.Grid
return checkButton; 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) _onClose(name)
{ {
if(name) if(name)

View File

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