mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 19:57:25 +01:00
Allow deleting instrument from work
This commit is contained in:
parent
44ef84423f
commit
a942a2e677
1 changed files with 23 additions and 0 deletions
|
|
@ -192,6 +192,19 @@ impl WorkEditor {
|
||||||
})).show();
|
})).show();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
remove_instrument_button.connect_clicked(clone!(@strong result => move |_| {
|
||||||
|
let row = result.get_selected_instrument_row();
|
||||||
|
match row {
|
||||||
|
Some(row) => {
|
||||||
|
let index = row.get_index();
|
||||||
|
let index: usize = index.try_into().unwrap();
|
||||||
|
result.instruments.borrow_mut().remove(index);
|
||||||
|
result.show_instruments();
|
||||||
|
}
|
||||||
|
None => (),
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
result.window.set_transient_for(Some(parent));
|
result.window.set_transient_for(Some(parent));
|
||||||
|
|
||||||
result
|
result
|
||||||
|
|
@ -214,4 +227,14 @@ impl WorkEditor {
|
||||||
self.instrument_list.insert(&row, -1);
|
self.instrument_list.insert(&row, -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_selected_instrument_row(&self) -> Option<SelectorRow> {
|
||||||
|
match self.instrument_list.get_selected_rows().first() {
|
||||||
|
Some(row) => match row.get_child() {
|
||||||
|
Some(child) => Some(child.downcast().unwrap()),
|
||||||
|
None => None,
|
||||||
|
},
|
||||||
|
None => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue