From 0e0ec58dbe0925e6dc15528891285ad22fb2cc24 Mon Sep 17 00:00:00 2001 From: "Sakith B." Date: Wed, 10 Jan 2024 21:12:48 +0530 Subject: [PATCH] added album to the subtitle in the menu --- src/helpers/shell/PanelButton.ts | 26 +++++++++++++++----------- src/helpers/shell/ScrollingLabel.ts | 12 +++++++++++- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/helpers/shell/PanelButton.ts b/src/helpers/shell/PanelButton.ts index 3d29c75..8ea16e8 100644 --- a/src/helpers/shell/PanelButton.ts +++ b/src/helpers/shell/PanelButton.ts @@ -52,7 +52,7 @@ class PanelButton extends PanelMenu.Button { private menuPlayerIcons: St.BoxLayout; private menuLabelTitle: InstanceType; - private menuLabelArtist: InstanceType; + private menuLabelSubtitle: InstanceType; private doubleTapSourceId: number; private changeListenerIds: Map, number>; @@ -406,8 +406,8 @@ class PanelButton extends PanelMenu.Button { this.menuLabels.remove_child(this.menuLabelTitle); } - if (this.menuLabelArtist != null) { - this.menuLabels.remove_child(this.menuLabelArtist); + if (this.menuLabelSubtitle != null) { + this.menuLabels.remove_child(this.menuLabelSubtitle); } this.menuLabelTitle = new ScrollingLabel( @@ -422,20 +422,24 @@ class PanelButton extends PanelMenu.Button { this.menuLabelTitle.label.xAlign = Clutter.ActorAlign.CENTER; this.menuLabelTitle.label.xExpand = true; - this.menuLabelArtist = new ScrollingLabel( - this.playerProxy.metadata["xesam:artist"]?.join(", ") || "Unknown artist", + const artistText = this.playerProxy.metadata["xesam:artist"]?.join(", ") || "Unknown artist"; + const albumText = this.playerProxy.metadata["xesam:album"] || ""; + + this.menuLabelSubtitle = new ScrollingLabel( + [artistText, albumText].join(" / "), this.extension.labelWidth, true, this.extension.scrollLabels, this.playerProxy.playbackStatus !== PlaybackStatus.PLAYING, + Clutter.TimelineDirection.BACKWARD, ); // this.menuLabelArtist.label.add_style_class_name("popup-menu-label-artist"); - this.menuLabelArtist.label.xAlign = Clutter.ActorAlign.CENTER; - this.menuLabelArtist.label.xExpand = true; + this.menuLabelSubtitle.label.xAlign = Clutter.ActorAlign.CENTER; + this.menuLabelSubtitle.label.xExpand = true; this.menuLabels.add_child(this.menuLabelTitle); - this.menuLabels.add_child(this.menuLabelArtist); + this.menuLabels.add_child(this.menuLabelSubtitle); if (this.menuLabels.get_parent() == null) { this.menuBox.add_child(this.menuLabels); @@ -758,12 +762,12 @@ class PanelButton extends PanelMenu.Button { if (this.playerProxy.playbackStatus !== PlaybackStatus.PLAYING) { this.buttonLabel?.pauseScrolling(); this.menuLabelTitle.pauseScrolling(); - this.menuLabelArtist.pauseScrolling(); + this.menuLabelSubtitle.pauseScrolling(); this.menuSlider.pauseTransition(); } else { this.buttonLabel?.resumeScrolling(); this.menuLabelTitle.resumeScrolling(); - this.menuLabelArtist.resumeScrolling(); + this.menuLabelSubtitle.resumeScrolling(); this.menuSlider.resumeTransition(); } }); @@ -985,7 +989,7 @@ class PanelButton extends PanelMenu.Button { this.menuPlayerIcons = null; this.menuLabelTitle = null; - this.menuLabelArtist = null; + this.menuLabelSubtitle = null; if (this.doubleTapSourceId != null) { GLib.source_remove(this.doubleTapSourceId); diff --git a/src/helpers/shell/ScrollingLabel.ts b/src/helpers/shell/ScrollingLabel.ts index 7d0be7b..97ff35a 100644 --- a/src/helpers/shell/ScrollingLabel.ts +++ b/src/helpers/shell/ScrollingLabel.ts @@ -13,10 +13,18 @@ class ScrollingLabel extends St.ScrollView { private initPaused: boolean; private labelWidth: number; + private direction: Clutter.TimelineDirection; private transition: Clutter.PropertyTransition; - constructor(text: string, labelWidth: number, isFixedWidth: boolean, isScrolling: boolean, initPaused: boolean) { + constructor( + text: string, + labelWidth: number, + isFixedWidth: boolean, + isScrolling: boolean, + initPaused: boolean, + direction = Clutter.TimelineDirection.FORWARD, + ) { super({ hscrollbarPolicy: St.PolicyType.NEVER, vscrollbarPolicy: St.PolicyType.NEVER, @@ -24,6 +32,7 @@ class ScrollingLabel extends St.ScrollView { this.initPaused = initPaused; this.labelWidth = labelWidth; + this.direction = direction; this.box = new St.BoxLayout({ xExpand: true, @@ -104,6 +113,7 @@ class ScrollingLabel extends St.ScrollView { this.transition = new Clutter.PropertyTransition({ propertyName: "value", progressMode: Clutter.AnimationMode.LINEAR, + direction: this.direction, repeatCount: -1, duration, interval,