mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 19:57:25 +01:00
Adapt medium preview to track structure changes
This commit is contained in:
parent
2071de60d9
commit
3702c9ad79
1 changed files with 37 additions and 20 deletions
|
|
@ -1,12 +1,9 @@
|
||||||
use super::medium_editor::MediumEditor;
|
|
||||||
use crate::navigator::{NavigationHandle, Screen};
|
use crate::navigator::{NavigationHandle, Screen};
|
||||||
use crate::widgets::Widget;
|
use crate::widgets::Widget;
|
||||||
use gettextrs::gettext;
|
use gettextrs::gettext;
|
||||||
use glib::clone;
|
use glib::clone;
|
||||||
use gtk::prelude::*;
|
use gtk::prelude::*;
|
||||||
use gtk_macros::get_widget;
|
use gtk_macros::get_widget;
|
||||||
use libadwaita::prelude::*;
|
|
||||||
use log::debug;
|
|
||||||
use musicus_backend::db::Medium;
|
use musicus_backend::db::Medium;
|
||||||
use musicus_backend::import::ImportSession;
|
use musicus_backend::import::ImportSession;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
@ -49,12 +46,12 @@ impl Screen<(Arc<ImportSession>, Medium), ()> for MediumPreview {
|
||||||
|
|
||||||
name_label.set_text(&medium.name);
|
name_label.set_text(&medium.name);
|
||||||
|
|
||||||
for track_set in medium.tracks {
|
let mut last_recording_id = "";
|
||||||
let recording = &track_set.recording;
|
let mut last_list = None::<gtk::ListBox>;
|
||||||
|
|
||||||
let frame = gtk::FrameBuilder::new()
|
for track in &medium.tracks {
|
||||||
.margin_bottom(12)
|
if track.recording.id != last_recording_id {
|
||||||
.build();
|
last_recording_id = &track.recording.id;
|
||||||
|
|
||||||
let list = gtk::ListBoxBuilder::new()
|
let list = gtk::ListBoxBuilder::new()
|
||||||
.selection_mode(gtk::SelectionMode::None)
|
.selection_mode(gtk::SelectionMode::None)
|
||||||
|
|
@ -62,16 +59,30 @@ impl Screen<(Arc<ImportSession>, Medium), ()> for MediumPreview {
|
||||||
|
|
||||||
let header = libadwaita::ActionRowBuilder::new()
|
let header = libadwaita::ActionRowBuilder::new()
|
||||||
.activatable(false)
|
.activatable(false)
|
||||||
.title(&recording.work.get_title())
|
.title(&track.recording.work.get_title())
|
||||||
.subtitle(&recording.get_performers())
|
.subtitle(&track.recording.get_performers())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
list.append(&header);
|
list.append(&header);
|
||||||
|
|
||||||
for track in track_set.tracks {
|
if let Some(list) = &last_list {
|
||||||
|
let frame = gtk::FrameBuilder::new()
|
||||||
|
.margin_bottom(12)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
frame.set_child(Some(list));
|
||||||
|
medium_box.append(&frame);
|
||||||
|
|
||||||
|
last_list = None;
|
||||||
|
}
|
||||||
|
|
||||||
|
last_list = Some(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(list) = &last_list {
|
||||||
let mut parts = Vec::<String>::new();
|
let mut parts = Vec::<String>::new();
|
||||||
for part in &track.work_parts {
|
for part in &track.work_parts {
|
||||||
parts.push(track_set.recording.work.parts[*part].title.clone());
|
parts.push(track.recording.work.parts[*part].title.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
let title = if parts.is_empty() {
|
let title = if parts.is_empty() {
|
||||||
|
|
@ -89,8 +100,14 @@ impl Screen<(Arc<ImportSession>, Medium), ()> for MediumPreview {
|
||||||
|
|
||||||
list.append(&row);
|
list.append(&row);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
frame.set_child(Some(&list));
|
if let Some(list) = &last_list {
|
||||||
|
let frame = gtk::FrameBuilder::new()
|
||||||
|
.margin_bottom(12)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
frame.set_child(Some(list));
|
||||||
medium_box.append(&frame);
|
medium_box.append(&frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue