Skip to content

Commit

Permalink
dont hijack the whole player view for now-player activation
Browse files Browse the repository at this point in the history
  • Loading branch information
vixalien committed Oct 30, 2023
1 parent 71a272b commit 2820734
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 17 deletions.
8 changes: 8 additions & 0 deletions data/ui/components/player/full.blp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Gtk 4.0;
using Adw 1;
using Gdk 4.0;

template $FullPlayerView : ActionBar {
// to make the thumbnail look aligned
Expand All @@ -13,6 +14,13 @@ template $FullPlayerView : ActionBar {
$PlayerPreview {
valign: center;
size: 74;
cursor: Gdk.Cursor {
name: "pointer";
};

GestureClick {
pressed => $gesture_pressed_cb();
}
}

Box now_playing_labels {
Expand Down
5 changes: 5 additions & 0 deletions data/ui/components/player/mini.blp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ template $MiniPlayerView : Overlay {
margin-top: 6;
margin-start: 6;
margin-end: 6;
hexpand: true;

$PlayerPreview player_preview {
valign: center;
Expand Down Expand Up @@ -40,6 +41,10 @@ template $MiniPlayerView : Overlay {
ellipsize: end;
}
}

GestureClick {
pressed => $gesture_pressed_cb();
}
}

Box buttons {
Expand Down
9 changes: 9 additions & 0 deletions src/components/player/full.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,15 @@ export class FullPlayerView extends Gtk.ActionBar {
: track.duration ?? "00:00";
}

private gesture_pressed_cb(gesture: Gtk.Gesture) {
gesture.set_state(Gtk.EventSequenceState.CLAIMED);

this.activate_action(
"win.visible-view",
GLib.Variant.new_string("now-playing"),
);
}

vfunc_map(): void {
this.listeners.clear();
this.setup_player();
Expand Down
9 changes: 9 additions & 0 deletions src/components/player/mini.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,13 @@ export class MiniPlayerView extends Gtk.Overlay {
this.listeners.clear();
super.vfunc_unmap();
}

private gesture_pressed_cb(gesture: Gtk.Gesture) {
gesture.set_state(Gtk.EventSequenceState.CLAIMED);

this.activate_action(
"win.visible-view",
GLib.Variant.new_string("now-playing"),
);
}
}
17 changes: 0 additions & 17 deletions src/components/player/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,5 @@ export class PlayerView extends Adw.Bin {
this.squeezer.add(this.mini);

this.set_child(this.squeezer);

const gesture = new Gtk.GestureClick({
button: 1,
});

gesture.connect("pressed", this.gesture_pressed_cb.bind(this));

this.add_controller(gesture);
}

private gesture_pressed_cb(gesture: Gtk.Gesture) {
gesture.set_state(Gtk.EventSequenceState.CLAIMED);

this.activate_action(
"win.visible-view",
GLib.Variant.new_string("now-playing"),
);
}
}

0 comments on commit 2820734

Please sign in to comment.