mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-31 16:31:58 +02:00
Use "const" where possible
Increase readability by using "const" for identifiers that will not be reassigned
This commit is contained in:
@@ -4,7 +4,7 @@ const { HeaderBar } = imports.clapper_src.headerbar;
|
|||||||
const { Widget } = imports.clapper_src.widget;
|
const { Widget } = imports.clapper_src.widget;
|
||||||
const Debug = imports.clapper_src.debug;
|
const Debug = imports.clapper_src.debug;
|
||||||
|
|
||||||
let { debug } = Debug;
|
const { debug } = Debug;
|
||||||
|
|
||||||
var App = GObject.registerClass(
|
var App = GObject.registerClass(
|
||||||
class ClapperApp extends AppBase
|
class ClapperApp extends AppBase
|
||||||
@@ -27,13 +27,13 @@ class ClapperApp extends AppBase
|
|||||||
this.active_window.isClapperApp = true;
|
this.active_window.isClapperApp = true;
|
||||||
this.active_window.add_css_class('nobackground');
|
this.active_window.add_css_class('nobackground');
|
||||||
|
|
||||||
let clapperWidget = new Widget();
|
const clapperWidget = new Widget();
|
||||||
this.active_window.set_child(clapperWidget);
|
this.active_window.set_child(clapperWidget);
|
||||||
|
|
||||||
let headerBar = new HeaderBar(this.active_window);
|
const headerBar = new HeaderBar(this.active_window);
|
||||||
this.active_window.set_titlebar(headerBar);
|
this.active_window.set_titlebar(headerBar);
|
||||||
|
|
||||||
let size = clapperWidget.windowSize;
|
const size = clapperWidget.windowSize;
|
||||||
this.active_window.set_default_size(size[0], size[1]);
|
this.active_window.set_default_size(size[0], size[1]);
|
||||||
debug(`restored window size: ${size[0]}x${size[1]}`);
|
debug(`restored window size: ${size[0]}x${size[1]}`);
|
||||||
}
|
}
|
||||||
@@ -62,7 +62,7 @@ class ClapperApp extends AppBase
|
|||||||
if(!this.playlist.length)
|
if(!this.playlist.length)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let { player } = window.get_child();
|
const { player } = window.get_child();
|
||||||
player.set_playlist(this.playlist);
|
player.set_playlist(this.playlist);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -3,8 +3,8 @@ const Debug = imports.clapper_src.debug;
|
|||||||
const Menu = imports.clapper_src.menu;
|
const Menu = imports.clapper_src.menu;
|
||||||
const Misc = imports.clapper_src.misc;
|
const Misc = imports.clapper_src.misc;
|
||||||
|
|
||||||
let { debug } = Debug;
|
const { debug } = Debug;
|
||||||
let { settings } = Misc;
|
const { settings } = Misc;
|
||||||
|
|
||||||
var AppBase = GObject.registerClass(
|
var AppBase = GObject.registerClass(
|
||||||
class ClapperAppBase extends Gtk.Application
|
class ClapperAppBase extends Gtk.Application
|
||||||
@@ -22,7 +22,7 @@ class ClapperAppBase extends Gtk.Application
|
|||||||
{
|
{
|
||||||
super.vfunc_startup();
|
super.vfunc_startup();
|
||||||
|
|
||||||
let window = new Gtk.ApplicationWindow({
|
const window = new Gtk.ApplicationWindow({
|
||||||
application: this,
|
application: this,
|
||||||
title: Misc.appName,
|
title: Misc.appName,
|
||||||
});
|
});
|
||||||
@@ -37,7 +37,7 @@ class ClapperAppBase extends Gtk.Application
|
|||||||
window.add_css_class('brightscale');
|
window.add_css_class('brightscale');
|
||||||
|
|
||||||
for(let action in Menu.actions) {
|
for(let action in Menu.actions) {
|
||||||
let simpleAction = new Gio.SimpleAction({
|
const simpleAction = new Gio.SimpleAction({
|
||||||
name: action
|
name: action
|
||||||
});
|
});
|
||||||
simpleAction.connect(
|
simpleAction.connect(
|
||||||
@@ -66,7 +66,7 @@ class ClapperAppBase extends Gtk.Application
|
|||||||
|
|
||||||
_onFirstActivate()
|
_onFirstActivate()
|
||||||
{
|
{
|
||||||
let gtkSettings = Gtk.Settings.get_default();
|
const gtkSettings = Gtk.Settings.get_default();
|
||||||
settings.bind(
|
settings.bind(
|
||||||
'dark-theme', gtkSettings,
|
'dark-theme', gtkSettings,
|
||||||
'gtk-application-prefer-dark-theme',
|
'gtk-application-prefer-dark-theme',
|
||||||
|
@@ -10,10 +10,10 @@ class ClapperAppRemote extends AppBase
|
|||||||
{
|
{
|
||||||
super.vfunc_startup();
|
super.vfunc_startup();
|
||||||
|
|
||||||
let clapperWidget = new WidgetRemote();
|
const clapperWidget = new WidgetRemote();
|
||||||
this.active_window.set_child(clapperWidget);
|
this.active_window.set_child(clapperWidget);
|
||||||
|
|
||||||
let headerBar = new HeaderBarBase(this.active_window);
|
const headerBar = new HeaderBarBase(this.active_window);
|
||||||
this.active_window.set_titlebar(headerBar);
|
this.active_window.set_titlebar(headerBar);
|
||||||
|
|
||||||
this.active_window.maximize();
|
this.active_window.maximize();
|
||||||
|
@@ -7,7 +7,7 @@ class ClapperCustomButton extends Gtk.Button
|
|||||||
{
|
{
|
||||||
opts = opts || {};
|
opts = opts || {};
|
||||||
|
|
||||||
let defaults = {
|
const defaults = {
|
||||||
margin_top: 4,
|
margin_top: 4,
|
||||||
margin_bottom: 4,
|
margin_bottom: 4,
|
||||||
margin_start: 2,
|
margin_start: 2,
|
||||||
@@ -70,7 +70,7 @@ class ClapperCustomButton extends Gtk.Button
|
|||||||
if(!this.isFullscreen)
|
if(!this.isFullscreen)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let { player } = this.get_ancestor(Gtk.Grid);
|
const { player } = this.get_ancestor(Gtk.Grid);
|
||||||
player._setHideControlsTimeout();
|
player._setHideControlsTimeout();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -174,11 +174,11 @@ class ClapperPopoverButton extends IconButton
|
|||||||
|
|
||||||
this.popover.set_offset(0, -this.margin_top);
|
this.popover.set_offset(0, -this.margin_top);
|
||||||
|
|
||||||
let cssClass = 'osd';
|
const cssClass = 'osd';
|
||||||
if(isFullscreen === this.popover.has_css_class(cssClass))
|
if(isFullscreen === this.popover.has_css_class(cssClass))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let action = (isFullscreen) ? 'add' : 'remove';
|
const action = (isFullscreen) ? 'add' : 'remove';
|
||||||
this.popover[action + '_css_class'](cssClass);
|
this.popover[action + '_css_class'](cssClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,7 +192,7 @@ class ClapperPopoverButton extends IconButton
|
|||||||
|
|
||||||
_onClosed()
|
_onClosed()
|
||||||
{
|
{
|
||||||
let { player } = this.get_ancestor(Gtk.Grid);
|
const { player } = this.get_ancestor(Gtk.Grid);
|
||||||
player.widget.grab_focus();
|
player.widget.grab_focus();
|
||||||
|
|
||||||
this.unset_state_flags(Gtk.StateFlags.CHECKED);
|
this.unset_state_flags(Gtk.StateFlags.CHECKED);
|
||||||
|
82
clapper_src/controls.js
vendored
82
clapper_src/controls.js
vendored
@@ -7,8 +7,8 @@ const Revealers = imports.clapper_src.revealers;
|
|||||||
const CONTROLS_MARGIN = 2;
|
const CONTROLS_MARGIN = 2;
|
||||||
const CONTROLS_SPACING = 0;
|
const CONTROLS_SPACING = 0;
|
||||||
|
|
||||||
let { debug } = Debug;
|
const { debug } = Debug;
|
||||||
let { settings } = Misc;
|
const { settings } = Misc;
|
||||||
|
|
||||||
var Controls = GObject.registerClass(
|
var Controls = GObject.registerClass(
|
||||||
class ClapperControls extends Gtk.Box
|
class ClapperControls extends Gtk.Box
|
||||||
@@ -37,7 +37,7 @@ class ClapperControls extends Gtk.Box
|
|||||||
|
|
||||||
this._addTogglePlayButton();
|
this._addTogglePlayButton();
|
||||||
|
|
||||||
let elapsedRevealer = new Revealers.ButtonsRevealer('SLIDE_RIGHT');
|
const elapsedRevealer = new Revealers.ButtonsRevealer('SLIDE_RIGHT');
|
||||||
this.elapsedButton = this.addLabelButton('00:00/00:00', elapsedRevealer);
|
this.elapsedButton = this.addLabelButton('00:00/00:00', elapsedRevealer);
|
||||||
elapsedRevealer.set_reveal_child(true);
|
elapsedRevealer.set_reveal_child(true);
|
||||||
this.revealersArr.push(elapsedRevealer);
|
this.revealersArr.push(elapsedRevealer);
|
||||||
@@ -45,14 +45,16 @@ class ClapperControls extends Gtk.Box
|
|||||||
|
|
||||||
this._addPositionScale();
|
this._addPositionScale();
|
||||||
|
|
||||||
let revealTracksButton = new Buttons.IconToggleButton(
|
const revealTracksButton = new Buttons.IconToggleButton(
|
||||||
'go-previous-symbolic',
|
'go-previous-symbolic',
|
||||||
'go-next-symbolic'
|
'go-next-symbolic'
|
||||||
);
|
);
|
||||||
revealTracksButton.floatUnaffected = false;
|
revealTracksButton.floatUnaffected = false;
|
||||||
revealTracksButton.add_css_class('narrowbutton');
|
revealTracksButton.add_css_class('narrowbutton');
|
||||||
this.buttonsArr.push(revealTracksButton);
|
this.buttonsArr.push(revealTracksButton);
|
||||||
let tracksRevealer = new Revealers.ButtonsRevealer('SLIDE_LEFT', revealTracksButton);
|
const tracksRevealer = new Revealers.ButtonsRevealer(
|
||||||
|
'SLIDE_LEFT', revealTracksButton
|
||||||
|
);
|
||||||
this.visualizationsButton = this.addPopoverButton(
|
this.visualizationsButton = this.addPopoverButton(
|
||||||
'display-projector-symbolic',
|
'display-projector-symbolic',
|
||||||
tracksRevealer
|
tracksRevealer
|
||||||
@@ -96,7 +98,7 @@ class ClapperControls extends Gtk.Box
|
|||||||
this.unfloatButton.connect('clicked', this._onUnfloatClicked.bind(this));
|
this.unfloatButton.connect('clicked', this._onUnfloatClicked.bind(this));
|
||||||
this.unfloatButton.set_visible(false);
|
this.unfloatButton.set_visible(false);
|
||||||
|
|
||||||
let keyController = new Gtk.EventControllerKey();
|
const keyController = new Gtk.EventControllerKey();
|
||||||
keyController.connect('key-pressed', this._onControlsKeyPressed.bind(this));
|
keyController.connect('key-pressed', this._onControlsKeyPressed.bind(this));
|
||||||
keyController.connect('key-released', this._onControlsKeyReleased.bind(this));
|
keyController.connect('key-released', this._onControlsKeyReleased.bind(this));
|
||||||
this.add_controller(keyController);
|
this.add_controller(keyController);
|
||||||
@@ -137,7 +139,7 @@ class ClapperControls extends Gtk.Box
|
|||||||
{
|
{
|
||||||
value = value || 0;
|
value = value || 0;
|
||||||
|
|
||||||
let elapsed = Misc.getFormattedTime(value, this.showHours)
|
const elapsed = Misc.getFormattedTime(value, this.showHours)
|
||||||
+ '/' + this.durationFormatted;
|
+ '/' + this.durationFormatted;
|
||||||
|
|
||||||
this.elapsedButton.set_label(elapsed);
|
this.elapsedButton.set_label(elapsed);
|
||||||
@@ -145,7 +147,7 @@ class ClapperControls extends Gtk.Box
|
|||||||
|
|
||||||
addButton(buttonIcon, revealer)
|
addButton(buttonIcon, revealer)
|
||||||
{
|
{
|
||||||
let button = (buttonIcon instanceof Gtk.Button)
|
const button = (buttonIcon instanceof Gtk.Button)
|
||||||
? buttonIcon
|
? buttonIcon
|
||||||
: new Buttons.IconButton(buttonIcon);
|
: new Buttons.IconButton(buttonIcon);
|
||||||
|
|
||||||
@@ -162,14 +164,14 @@ class ClapperControls extends Gtk.Box
|
|||||||
addLabelButton(text, revealer)
|
addLabelButton(text, revealer)
|
||||||
{
|
{
|
||||||
text = text || '';
|
text = text || '';
|
||||||
let button = new Buttons.LabelButton(text);
|
const button = new Buttons.LabelButton(text);
|
||||||
|
|
||||||
return this.addButton(button, revealer);
|
return this.addButton(button, revealer);
|
||||||
}
|
}
|
||||||
|
|
||||||
addPopoverButton(iconName, revealer)
|
addPopoverButton(iconName, revealer)
|
||||||
{
|
{
|
||||||
let button = new Buttons.PopoverButton(iconName);
|
const button = new Buttons.PopoverButton(iconName);
|
||||||
|
|
||||||
return this.addButton(button, revealer);
|
return this.addButton(button, revealer);
|
||||||
}
|
}
|
||||||
@@ -189,7 +191,7 @@ class ClapperControls extends Gtk.Box
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let el = array[i];
|
const el = array[i];
|
||||||
let checkButton;
|
let checkButton;
|
||||||
|
|
||||||
if(child) {
|
if(child) {
|
||||||
@@ -230,7 +232,7 @@ class ClapperControls extends Gtk.Box
|
|||||||
|
|
||||||
_handleTrackChange(checkButton)
|
_handleTrackChange(checkButton)
|
||||||
{
|
{
|
||||||
let clapperWidget = this.get_ancestor(Gtk.Grid);
|
const clapperWidget = this.get_ancestor(Gtk.Grid);
|
||||||
|
|
||||||
/* Reenabling audio is slow (as expected),
|
/* Reenabling audio is slow (as expected),
|
||||||
* so it is better to toggle mute instead */
|
* so it is better to toggle mute instead */
|
||||||
@@ -255,7 +257,7 @@ class ClapperControls extends Gtk.Box
|
|||||||
](false);
|
](false);
|
||||||
}
|
}
|
||||||
|
|
||||||
let setTrack = `set_${checkButton.type}_track`;
|
const setTrack = `set_${checkButton.type}_track`;
|
||||||
|
|
||||||
clapperWidget.player[setTrack](checkButton.activeId);
|
clapperWidget.player[setTrack](checkButton.activeId);
|
||||||
clapperWidget.player[`${setTrack}_enabled`](true);
|
clapperWidget.player[`${setTrack}_enabled`](true);
|
||||||
@@ -266,8 +268,8 @@ class ClapperControls extends Gtk.Box
|
|||||||
|
|
||||||
_handleVisualizationChange(checkButton)
|
_handleVisualizationChange(checkButton)
|
||||||
{
|
{
|
||||||
let clapperWidget = this.get_ancestor(Gtk.Grid);
|
const clapperWidget = this.get_ancestor(Gtk.Grid);
|
||||||
let isEnabled = clapperWidget.player.get_visualization_enabled();
|
const isEnabled = clapperWidget.player.get_visualization_enabled();
|
||||||
|
|
||||||
if(!checkButton.activeId) {
|
if(!checkButton.activeId) {
|
||||||
if(isEnabled) {
|
if(isEnabled) {
|
||||||
@@ -277,7 +279,7 @@ class ClapperControls extends Gtk.Box
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let currVis = clapperWidget.player.get_current_visualization();
|
const currVis = clapperWidget.player.get_current_visualization();
|
||||||
|
|
||||||
if(currVis === checkButton.activeId)
|
if(currVis === checkButton.activeId)
|
||||||
return;
|
return;
|
||||||
@@ -315,7 +317,7 @@ class ClapperControls extends Gtk.Box
|
|||||||
can_focus: false,
|
can_focus: false,
|
||||||
visible: false,
|
visible: false,
|
||||||
});
|
});
|
||||||
let scrollController = new Gtk.EventControllerScroll();
|
const scrollController = new Gtk.EventControllerScroll();
|
||||||
scrollController.set_flags(Gtk.EventControllerScrollFlags.BOTH_AXES);
|
scrollController.set_flags(Gtk.EventControllerScrollFlags.BOTH_AXES);
|
||||||
scrollController.connect('scroll', this._onPositionScaleScroll.bind(this));
|
scrollController.connect('scroll', this._onPositionScaleScroll.bind(this));
|
||||||
this.positionScale.add_controller(scrollController);
|
this.positionScale.add_controller(scrollController);
|
||||||
@@ -336,7 +338,7 @@ class ClapperControls extends Gtk.Box
|
|||||||
this.positionAdjustment.set_page_increment(0);
|
this.positionAdjustment.set_page_increment(0);
|
||||||
this.positionAdjustment.set_step_increment(8);
|
this.positionAdjustment.set_step_increment(8);
|
||||||
|
|
||||||
let box = new Gtk.Box({
|
const box = new Gtk.Box({
|
||||||
orientation: Gtk.Orientation.HORIZONTAL,
|
orientation: Gtk.Orientation.HORIZONTAL,
|
||||||
hexpand: true,
|
hexpand: true,
|
||||||
valign: Gtk.Align.CENTER,
|
valign: Gtk.Align.CENTER,
|
||||||
@@ -366,7 +368,7 @@ class ClapperControls extends Gtk.Box
|
|||||||
this.volumeAdjustment.set_page_increment(0.05);
|
this.volumeAdjustment.set_page_increment(0.05);
|
||||||
|
|
||||||
for(let i of [0, 1, Misc.maxVolume]) {
|
for(let i of [0, 1, Misc.maxVolume]) {
|
||||||
let text = (!i) ? '0%' : (i % 1 === 0) ? `${i}00%` : `${i * 10}0%`;
|
const text = (!i) ? '0%' : (i % 1 === 0) ? `${i}00%` : `${i * 10}0%`;
|
||||||
this.volumeScale.add_mark(i, Gtk.PositionType.LEFT, text);
|
this.volumeScale.add_mark(i, Gtk.PositionType.LEFT, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -378,7 +380,7 @@ class ClapperControls extends Gtk.Box
|
|||||||
|
|
||||||
_updateVolumeButtonIcon(volume)
|
_updateVolumeButtonIcon(volume)
|
||||||
{
|
{
|
||||||
let icon = (volume <= 0)
|
const icon = (volume <= 0)
|
||||||
? 'muted'
|
? 'muted'
|
||||||
: (volume <= 0.3)
|
: (volume <= 0.3)
|
||||||
? 'low'
|
? 'low'
|
||||||
@@ -388,7 +390,7 @@ class ClapperControls extends Gtk.Box
|
|||||||
? 'high'
|
? 'high'
|
||||||
: 'overamplified';
|
: 'overamplified';
|
||||||
|
|
||||||
let iconName = `audio-volume-${icon}-symbolic`;
|
const iconName = `audio-volume-${icon}-symbolic`;
|
||||||
if(this.volumeButton.icon_name === iconName)
|
if(this.volumeButton.icon_name === iconName)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -401,8 +403,8 @@ class ClapperControls extends Gtk.Box
|
|||||||
this.disconnect(this.realizeSignal);
|
this.disconnect(this.realizeSignal);
|
||||||
this.realizeSignal = null;
|
this.realizeSignal = null;
|
||||||
|
|
||||||
let { player } = this.get_ancestor(Gtk.Grid);
|
const { player } = this.get_ancestor(Gtk.Grid);
|
||||||
let scrollController = new Gtk.EventControllerScroll();
|
const scrollController = new Gtk.EventControllerScroll();
|
||||||
scrollController.set_flags(
|
scrollController.set_flags(
|
||||||
Gtk.EventControllerScrollFlags.VERTICAL
|
Gtk.EventControllerScrollFlags.VERTICAL
|
||||||
| Gtk.EventControllerScrollFlags.DISCRETE
|
| Gtk.EventControllerScrollFlags.DISCRETE
|
||||||
@@ -410,7 +412,7 @@ class ClapperControls extends Gtk.Box
|
|||||||
scrollController.connect('scroll', player._onScroll.bind(player));
|
scrollController.connect('scroll', player._onScroll.bind(player));
|
||||||
this.volumeButton.add_controller(scrollController);
|
this.volumeButton.add_controller(scrollController);
|
||||||
|
|
||||||
let initialVolume = (settings.get_string('volume-initial') === 'custom')
|
const initialVolume = (settings.get_string('volume-initial') === 'custom')
|
||||||
? settings.get_int('volume-value') / 100
|
? settings.get_int('volume-value') / 100
|
||||||
: Misc.getCubicValue(settings.get_double('volume-last'));
|
: Misc.getCubicValue(settings.get_double('volume-last'));
|
||||||
|
|
||||||
@@ -420,7 +422,7 @@ class ClapperControls extends Gtk.Box
|
|||||||
|
|
||||||
_onPlayerResize(widget, width, height)
|
_onPlayerResize(widget, width, height)
|
||||||
{
|
{
|
||||||
let isMobile = (width < 560);
|
const isMobile = (width < 560);
|
||||||
if(this.isMobile === isMobile)
|
if(this.isMobile === isMobile)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -433,13 +435,13 @@ class ClapperControls extends Gtk.Box
|
|||||||
|
|
||||||
_onUnfullscreenClicked(button)
|
_onUnfullscreenClicked(button)
|
||||||
{
|
{
|
||||||
let root = button.get_root();
|
const root = button.get_root();
|
||||||
root.unfullscreen();
|
root.unfullscreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
_onUnfloatClicked(button)
|
_onUnfloatClicked(button)
|
||||||
{
|
{
|
||||||
let clapperWidget = this.get_ancestor(Gtk.Grid);
|
const clapperWidget = this.get_ancestor(Gtk.Grid);
|
||||||
clapperWidget.setFloatingMode(false);
|
clapperWidget.setFloatingMode(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -465,19 +467,19 @@ class ClapperControls extends Gtk.Box
|
|||||||
_onTogglePlayClicked()
|
_onTogglePlayClicked()
|
||||||
{
|
{
|
||||||
/* Parent of controls changes, so get ancestor instead */
|
/* Parent of controls changes, so get ancestor instead */
|
||||||
let { player } = this.get_ancestor(Gtk.Grid);
|
const { player } = this.get_ancestor(Gtk.Grid);
|
||||||
player.toggle_play();
|
player.toggle_play();
|
||||||
}
|
}
|
||||||
|
|
||||||
_onPositionScaleScroll(controller, dx, dy)
|
_onPositionScaleScroll(controller, dx, dy)
|
||||||
{
|
{
|
||||||
let { player } = this.get_ancestor(Gtk.Grid);
|
const { player } = this.get_ancestor(Gtk.Grid);
|
||||||
player._onScroll(controller, dx || dy, 0);
|
player._onScroll(controller, dx || dy, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
_onPositionScaleValueChanged(scale)
|
_onPositionScaleValueChanged(scale)
|
||||||
{
|
{
|
||||||
let positionSeconds = Math.round(scale.get_value());
|
const positionSeconds = Math.round(scale.get_value());
|
||||||
|
|
||||||
this.currentPosition = positionSeconds;
|
this.currentPosition = positionSeconds;
|
||||||
this.updateElapsedLabel(positionSeconds);
|
this.updateElapsedLabel(positionSeconds);
|
||||||
@@ -485,16 +487,16 @@ class ClapperControls extends Gtk.Box
|
|||||||
|
|
||||||
_onVolumeScaleValueChanged(scale)
|
_onVolumeScaleValueChanged(scale)
|
||||||
{
|
{
|
||||||
let volume = scale.get_value();
|
const volume = scale.get_value();
|
||||||
let linearVolume = Misc.getLinearValue(volume);
|
const linearVolume = Misc.getLinearValue(volume);
|
||||||
let { player } = this.get_ancestor(Gtk.Grid);
|
const { player } = this.get_ancestor(Gtk.Grid);
|
||||||
|
|
||||||
player.set_volume(linearVolume);
|
player.set_volume(linearVolume);
|
||||||
|
|
||||||
/* FIXME: All of below should be placed in 'volume-changed'
|
/* FIXME: All of below should be placed in 'volume-changed'
|
||||||
* event once we move to message bus API */
|
* event once we move to message bus API */
|
||||||
let cssClass = 'overamp';
|
const cssClass = 'overamp';
|
||||||
let hasOveramp = (scale.has_css_class(cssClass));
|
const hasOveramp = (scale.has_css_class(cssClass));
|
||||||
|
|
||||||
if(volume > 1) {
|
if(volume > 1) {
|
||||||
if(!hasOveramp)
|
if(!hasOveramp)
|
||||||
@@ -510,22 +512,22 @@ class ClapperControls extends Gtk.Box
|
|||||||
|
|
||||||
_onPositionScaleDragging(scale)
|
_onPositionScaleDragging(scale)
|
||||||
{
|
{
|
||||||
let isPositionDragging = scale.has_css_class('dragging');
|
const isPositionDragging = scale.has_css_class('dragging');
|
||||||
|
|
||||||
if((this.isPositionDragging = isPositionDragging))
|
if((this.isPositionDragging = isPositionDragging))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let clapperWidget = this.get_ancestor(Gtk.Grid);
|
const clapperWidget = this.get_ancestor(Gtk.Grid);
|
||||||
if(!clapperWidget) return;
|
if(!clapperWidget) return;
|
||||||
|
|
||||||
let positionSeconds = Math.round(scale.get_value());
|
const positionSeconds = Math.round(scale.get_value());
|
||||||
clapperWidget.player.seek_seconds(positionSeconds);
|
clapperWidget.player.seek_seconds(positionSeconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Only happens when navigating through controls panel */
|
/* Only happens when navigating through controls panel */
|
||||||
_onControlsKeyPressed(controller, keyval, keycode, state)
|
_onControlsKeyPressed(controller, keyval, keycode, state)
|
||||||
{
|
{
|
||||||
let { player } = this.get_ancestor(Gtk.Grid);
|
const { player } = this.get_ancestor(Gtk.Grid);
|
||||||
player._setHideControlsTimeout();
|
player._setHideControlsTimeout();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -539,7 +541,7 @@ class ClapperControls extends Gtk.Box
|
|||||||
case Gdk.KEY_Left:
|
case Gdk.KEY_Left:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
let { player } = this.get_ancestor(Gtk.Grid);
|
const { player } = this.get_ancestor(Gtk.Grid);
|
||||||
player._onWidgetKeyReleased(controller, keyval, keycode, state);
|
player._onWidgetKeyReleased(controller, keyval, keycode, state);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -1,14 +1,14 @@
|
|||||||
const { Gio, GLib, GObject } = imports.gi;
|
const { Gio, GLib, GObject } = imports.gi;
|
||||||
const Debug = imports.clapper_src.debug;
|
const Debug = imports.clapper_src.debug;
|
||||||
|
|
||||||
let { debug } = Debug;
|
const { debug } = Debug;
|
||||||
|
|
||||||
var Daemon = GObject.registerClass(
|
var Daemon = GObject.registerClass(
|
||||||
class ClapperDaemon extends Gio.SubprocessLauncher
|
class ClapperDaemon extends Gio.SubprocessLauncher
|
||||||
{
|
{
|
||||||
_init()
|
_init()
|
||||||
{
|
{
|
||||||
let port = ARGV[0] || 8080;
|
const port = ARGV[0] || 8080;
|
||||||
|
|
||||||
/* FIXME: show output when debugging is on */
|
/* FIXME: show output when debugging is on */
|
||||||
const flags = Gio.SubprocessFlags.STDOUT_SILENCE
|
const flags = Gio.SubprocessFlags.STDOUT_SILENCE
|
||||||
|
@@ -4,7 +4,7 @@ const Misc = imports.clapper_src.misc;
|
|||||||
const Prefs = imports.clapper_src.prefs;
|
const Prefs = imports.clapper_src.prefs;
|
||||||
const PrefsBase = imports.clapper_src.prefsBase;
|
const PrefsBase = imports.clapper_src.prefsBase;
|
||||||
|
|
||||||
let { debug } = Debug;
|
const { debug } = Debug;
|
||||||
|
|
||||||
var FileChooser = GObject.registerClass(
|
var FileChooser = GObject.registerClass(
|
||||||
class ClapperFileChooser extends Gtk.FileChooserNative
|
class ClapperFileChooser extends Gtk.FileChooserNative
|
||||||
@@ -17,7 +17,7 @@ class ClapperFileChooser extends Gtk.FileChooserNative
|
|||||||
select_multiple: true,
|
select_multiple: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
let filter = new Gtk.FileFilter({
|
const filter = new Gtk.FileFilter({
|
||||||
name: 'Media Files',
|
name: 'Media Files',
|
||||||
});
|
});
|
||||||
filter.add_mime_type('video/*');
|
filter.add_mime_type('video/*');
|
||||||
@@ -44,16 +44,16 @@ class ClapperFileChooser extends Gtk.FileChooserNative
|
|||||||
this.responseSignal = null;
|
this.responseSignal = null;
|
||||||
|
|
||||||
if(response === Gtk.ResponseType.ACCEPT) {
|
if(response === Gtk.ResponseType.ACCEPT) {
|
||||||
let index = 0;
|
const files = this.get_files();
|
||||||
let files = this.get_files();
|
const playlist = [];
|
||||||
|
|
||||||
|
let index = 0;
|
||||||
let file;
|
let file;
|
||||||
let subs;
|
let subs;
|
||||||
let playlist = [];
|
|
||||||
|
|
||||||
while((file = files.get_item(index))) {
|
while((file = files.get_item(index))) {
|
||||||
let filename = file.get_basename();
|
const filename = file.get_basename();
|
||||||
let [type, isUncertain] = Gio.content_type_guess(filename, null);
|
const [type, isUncertain] = Gio.content_type_guess(filename, null);
|
||||||
|
|
||||||
if(this.subsMimes.includes(type)) {
|
if(this.subsMimes.includes(type)) {
|
||||||
subs = file;
|
subs = file;
|
||||||
@@ -66,7 +66,7 @@ class ClapperFileChooser extends Gtk.FileChooserNative
|
|||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
let { player } = this.get_transient_for().get_child();
|
const { player } = this.get_transient_for().get_child();
|
||||||
|
|
||||||
if(playlist.length)
|
if(playlist.length)
|
||||||
player.set_playlist(playlist);
|
player.set_playlist(playlist);
|
||||||
@@ -94,14 +94,14 @@ class ClapperUriDialog extends Gtk.Dialog
|
|||||||
default_width: 460,
|
default_width: 460,
|
||||||
});
|
});
|
||||||
|
|
||||||
let box = new Gtk.Box({
|
const box = new Gtk.Box({
|
||||||
orientation: Gtk.Orientation.HORIZONTAL,
|
orientation: Gtk.Orientation.HORIZONTAL,
|
||||||
valign: Gtk.Align.CENTER,
|
valign: Gtk.Align.CENTER,
|
||||||
spacing: 6,
|
spacing: 6,
|
||||||
});
|
});
|
||||||
box.add_css_class('uridialogbox');
|
box.add_css_class('uridialogbox');
|
||||||
|
|
||||||
let linkEntry = new Gtk.Entry({
|
const linkEntry = new Gtk.Entry({
|
||||||
activates_default: true,
|
activates_default: true,
|
||||||
truncate_multiline: true,
|
truncate_multiline: true,
|
||||||
width_request: 220,
|
width_request: 220,
|
||||||
@@ -112,7 +112,7 @@ class ClapperUriDialog extends Gtk.Dialog
|
|||||||
linkEntry.connect('notify::text', this._onTextNotify.bind(this));
|
linkEntry.connect('notify::text', this._onTextNotify.bind(this));
|
||||||
box.append(linkEntry);
|
box.append(linkEntry);
|
||||||
|
|
||||||
let openButton = new Gtk.Button({
|
const openButton = new Gtk.Button({
|
||||||
label: "Open",
|
label: "Open",
|
||||||
halign: Gtk.Align.END,
|
halign: Gtk.Align.END,
|
||||||
sensitive: false,
|
sensitive: false,
|
||||||
@@ -120,7 +120,7 @@ class ClapperUriDialog extends Gtk.Dialog
|
|||||||
openButton.connect('clicked', this._onOpenButtonClicked.bind(this));
|
openButton.connect('clicked', this._onOpenButtonClicked.bind(this));
|
||||||
box.append(openButton);
|
box.append(openButton);
|
||||||
|
|
||||||
let area = this.get_content_area();
|
const area = this.get_content_area();
|
||||||
area.append(box);
|
area.append(box);
|
||||||
|
|
||||||
this.closeSignal = this.connect('close-request', this._onCloseRequest.bind(this));
|
this.closeSignal = this.connect('close-request', this._onCloseRequest.bind(this));
|
||||||
@@ -131,7 +131,7 @@ class ClapperUriDialog extends Gtk.Dialog
|
|||||||
|
|
||||||
openUri(uri)
|
openUri(uri)
|
||||||
{
|
{
|
||||||
let { player } = this.get_transient_for().get_child();
|
const { player } = this.get_transient_for().get_child();
|
||||||
player.set_playlist([uri]);
|
player.set_playlist([uri]);
|
||||||
|
|
||||||
this.close();
|
this.close();
|
||||||
@@ -139,17 +139,17 @@ class ClapperUriDialog extends Gtk.Dialog
|
|||||||
|
|
||||||
_onTextNotify(entry)
|
_onTextNotify(entry)
|
||||||
{
|
{
|
||||||
let isUriValid = (entry.text.length)
|
const isUriValid = (entry.text.length)
|
||||||
? Gst.uri_is_valid(entry.text)
|
? Gst.uri_is_valid(entry.text)
|
||||||
: false;
|
: false;
|
||||||
|
|
||||||
let button = entry.get_next_sibling();
|
const button = entry.get_next_sibling();
|
||||||
button.set_sensitive(isUriValid);
|
button.set_sensitive(isUriValid);
|
||||||
}
|
}
|
||||||
|
|
||||||
_onOpenButtonClicked(button)
|
_onOpenButtonClicked(button)
|
||||||
{
|
{
|
||||||
let entry = button.get_prev_sibling();
|
const entry = button.get_prev_sibling();
|
||||||
this.openUri(entry.text);
|
this.openUri(entry.text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,7 +176,7 @@ class ClapperPrefsDialog extends Gtk.Dialog
|
|||||||
default_height: 400,
|
default_height: 400,
|
||||||
});
|
});
|
||||||
|
|
||||||
let pages = [
|
const pages = [
|
||||||
{
|
{
|
||||||
title: 'Player',
|
title: 'Player',
|
||||||
pages: [
|
pages: [
|
||||||
@@ -217,10 +217,10 @@ class ClapperPrefsDialog extends Gtk.Dialog
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
let prefsNotebook = new PrefsBase.Notebook(pages);
|
const prefsNotebook = new PrefsBase.Notebook(pages);
|
||||||
prefsNotebook.add_css_class('prefsnotebook');
|
prefsNotebook.add_css_class('prefsnotebook');
|
||||||
|
|
||||||
let area = this.get_content_area();
|
const area = this.get_content_area();
|
||||||
area.append(prefsNotebook);
|
area.append(prefsNotebook);
|
||||||
|
|
||||||
this.closeSignal = this.connect('close-request', this._onCloseRequest.bind(this));
|
this.closeSignal = this.connect('close-request', this._onCloseRequest.bind(this));
|
||||||
@@ -236,8 +236,8 @@ class ClapperPrefsDialog extends Gtk.Dialog
|
|||||||
dialog.disconnect(this.closeSignal);
|
dialog.disconnect(this.closeSignal);
|
||||||
this.closeSignal = null;
|
this.closeSignal = null;
|
||||||
|
|
||||||
let area = dialog.get_content_area();
|
const area = dialog.get_content_area();
|
||||||
let notebook = area.get_first_child();
|
const notebook = area.get_first_child();
|
||||||
notebook._onClose();
|
notebook._onClose();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -247,15 +247,15 @@ class ClapperAboutDialog extends Gtk.AboutDialog
|
|||||||
{
|
{
|
||||||
_init(window)
|
_init(window)
|
||||||
{
|
{
|
||||||
let gstVer = [
|
const gstVer = [
|
||||||
Gst.VERSION_MAJOR, Gst.VERSION_MINOR, Gst.VERSION_MICRO
|
Gst.VERSION_MAJOR, Gst.VERSION_MINOR, Gst.VERSION_MICRO
|
||||||
].join('.');
|
].join('.');
|
||||||
|
|
||||||
let gtkVer = [
|
const gtkVer = [
|
||||||
Gtk.MAJOR_VERSION, Gtk.MINOR_VERSION, Gtk.MICRO_VERSION
|
Gtk.MAJOR_VERSION, Gtk.MINOR_VERSION, Gtk.MICRO_VERSION
|
||||||
].join('.');
|
].join('.');
|
||||||
|
|
||||||
let osInfo = [
|
const osInfo = [
|
||||||
'GTK version' + ': ' + gtkVer,
|
'GTK version' + ': ' + gtkVer,
|
||||||
'GStreamer version' + ': ' + gstVer
|
'GStreamer version' + ': ' + gstVer
|
||||||
].join('\n');
|
].join('\n');
|
||||||
|
@@ -8,7 +8,7 @@ class ClapperHeaderBar extends HeaderBarBase
|
|||||||
{
|
{
|
||||||
super._init(window);
|
super._init(window);
|
||||||
|
|
||||||
let clapperWidget = window.get_child();
|
const clapperWidget = window.get_child();
|
||||||
clapperWidget.controls.unfloatButton.bind_property('visible', this, 'visible',
|
clapperWidget.controls.unfloatButton.bind_property('visible', this, 'visible',
|
||||||
GObject.BindingFlags.INVERT_BOOLEAN
|
GObject.BindingFlags.INVERT_BOOLEAN
|
||||||
);
|
);
|
||||||
@@ -16,13 +16,13 @@ class ClapperHeaderBar extends HeaderBarBase
|
|||||||
|
|
||||||
_onFloatButtonClicked()
|
_onFloatButtonClicked()
|
||||||
{
|
{
|
||||||
let clapperWidget = this.get_prev_sibling();
|
const clapperWidget = this.get_prev_sibling();
|
||||||
clapperWidget.setFloatingMode(true);
|
clapperWidget.setFloatingMode(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
_onFullscreenButtonClicked()
|
_onFullscreenButtonClicked()
|
||||||
{
|
{
|
||||||
let window = this.get_parent();
|
const window = this.get_parent();
|
||||||
window.fullscreen();
|
window.fullscreen();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -10,11 +10,11 @@ class ClapperHeaderBarBase extends Gtk.HeaderBar
|
|||||||
can_focus: false,
|
can_focus: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
let clapperPath = Misc.getClapperPath();
|
const clapperPath = Misc.getClapperPath();
|
||||||
let uiBuilder = Gtk.Builder.new_from_file(
|
const uiBuilder = Gtk.Builder.new_from_file(
|
||||||
`${clapperPath}/ui/clapper.ui`
|
`${clapperPath}/ui/clapper.ui`
|
||||||
);
|
);
|
||||||
let models = {
|
const models = {
|
||||||
addMediaMenu: uiBuilder.get_object('addMediaMenu'),
|
addMediaMenu: uiBuilder.get_object('addMediaMenu'),
|
||||||
settingsMenu: uiBuilder.get_object('settingsMenu'),
|
settingsMenu: uiBuilder.get_object('settingsMenu'),
|
||||||
};
|
};
|
||||||
@@ -22,32 +22,32 @@ class ClapperHeaderBarBase extends Gtk.HeaderBar
|
|||||||
this.add_css_class('noborder');
|
this.add_css_class('noborder');
|
||||||
this.set_title_widget(this._createWidgetForWindow(window));
|
this.set_title_widget(this._createWidgetForWindow(window));
|
||||||
|
|
||||||
let addMediaButton = new Gtk.MenuButton({
|
const addMediaButton = new Gtk.MenuButton({
|
||||||
icon_name: 'list-add-symbolic',
|
icon_name: 'list-add-symbolic',
|
||||||
});
|
});
|
||||||
let addMediaPopover = new HeaderBarPopover(models.addMediaMenu);
|
const addMediaPopover = new HeaderBarPopover(models.addMediaMenu);
|
||||||
addMediaButton.set_popover(addMediaPopover);
|
addMediaButton.set_popover(addMediaPopover);
|
||||||
this.pack_start(addMediaButton);
|
this.pack_start(addMediaButton);
|
||||||
|
|
||||||
let openMenuButton = new Gtk.MenuButton({
|
const openMenuButton = new Gtk.MenuButton({
|
||||||
icon_name: 'open-menu-symbolic',
|
icon_name: 'open-menu-symbolic',
|
||||||
});
|
});
|
||||||
let settingsPopover = new HeaderBarPopover(models.settingsMenu);
|
const settingsPopover = new HeaderBarPopover(models.settingsMenu);
|
||||||
openMenuButton.set_popover(settingsPopover);
|
openMenuButton.set_popover(settingsPopover);
|
||||||
this.pack_end(openMenuButton);
|
this.pack_end(openMenuButton);
|
||||||
|
|
||||||
let buttonsBox = new Gtk.Box({
|
const buttonsBox = new Gtk.Box({
|
||||||
orientation: Gtk.Orientation.HORIZONTAL,
|
orientation: Gtk.Orientation.HORIZONTAL,
|
||||||
});
|
});
|
||||||
buttonsBox.add_css_class('linked');
|
buttonsBox.add_css_class('linked');
|
||||||
|
|
||||||
let floatButton = new Gtk.Button({
|
const floatButton = new Gtk.Button({
|
||||||
icon_name: 'preferences-desktop-remote-desktop-symbolic',
|
icon_name: 'preferences-desktop-remote-desktop-symbolic',
|
||||||
});
|
});
|
||||||
floatButton.connect('clicked', this._onFloatButtonClicked.bind(this));
|
floatButton.connect('clicked', this._onFloatButtonClicked.bind(this));
|
||||||
buttonsBox.append(floatButton);
|
buttonsBox.append(floatButton);
|
||||||
|
|
||||||
let fullscreenButton = new Gtk.Button({
|
const fullscreenButton = new Gtk.Button({
|
||||||
icon_name: 'view-fullscreen-symbolic',
|
icon_name: 'view-fullscreen-symbolic',
|
||||||
});
|
});
|
||||||
fullscreenButton.connect('clicked', this._onFullscreenButtonClicked.bind(this));
|
fullscreenButton.connect('clicked', this._onFullscreenButtonClicked.bind(this));
|
||||||
@@ -67,7 +67,7 @@ class ClapperHeaderBarBase extends Gtk.HeaderBar
|
|||||||
|
|
||||||
_createWidgetForWindow(window)
|
_createWidgetForWindow(window)
|
||||||
{
|
{
|
||||||
let box = new Gtk.Box({
|
const box = new Gtk.Box({
|
||||||
orientation: Gtk.Orientation.VERTICAL,
|
orientation: Gtk.Orientation.VERTICAL,
|
||||||
valign: Gtk.Align.CENTER,
|
valign: Gtk.Align.CENTER,
|
||||||
});
|
});
|
||||||
@@ -120,16 +120,15 @@ class ClapperHeaderBarPopover extends Gtk.PopoverMenu
|
|||||||
|
|
||||||
_onClosed()
|
_onClosed()
|
||||||
{
|
{
|
||||||
let root = this.get_root();
|
const { child } = this.get_root();
|
||||||
let clapperWidget = root.get_child();
|
|
||||||
|
|
||||||
if(
|
if(
|
||||||
!clapperWidget
|
!child
|
||||||
|| !clapperWidget.player
|
|| !child.player
|
||||||
|| !clapperWidget.player.widget
|
|| !child.player.widget
|
||||||
)
|
)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
clapperWidget.player.widget.grab_focus();
|
child.player.widget.grab_focus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
const { Gio, GstAudio, GstPlayer, Gdk, Gtk } = imports.gi;
|
const { Gio, GstAudio, GstPlayer, Gdk, Gtk } = imports.gi;
|
||||||
const Debug = imports.clapper_src.debug;
|
const Debug = imports.clapper_src.debug;
|
||||||
|
|
||||||
|
const { debug } = Debug;
|
||||||
|
|
||||||
var appName = 'Clapper';
|
var appName = 'Clapper';
|
||||||
var appId = 'com.github.rafostar.Clapper';
|
var appId = 'com.github.rafostar.Clapper';
|
||||||
|
|
||||||
@@ -14,7 +16,6 @@ var settings = new Gio.Settings({
|
|||||||
var maxVolume = 1.5;
|
var maxVolume = 1.5;
|
||||||
var isOldGtk = (Gtk.MINOR_VERSION === 99 && Gtk.MICRO_VERSION <= 4);
|
var isOldGtk = (Gtk.MINOR_VERSION === 99 && Gtk.MICRO_VERSION <= 4);
|
||||||
|
|
||||||
let { debug } = Debug;
|
|
||||||
let inhibitCookie;
|
let inhibitCookie;
|
||||||
|
|
||||||
function getClapperPath()
|
function getClapperPath()
|
||||||
@@ -56,7 +57,7 @@ function inhibitForState(state, window)
|
|||||||
if(inhibitCookie)
|
if(inhibitCookie)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let app = window.get_application();
|
const app = window.get_application();
|
||||||
|
|
||||||
inhibitCookie = app.inhibit(
|
inhibitCookie = app.inhibit(
|
||||||
window,
|
window,
|
||||||
@@ -72,7 +73,7 @@ function inhibitForState(state, window)
|
|||||||
if(!inhibitCookie)
|
if(!inhibitCookie)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let app = window.get_application();
|
const app = window.get_application();
|
||||||
app.uninhibit(inhibitCookie);
|
app.uninhibit(inhibitCookie);
|
||||||
inhibitCookie = null;
|
inhibitCookie = null;
|
||||||
}
|
}
|
||||||
@@ -88,11 +89,11 @@ function getFormattedTime(time, showHours)
|
|||||||
hours = ('0' + Math.floor(time / 3600)).slice(-2);
|
hours = ('0' + Math.floor(time / 3600)).slice(-2);
|
||||||
time -= hours * 3600;
|
time -= hours * 3600;
|
||||||
}
|
}
|
||||||
let minutes = ('0' + Math.floor(time / 60)).slice(-2);
|
const minutes = ('0' + Math.floor(time / 60)).slice(-2);
|
||||||
time -= minutes * 60;
|
time -= minutes * 60;
|
||||||
let seconds = ('0' + Math.floor(time)).slice(-2);
|
const seconds = ('0' + Math.floor(time)).slice(-2);
|
||||||
|
|
||||||
let parsed = (hours) ? `${hours}:` : '';
|
const parsed = (hours) ? `${hours}:` : '';
|
||||||
return parsed + `${minutes}:${seconds}`;
|
return parsed + `${minutes}:${seconds}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -4,8 +4,8 @@ const Debug = imports.clapper_src.debug;
|
|||||||
const Misc = imports.clapper_src.misc;
|
const Misc = imports.clapper_src.misc;
|
||||||
const { PlayerBase } = imports.clapper_src.playerBase;
|
const { PlayerBase } = imports.clapper_src.playerBase;
|
||||||
|
|
||||||
let { debug } = Debug;
|
const { debug } = Debug;
|
||||||
let { settings } = Misc;
|
const { settings } = Misc;
|
||||||
|
|
||||||
var Player = GObject.registerClass(
|
var Player = GObject.registerClass(
|
||||||
class ClapperPlayer extends PlayerBase
|
class ClapperPlayer extends PlayerBase
|
||||||
@@ -37,26 +37,26 @@ class ClapperPlayer extends PlayerBase
|
|||||||
this._hideControlsTimeout = null;
|
this._hideControlsTimeout = null;
|
||||||
this._updateTimeTimeout = null;
|
this._updateTimeTimeout = null;
|
||||||
|
|
||||||
let clickGesture = new Gtk.GestureClick();
|
const clickGesture = new Gtk.GestureClick();
|
||||||
clickGesture.set_button(0);
|
clickGesture.set_button(0);
|
||||||
clickGesture.connect('pressed', this._onWidgetPressed.bind(this));
|
clickGesture.connect('pressed', this._onWidgetPressed.bind(this));
|
||||||
this.widget.add_controller(clickGesture);
|
this.widget.add_controller(clickGesture);
|
||||||
|
|
||||||
let dragGesture = new Gtk.GestureDrag();
|
const dragGesture = new Gtk.GestureDrag();
|
||||||
dragGesture.connect('drag-update', this._onWidgetDragUpdate.bind(this));
|
dragGesture.connect('drag-update', this._onWidgetDragUpdate.bind(this));
|
||||||
this.widget.add_controller(dragGesture);
|
this.widget.add_controller(dragGesture);
|
||||||
|
|
||||||
let keyController = new Gtk.EventControllerKey();
|
const keyController = new Gtk.EventControllerKey();
|
||||||
keyController.connect('key-pressed', this._onWidgetKeyPressed.bind(this));
|
keyController.connect('key-pressed', this._onWidgetKeyPressed.bind(this));
|
||||||
keyController.connect('key-released', this._onWidgetKeyReleased.bind(this));
|
keyController.connect('key-released', this._onWidgetKeyReleased.bind(this));
|
||||||
this.widget.add_controller(keyController);
|
this.widget.add_controller(keyController);
|
||||||
|
|
||||||
let scrollController = new Gtk.EventControllerScroll();
|
const scrollController = new Gtk.EventControllerScroll();
|
||||||
scrollController.set_flags(Gtk.EventControllerScrollFlags.BOTH_AXES);
|
scrollController.set_flags(Gtk.EventControllerScrollFlags.BOTH_AXES);
|
||||||
scrollController.connect('scroll', this._onScroll.bind(this));
|
scrollController.connect('scroll', this._onScroll.bind(this));
|
||||||
this.widget.add_controller(scrollController);
|
this.widget.add_controller(scrollController);
|
||||||
|
|
||||||
let motionController = new Gtk.EventControllerMotion();
|
const motionController = new Gtk.EventControllerMotion();
|
||||||
motionController.connect('enter', this._onWidgetEnter.bind(this));
|
motionController.connect('enter', this._onWidgetEnter.bind(this));
|
||||||
motionController.connect('leave', this._onWidgetLeave.bind(this));
|
motionController.connect('leave', this._onWidgetLeave.bind(this));
|
||||||
motionController.connect('motion', this._onWidgetMotion.bind(this));
|
motionController.connect('motion', this._onWidgetMotion.bind(this));
|
||||||
@@ -104,30 +104,30 @@ class ClapperPlayer extends PlayerBase
|
|||||||
return this.set_media(this._playlist[this._trackId]);
|
return this.set_media(this._playlist[this._trackId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
let fileUri = file.get_uri();
|
const uri = file.get_uri();
|
||||||
if(fileUri.endsWith('.claps'))
|
if(uri.endsWith('.claps'))
|
||||||
return this.load_playlist_file(file);
|
return this.load_playlist_file(file);
|
||||||
|
|
||||||
this.is_local_file = true;
|
this.is_local_file = true;
|
||||||
this.set_uri(fileUri);
|
this.set_uri(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
load_playlist_file(file)
|
load_playlist_file(file)
|
||||||
{
|
{
|
||||||
let stream = new Gio.DataInputStream({
|
const stream = new Gio.DataInputStream({
|
||||||
base_stream: file.read(null)
|
base_stream: file.read(null)
|
||||||
});
|
});
|
||||||
let listdir = file.get_parent();
|
const listdir = file.get_parent();
|
||||||
let playlist = [];
|
const playlist = [];
|
||||||
let line;
|
|
||||||
|
|
||||||
|
let line;
|
||||||
while((line = stream.read_line(null)[0])) {
|
while((line = stream.read_line(null)[0])) {
|
||||||
line = (line instanceof Uint8Array)
|
line = (line instanceof Uint8Array)
|
||||||
? ByteArray.toString(line).trim()
|
? ByteArray.toString(line).trim()
|
||||||
: String(line).trim();
|
: String(line).trim();
|
||||||
|
|
||||||
if(!Gst.uri_is_valid(line)) {
|
if(!Gst.uri_is_valid(line)) {
|
||||||
let lineFile = listdir.resolve_relative_path(line);
|
const lineFile = listdir.resolve_relative_path(line);
|
||||||
if(!lineFile)
|
if(!lineFile)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -158,7 +158,7 @@ class ClapperPlayer extends PlayerBase
|
|||||||
|
|
||||||
set_subtitles(source)
|
set_subtitles(source)
|
||||||
{
|
{
|
||||||
let uri = (source.get_uri)
|
const uri = (source.get_uri)
|
||||||
? source.get_uri()
|
? source.get_uri()
|
||||||
: source;
|
: source;
|
||||||
|
|
||||||
@@ -217,10 +217,11 @@ class ClapperPlayer extends PlayerBase
|
|||||||
{
|
{
|
||||||
this.seek_done = false;
|
this.seek_done = false;
|
||||||
|
|
||||||
let { controls } = this.widget.get_ancestor(Gtk.Grid);
|
const { controls } = this.widget.get_ancestor(Gtk.Grid);
|
||||||
let max = controls.positionAdjustment.get_upper();
|
const max = controls.positionAdjustment.get_upper();
|
||||||
|
const seekingUnit = settings.get_string('seeking-unit');
|
||||||
|
|
||||||
let seekingValue = settings.get_int('seeking-value');
|
let seekingValue = settings.get_int('seeking-value');
|
||||||
let seekingUnit = settings.get_string('seeking-unit');
|
|
||||||
|
|
||||||
switch(seekingUnit) {
|
switch(seekingUnit) {
|
||||||
case 'minute':
|
case 'minute':
|
||||||
@@ -246,16 +247,16 @@ class ClapperPlayer extends PlayerBase
|
|||||||
|
|
||||||
adjust_volume(isIncrease)
|
adjust_volume(isIncrease)
|
||||||
{
|
{
|
||||||
let { controls } = this.widget.get_ancestor(Gtk.Grid);
|
const { controls } = this.widget.get_ancestor(Gtk.Grid);
|
||||||
|
const value = (isIncrease) ? 0.05 : -0.05;
|
||||||
|
const volume = controls.volumeScale.get_value() + value;
|
||||||
|
|
||||||
let value = (isIncrease) ? 0.05 : -0.05;
|
|
||||||
let volume = controls.volumeScale.get_value() + value;
|
|
||||||
controls.volumeScale.set_value(volume);
|
controls.volumeScale.set_value(volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
toggle_play()
|
toggle_play()
|
||||||
{
|
{
|
||||||
let action = (this.state === GstPlayer.PlayerState.PLAYING)
|
const action = (this.state === GstPlayer.PlayerState.PLAYING)
|
||||||
? 'pause'
|
? 'pause'
|
||||||
: 'play';
|
: 'play';
|
||||||
|
|
||||||
@@ -284,7 +285,7 @@ class ClapperPlayer extends PlayerBase
|
|||||||
this._hideCursorTimeout = null;
|
this._hideCursorTimeout = null;
|
||||||
|
|
||||||
if(this.cursorInPlayer) {
|
if(this.cursorInPlayer) {
|
||||||
let blankCursor = Gdk.Cursor.new_from_name('none', null);
|
const blankCursor = Gdk.Cursor.new_from_name('none', null);
|
||||||
this.widget.set_cursor(blankCursor);
|
this.widget.set_cursor(blankCursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,7 +300,7 @@ class ClapperPlayer extends PlayerBase
|
|||||||
this._hideControlsTimeout = null;
|
this._hideControlsTimeout = null;
|
||||||
|
|
||||||
if(this.cursorInPlayer) {
|
if(this.cursorInPlayer) {
|
||||||
let clapperWidget = this.widget.get_ancestor(Gtk.Grid);
|
const clapperWidget = this.widget.get_ancestor(Gtk.Grid);
|
||||||
if(clapperWidget.fullscreenMode || clapperWidget.floatingMode) {
|
if(clapperWidget.fullscreenMode || clapperWidget.floatingMode) {
|
||||||
this._clearTimeout('updateTime');
|
this._clearTimeout('updateTime');
|
||||||
clapperWidget.revealControls(false);
|
clapperWidget.revealControls(false);
|
||||||
@@ -313,8 +314,9 @@ class ClapperPlayer extends PlayerBase
|
|||||||
_setUpdateTimeInterval()
|
_setUpdateTimeInterval()
|
||||||
{
|
{
|
||||||
this._clearTimeout('updateTime');
|
this._clearTimeout('updateTime');
|
||||||
let clapperWidget = this.widget.get_ancestor(Gtk.Grid);
|
|
||||||
let nextUpdate = clapperWidget.updateTime();
|
const clapperWidget = this.widget.get_ancestor(Gtk.Grid);
|
||||||
|
const nextUpdate = clapperWidget.updateTime();
|
||||||
|
|
||||||
if(nextUpdate === null)
|
if(nextUpdate === null)
|
||||||
return;
|
return;
|
||||||
@@ -346,9 +348,9 @@ class ClapperPlayer extends PlayerBase
|
|||||||
window.disconnect(this.closeRequestSignal);
|
window.disconnect(this.closeRequestSignal);
|
||||||
this.closeRequestSignal = null;
|
this.closeRequestSignal = null;
|
||||||
|
|
||||||
let clapperWidget = this.widget.get_ancestor(Gtk.Grid);
|
const clapperWidget = this.widget.get_ancestor(Gtk.Grid);
|
||||||
if(!clapperWidget.fullscreenMode) {
|
if(!clapperWidget.fullscreenMode) {
|
||||||
let size = (Misc.isOldGtk)
|
const size = (Misc.isOldGtk)
|
||||||
? window.get_size()
|
? window.get_size()
|
||||||
: window.get_default_size();
|
: window.get_default_size();
|
||||||
|
|
||||||
@@ -366,7 +368,7 @@ class ClapperPlayer extends PlayerBase
|
|||||||
this.emitWs('state_changed', state);
|
this.emitWs('state_changed', state);
|
||||||
|
|
||||||
if(state !== GstPlayer.PlayerState.BUFFERING) {
|
if(state !== GstPlayer.PlayerState.BUFFERING) {
|
||||||
let root = player.widget.get_root();
|
const root = player.widget.get_root();
|
||||||
Misc.inhibitForState(state, root);
|
Misc.inhibitForState(state, root);
|
||||||
|
|
||||||
if(this.quitOnStop) {
|
if(this.quitOnStop) {
|
||||||
@@ -377,7 +379,7 @@ class ClapperPlayer extends PlayerBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let clapperWidget = player.widget.get_ancestor(Gtk.Grid);
|
const clapperWidget = player.widget.get_ancestor(Gtk.Grid);
|
||||||
if(!clapperWidget) return;
|
if(!clapperWidget) return;
|
||||||
|
|
||||||
if(!this.seek_done && state !== GstPlayer.PlayerState.BUFFERING) {
|
if(!this.seek_done && state !== GstPlayer.PlayerState.BUFFERING) {
|
||||||
@@ -413,8 +415,8 @@ class ClapperPlayer extends PlayerBase
|
|||||||
this.doneStartup = true;
|
this.doneStartup = true;
|
||||||
|
|
||||||
if(settings.get_boolean('fullscreen-auto')) {
|
if(settings.get_boolean('fullscreen-auto')) {
|
||||||
let root = player.widget.get_root();
|
const root = player.widget.get_root();
|
||||||
let clapperWidget = root.get_child();
|
const clapperWidget = root.get_child();
|
||||||
if(!clapperWidget.fullscreenMode) {
|
if(!clapperWidget.fullscreenMode) {
|
||||||
this.playOnFullscreen = true;
|
this.playOnFullscreen = true;
|
||||||
root.fullscreen();
|
root.fullscreen();
|
||||||
@@ -441,19 +443,21 @@ class ClapperPlayer extends PlayerBase
|
|||||||
this.widget.disconnect(this._realizeSignal);
|
this.widget.disconnect(this._realizeSignal);
|
||||||
this._realizeSignal = null;
|
this._realizeSignal = null;
|
||||||
|
|
||||||
let root = this.widget.get_root();
|
const root = this.widget.get_root();
|
||||||
if(!root) return;
|
if(!root) return;
|
||||||
|
|
||||||
this.closeRequestSignal = root.connect('close-request', this._onCloseRequest.bind(this));
|
this.closeRequestSignal = root.connect(
|
||||||
|
'close-request', this._onCloseRequest.bind(this)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Widget only - does not happen when using controls navigation */
|
/* Widget only - does not happen when using controls navigation */
|
||||||
_onWidgetKeyPressed(controller, keyval, keycode, state)
|
_onWidgetKeyPressed(controller, keyval, keycode, state)
|
||||||
{
|
{
|
||||||
this.keyPressCount++;
|
const clapperWidget = this.widget.get_ancestor(Gtk.Grid);
|
||||||
|
|
||||||
let bool = false;
|
let bool = false;
|
||||||
let clapperWidget = this.widget.get_ancestor(Gtk.Grid);
|
|
||||||
|
this.keyPressCount++;
|
||||||
|
|
||||||
switch(keyval) {
|
switch(keyval) {
|
||||||
case Gdk.KEY_Up:
|
case Gdk.KEY_Up:
|
||||||
@@ -479,10 +483,10 @@ class ClapperPlayer extends PlayerBase
|
|||||||
/* Also happens after using controls navigation for selected keys */
|
/* Also happens after using controls navigation for selected keys */
|
||||||
_onWidgetKeyReleased(controller, keyval, keycode, state)
|
_onWidgetKeyReleased(controller, keyval, keycode, state)
|
||||||
{
|
{
|
||||||
this.keyPressCount = 0;
|
const clapperWidget = this.widget.get_ancestor(Gtk.Grid);
|
||||||
|
let value, root;
|
||||||
|
|
||||||
let value;
|
this.keyPressCount = 0;
|
||||||
let clapperWidget = this.widget.get_ancestor(Gtk.Grid);
|
|
||||||
|
|
||||||
switch(keyval) {
|
switch(keyval) {
|
||||||
case Gdk.KEY_space:
|
case Gdk.KEY_space:
|
||||||
@@ -509,13 +513,13 @@ class ClapperPlayer extends PlayerBase
|
|||||||
break;
|
break;
|
||||||
case Gdk.KEY_Escape:
|
case Gdk.KEY_Escape:
|
||||||
if(clapperWidget.fullscreenMode) {
|
if(clapperWidget.fullscreenMode) {
|
||||||
let root = this.widget.get_root();
|
root = this.widget.get_root();
|
||||||
root.unfullscreen();
|
root.unfullscreen();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Gdk.KEY_q:
|
case Gdk.KEY_q:
|
||||||
case Gdk.KEY_Q:
|
case Gdk.KEY_Q:
|
||||||
let root = this.widget.get_root();
|
root = this.widget.get_root();
|
||||||
root.emit('close-request');
|
root.emit('close-request');
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -525,14 +529,14 @@ class ClapperPlayer extends PlayerBase
|
|||||||
|
|
||||||
_onWidgetPressed(gesture, nPress, x, y)
|
_onWidgetPressed(gesture, nPress, x, y)
|
||||||
{
|
{
|
||||||
let button = gesture.get_current_button();
|
const button = gesture.get_current_button();
|
||||||
let isDouble = (nPress % 2 == 0);
|
const isDouble = (nPress % 2 == 0);
|
||||||
this.dragAllowed = !isDouble;
|
this.dragAllowed = !isDouble;
|
||||||
|
|
||||||
switch(button) {
|
switch(button) {
|
||||||
case Gdk.BUTTON_PRIMARY:
|
case Gdk.BUTTON_PRIMARY:
|
||||||
if(isDouble) {
|
if(isDouble) {
|
||||||
let clapperWidget = this.widget.get_ancestor(Gtk.Grid);
|
const clapperWidget = this.widget.get_ancestor(Gtk.Grid);
|
||||||
clapperWidget.toggleFullscreen();
|
clapperWidget.toggleFullscreen();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -551,7 +555,7 @@ class ClapperPlayer extends PlayerBase
|
|||||||
|
|
||||||
this._setHideCursorTimeout();
|
this._setHideCursorTimeout();
|
||||||
|
|
||||||
let clapperWidget = this.widget.get_ancestor(Gtk.Grid);
|
const clapperWidget = this.widget.get_ancestor(Gtk.Grid);
|
||||||
if(clapperWidget.fullscreenMode || clapperWidget.floatingMode)
|
if(clapperWidget.fullscreenMode || clapperWidget.floatingMode)
|
||||||
this._setHideControlsTimeout();
|
this._setHideControlsTimeout();
|
||||||
}
|
}
|
||||||
@@ -577,11 +581,11 @@ class ClapperPlayer extends PlayerBase
|
|||||||
Math.abs(this.posX - posX) >= 0.5
|
Math.abs(this.posX - posX) >= 0.5
|
||||||
|| Math.abs(this.posY - posY) >= 0.5
|
|| Math.abs(this.posY - posY) >= 0.5
|
||||||
) {
|
) {
|
||||||
let defaultCursor = Gdk.Cursor.new_from_name('default', null);
|
const defaultCursor = Gdk.Cursor.new_from_name('default', null);
|
||||||
this.widget.set_cursor(defaultCursor);
|
this.widget.set_cursor(defaultCursor);
|
||||||
this._setHideCursorTimeout();
|
this._setHideCursorTimeout();
|
||||||
|
|
||||||
let clapperWidget = this.widget.get_ancestor(Gtk.Grid);
|
const clapperWidget = this.widget.get_ancestor(Gtk.Grid);
|
||||||
|
|
||||||
if(clapperWidget.floatingMode && !clapperWidget.fullscreenMode) {
|
if(clapperWidget.floatingMode && !clapperWidget.fullscreenMode) {
|
||||||
clapperWidget.revealerBottom.set_can_focus(false);
|
clapperWidget.revealerBottom.set_can_focus(false);
|
||||||
@@ -616,20 +620,20 @@ class ClapperPlayer extends PlayerBase
|
|||||||
if(!this.dragAllowed)
|
if(!this.dragAllowed)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let clapperWidget = this.widget.get_ancestor(Gtk.Grid);
|
const clapperWidget = this.widget.get_ancestor(Gtk.Grid);
|
||||||
if(clapperWidget.fullscreenMode)
|
if(clapperWidget.fullscreenMode)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let { gtk_double_click_distance } = this.widget.get_settings();
|
const { gtk_double_click_distance } = this.widget.get_settings();
|
||||||
|
|
||||||
if (
|
if (
|
||||||
Math.abs(offsetX) > gtk_double_click_distance
|
Math.abs(offsetX) > gtk_double_click_distance
|
||||||
|| Math.abs(offsetY) > gtk_double_click_distance
|
|| Math.abs(offsetY) > gtk_double_click_distance
|
||||||
) {
|
) {
|
||||||
let [isActive, startX, startY] = gesture.get_start_point();
|
const [isActive, startX, startY] = gesture.get_start_point();
|
||||||
if(!isActive) return;
|
if(!isActive) return;
|
||||||
|
|
||||||
let native = this.widget.get_native();
|
const native = this.widget.get_native();
|
||||||
if(!native) return;
|
if(!native) return;
|
||||||
|
|
||||||
let [isShared, winX, winY] = this.widget.translate_coordinates(
|
let [isShared, winX, winY] = this.widget.translate_coordinates(
|
||||||
@@ -637,7 +641,7 @@ class ClapperPlayer extends PlayerBase
|
|||||||
);
|
);
|
||||||
if(!isShared) return;
|
if(!isShared) return;
|
||||||
|
|
||||||
let [nativeX, nativeY] = native.get_surface_transform();
|
const [nativeX, nativeY] = native.get_surface_transform();
|
||||||
winX += nativeX;
|
winX += nativeX;
|
||||||
winY += nativeY;
|
winY += nativeY;
|
||||||
|
|
||||||
@@ -656,13 +660,13 @@ class ClapperPlayer extends PlayerBase
|
|||||||
|
|
||||||
_onScroll(controller, dx, dy)
|
_onScroll(controller, dx, dy)
|
||||||
{
|
{
|
||||||
let isHorizontal = Math.abs(dx) >= Math.abs(dy);
|
const isHorizontal = (Math.abs(dx) >= Math.abs(dy));
|
||||||
let isIncrease = (isHorizontal) ? dx < 0 : dy < 0;
|
const isIncrease = (isHorizontal) ? dx < 0 : dy < 0;
|
||||||
|
|
||||||
if(isHorizontal) {
|
if(isHorizontal) {
|
||||||
this.adjust_position(isIncrease);
|
this.adjust_position(isIncrease);
|
||||||
let { controls } = this.widget.get_ancestor(Gtk.Grid);
|
const { controls } = this.widget.get_ancestor(Gtk.Grid);
|
||||||
let value = Math.round(controls.positionScale.get_value());
|
const value = Math.round(controls.positionScale.get_value());
|
||||||
this.seek_seconds(value);
|
this.seek_seconds(value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -3,8 +3,8 @@ const Debug = imports.clapper_src.debug;
|
|||||||
const Misc = imports.clapper_src.misc;
|
const Misc = imports.clapper_src.misc;
|
||||||
const { WebApp } = imports.clapper_src.webApp;
|
const { WebApp } = imports.clapper_src.webApp;
|
||||||
|
|
||||||
let { debug } = Debug;
|
const { debug } = Debug;
|
||||||
let { settings } = Misc;
|
const { settings } = Misc;
|
||||||
|
|
||||||
let WebServer;
|
let WebServer;
|
||||||
|
|
||||||
@@ -16,27 +16,27 @@ class ClapperPlayerBase extends GstPlayer.Player
|
|||||||
if(!Gst.is_initialized())
|
if(!Gst.is_initialized())
|
||||||
Gst.init(null);
|
Gst.init(null);
|
||||||
|
|
||||||
let plugin = 'gtk4glsink';
|
const plugin = 'gtk4glsink';
|
||||||
let gtkglsink = Gst.ElementFactory.make(plugin, null);
|
const gtk4glsink = Gst.ElementFactory.make(plugin, null);
|
||||||
|
|
||||||
if(!gtkglsink) {
|
if(!gtk4glsink) {
|
||||||
return debug(new Error(
|
return debug(new Error(
|
||||||
`Could not load "${plugin}".`
|
`Could not load "${plugin}".`
|
||||||
+ ' Do you have gstreamer-plugins-good-gtk4 installed?'
|
+ ' Do you have gstreamer-plugins-good-gtk4 installed?'
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
let glsinkbin = Gst.ElementFactory.make('glsinkbin', null);
|
const glsinkbin = Gst.ElementFactory.make('glsinkbin', null);
|
||||||
glsinkbin.sink = gtkglsink;
|
glsinkbin.sink = gtk4glsink;
|
||||||
|
|
||||||
let context = GLib.MainContext.ref_thread_default();
|
const context = GLib.MainContext.ref_thread_default();
|
||||||
let acquired = context.acquire();
|
const acquired = context.acquire();
|
||||||
debug(`default context acquired: ${acquired}`);
|
debug(`default context acquired: ${acquired}`);
|
||||||
|
|
||||||
let dispatcher = new GstPlayer.PlayerGMainContextSignalDispatcher({
|
const dispatcher = new GstPlayer.PlayerGMainContextSignalDispatcher({
|
||||||
application_context: context,
|
application_context: context,
|
||||||
});
|
});
|
||||||
let renderer = new GstPlayer.PlayerVideoOverlayVideoRenderer({
|
const renderer = new GstPlayer.PlayerVideoOverlayVideoRenderer({
|
||||||
video_sink: glsinkbin
|
video_sink: glsinkbin
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ class ClapperPlayerBase extends GstPlayer.Player
|
|||||||
|
|
||||||
set_and_bind_settings()
|
set_and_bind_settings()
|
||||||
{
|
{
|
||||||
let settingsToSet = [
|
const settingsToSet = [
|
||||||
'seeking-mode',
|
'seeking-mode',
|
||||||
'audio-offset',
|
'audio-offset',
|
||||||
'subtitle-offset',
|
'subtitle-offset',
|
||||||
@@ -79,13 +79,13 @@ 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;
|
const flag = Gio.SettingsBindFlags.GET;
|
||||||
settings.bind('subtitle-font', this.pipeline, 'subtitle_font_desc', flag);
|
settings.bind('subtitle-font', this.pipeline, 'subtitle_font_desc', flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
set_initial_config()
|
set_initial_config()
|
||||||
{
|
{
|
||||||
let gstPlayerConfig = {
|
const gstPlayerConfig = {
|
||||||
position_update_interval: 1000,
|
position_update_interval: 1000,
|
||||||
user_agent: 'clapper',
|
user_agent: 'clapper',
|
||||||
};
|
};
|
||||||
@@ -96,19 +96,19 @@ class ClapperPlayerBase extends GstPlayer.Player
|
|||||||
this.set_mute(false);
|
this.set_mute(false);
|
||||||
|
|
||||||
/* FIXME: change into option in preferences */
|
/* FIXME: change into option in preferences */
|
||||||
let pipeline = this.get_pipeline();
|
const pipeline = this.get_pipeline();
|
||||||
pipeline.ring_buffer_max_size = 8 * 1024 * 1024;
|
pipeline.ring_buffer_max_size = 8 * 1024 * 1024;
|
||||||
}
|
}
|
||||||
|
|
||||||
set_config_option(option, value)
|
set_config_option(option, value)
|
||||||
{
|
{
|
||||||
let setOption = GstPlayer.Player[`config_set_${option}`];
|
const setOption = GstPlayer.Player[`config_set_${option}`];
|
||||||
if(!setOption)
|
if(!setOption)
|
||||||
return debug(`unsupported option: ${option}`, 'LEVEL_WARNING');
|
return debug(`unsupported option: ${option}`, 'LEVEL_WARNING');
|
||||||
|
|
||||||
let config = this.get_config();
|
const config = this.get_config();
|
||||||
setOption(config, value);
|
setOption(config, value);
|
||||||
let success = this.set_config(config);
|
const success = this.set_config(config);
|
||||||
|
|
||||||
if(!success)
|
if(!success)
|
||||||
debug(`could not change option: ${option}`);
|
debug(`could not change option: ${option}`);
|
||||||
@@ -139,12 +139,12 @@ class ClapperPlayerBase extends GstPlayer.Player
|
|||||||
|
|
||||||
set_plugin_rank(name, rank)
|
set_plugin_rank(name, rank)
|
||||||
{
|
{
|
||||||
let gstRegistry = Gst.Registry.get();
|
const gstRegistry = Gst.Registry.get();
|
||||||
let feature = gstRegistry.lookup_feature(name);
|
const feature = gstRegistry.lookup_feature(name);
|
||||||
if(!feature)
|
if(!feature)
|
||||||
return debug(`plugin unavailable: ${name}`);
|
return debug(`plugin unavailable: ${name}`);
|
||||||
|
|
||||||
let oldRank = feature.get_rank();
|
const oldRank = feature.get_rank();
|
||||||
if(rank === oldRank)
|
if(rank === oldRank)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -179,7 +179,7 @@ class ClapperPlayerBase extends GstPlayer.Player
|
|||||||
|
|
||||||
switch(key) {
|
switch(key) {
|
||||||
case 'seeking-mode':
|
case 'seeking-mode':
|
||||||
let isSeekMode = (typeof this.set_seek_mode !== 'undefined');
|
const isSeekMode = (typeof this.set_seek_mode !== 'undefined');
|
||||||
this.seekingMode = settings.get_string('seeking-mode');
|
this.seekingMode = settings.get_string('seeking-mode');
|
||||||
switch(this.seekingMode) {
|
switch(this.seekingMode) {
|
||||||
case 'fast':
|
case 'fast':
|
||||||
@@ -212,9 +212,9 @@ class ClapperPlayerBase extends GstPlayer.Player
|
|||||||
if(!root || !root.isClapperApp)
|
if(!root || !root.isClapperApp)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
let gpuClass = 'gpufriendly';
|
const gpuClass = 'gpufriendly';
|
||||||
let renderShadows = settings.get_boolean(key);
|
const renderShadows = settings.get_boolean(key);
|
||||||
let hasShadows = !root.has_css_class(gpuClass);
|
const hasShadows = !root.has_css_class(gpuClass);
|
||||||
|
|
||||||
if(renderShadows === hasShadows)
|
if(renderShadows === hasShadows)
|
||||||
break;
|
break;
|
||||||
@@ -238,8 +238,8 @@ class ClapperPlayerBase extends GstPlayer.Player
|
|||||||
if(!root || !root.isClapperApp)
|
if(!root || !root.isClapperApp)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
let brightClass = 'brightscale';
|
const brightClass = 'brightscale';
|
||||||
let isBrighter = root.has_css_class(brightClass);
|
const isBrighter = root.has_css_class(brightClass);
|
||||||
|
|
||||||
if(key === 'dark-theme' && isBrighter && !settings.get_boolean(key)) {
|
if(key === 'dark-theme' && isBrighter && !settings.get_boolean(key)) {
|
||||||
root.remove_css_class(brightClass);
|
root.remove_css_class(brightClass);
|
||||||
@@ -247,7 +247,7 @@ class ClapperPlayerBase extends GstPlayer.Player
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
let setBrighter = settings.get_boolean('brighter-sliders');
|
const setBrighter = settings.get_boolean('brighter-sliders');
|
||||||
if(setBrighter === isBrighter)
|
if(setBrighter === isBrighter)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@@ -2,7 +2,7 @@ const { GObject, Gst, Gtk, Pango } = imports.gi;
|
|||||||
const Misc = imports.clapper_src.misc;
|
const Misc = imports.clapper_src.misc;
|
||||||
const PrefsBase = imports.clapper_src.prefsBase;
|
const PrefsBase = imports.clapper_src.prefsBase;
|
||||||
|
|
||||||
let { settings } = Misc;
|
const { settings } = Misc;
|
||||||
|
|
||||||
/* PlayFlags are not exported through GI */
|
/* PlayFlags are not exported through GI */
|
||||||
Gst.PlayFlags = {
|
Gst.PlayFlags = {
|
||||||
@@ -32,11 +32,11 @@ class ClapperGeneralPage extends PrefsBase.Grid
|
|||||||
this.addCheckButton('Auto enter fullscreen', 'fullscreen-auto');
|
this.addCheckButton('Auto enter fullscreen', 'fullscreen-auto');
|
||||||
|
|
||||||
this.addTitle('Volume');
|
this.addTitle('Volume');
|
||||||
let comboBox = this.addComboBoxText('Initial value', [
|
const comboBox = this.addComboBoxText('Initial value', [
|
||||||
['restore', "Restore"],
|
['restore', "Restore"],
|
||||||
['custom', "Custom"],
|
['custom', "Custom"],
|
||||||
], 'volume-initial');
|
], 'volume-initial');
|
||||||
let spinButton = this.addSpinButton('Value (percentage)', 0, 200, 'volume-value');
|
const spinButton = this.addSpinButton('Value (percentage)', 0, 200, 'volume-value');
|
||||||
this._onVolumeInitialChanged(spinButton, comboBox);
|
this._onVolumeInitialChanged(spinButton, comboBox);
|
||||||
comboBox.connect('changed', this._onVolumeInitialChanged.bind(this, spinButton));
|
comboBox.connect('changed', this._onVolumeInitialChanged.bind(this, spinButton));
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ class ClapperGeneralPage extends PrefsBase.Grid
|
|||||||
|
|
||||||
_onVolumeInitialChanged(spinButton, comboBox)
|
_onVolumeInitialChanged(spinButton, comboBox)
|
||||||
{
|
{
|
||||||
let value = comboBox.get_active_id();
|
const value = comboBox.get_active_id();
|
||||||
spinButton.set_visible(value === 'custom');
|
spinButton.set_visible(value === 'custom');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -116,12 +116,12 @@ class ClapperNetworkPage extends PrefsBase.Grid
|
|||||||
this.addPlayFlagCheckButton('Progressive download buffering', Gst.PlayFlags.DOWNLOAD);
|
this.addPlayFlagCheckButton('Progressive download buffering', Gst.PlayFlags.DOWNLOAD);
|
||||||
|
|
||||||
this.addTitle('Server');
|
this.addTitle('Server');
|
||||||
let webServer = this.addCheckButton('Control player remotely', 'webserver-enabled');
|
const webServer = this.addCheckButton('Control player remotely', 'webserver-enabled');
|
||||||
let serverPort = this.addSpinButton('Listening port', 1024, 65535, 'webserver-port');
|
const serverPort = this.addSpinButton('Listening port', 1024, 65535, 'webserver-port');
|
||||||
webServer.bind_property('active', serverPort, 'visible', GObject.BindingFlags.SYNC_CREATE);
|
webServer.bind_property('active', serverPort, 'visible', GObject.BindingFlags.SYNC_CREATE);
|
||||||
let webApp = this.addCheckButton('Start built-in web application', 'webapp-enabled');
|
const webApp = this.addCheckButton('Start built-in web application', 'webapp-enabled');
|
||||||
webServer.bind_property('active', webApp, 'visible', GObject.BindingFlags.SYNC_CREATE);
|
webServer.bind_property('active', webApp, 'visible', GObject.BindingFlags.SYNC_CREATE);
|
||||||
let webAppPort = this.addSpinButton('Web application port', 1024, 65535, 'webapp-port');
|
const webAppPort = this.addSpinButton('Web application port', 1024, 65535, 'webapp-port');
|
||||||
webServer.bind_property('active', webAppPort, 'visible', GObject.BindingFlags.SYNC_CREATE);
|
webServer.bind_property('active', webAppPort, 'visible', GObject.BindingFlags.SYNC_CREATE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -134,38 +134,38 @@ class ClapperGStreamerPage extends PrefsBase.Grid
|
|||||||
super._init();
|
super._init();
|
||||||
|
|
||||||
this.addTitle('Plugin Ranking');
|
this.addTitle('Plugin Ranking');
|
||||||
let listStore = new Gtk.ListStore();
|
const listStore = new Gtk.ListStore();
|
||||||
listStore.set_column_types([
|
listStore.set_column_types([
|
||||||
GObject.TYPE_BOOLEAN,
|
GObject.TYPE_BOOLEAN,
|
||||||
GObject.TYPE_STRING,
|
GObject.TYPE_STRING,
|
||||||
GObject.TYPE_STRING,
|
GObject.TYPE_STRING,
|
||||||
]);
|
]);
|
||||||
let treeView = new Gtk.TreeView({
|
const treeView = new Gtk.TreeView({
|
||||||
hexpand: true,
|
hexpand: true,
|
||||||
vexpand: true,
|
vexpand: true,
|
||||||
enable_search: false,
|
enable_search: false,
|
||||||
model: listStore,
|
model: listStore,
|
||||||
});
|
});
|
||||||
let treeSelection = treeView.get_selection();
|
const treeSelection = treeView.get_selection();
|
||||||
|
|
||||||
let apply = new Gtk.TreeViewColumn({
|
const apply = new Gtk.TreeViewColumn({
|
||||||
title: "Apply",
|
title: "Apply",
|
||||||
});
|
});
|
||||||
let name = new Gtk.TreeViewColumn({
|
const name = new Gtk.TreeViewColumn({
|
||||||
title: "Plugin",
|
title: "Plugin",
|
||||||
expand: true,
|
expand: true,
|
||||||
});
|
});
|
||||||
let rank = new Gtk.TreeViewColumn({
|
const rank = new Gtk.TreeViewColumn({
|
||||||
title: "Rank",
|
title: "Rank",
|
||||||
min_width: 90,
|
min_width: 90,
|
||||||
});
|
});
|
||||||
|
|
||||||
let applyCell = new Gtk.CellRendererToggle();
|
const applyCell = new Gtk.CellRendererToggle();
|
||||||
let nameCell = new Gtk.CellRendererText({
|
const nameCell = new Gtk.CellRendererText({
|
||||||
editable: true,
|
editable: true,
|
||||||
placeholder_text: "Insert plugin name",
|
placeholder_text: "Insert plugin name",
|
||||||
});
|
});
|
||||||
let rankCell = new Gtk.CellRendererText({
|
const rankCell = new Gtk.CellRendererText({
|
||||||
editable: true,
|
editable: true,
|
||||||
weight: Pango.Weight.BOLD,
|
weight: Pango.Weight.BOLD,
|
||||||
placeholder_text: "Insert plugin rank",
|
placeholder_text: "Insert plugin rank",
|
||||||
@@ -183,27 +183,27 @@ class ClapperGStreamerPage extends PrefsBase.Grid
|
|||||||
treeView.insert_column(name, 1);
|
treeView.insert_column(name, 1);
|
||||||
treeView.insert_column(rank, 2);
|
treeView.insert_column(rank, 2);
|
||||||
|
|
||||||
let frame = new Gtk.Frame({
|
const frame = new Gtk.Frame({
|
||||||
child: treeView
|
child: treeView
|
||||||
});
|
});
|
||||||
this.addToGrid(frame);
|
this.addToGrid(frame);
|
||||||
|
|
||||||
let addButton = new Gtk.Button({
|
const addButton = new Gtk.Button({
|
||||||
icon_name: 'list-add-symbolic',
|
icon_name: 'list-add-symbolic',
|
||||||
halign: Gtk.Align.END,
|
halign: Gtk.Align.END,
|
||||||
});
|
});
|
||||||
let removeButton = new Gtk.Button({
|
const removeButton = new Gtk.Button({
|
||||||
icon_name: 'list-remove-symbolic',
|
icon_name: 'list-remove-symbolic',
|
||||||
sensitive: false,
|
sensitive: false,
|
||||||
halign: Gtk.Align.END,
|
halign: Gtk.Align.END,
|
||||||
});
|
});
|
||||||
let label = new Gtk.Label({
|
const label = new Gtk.Label({
|
||||||
label: 'Changes require player restart',
|
label: 'Changes require player restart',
|
||||||
halign: Gtk.Align.START,
|
halign: Gtk.Align.START,
|
||||||
hexpand: true,
|
hexpand: true,
|
||||||
ellipsize: Pango.EllipsizeMode.END,
|
ellipsize: Pango.EllipsizeMode.END,
|
||||||
});
|
});
|
||||||
let box = new Gtk.Box({
|
const box = new Gtk.Box({
|
||||||
orientation: Gtk.Orientation.HORIZONTAL,
|
orientation: Gtk.Orientation.HORIZONTAL,
|
||||||
spacing: 6,
|
spacing: 6,
|
||||||
hexpand: true,
|
hexpand: true,
|
||||||
@@ -229,7 +229,7 @@ class ClapperGStreamerPage extends PrefsBase.Grid
|
|||||||
|
|
||||||
refreshListStore(listStore)
|
refreshListStore(listStore)
|
||||||
{
|
{
|
||||||
let data = JSON.parse(settings.get_string('plugin-ranking'));
|
const data = JSON.parse(settings.get_string('plugin-ranking'));
|
||||||
listStore.clear();
|
listStore.clear();
|
||||||
|
|
||||||
for(let plugin of data) {
|
for(let plugin of data) {
|
||||||
@@ -246,14 +246,14 @@ class ClapperGStreamerPage extends PrefsBase.Grid
|
|||||||
|
|
||||||
updatePlugin(index, prop, value)
|
updatePlugin(index, prop, value)
|
||||||
{
|
{
|
||||||
let data = JSON.parse(settings.get_string('plugin-ranking'));
|
const data = JSON.parse(settings.get_string('plugin-ranking'));
|
||||||
data[index][prop] = value;
|
data[index][prop] = value;
|
||||||
settings.set_string('plugin-ranking', JSON.stringify(data));
|
settings.set_string('plugin-ranking', JSON.stringify(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
_onTreeSelectionChanged(removeButton, treeSelection)
|
_onTreeSelectionChanged(removeButton, treeSelection)
|
||||||
{
|
{
|
||||||
let [isSelected, model, iter] = treeSelection.get_selected();
|
const [isSelected, model, iter] = treeSelection.get_selected();
|
||||||
this.activeIndex = -1;
|
this.activeIndex = -1;
|
||||||
|
|
||||||
if(isSelected) {
|
if(isSelected) {
|
||||||
@@ -265,7 +265,7 @@ class ClapperGStreamerPage extends PrefsBase.Grid
|
|||||||
|
|
||||||
_onAddButtonClicked(listStore, button)
|
_onAddButtonClicked(listStore, button)
|
||||||
{
|
{
|
||||||
let data = JSON.parse(settings.get_string('plugin-ranking'));
|
const data = JSON.parse(settings.get_string('plugin-ranking'));
|
||||||
data.push({
|
data.push({
|
||||||
apply: false,
|
apply: false,
|
||||||
name: '',
|
name: '',
|
||||||
@@ -279,14 +279,14 @@ class ClapperGStreamerPage extends PrefsBase.Grid
|
|||||||
if(this.activeIndex < 0)
|
if(this.activeIndex < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let data = JSON.parse(settings.get_string('plugin-ranking'));
|
const data = JSON.parse(settings.get_string('plugin-ranking'));
|
||||||
data.splice(this.activeIndex, 1);
|
data.splice(this.activeIndex, 1);
|
||||||
settings.set_string('plugin-ranking', JSON.stringify(data));
|
settings.set_string('plugin-ranking', JSON.stringify(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
_onApplyCellEdited(cell, path)
|
_onApplyCellEdited(cell, path)
|
||||||
{
|
{
|
||||||
let newState = !cell.active;
|
const newState = !cell.active;
|
||||||
this.updatePlugin(path, 'apply', newState);
|
this.updatePlugin(path, 'apply', newState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -323,18 +323,11 @@ class ClapperTweaksPage extends PrefsBase.Grid
|
|||||||
super._init();
|
super._init();
|
||||||
|
|
||||||
this.addTitle('Appearance');
|
this.addTitle('Appearance');
|
||||||
let darkCheck = this.addCheckButton('Enable dark theme', 'dark-theme');
|
const darkCheck = this.addCheckButton('Enable dark theme', 'dark-theme');
|
||||||
let brighterCheck = this.addCheckButton('Make sliders brighter', 'brighter-sliders');
|
const brighterCheck = this.addCheckButton('Make sliders brighter', 'brighter-sliders');
|
||||||
this._onDarkThemeToggled(brighterCheck, darkCheck);
|
darkCheck.bind_property('active', brighterCheck, 'visible', GObject.BindingFlags.SYNC_CREATE);
|
||||||
darkCheck.connect('toggled', this._onDarkThemeToggled.bind(this, brighterCheck));
|
|
||||||
|
|
||||||
this.addTitle('Performance');
|
this.addTitle('Performance');
|
||||||
this.addCheckButton('Render window shadows', 'render-shadows');
|
this.addCheckButton('Render window shadows', 'render-shadows');
|
||||||
}
|
}
|
||||||
|
|
||||||
_onDarkThemeToggled(brighterCheck, darkCheck)
|
|
||||||
{
|
|
||||||
let isActive = darkCheck.get_active();
|
|
||||||
brighterCheck.set_visible(isActive);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
@@ -2,8 +2,8 @@ const { Gio, GObject, Gtk } = imports.gi;
|
|||||||
const Debug = imports.clapper_src.debug;
|
const Debug = imports.clapper_src.debug;
|
||||||
const Misc = imports.clapper_src.misc;
|
const Misc = imports.clapper_src.misc;
|
||||||
|
|
||||||
let { debug } = Debug;
|
const { debug } = Debug;
|
||||||
let { settings } = Misc;
|
const { settings } = Misc;
|
||||||
|
|
||||||
var Notebook = GObject.registerClass(
|
var Notebook = GObject.registerClass(
|
||||||
class ClapperPrefsNotebook extends Gtk.Notebook
|
class ClapperPrefsNotebook extends Gtk.Notebook
|
||||||
@@ -32,7 +32,7 @@ class ClapperPrefsNotebook extends Gtk.Notebook
|
|||||||
|
|
||||||
addObjectPages(item)
|
addObjectPages(item)
|
||||||
{
|
{
|
||||||
let widget = (item.pages)
|
const widget = (item.pages)
|
||||||
? new Notebook(item.pages, true)
|
? new Notebook(item.pages, true)
|
||||||
: new item.widget();
|
: new item.widget();
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ class ClapperPrefsNotebook extends Gtk.Notebook
|
|||||||
|
|
||||||
addToNotebook(widget, title)
|
addToNotebook(widget, title)
|
||||||
{
|
{
|
||||||
let label = new Gtk.Label({
|
const label = new Gtk.Label({
|
||||||
label: title,
|
label: title,
|
||||||
});
|
});
|
||||||
this.append_page(widget, label);
|
this.append_page(widget, label);
|
||||||
@@ -49,11 +49,11 @@ class ClapperPrefsNotebook extends Gtk.Notebook
|
|||||||
|
|
||||||
_onClose()
|
_onClose()
|
||||||
{
|
{
|
||||||
let totalPages = this.get_n_pages();
|
const totalPages = this.get_n_pages();
|
||||||
let index = 0;
|
let index = 0;
|
||||||
|
|
||||||
while(index < totalPages) {
|
while(index < totalPages) {
|
||||||
let page = this.get_nth_page(index);
|
const page = this.get_nth_page(index);
|
||||||
page._onClose();
|
page._onClose();
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
@@ -99,38 +99,38 @@ class ClapperPrefsGrid extends Gtk.Grid
|
|||||||
|
|
||||||
addTitle(text)
|
addTitle(text)
|
||||||
{
|
{
|
||||||
let label = this.getLabel(text, true);
|
const label = this.getLabel(text, true);
|
||||||
|
|
||||||
return this.addToGrid(label);
|
return this.addToGrid(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
addComboBoxText(text, entries, setting)
|
addComboBoxText(text, entries, setting)
|
||||||
{
|
{
|
||||||
let label = this.getLabel(text + ':');
|
const label = this.getLabel(text + ':');
|
||||||
let widget = this.getComboBoxText(entries, setting);
|
const widget = this.getComboBoxText(entries, setting);
|
||||||
|
|
||||||
return this.addToGrid(label, widget);
|
return this.addToGrid(label, widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
addSpinButton(text, min, max, setting, precision)
|
addSpinButton(text, min, max, setting, precision)
|
||||||
{
|
{
|
||||||
let label = this.getLabel(text + ':');
|
const label = this.getLabel(text + ':');
|
||||||
let widget = this.getSpinButton(min, max, setting, precision);
|
const widget = this.getSpinButton(min, max, setting, precision);
|
||||||
|
|
||||||
return this.addToGrid(label, widget);
|
return this.addToGrid(label, widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
addCheckButton(text, setting)
|
addCheckButton(text, setting)
|
||||||
{
|
{
|
||||||
let widget = this.getCheckButton(text, setting);
|
const widget = this.getCheckButton(text, setting);
|
||||||
|
|
||||||
return this.addToGrid(widget);
|
return this.addToGrid(widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
addPlayFlagCheckButton(text, flag)
|
addPlayFlagCheckButton(text, flag)
|
||||||
{
|
{
|
||||||
let checkButton = this.addCheckButton(text);
|
const checkButton = this.addCheckButton(text);
|
||||||
let playFlags = settings.get_int('play-flags');
|
const playFlags = settings.get_int('play-flags');
|
||||||
|
|
||||||
checkButton.active = ((playFlags & flag) === flag);
|
checkButton.active = ((playFlags & flag) === flag);
|
||||||
checkButton.connect('toggled', this._onPlayFlagToggled.bind(this, flag));
|
checkButton.connect('toggled', this._onPlayFlagToggled.bind(this, flag));
|
||||||
@@ -140,17 +140,18 @@ class ClapperPrefsGrid extends Gtk.Grid
|
|||||||
|
|
||||||
addFontButton(text, setting)
|
addFontButton(text, setting)
|
||||||
{
|
{
|
||||||
let label = this.getLabel(text + ':');
|
const label = this.getLabel(text + ':');
|
||||||
let widget = this.getFontButton(setting);
|
const widget = this.getFontButton(setting);
|
||||||
|
|
||||||
return this.addToGrid(label, widget);
|
return this.addToGrid(label, widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
getLabel(text, isTitle)
|
getLabel(text, isTitle)
|
||||||
{
|
{
|
||||||
|
const marginTop = (isTitle && this.gridIndex > 0) ? 16 : 0;
|
||||||
|
const marginBottom = (isTitle) ? 2 : 0;
|
||||||
|
|
||||||
let marginLR = 0;
|
let marginLR = 0;
|
||||||
let marginTop = (isTitle && this.gridIndex > 0) ? 16 : 0;
|
|
||||||
let marginBottom = (isTitle) ? 2 : 0;
|
|
||||||
|
|
||||||
if(isTitle)
|
if(isTitle)
|
||||||
text = '<span font="12"><b>' + text + '</b></span>';
|
text = '<span font="12"><b>' + text + '</b></span>';
|
||||||
@@ -171,7 +172,7 @@ class ClapperPrefsGrid extends Gtk.Grid
|
|||||||
|
|
||||||
getComboBoxText(entries, setting)
|
getComboBoxText(entries, setting)
|
||||||
{
|
{
|
||||||
let comboBox = new Gtk.ComboBoxText(this.widgetDefaults);
|
const comboBox = new Gtk.ComboBoxText(this.widgetDefaults);
|
||||||
|
|
||||||
for(let entry of entries)
|
for(let entry of entries)
|
||||||
comboBox.append(entry[0], entry[1]);
|
comboBox.append(entry[0], entry[1]);
|
||||||
@@ -185,7 +186,7 @@ class ClapperPrefsGrid extends Gtk.Grid
|
|||||||
{
|
{
|
||||||
precision = precision || 1;
|
precision = precision || 1;
|
||||||
|
|
||||||
let spinButton = new Gtk.SpinButton(this.widgetDefaults);
|
const spinButton = new Gtk.SpinButton(this.widgetDefaults);
|
||||||
spinButton.set_range(min, max);
|
spinButton.set_range(min, max);
|
||||||
spinButton.set_digits(precision % 1 === 0 ? 0 : 3);
|
spinButton.set_digits(precision % 1 === 0 ? 0 : 3);
|
||||||
spinButton.set_increments(precision, 1);
|
spinButton.set_increments(precision, 1);
|
||||||
@@ -196,7 +197,7 @@ class ClapperPrefsGrid extends Gtk.Grid
|
|||||||
|
|
||||||
getCheckButton(text, setting)
|
getCheckButton(text, setting)
|
||||||
{
|
{
|
||||||
let checkButton = new Gtk.CheckButton({
|
const checkButton = new Gtk.CheckButton({
|
||||||
label: text || null,
|
label: text || null,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -208,7 +209,7 @@ class ClapperPrefsGrid extends Gtk.Grid
|
|||||||
|
|
||||||
getFontButton(setting)
|
getFontButton(setting)
|
||||||
{
|
{
|
||||||
let fontButton = new Gtk.FontButton({
|
const fontButton = new Gtk.FontButton({
|
||||||
use_font: true,
|
use_font: true,
|
||||||
use_size: true,
|
use_size: true,
|
||||||
});
|
});
|
||||||
|
@@ -3,7 +3,7 @@ const Debug = imports.clapper_src.debug;
|
|||||||
|
|
||||||
const REVEAL_TIME = 800;
|
const REVEAL_TIME = 800;
|
||||||
|
|
||||||
let { debug } = Debug;
|
const { debug } = Debug;
|
||||||
|
|
||||||
var CustomRevealer = GObject.registerClass(
|
var CustomRevealer = GObject.registerClass(
|
||||||
class ClapperCustomRevealer extends Gtk.Revealer
|
class ClapperCustomRevealer extends Gtk.Revealer
|
||||||
@@ -12,7 +12,7 @@ class ClapperCustomRevealer extends Gtk.Revealer
|
|||||||
{
|
{
|
||||||
opts = opts || {};
|
opts = opts || {};
|
||||||
|
|
||||||
let defaults = {
|
const defaults = {
|
||||||
visible: false,
|
visible: false,
|
||||||
can_focus: false,
|
can_focus: false,
|
||||||
};
|
};
|
||||||
@@ -96,9 +96,9 @@ class ClapperRevealerTop extends CustomRevealer
|
|||||||
transition_type: Gtk.RevealerTransitionType.CROSSFADE,
|
transition_type: Gtk.RevealerTransitionType.CROSSFADE,
|
||||||
valign: Gtk.Align.START,
|
valign: Gtk.Align.START,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.revealerName = 'top';
|
this.revealerName = 'top';
|
||||||
let initTime = GLib.DateTime.new_now_local().format('%X');
|
|
||||||
|
const initTime = GLib.DateTime.new_now_local().format('%X');
|
||||||
this.timeFormat = (initTime.length > 8)
|
this.timeFormat = (initTime.length > 8)
|
||||||
? '%I:%M %p'
|
? '%I:%M %p'
|
||||||
: '%H:%M';
|
: '%H:%M';
|
||||||
@@ -119,7 +119,7 @@ class ClapperRevealerTop extends CustomRevealer
|
|||||||
yalign: 0,
|
yalign: 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
let timeLabelOpts = {
|
const timeLabelOpts = {
|
||||||
margin_end: 10,
|
margin_end: 10,
|
||||||
xalign: 1,
|
xalign: 1,
|
||||||
yalign: 0,
|
yalign: 0,
|
||||||
@@ -127,9 +127,8 @@ class ClapperRevealerTop extends CustomRevealer
|
|||||||
this.currentTime = new Gtk.Label(timeLabelOpts);
|
this.currentTime = new Gtk.Label(timeLabelOpts);
|
||||||
this.currentTime.add_css_class('osdtime');
|
this.currentTime.add_css_class('osdtime');
|
||||||
|
|
||||||
this.endTime = new Gtk.Label(
|
timeLabelOpts.visible = false;
|
||||||
Object.assign(timeLabelOpts, { visible: false })
|
this.endTime = new Gtk.Label(timeLabelOpts);
|
||||||
);
|
|
||||||
this.endTime.add_css_class('osdendtime');
|
this.endTime.add_css_class('osdendtime');
|
||||||
|
|
||||||
this.revealerGrid.attach(this.mediaTitle, 0, 0, 1, 1);
|
this.revealerGrid.attach(this.mediaTitle, 0, 0, 1, 1);
|
||||||
@@ -146,16 +145,16 @@ class ClapperRevealerTop extends CustomRevealer
|
|||||||
|
|
||||||
setTimes(currTime, endTime)
|
setTimes(currTime, endTime)
|
||||||
{
|
{
|
||||||
let now = currTime.format(this.timeFormat);
|
const now = currTime.format(this.timeFormat);
|
||||||
let end = endTime.format(this.timeFormat);
|
const end = endTime.format(this.timeFormat);
|
||||||
let endText = `Ends at: ${end}`;
|
const endText = `Ends at: ${end}`;
|
||||||
|
|
||||||
this.currentTime.set_label(now);
|
this.currentTime.set_label(now);
|
||||||
this.endTime.set_label(endText);
|
this.endTime.set_label(endText);
|
||||||
|
|
||||||
/* Make sure that next timeout is always run after clock changes,
|
/* Make sure that next timeout is always run after clock changes,
|
||||||
* by delaying it for additional few milliseconds */
|
* by delaying it for additional few milliseconds */
|
||||||
let nextUpdate = 60002 - parseInt(currTime.get_seconds() * 1000);
|
const nextUpdate = 60002 - parseInt(currTime.get_seconds() * 1000);
|
||||||
debug(`updated current time: ${now}, ends at: ${end}`);
|
debug(`updated current time: ${now}, ends at: ${end}`);
|
||||||
|
|
||||||
return nextUpdate;
|
return nextUpdate;
|
||||||
@@ -195,27 +194,27 @@ class ClapperRevealerBottom extends CustomRevealer
|
|||||||
if(isFloating === this.revealerBox.has_css_class('floatingcontrols'))
|
if(isFloating === this.revealerBox.has_css_class('floatingcontrols'))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let action = (isFloating) ? 'add' : 'remove';
|
const action = (isFloating) ? 'add' : 'remove';
|
||||||
this.revealerBox[`${action}_css_class`]('floatingcontrols');
|
this.revealerBox[`${action}_css_class`]('floatingcontrols');
|
||||||
}
|
}
|
||||||
|
|
||||||
set_visible(isVisible)
|
set_visible(isVisible)
|
||||||
{
|
{
|
||||||
let isChange = super.set_visible(isVisible);
|
const isChange = super.set_visible(isVisible);
|
||||||
if(!isChange || !this.can_focus) return;
|
if(!isChange || !this.can_focus) return;
|
||||||
|
|
||||||
let parent = this.get_parent();
|
const parent = this.get_parent();
|
||||||
let playerWidget = parent.get_first_child();
|
const playerWidget = parent.get_first_child();
|
||||||
if(!playerWidget) return;
|
if(!playerWidget) return;
|
||||||
|
|
||||||
if(isVisible) {
|
if(isVisible) {
|
||||||
let box = this.get_first_child();
|
const box = this.get_first_child();
|
||||||
if(!box) return;
|
if(!box) return;
|
||||||
|
|
||||||
let controls = box.get_first_child();
|
const controls = box.get_first_child();
|
||||||
if(!controls) return;
|
if(!controls) return;
|
||||||
|
|
||||||
let togglePlayButton = controls.get_first_child();
|
const togglePlayButton = controls.get_first_child();
|
||||||
if(togglePlayButton) {
|
if(togglePlayButton) {
|
||||||
togglePlayButton.grab_focus();
|
togglePlayButton.grab_focus();
|
||||||
debug('focus moved to toggle play button');
|
debug('focus moved to toggle play button');
|
||||||
@@ -240,7 +239,7 @@ class ClapperButtonsRevealer extends Gtk.Revealer
|
|||||||
transition_type: Gtk.RevealerTransitionType[trType],
|
transition_type: Gtk.RevealerTransitionType[trType],
|
||||||
});
|
});
|
||||||
|
|
||||||
let revealerBox = new Gtk.Box({
|
const revealerBox = new Gtk.Box({
|
||||||
orientation: Gtk.Orientation.HORIZONTAL,
|
orientation: Gtk.Orientation.HORIZONTAL,
|
||||||
});
|
});
|
||||||
this.set_child(revealerBox);
|
this.set_child(revealerBox);
|
||||||
@@ -257,7 +256,7 @@ class ClapperButtonsRevealer extends Gtk.Revealer
|
|||||||
if(this.reveal_child === isReveal)
|
if(this.reveal_child === isReveal)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let grandson = this.child.get_first_child();
|
const grandson = this.child.get_first_child();
|
||||||
if(grandson && grandson.isFloating && !grandson.isFullscreen)
|
if(grandson && grandson.isFloating && !grandson.isFullscreen)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@@ -2,7 +2,7 @@ const { Gio, GObject } = imports.gi;
|
|||||||
const Debug = imports.clapper_src.debug;
|
const Debug = imports.clapper_src.debug;
|
||||||
const Misc = imports.clapper_src.misc;
|
const Misc = imports.clapper_src.misc;
|
||||||
|
|
||||||
let { debug } = Debug;
|
const { debug } = Debug;
|
||||||
|
|
||||||
var WebApp = GObject.registerClass(
|
var WebApp = GObject.registerClass(
|
||||||
class ClapperWebApp extends Gio.SubprocessLauncher
|
class ClapperWebApp extends Gio.SubprocessLauncher
|
||||||
|
@@ -3,8 +3,8 @@ const Debug = imports.clapper_src.debug;
|
|||||||
const Misc = imports.clapper_src.misc;
|
const Misc = imports.clapper_src.misc;
|
||||||
const WebHelpers = imports.clapper_src.webHelpers;
|
const WebHelpers = imports.clapper_src.webHelpers;
|
||||||
|
|
||||||
let { debug } = Debug;
|
const { debug } = Debug;
|
||||||
let { settings } = Misc;
|
const { settings } = Misc;
|
||||||
|
|
||||||
var WebClient = GObject.registerClass(
|
var WebClient = GObject.registerClass(
|
||||||
class ClapperWebClient extends Soup.Session
|
class ClapperWebClient extends Soup.Session
|
||||||
|
@@ -2,7 +2,7 @@ const { Soup } = imports.gi;
|
|||||||
const ByteArray = imports.byteArray;
|
const ByteArray = imports.byteArray;
|
||||||
const Debug = imports.clapper_src.debug;
|
const Debug = imports.clapper_src.debug;
|
||||||
|
|
||||||
let { debug } = Debug;
|
const { debug } = Debug;
|
||||||
|
|
||||||
function parseData(dataType, bytes)
|
function parseData(dataType, bytes)
|
||||||
{
|
{
|
||||||
|
@@ -2,7 +2,7 @@ const { Soup, GObject } = imports.gi;
|
|||||||
const Debug = imports.clapper_src.debug;
|
const Debug = imports.clapper_src.debug;
|
||||||
const WebHelpers = imports.clapper_src.webHelpers;
|
const WebHelpers = imports.clapper_src.webHelpers;
|
||||||
|
|
||||||
let { debug } = Debug;
|
const { debug } = Debug;
|
||||||
|
|
||||||
var WebServer = GObject.registerClass(
|
var WebServer = GObject.registerClass(
|
||||||
class ClapperWebServer extends Soup.Server
|
class ClapperWebServer extends Soup.Server
|
||||||
|
@@ -5,8 +5,8 @@ const Misc = imports.clapper_src.misc;
|
|||||||
const { Player } = imports.clapper_src.player;
|
const { Player } = imports.clapper_src.player;
|
||||||
const Revealers = imports.clapper_src.revealers;
|
const Revealers = imports.clapper_src.revealers;
|
||||||
|
|
||||||
let { debug } = Debug;
|
const { debug } = Debug;
|
||||||
let { settings } = Misc;
|
const { settings } = Misc;
|
||||||
|
|
||||||
var Widget = GObject.registerClass({
|
var Widget = GObject.registerClass({
|
||||||
Signals: {
|
Signals: {
|
||||||
@@ -60,7 +60,7 @@ var Widget = GObject.registerClass({
|
|||||||
this.overlay.add_overlay(this.revealerTop);
|
this.overlay.add_overlay(this.revealerTop);
|
||||||
this.overlay.add_overlay(this.revealerBottom);
|
this.overlay.add_overlay(this.revealerBottom);
|
||||||
|
|
||||||
let motionController = new Gtk.EventControllerMotion();
|
const motionController = new Gtk.EventControllerMotion();
|
||||||
motionController.connect('leave', this._onLeave.bind(this));
|
motionController.connect('leave', this._onLeave.bind(this));
|
||||||
this.add_controller(motionController);
|
this.add_controller(motionController);
|
||||||
}
|
}
|
||||||
@@ -79,10 +79,10 @@ var Widget = GObject.registerClass({
|
|||||||
|
|
||||||
toggleFullscreen()
|
toggleFullscreen()
|
||||||
{
|
{
|
||||||
let root = this.get_root();
|
const root = this.get_root();
|
||||||
if(!root) return;
|
if(!root) return;
|
||||||
|
|
||||||
let un = (this.fullscreenMode) ? 'un' : '';
|
const un = (this.fullscreenMode) ? 'un' : '';
|
||||||
root[`${un}fullscreen`]();
|
root[`${un}fullscreen`]();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,8 +93,8 @@ var Widget = GObject.registerClass({
|
|||||||
|
|
||||||
this.fullscreenMode = isFullscreen;
|
this.fullscreenMode = isFullscreen;
|
||||||
|
|
||||||
let root = this.get_root();
|
const root = this.get_root();
|
||||||
let action = (isFullscreen) ? 'add' : 'remove';
|
const action = (isFullscreen) ? 'add' : 'remove';
|
||||||
root[action + '_css_class']('gpufriendlyfs');
|
root[action + '_css_class']('gpufriendlyfs');
|
||||||
|
|
||||||
if(!this.floatingMode)
|
if(!this.floatingMode)
|
||||||
@@ -121,8 +121,8 @@ var Widget = GObject.registerClass({
|
|||||||
if(this.floatingMode === isFloating)
|
if(this.floatingMode === isFloating)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let root = this.get_root();
|
const root = this.get_root();
|
||||||
let size = (Misc.isOldGtk)
|
const size = (Misc.isOldGtk)
|
||||||
? root.get_size()
|
? root.get_size()
|
||||||
: root.get_default_size();
|
: root.get_default_size();
|
||||||
|
|
||||||
@@ -145,7 +145,7 @@ var Widget = GObject.registerClass({
|
|||||||
this.controls.unfloatButton.set_visible(isFloating);
|
this.controls.unfloatButton.set_visible(isFloating);
|
||||||
this._setWindowFloating(isFloating);
|
this._setWindowFloating(isFloating);
|
||||||
|
|
||||||
let resize = (isFloating)
|
const resize = (isFloating)
|
||||||
? this.floatSize
|
? this.floatSize
|
||||||
: this.windowSize;
|
: this.windowSize;
|
||||||
|
|
||||||
@@ -162,19 +162,19 @@ var Widget = GObject.registerClass({
|
|||||||
|
|
||||||
_setWindowFloating(isFloating)
|
_setWindowFloating(isFloating)
|
||||||
{
|
{
|
||||||
let root = this.get_root();
|
const root = this.get_root();
|
||||||
|
const cssClass = 'floatingwindow';
|
||||||
|
|
||||||
let cssClass = 'floatingwindow';
|
|
||||||
if(isFloating === root.has_css_class(cssClass))
|
if(isFloating === root.has_css_class(cssClass))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let action = (isFloating) ? 'add' : 'remove';
|
const action = (isFloating) ? 'add' : 'remove';
|
||||||
root[action + '_css_class'](cssClass);
|
root[action + '_css_class'](cssClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
_saveWindowSize(size)
|
_saveWindowSize(size)
|
||||||
{
|
{
|
||||||
let rootName = (this.floatingMode)
|
const rootName = (this.floatingMode)
|
||||||
? 'float'
|
? 'float'
|
||||||
: 'window';
|
: 'window';
|
||||||
|
|
||||||
@@ -198,7 +198,7 @@ var Widget = GObject.registerClass({
|
|||||||
|
|
||||||
_updateMediaInfo()
|
_updateMediaInfo()
|
||||||
{
|
{
|
||||||
let mediaInfo = this.player.get_media_info();
|
const mediaInfo = this.player.get_media_info();
|
||||||
if(!mediaInfo)
|
if(!mediaInfo)
|
||||||
return GLib.SOURCE_REMOVE;
|
return GLib.SOURCE_REMOVE;
|
||||||
|
|
||||||
@@ -206,12 +206,12 @@ var Widget = GObject.registerClass({
|
|||||||
this.updateTitles(mediaInfo);
|
this.updateTitles(mediaInfo);
|
||||||
|
|
||||||
/* Show/hide position scale on LIVE */
|
/* Show/hide position scale on LIVE */
|
||||||
let isLive = mediaInfo.is_live();
|
const isLive = mediaInfo.is_live();
|
||||||
this.isSeekable = mediaInfo.is_seekable();
|
this.isSeekable = mediaInfo.is_seekable();
|
||||||
this.controls.setLiveMode(isLive, this.isSeekable);
|
this.controls.setLiveMode(isLive, this.isSeekable);
|
||||||
|
|
||||||
let streamList = mediaInfo.get_stream_list();
|
const streamList = mediaInfo.get_stream_list();
|
||||||
let parsedInfo = {
|
const parsedInfo = {
|
||||||
videoTracks: [],
|
videoTracks: [],
|
||||||
audioTracks: [],
|
audioTracks: [],
|
||||||
subtitleTracks: []
|
subtitleTracks: []
|
||||||
@@ -253,7 +253,7 @@ var Widget = GObject.registerClass({
|
|||||||
debug(`unrecognized media info type: ${info.constructor}`);
|
debug(`unrecognized media info type: ${info.constructor}`);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
let tracksArr = parsedInfo[`${type}Tracks`];
|
const tracksArr = parsedInfo[`${type}Tracks`];
|
||||||
if(!tracksArr.length)
|
if(!tracksArr.length)
|
||||||
{
|
{
|
||||||
tracksArr[0] = {
|
tracksArr[0] = {
|
||||||
@@ -272,15 +272,15 @@ var Widget = GObject.registerClass({
|
|||||||
let anyButtonShown = false;
|
let anyButtonShown = false;
|
||||||
|
|
||||||
for(let type of ['video', 'audio', 'subtitle']) {
|
for(let type of ['video', 'audio', 'subtitle']) {
|
||||||
let currStream = this.player[`get_current_${type}_track`]();
|
const currStream = this.player[`get_current_${type}_track`]();
|
||||||
let activeId = (currStream) ? currStream.get_index() : -1;
|
const activeId = (currStream) ? currStream.get_index() : -1;
|
||||||
|
|
||||||
if(currStream && type !== 'subtitle') {
|
if(currStream && type !== 'subtitle') {
|
||||||
let caps = currStream.get_caps();
|
const caps = currStream.get_caps();
|
||||||
debug(`${type} caps: ${caps.to_string()}`, 'LEVEL_INFO');
|
debug(`${type} caps: ${caps.to_string()}`, 'LEVEL_INFO');
|
||||||
}
|
}
|
||||||
if(type === 'video') {
|
if(type === 'video') {
|
||||||
let isShowVis = (parsedInfo[`${type}Tracks`].length === 0);
|
const isShowVis = (parsedInfo[`${type}Tracks`].length === 0);
|
||||||
this.showVisualizationsButton(isShowVis);
|
this.showVisualizationsButton(isShowVis);
|
||||||
}
|
}
|
||||||
if(!parsedInfo[`${type}Tracks`].length) {
|
if(!parsedInfo[`${type}Tracks`].length) {
|
||||||
@@ -324,8 +324,8 @@ var Widget = GObject.registerClass({
|
|||||||
subtitle = null;
|
subtitle = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
let root = this.get_root();
|
const root = this.get_root();
|
||||||
let headerbar = root.get_titlebar();
|
const headerbar = root.get_titlebar();
|
||||||
|
|
||||||
if(headerbar && headerbar.updateHeaderBar)
|
if(headerbar && headerbar.updateHeaderBar)
|
||||||
headerbar.updateHeaderBar(title, subtitle);
|
headerbar.updateHeaderBar(title, subtitle);
|
||||||
@@ -338,11 +338,11 @@ var Widget = GObject.registerClass({
|
|||||||
if(!this.revealerTop.visible)
|
if(!this.revealerTop.visible)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
let currTime = GLib.DateTime.new_now_local();
|
const currTime = GLib.DateTime.new_now_local();
|
||||||
let endTime = currTime.add_seconds(
|
const endTime = currTime.add_seconds(
|
||||||
this.controls.positionAdjustment.get_upper() - this.controls.currentPosition
|
this.controls.positionAdjustment.get_upper() - this.controls.currentPosition
|
||||||
);
|
);
|
||||||
let nextUpdate = this.revealerTop.setTimes(currTime, endTime);
|
const nextUpdate = this.revealerTop.setTimes(currTime, endTime);
|
||||||
|
|
||||||
return nextUpdate;
|
return nextUpdate;
|
||||||
}
|
}
|
||||||
@@ -351,11 +351,11 @@ var Widget = GObject.registerClass({
|
|||||||
{
|
{
|
||||||
if(isShow && !this.controls.visualizationsButton.isVisList) {
|
if(isShow && !this.controls.visualizationsButton.isVisList) {
|
||||||
debug('creating visualizations list');
|
debug('creating visualizations list');
|
||||||
let visArr = GstPlayer.Player.visualizations_get();
|
const visArr = GstPlayer.Player.visualizations_get();
|
||||||
if(!visArr.length)
|
if(!visArr.length)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let parsedVisArr = [{
|
const parsedVisArr = [{
|
||||||
label: 'Disabled',
|
label: 'Disabled',
|
||||||
type: 'visualization',
|
type: 'visualization',
|
||||||
activeId: null
|
activeId: null
|
||||||
@@ -381,7 +381,7 @@ var Widget = GObject.registerClass({
|
|||||||
if(this.controls.visualizationsButton.visible === isShow)
|
if(this.controls.visualizationsButton.visible === isShow)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let action = (isShow) ? 'show' : 'hide';
|
const action = (isShow) ? 'show' : 'hide';
|
||||||
this.controls.visualizationsButton[action]();
|
this.controls.visualizationsButton[action]();
|
||||||
debug(`show visualizations button: ${isShow}`);
|
debug(`show visualizations button: ${isShow}`);
|
||||||
}
|
}
|
||||||
@@ -421,13 +421,13 @@ var Widget = GObject.registerClass({
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
let isNotStopped = (state !== GstPlayer.PlayerState.STOPPED);
|
const isNotStopped = (state !== GstPlayer.PlayerState.STOPPED);
|
||||||
this.revealerTop.endTime.set_visible(isNotStopped);
|
this.revealerTop.endTime.set_visible(isNotStopped);
|
||||||
}
|
}
|
||||||
|
|
||||||
_onPlayerDurationChanged(player)
|
_onPlayerDurationChanged(player)
|
||||||
{
|
{
|
||||||
let duration = Math.floor(player.get_duration() / 1000000000);
|
const duration = Math.floor(player.get_duration() / 1000000000);
|
||||||
|
|
||||||
/* Sometimes GstPlayer might re-emit
|
/* Sometimes GstPlayer might re-emit
|
||||||
* duration changed during playback */
|
* duration changed during playback */
|
||||||
@@ -451,7 +451,7 @@ var Widget = GObject.registerClass({
|
|||||||
)
|
)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let positionSeconds = Math.round(position / 1000000000);
|
const positionSeconds = Math.round(position / 1000000000);
|
||||||
if(positionSeconds === this.controls.currentPosition)
|
if(positionSeconds === this.controls.currentPosition)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -460,7 +460,7 @@ var Widget = GObject.registerClass({
|
|||||||
|
|
||||||
_onPlayerVolumeChanged(player)
|
_onPlayerVolumeChanged(player)
|
||||||
{
|
{
|
||||||
let volume = player.get_volume();
|
const volume = player.get_volume();
|
||||||
|
|
||||||
/* FIXME: This check should not be needed, GstPlayer should not
|
/* FIXME: This check should not be needed, GstPlayer should not
|
||||||
* emit 'volume-changed' with the same values, but it does. */
|
* emit 'volume-changed' with the same values, but it does. */
|
||||||
@@ -470,13 +470,13 @@ var Widget = GObject.registerClass({
|
|||||||
/* Once above is fixed in GstPlayer, remove this var too */
|
/* Once above is fixed in GstPlayer, remove this var too */
|
||||||
this.controls.currentVolume = volume;
|
this.controls.currentVolume = volume;
|
||||||
|
|
||||||
let cubicVolume = Misc.getCubicValue(volume);
|
const cubicVolume = Misc.getCubicValue(volume);
|
||||||
this.controls._updateVolumeButtonIcon(cubicVolume);
|
this.controls._updateVolumeButtonIcon(cubicVolume);
|
||||||
}
|
}
|
||||||
|
|
||||||
_onStateNotify(toplevel)
|
_onStateNotify(toplevel)
|
||||||
{
|
{
|
||||||
let isFullscreen = Boolean(
|
const isFullscreen = Boolean(
|
||||||
toplevel.state & Gdk.ToplevelState.FULLSCREEN
|
toplevel.state & Gdk.ToplevelState.FULLSCREEN
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -504,10 +504,10 @@ var Widget = GObject.registerClass({
|
|||||||
{
|
{
|
||||||
this.disconnect(this.mapSignal);
|
this.disconnect(this.mapSignal);
|
||||||
|
|
||||||
let root = this.get_root();
|
const root = this.get_root();
|
||||||
if(!root) return;
|
if(!root) return;
|
||||||
|
|
||||||
let surface = root.get_surface();
|
const surface = root.get_surface();
|
||||||
surface.connect('notify::state', this._onStateNotify.bind(this));
|
surface.connect('notify::state', this._onStateNotify.bind(this));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -62,7 +62,7 @@ class ClapperWidgetRemote extends Gtk.Grid
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'close':
|
case 'close':
|
||||||
let root = this.get_root();
|
const root = this.get_root();
|
||||||
root.run_dispose();
|
root.run_dispose();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Reference in New Issue
Block a user