mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 11:47:25 +01:00
Display all search results on home page
This commit is contained in:
parent
ff3c3728ad
commit
9d4f37f601
2 changed files with 135 additions and 75 deletions
|
|
@ -26,7 +26,10 @@ template $MusicusHomePage : Adw.NavigationPage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Gtk.ScrolledWindow {
|
Gtk.Stack stack {
|
||||||
|
Gtk.StackPage {
|
||||||
|
name: "results";
|
||||||
|
child: Gtk.ScrolledWindow {
|
||||||
hscrollbar-policy: never;
|
hscrollbar-policy: never;
|
||||||
|
|
||||||
Adw.Clamp {
|
Adw.Clamp {
|
||||||
|
|
@ -56,6 +59,22 @@ template $MusicusHomePage : Adw.NavigationPage {
|
||||||
selection-mode: none;
|
selection-mode: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Gtk.Label {
|
||||||
|
styles ["heading"]
|
||||||
|
visible: bind ensembles_flow_box.visible;
|
||||||
|
halign: start;
|
||||||
|
label: _("Ensembles");
|
||||||
|
}
|
||||||
|
|
||||||
|
Gtk.FlowBox ensembles_flow_box {
|
||||||
|
margin-top: 12;
|
||||||
|
margin-bottom: 24;
|
||||||
|
column-spacing: 12;
|
||||||
|
row-spacing: 12;
|
||||||
|
homogeneous: true;
|
||||||
|
selection-mode: none;
|
||||||
|
}
|
||||||
|
|
||||||
Gtk.Label {
|
Gtk.Label {
|
||||||
styles ["heading"]
|
styles ["heading"]
|
||||||
visible: bind works_flow_box.visible;
|
visible: bind works_flow_box.visible;
|
||||||
|
|
@ -89,6 +108,16 @@ template $MusicusHomePage : Adw.NavigationPage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
Gtk.StackPage {
|
||||||
|
name: "empty";
|
||||||
|
child: Adw.StatusPage {
|
||||||
|
icon-name: "system-search-symbolic";
|
||||||
|
title: _("Nothing Found");
|
||||||
|
description: _("Try a different search.");
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,12 @@ mod imp {
|
||||||
#[template_child]
|
#[template_child]
|
||||||
pub search_entry: TemplateChild<MusicusSearchEntry>,
|
pub search_entry: TemplateChild<MusicusSearchEntry>,
|
||||||
#[template_child]
|
#[template_child]
|
||||||
|
pub stack: TemplateChild<gtk::Stack>,
|
||||||
|
#[template_child]
|
||||||
pub persons_flow_box: TemplateChild<gtk::FlowBox>,
|
pub persons_flow_box: TemplateChild<gtk::FlowBox>,
|
||||||
#[template_child]
|
#[template_child]
|
||||||
|
pub ensembles_flow_box: TemplateChild<gtk::FlowBox>,
|
||||||
|
#[template_child]
|
||||||
pub works_flow_box: TemplateChild<gtk::FlowBox>,
|
pub works_flow_box: TemplateChild<gtk::FlowBox>,
|
||||||
#[template_child]
|
#[template_child]
|
||||||
pub recordings_flow_box: TemplateChild<gtk::FlowBox>,
|
pub recordings_flow_box: TemplateChild<gtk::FlowBox>,
|
||||||
|
|
@ -73,12 +77,6 @@ mod imp {
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
self.obj().query(&LibraryQuery::default());
|
self.obj().query(&LibraryQuery::default());
|
||||||
|
|
||||||
for _ in 0..9 {
|
|
||||||
self.works_flow_box.append(&MusicusTile::with_title("Test"));
|
|
||||||
self.recordings_flow_box
|
|
||||||
.append(&MusicusTile::with_title("Test"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -112,19 +110,52 @@ impl MusicusHomePage {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn query(&self, query: &LibraryQuery) {
|
fn query(&self, query: &LibraryQuery) {
|
||||||
|
let imp = self.imp();
|
||||||
let results = self.library().query(query);
|
let results = self.library().query(query);
|
||||||
|
|
||||||
clear_flowbox(&self.imp().persons_flow_box);
|
for flowbox in [
|
||||||
for person in results.persons {
|
&imp.persons_flow_box,
|
||||||
self.imp()
|
&imp.ensembles_flow_box,
|
||||||
.persons_flow_box
|
&imp.works_flow_box,
|
||||||
.append(&MusicusTile::with_title(&person.name_fl()));
|
&imp.recordings_flow_box,
|
||||||
}
|
] {
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn clear_flowbox(flowbox: >k::FlowBox) {
|
|
||||||
while let Some(widget) = flowbox.first_child() {
|
while let Some(widget) = flowbox.first_child() {
|
||||||
flowbox.remove(&widget);
|
flowbox.remove(&widget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if results.is_empty() {
|
||||||
|
imp.stack.set_visible_child_name("empty");
|
||||||
|
} else {
|
||||||
|
imp.stack.set_visible_child_name("results");
|
||||||
|
|
||||||
|
imp.persons_flow_box
|
||||||
|
.set_visible(!results.persons.is_empty());
|
||||||
|
imp.ensembles_flow_box
|
||||||
|
.set_visible(!results.ensembles.is_empty());
|
||||||
|
imp.works_flow_box.set_visible(!results.works.is_empty());
|
||||||
|
imp.recordings_flow_box
|
||||||
|
.set_visible(!results.recordings.is_empty());
|
||||||
|
|
||||||
|
for person in results.persons {
|
||||||
|
imp.persons_flow_box
|
||||||
|
.append(&MusicusTile::with_title(&person.name_fl()));
|
||||||
|
}
|
||||||
|
|
||||||
|
for ensemble in results.ensembles {
|
||||||
|
imp.ensembles_flow_box
|
||||||
|
.append(&MusicusTile::with_title(&ensemble.name));
|
||||||
|
}
|
||||||
|
|
||||||
|
for work in results.works {
|
||||||
|
imp.works_flow_box
|
||||||
|
.append(&MusicusTile::with_subtitle(&work.title, &work.composer.name_fl()));
|
||||||
|
}
|
||||||
|
|
||||||
|
for _recording in results.recordings {
|
||||||
|
imp.recordings_flow_box
|
||||||
|
.append(&MusicusTile::with_title("TODO"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue