From f436557bf5d7f838304e77e9bbfcbc7a214a5f48 Mon Sep 17 00:00:00 2001 From: Erica Z Date: Fri, 25 Oct 2024 11:05:01 +0200 Subject: [PATCH] add "no songs queued" placeholder --- src/ui/play_queue.blp | 53 ++++++++++++++++++++++++++++-------------- src/ui/play_queue.vala | 4 ++++ 2 files changed, 40 insertions(+), 17 deletions(-) diff --git a/src/ui/play_queue.blp b/src/ui/play_queue.blp index 7b87a8a..692b9bd 100644 --- a/src/ui/play_queue.blp +++ b/src/ui/play_queue.blp @@ -1,29 +1,48 @@ using Gtk 4.0; +using Adw 1; +using Gio 2.0; template $UiPlayQueue: Box { name: "play-queue"; - ScrolledWindow { - hexpand: true; - vscrollbar-policy: always; - hscrollbar-policy: never; + Stack { + visible-child-name: bind $visible_child_name (template.playbin as <$Playbin>.play_queue as .n-items) as ; - ListView view { - show-separators: true; - single-click-activate: true; + StackPage { + name: "empty"; - styles [ "rich-list" ] - - activate => $on_row_activated (); - - model: NoSelection { - model: bind template.playbin as <$Playbin>.play_queue; + child: Adw.StatusPage { + icon-name: "list-remove-all"; + title: "No songs queued"; }; + } - factory: SignalListItemFactory { - setup => $on_song_list_setup (); - bind => $on_song_list_bind (); - unbind => $on_song_list_unbind (); + StackPage { + name: "not-empty"; + + child: ScrolledWindow { + hexpand: true; + vscrollbar-policy: always; + hscrollbar-policy: never; + + ListView view { + show-separators: true; + single-click-activate: true; + + styles [ "rich-list" ] + + activate => $on_row_activated (); + + model: NoSelection { + model: bind template.playbin as <$Playbin>.play_queue; + }; + + factory: SignalListItemFactory { + setup => $on_song_list_setup (); + bind => $on_song_list_bind (); + unbind => $on_song_list_unbind (); + }; + } }; } } diff --git a/src/ui/play_queue.vala b/src/ui/play_queue.vala index aea16eb..abadf21 100644 --- a/src/ui/play_queue.vala +++ b/src/ui/play_queue.vala @@ -161,4 +161,8 @@ public class Ui.PlayQueue : Gtk.Box { [GtkCallback] private void on_row_activated (uint position) { playbin.select_track (position); } + + [GtkCallback] private string visible_child_name (uint n_items) { + return n_items > 0 ? "not-empty" : "empty"; + } }