Skip to content

Commit a375617

Browse files
committed
sound applet: Fix panel album art not being discarded and falling
out of sync with the active player. Fixing 9211ead revealed a few issues with panel art: - Art from paused or defunct sources would not be discarded, and could be re-used when another source without art/mpris was played. - Switching between active multiple sources, panel art would only refresh if a switched-to source was paused and resumed. - The volume level icon would not always be restored when no sources were playing, but were still active. Fixes linuxmint/mint22.3-beta#85.
1 parent 2a8f62d commit a375617

File tree

1 file changed

+21
-11
lines changed
  • files/usr/share/cinnamon/applets/sound@cinnamon.org

1 file changed

+21
-11
lines changed

files/usr/share/cinnamon/applets/sound@cinnamon.org/applet.js

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,8 @@ class Player extends PopupMenu.PopupMenuSection {
885885
_showCover(cover_path) {
886886
if (! cover_path || ! GLib.file_test(cover_path, GLib.FileTest.EXISTS)) {
887887
this.cover = new St.Icon({style_class: 'sound-player-generic-coverart', important: true, icon_name: "media-optical", icon_size: 300, icon_type: St.IconType.FULLCOLOR});
888-
cover_path = null;
888+
this._cover_path = null;
889+
this._applet.setAppletTextIcon(this, null);
889890
}
890891
else {
891892
this._cover_path = cover_path;
@@ -1330,15 +1331,21 @@ class CinnamonSoundApplet extends Applet.TextIconApplet {
13301331
this._icon_path = null;
13311332
}
13321333

1333-
if (this.showalbum) {
1334-
if (path && player && (player === true || player._playerStatus == 'Playing')) {
1335-
this.setIcon(path, "player-path");
1334+
if (player && (player === true || player._playerStatus == 'Playing')) {
1335+
// Something is playing
1336+
if (this.showalbum) {
1337+
if (path) {
1338+
this.setIcon(path, "player-path");
1339+
} else {
1340+
this.setIcon('xsi-media-optical-cd-audio', 'player-name');
1341+
}
13361342
} else {
1337-
this.setIcon('xsi-media-optical-cd-audio', 'player-name');
1343+
this.setIcon('xsi-audio-x-generic', 'player-name');
13381344
}
1339-
}
1340-
else {
1341-
this.setIcon('xsi-audio-x-generic', 'player-name');
1345+
} else {
1346+
// Nothing is playing - clear player icon and show volume icon
1347+
this._playerIcon = [null, false];
1348+
this.setIcon(this._outputIcon);
13421349
}
13431350
}
13441351

@@ -1425,7 +1432,7 @@ class CinnamonSoundApplet extends Applet.TextIconApplet {
14251432

14261433
this._changeActivePlayer(owner);
14271434
this._updatePlayerMenuItems();
1428-
this.setAppletTextIcon();
1435+
this.setAppletTextIcon(this._players[this._activePlayer], true);
14291436
}
14301437
}
14311438

@@ -1434,7 +1441,7 @@ class CinnamonSoundApplet extends Applet.TextIconApplet {
14341441
// The player exists, switch to it
14351442
this._changeActivePlayer(owner);
14361443
this._updatePlayerMenuItems();
1437-
this.setAppletTextIcon();
1444+
this.setAppletTextIcon(this._players[this._activePlayer], true);
14381445
} else {
14391446
// The player doesn't seem to exist. Remove it from the players list
14401447
this._removePlayerItem(owner);
@@ -1470,7 +1477,7 @@ class CinnamonSoundApplet extends Applet.TextIconApplet {
14701477
}
14711478
}
14721479
this._updatePlayerMenuItems();
1473-
this.setAppletTextIcon();
1480+
this.setAppletTextIcon(this._players[this._activePlayer], true);
14741481
}
14751482
}
14761483

@@ -1580,6 +1587,9 @@ class CinnamonSoundApplet extends Applet.TextIconApplet {
15801587
if (this.playerControl && this._activePlayer != null) {
15811588
let menuItem = this._players[player];
15821589
this.menu.addMenuItem(menuItem, 2);
1590+
this._icon_path = menuItem._cover_path || null;
1591+
} else {
1592+
this._icon_path = null;
15831593
}
15841594

15851595
this._updatePlayerMenuItems();

0 commit comments

Comments
 (0)