From af4da894fc719bf60ee78fe0d6fa5c70ce1ff45b Mon Sep 17 00:00:00 2001 From: Erica Z Date: Sun, 20 Oct 2024 17:28:47 +0200 Subject: [PATCH] only show cover art in playbar if view isnt play queue --- src/ui/playbar.blp | 50 +++++++++++++++++++++++++++------------------ src/ui/playbar.vala | 3 +++ src/ui/window.blp | 19 ++++++++++++++++- src/ui/window.vala | 4 ++++ 4 files changed, 55 insertions(+), 21 deletions(-) diff --git a/src/ui/playbar.blp b/src/ui/playbar.blp index 2991848..a137234 100644 --- a/src/ui/playbar.blp +++ b/src/ui/playbar.blp @@ -10,29 +10,39 @@ template $UiPlaybar: Box { [start] Box { - orientation: vertical; - valign: center; - - Label { - styles [ "heading" ] - xalign: 0; - halign: start; - label: bind $song_title (template.song) as ; - ellipsize: end; + Picture { + visible: bind template.show_cover_art; + valign: center; + halign: center; + paintable: bind template.playing_cover_art; } - Label { - styles [ "caption" ] - xalign: 0; - label: bind $song_artist (template.song) as ; - ellipsize: end; - } + Box { + margin-start: 6; + orientation: vertical; + valign: center; - Label { - styles [ "caption" ] - xalign: 0; - label: bind $song_album (template.song) as ; - ellipsize: end; + Label { + styles [ "heading" ] + xalign: 0; + halign: start; + label: bind $song_title (template.song) as ; + ellipsize: end; + } + + Label { + styles [ "caption" ] + xalign: 0; + label: bind $song_artist (template.song) as ; + ellipsize: end; + } + + Label { + styles [ "caption" ] + xalign: 0; + label: bind $song_album (template.song) as ; + ellipsize: end; + } } } diff --git a/src/ui/playbar.vala b/src/ui/playbar.vala index 16d33ab..4c9e876 100644 --- a/src/ui/playbar.vala +++ b/src/ui/playbar.vala @@ -1,7 +1,10 @@ [GtkTemplate (ui = "/eu/callcc/audrey/ui/playbar.ui")] class Ui.Playbar : Gtk.Box { public Subsonic.Song? song { get; set; } + public Gdk.Paintable? playing_cover_art { get; set; } public Playbin playbin { get; set; } + public bool show_cover_art { get; set; default = true; } + public int volume { get { return playbin == null ? 100 : playbin.volume; } set { playbin.volume = value; } diff --git a/src/ui/window.blp b/src/ui/window.blp index 1d2ea15..d63e1c5 100644 --- a/src/ui/window.blp +++ b/src/ui/window.blp @@ -36,8 +36,23 @@ template $UiWindow: Adw.ApplicationWindow { content: Adw.ViewStack stack { Adw.ViewStackPage { - title: _("Play queue"); + icon-name: "audio-input-microphone"; + title: _("Artists"); + + child: Box {}; + } + + Adw.ViewStackPage { + icon-name: "media-optical-cd"; + title: _("Albums"); + + child: Box {}; + } + + Adw.ViewStackPage { icon-name: "media-playback-start"; + title: _("Play queue"); + name: "play-queue"; child: Box { name: "play-queue-page"; @@ -79,6 +94,8 @@ template $UiWindow: Adw.ApplicationWindow { $UiPlaybar playbar { song: bind template.song; playbin: bind template.playbin; + playing_cover_art: bind template.playing_cover_art; + show_cover_art: bind $show_playbar_cover_art (stack.visible-child-name) as ; } }; } diff --git a/src/ui/window.vala b/src/ui/window.vala index cbd3a18..cc66861 100644 --- a/src/ui/window.vala +++ b/src/ui/window.vala @@ -111,4 +111,8 @@ class Ui.Window : Adw.ApplicationWindow { this.playbin.select_track (0); }); } + + [GtkCallback] private bool show_playbar_cover_art (string? stack_child) { + return stack_child != "play-queue"; + } }