Compare commits

..

No commits in common. "ea00c7d932473f0c7b273e882967fe6b272bd244" and "1eb5622604a00d97698d2726d9f9b972e5924ba7" have entirely different histories.

2 changed files with 5 additions and 18 deletions

View file

@ -20,7 +20,6 @@ struct AppModel {
struct Sample { struct Sample {
name: String, name: String,
bpm: f32, bpm: f32,
key: String, // todo: key struct?
} }
#[relm4::component] #[relm4::component]
@ -33,8 +32,8 @@ impl SimpleComponent for AppModel {
view! { view! {
gtk::Window { gtk::Window {
set_title: Some("SampleAmp"), set_title: Some("SampleAmp"),
set_default_width: 1000, set_default_width: 700,
set_default_height: 600, set_default_height: 400,
connect_close_request[sender] => move |_| { connect_close_request[sender] => move |_| {
sender.input(AppMsg::Close); sender.input(AppMsg::Close);
@ -71,8 +70,7 @@ impl SimpleComponent for AppModel {
set_factory: Some(&factory_bpm) set_factory: Some(&factory_bpm)
}, },
append_column = &gtk::ColumnViewColumn { append_column = &gtk::ColumnViewColumn {
set_title: Some("Key"), set_title: Some("Key")
set_factory: Some(&factory_key)
}, },
append_column = &gtk::ColumnViewColumn { append_column = &gtk::ColumnViewColumn {
set_title: Some("Tags"), set_title: Some("Tags"),
@ -119,20 +117,10 @@ impl SimpleComponent for AppModel {
item.set_child(Some(&cell)) item.set_child(Some(&cell))
}); });
let factory_key = gtk::SignalListItemFactory::new();
factory_key.connect_bind(move |_factory, item| {
let item = item.downcast_ref::<gtk::ListItem>().unwrap();
let obj = item.item().and_downcast::<BoxedAnyObject>().unwrap();
let sample: Ref<Sample> = obj.borrow();
let cell = gtk::Label::new(Some(&sample.key.to_string()));
cell.set_halign(gtk::Align::Start);
item.set_child(Some(&cell))
});
let samples = gtk::gio::ListStore::new(gtk::glib::types::Type::OBJECT); let samples = gtk::gio::ListStore::new(gtk::glib::types::Type::OBJECT);
let sample_a = BoxedAnyObject::new(Sample{name: "01 MOOLOO-108 bpm a.wav".to_string(), bpm: 108.0, key: "A".to_string()}); let sample_a = BoxedAnyObject::new(Sample{name: "01 MOOLOO-108 bpm a.wav".to_string(), bpm: 108.0});
samples.append(&sample_a); samples.append(&sample_a);
let sample_b = BoxedAnyObject::new(Sample{name: "03 FAST AND FURIOUS-144.3 bpm a.wav".to_string(), bpm: 144.3, key: "A".to_string()}); let sample_b = BoxedAnyObject::new(Sample{name: "03 FAST AND FURIOUS-144.3 bpm a.wav".to_string(), bpm: 144.3});
samples.append(&sample_b); samples.append(&sample_b);
let samples = gtk::MultiSelection::new(Some(samples)); let samples = gtk::MultiSelection::new(Some(samples));
@ -142,7 +130,6 @@ impl SimpleComponent for AppModel {
collections: FactoryVecDeque::new(gtk::ListBox::default(), sender.input_sender()), collections: FactoryVecDeque::new(gtk::ListBox::default(), sender.input_sender()),
}; };
model.collections.guard().push_back("All".to_string());
model.collections.guard().push_back("Tape808 & Tape909".to_string()); model.collections.guard().push_back("Tape808 & Tape909".to_string());
model.collections.guard().push_back("Zero-G Planet of The Breaks".to_string()); model.collections.guard().push_back("Zero-G Planet of The Breaks".to_string());