Skip to content

Commit

Permalink
chore: drop can-play-previous
Browse files Browse the repository at this point in the history
The 'Previous' action is now always available, since a30d326
  • Loading branch information
DaPigGuy committed Aug 2, 2024
1 parent a30d326 commit 2a1aa50
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 39 deletions.
25 changes: 2 additions & 23 deletions src/mpris.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,18 +285,6 @@ export class MPRIS extends DBusInterface {
);
}),

this.player.queue.connect("notify::can-play-previous", () => {
this._properties_changed(
this.MEDIA_PLAYER2_PLAYER_IFACE,
{
CanGoPrevious: GLib.Variant.new_boolean(
this.player.queue.can_play_previous,
),
},
[],
);
}),

this.player.connect("notify::seeking", () => {
if (!this.player.seeking) {
this._on_seek_finished(this, this.player.timestamp);
Expand Down Expand Up @@ -396,7 +384,7 @@ export class MPRIS extends DBusInterface {
// already started
if (this.player.queue.repeat === RepeatMode.ONE) {
this._seeked(0);
if (this.player.queue.can_play_previous) {
if (this.player.queue.position > 0) {
return;
}
}
Expand Down Expand Up @@ -429,12 +417,6 @@ export class MPRIS extends DBusInterface {
this.previous_state.set("can_go_next", has_next);
}

const has_previous = this.player.queue.can_play_previous;
if (has_previous != this.previous_state.get("can_go_previous")) {
properties.CanGoPrevious = GLib.Variant.new_boolean(has_previous);
this.previous_state.set("can_go_previous", has_next);
}

if (this.previous_state.get("can_play") != true) {
properties.CanPause = GLib.Variant.new_boolean(true);
properties.CanPlay = GLib.Variant.new_boolean(true);
Expand Down Expand Up @@ -633,10 +615,7 @@ export class MPRIS extends DBusInterface {
MinimumRate: GLib.Variant.new_double(1.0),
MaximumRate: GLib.Variant.new_double(1.0),
CanGoNext: GLib.Variant.new_boolean(this.player.queue.can_play_next),
CanGoPrevious: GLib.Variant.new(
"b",
this.player.queue.can_play_previous,
),
CanGoPrevious: GLib.Variant.new_boolean(true),
CanPlay: GLib.Variant.new_boolean(can_play),
CanPause: GLib.Variant.new_boolean(can_play),
CanSeek: GLib.Variant.new_boolean(true),
Expand Down
16 changes: 0 additions & 16 deletions src/player/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,6 @@ export class Queue extends GObject.Object {
false,
GObject.ParamFlags.READABLE,
),
"can-play-previous": GObject.param_spec_boolean(
"can-play-previous",
"Can play previous",
"Whether the previous song can be played",
false,
GObject.ParamFlags.READABLE,
),
repeat: GObject.param_spec_uint(
"repeat",
"Repeat",
Expand Down Expand Up @@ -290,11 +283,6 @@ export class Queue extends GObject.Object {
return this.position < this.list.n_items - 1;
}

get can_play_previous() {
if (this.repeat === RepeatMode.ALL) return true;
return this.position > 0;
}

private _position = -1;

get position() {
Expand All @@ -311,7 +299,6 @@ export class Queue extends GObject.Object {
this.notify("current");
this.notify("current-is-video");
this.notify("can-play-next");
this.notify("can-play-previous");
}
}

Expand Down Expand Up @@ -492,7 +479,6 @@ export class Queue extends GObject.Object {
name: "previous",
parameter_type: null,
activate: () => this.previous(),
bind_enabled: [this, "can-play-previous"],
}),
);

Expand Down Expand Up @@ -541,7 +527,6 @@ export class Queue extends GObject.Object {
this.repeat = (this.repeat + 1) % 3;

this.notify("can-play-next");
this.notify("can-play-previous");
}

private async active_chip_changed_cb() {
Expand All @@ -556,7 +541,6 @@ export class Queue extends GObject.Object {

this.add_tracks("remaining", queue.tracks);

this.notify("can-play-previous");
this.notify("can-play-next");
}
}
Expand Down

0 comments on commit 2a1aa50

Please sign in to comment.