Restore initial GUI state after playback

This commit is contained in:
Rafał Dzięgiel
2021-04-27 11:14:09 +02:00
parent 3238270c0d
commit 047dd12fbb
2 changed files with 19 additions and 5 deletions

20
src/controls.js vendored
View File

@@ -7,6 +7,8 @@ const Revealers = imports.src.revealers;
const { debug } = Debug;
const { settings } = Misc;
const INITIAL_ELAPSED = '00:00/00:00';
var Controls = GObject.registerClass(
class ClapperControls extends Gtk.Box
{
@@ -21,7 +23,6 @@ class ClapperControls extends Gtk.Box
this.minFullViewWidth = 560;
this.currentPosition = 0;
this.currentDuration = 0;
this.isPositionDragging = false;
this.isMobile = false;
this.isFullscreen = false;
@@ -109,6 +110,21 @@ class ClapperControls extends Gtk.Box
this.positionScale.visible = isSeekable;
}
setInitialState()
{
this.currentPosition = 0;
this.positionScale.set_value(0);
this.positionScale.visible = false;
this.elapsedButton.set_label(INITIAL_ELAPSED);
this.togglePlayButton.setPrimaryIcon();
for(let type of ['video', 'audio', 'subtitle'])
this[`${type}TracksButton`].visible = false;
this.visualizationsButton.visible = false;
}
updateElapsedLabel(value)
{
value = value || 0;
@@ -291,7 +307,7 @@ class ClapperControls extends Gtk.Box
_addElapsedButton()
{
const elapsedRevealer = new Revealers.ButtonsRevealer('SLIDE_RIGHT');
this.elapsedButton = this.addElapsedPopoverButton('00:00/00:00', elapsedRevealer);
this.elapsedButton = this.addElapsedPopoverButton(INITIAL_ELAPSED, elapsedRevealer);
elapsedRevealer.set_reveal_child(true);
this.revealersArr.push(elapsedRevealer);

View File

@@ -431,10 +431,8 @@ class ClapperWidget extends Gtk.Grid
break;
case GstClapper.ClapperState.STOPPED:
debug('player state changed to: STOPPED');
this.controls.currentPosition = 0;
this.controls.positionScale.set_value(0);
this.controls.setInitialState();
this.revealerTop.showTitle = false;
this.controls.togglePlayButton.setPrimaryIcon();
break;
case GstClapper.ClapperState.PAUSED:
debug('player state changed to: PAUSED');