Skip to content

Commit

Permalink
added album to the subtitle in the menu
Browse files Browse the repository at this point in the history
  • Loading branch information
sakithb committed Jan 10, 2024
1 parent 183dac3 commit 0e0ec58
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
26 changes: 15 additions & 11 deletions src/helpers/shell/PanelButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class PanelButton extends PanelMenu.Button {
private menuPlayerIcons: St.BoxLayout;

private menuLabelTitle: InstanceType<typeof ScrollingLabel>;
private menuLabelArtist: InstanceType<typeof ScrollingLabel>;
private menuLabelSubtitle: InstanceType<typeof ScrollingLabel>;

private doubleTapSourceId: number;
private changeListenerIds: Map<KeysOf<PlayerProxyProperties>, number>;
Expand Down Expand Up @@ -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(
Expand All @@ -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);
Expand Down Expand Up @@ -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();
}
});
Expand Down Expand Up @@ -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);
Expand Down
12 changes: 11 additions & 1 deletion src/helpers/shell/ScrollingLabel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,26 @@ 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,
});

this.initPaused = initPaused;
this.labelWidth = labelWidth;
this.direction = direction;

this.box = new St.BoxLayout({
xExpand: true,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 0e0ec58

Please sign in to comment.