From 047dd12fbbccb4f3937dcd7e0513dfa25a08480e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Tue, 27 Apr 2021 11:14:09 +0200 Subject: [PATCH] Restore initial GUI state after playback --- src/controls.js | 20 ++++++++++++++++++-- src/widget.js | 4 +--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/controls.js b/src/controls.js index 63cd4309..6d3bf1a3 100644 --- a/src/controls.js +++ b/src/controls.js @@ -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); diff --git a/src/widget.js b/src/widget.js index 234ff64c..10a5f2a2 100644 --- a/src/widget.js +++ b/src/widget.js @@ -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');