From 5e4dfb322cfdad3b122718cb3a4ffec35d52cacf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Wed, 15 Dec 2021 12:44:23 +0100 Subject: [PATCH] Append "PiP" suffix to window title when in floating mode We are gonna take advantage of this simple change elsewhere --- src/revealers.js | 8 +++++--- src/widget.js | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/revealers.js b/src/revealers.js index bfab15df..21ffae1e 100644 --- a/src/revealers.js +++ b/src/revealers.js @@ -325,15 +325,17 @@ class ClapperControlsRevealer extends Gtk.Revealer _onControlsRevealed() { - if(this.child_revealed) { - const clapperWidget = this.root.child; - if(!clapperWidget) return; + const clapperWidget = this.root.child; + if(!clapperWidget) return; + if(this.child_revealed) { const [width, height] = this.root.get_default_size(); clapperWidget.player.widget.height_request = -1; this.root.set_default_size(width, height); } + + clapperWidget.refreshWindowTitle(this.root.title); } _onUnrevealTick(playerWidget, width, height) diff --git a/src/widget.js b/src/widget.js index 63bf967f..bf1dd5d5 100644 --- a/src/widget.js +++ b/src/widget.js @@ -319,11 +319,24 @@ class ClapperWidget extends Gtk.Grid title = item.filename; } - this.root.title = title; + this.refreshWindowTitle(title); this.revealerTop.title = title; this.revealerTop.showTitle = true; } + refreshWindowTitle(title) + { + const isFloating = !this.controlsRevealer.child_revealed; + const pipSuffix = ' - PiP'; + const hasPipSuffix = title.endsWith(pipSuffix); + + this.root.title = (isFloating && !hasPipSuffix) + ? title + pipSuffix + : (!isFloating && hasPipSuffix) + ? title.substring(0, title.length - pipSuffix.length) + : title; + } + updateTime() { if(