From 7ce150ad6d857f85cf9fd56c2f2aaf6847733dd7 Mon Sep 17 00:00:00 2001 From: Sakith B Date: Tue, 14 Sep 2021 00:25:17 +0530 Subject: [PATCH] Added active player indicator --- player.js | 13 ++++++++++++- stylesheet.css | 4 ++++ widget.js | 17 ++++++++++------- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/player.js b/player.js index f9ec4a9..3e94bc0 100644 --- a/player.js +++ b/player.js @@ -106,6 +106,7 @@ const Player = GObject.registerClass( this.containerButtonLabel = new St.Button({ style_class: "panel-button", + style: "padding: 0px 5px", }); this.containerButtonLabel.connect("button-release-event", this._mouseActionButton.bind(this)); @@ -687,13 +688,13 @@ const Player = GObject.registerClass( this._menuIcon = new St.Icon({ gicon: this.trackIcon, - y_align: Clutter.ActorAlign.CENTER, style_class: "popup-menu-icon", }); this._menuLabel = new St.Label({ text: this.label, y_align: Clutter.ActorAlign.CENTER, + y_expand: true, style: this.maxWidthStyle, }); @@ -820,5 +821,15 @@ const Player = GObject.registerClass( return file; } + + set active(active) { + if (active) { + this._menuItem.add_style_class_name("selected"); + this._menuItem.track_hover = false; + } else { + this._menuItem.remove_style_class_name("selected"); + this._menuItem.track_hover = true; + } + } } ); diff --git a/stylesheet.css b/stylesheet.css index bb749ab..437e389 100644 --- a/stylesheet.css +++ b/stylesheet.css @@ -8,6 +8,10 @@ background-color: rgba(160, 160, 160, 0.2); } +.popup-menu-button:active { + background-color: rgba(160, 160, 160, 0.4); +} + .popup-menu-button-active { border-radius: 99px; background-color: rgba(160, 160, 160, 0.2); diff --git a/widget.js b/widget.js index 7e89f77..b1cceaf 100644 --- a/widget.js +++ b/widget.js @@ -121,10 +121,8 @@ const MediaControls = GObject.registerClass( this.settings.elementOrder.forEach((element) => { if (element === "icon" && this.settings.showPlayerIcon) { - log("Adding icon"); this.player.dummyContainer.add_child(this.player.buttonPlayer); } else if (element === "title" && this.settings.showTrackName) { - log("Adding title"); this.player.dummyContainer.add_child(this.player.containerButtonLabel); if (this.settings.showSeperators) { this.player.subContainerLabel.add_child(this.player.labelSeperatorStart); @@ -134,7 +132,6 @@ const MediaControls = GObject.registerClass( this.player.subContainerLabel.add_child(this.player.labelSeperatorEnd); } } else if (element === "controls" && this.settings.showControls) { - log("Adding controls"); this.player.dummyContainer.add_child(this.player.containerControls); if (this.settings.showPrevButton) { this.player.containerControls.add_child(this.player.buttonPrev); @@ -146,7 +143,6 @@ const MediaControls = GObject.registerClass( this.player.containerControls.add_child(this.player.buttonNext); } } else if (element === "menu" && this.settings.showMenu) { - log("Adding menu"); this.player.dummyContainer.add_child(this.player.buttonMenu); } }); @@ -202,9 +198,9 @@ const MediaControls = GObject.registerClass( _updatePlayer(player = null) { if (this.player) { + this.player.active = false; this.removeWidgets(); Gio.bus_unwatch_name(this.playerWatchId); - Main.panel.menuManager.removeMenu(this.player.menu); this.player = null; @@ -242,11 +238,14 @@ const MediaControls = GObject.registerClass( null, this.playerVanished.bind(this) ); + this.removeWidgets(); this.addWidgets(); + + this.player.active = true; } - log("[MediaControls] Updated player"); + log("[MediaControls] Updated player", player ? player.busName : player); } _activatePlayer(playerItem) { @@ -279,7 +278,11 @@ const MediaControls = GObject.registerClass( if (playerObj) { this.menu.addMenuItem(playerObj.menuItem); playerObj.hidden = false; - this._updatePlayer(); + if (this._isFixedPlayer) { + this._updatePlayer(this.player); + } else { + this._updatePlayer(); + } } }