diff --git a/src/dialogs/work_editor.rs b/src/dialogs/work_editor.rs index 54a4fd6..29428fe 100644 --- a/src/dialogs/work_editor.rs +++ b/src/dialogs/work_editor.rs @@ -192,6 +192,19 @@ impl WorkEditor { })).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 @@ -214,4 +227,14 @@ impl WorkEditor { self.instrument_list.insert(&row, -1); } } + + fn get_selected_instrument_row(&self) -> Option { + match self.instrument_list.get_selected_rows().first() { + Some(row) => match row.get_child() { + Some(child) => Some(child.downcast().unwrap()), + None => None, + }, + None => None, + } + } }