Skip to content

Commit

Permalink
Add album name support #40
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisLauinger77 committed Dec 2, 2023
1 parent 5ef66fe commit 9b7378a
Show file tree
Hide file tree
Showing 5 changed files with 267 additions and 196 deletions.
45 changes: 36 additions & 9 deletions player.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,10 @@ export const Player = GObject.registerClass(
this._infoIcon.set_gicon(this.trackIcon);
this.infoTitleLabel.set_text(this.title);
this.infoArtistLabel.set_text(this.artist);
this.infoAlbumLabel.set_text(this.album);
wrappingText(!this._mcExtension.cliptextsmenu, this.infoTitleLabel);
wrappingText(!this._mcExtension.cliptextsmenu, this.infoArtistLabel);
wrappingText(!this._mcExtension.cliptextsmenu, this.infoAlbumLabel);
this._updateInfoIcon();
}
}
Expand Down Expand Up @@ -510,7 +512,12 @@ export const Player = GObject.registerClass(
}

_updateInfoIcon() {
const iconSize = Math.max(200, this.infoTitleLabel.width, this.infoArtistLabel.width);
const iconSize = Math.max(
200,
this.infoTitleLabel.width,
this.infoArtistLabel.width,
this.infoAlbumLabel.width
);
this._infoIcon.set_icon_size(iconSize);
}

Expand All @@ -521,10 +528,12 @@ export const Player = GObject.registerClass(

if (this._infoItem) {
this.infoArtistLabel.set_style(this.maxWidthStyle);
this.infoAlbumLabel.set_style(this.maxWidthStyle);
this.infoTitleLabel.set_style(`font-size: large; ${this.maxWidthStyle}`);

wrappingText(!this._mcExtension.cliptextsmenu, this.infoTitleLabel);
wrappingText(!this._mcExtension.cliptextsmenu, this.infoArtistLabel);
wrappingText(!this._mcExtension.cliptextsmenu, this.infoAlbumLabel);

if (this._mcExtension.maxWidgetWidth !== 0) {
this._infoIcon.set_icon_size(this._mcExtension.maxWidgetWidth);
Expand Down Expand Up @@ -608,7 +617,7 @@ export const Player = GObject.registerClass(

this._infoItem.add(this._infoIcon);

// Track title and artist
// Track title artist album

this.infoTitleLabel = new St.Label({
text: this.title,
Expand All @@ -621,8 +630,14 @@ export const Player = GObject.registerClass(
x_align: Clutter.ActorAlign.CENTER,
});

this.infoAlbumLabel = new St.Label({
text: this.album || "",
x_align: Clutter.ActorAlign.CENTER,
});

this._infoItem.add(this.infoTitleLabel);
this._infoItem.add(this.infoArtistLabel);
this._infoItem.add(this.infoAlbumLabel);

// Spacer

Expand Down Expand Up @@ -1077,22 +1092,29 @@ export const Player = GObject.registerClass(

get label() {
let label = "";

const trackLabelSetting = this._mcExtension.trackLabel;
let sepLabel = trackLabelSetting[1];
if (!sepLabel) {
sepLabel = " ";
} else {
sepLabel = ` ${sepLabel} `;
}
let labelartist = this.artist === _("Unknown artist") ? null : this.artist;
let labelalbum = this.album === _("Unknown album") ? null : this.album;
const labelEls = {
track: this.title,
artist: this.artist === _("Unknown artist") ? null : this.artist,
trackalbum: this.title + sepLabel + labelartist,
artist: labelartist,
artistalbum: labelartist + sepLabel + labelalbum,
album: labelalbum,
url: this.url,
name: this.name,
status: this._status,
file: this.file,
none: null,
};

const trackLabelSetting = this._mcExtension.trackLabel;

const startLabel = labelEls[trackLabelSetting[0]] || "";
const endLabel = labelEls[trackLabelSetting[2]] || "";
let sepLabel = trackLabelSetting[1];

if (!(startLabel && endLabel)) {
sepLabel = "";
Expand All @@ -1117,14 +1139,19 @@ export const Player = GObject.registerClass(
}

get title() {
return this._metadata["title"] || "No track";
return this._metadata["title"] || _("No track");
}

get artist() {
const artist = this._metadata["artist"];
return (Array.isArray(artist) ? artist.join(", ") : artist) || _("Unknown artist");
}

get album() {
const album = this._metadata["album"];
return (Array.isArray(album) ? album.join(", ") : album) || _("Unknown album");
}

get image() {
return this._metadata["image"];
}
Expand Down
Loading

0 comments on commit 9b7378a

Please sign in to comment.