--- gigedit/trunk/src/gigedit/mainwindow.cpp 2014/06/24 02:50:05 2658 +++ gigedit/trunk/src/gigedit/mainwindow.cpp 2014/07/07 15:01:01 2666 @@ -902,7 +902,28 @@ // load the instrument gig::File* pFile = (gig::File*) instr->GetParent(); load_gig(pFile, 0 /*file name*/, true /*shared instrument*/); - //TODO: automatically select the given instrument + // automatically select the given instrument + int i = 0; + for (gig::Instrument* instrument = pFile->GetFirstInstrument(); instrument; + instrument = pFile->GetNextInstrument(), ++i) + { + if (instrument == instr) { + // select item in "instruments" tree view + m_TreeView.get_selection()->select(Gtk::TreePath(ToString(i))); + // make sure the selected item in the "instruments" tree view is + // visible (scroll to it) + m_TreeView.scroll_to_row(Gtk::TreePath(ToString(i))); + // select item in instrument menu + { + const std::vector children = + instrument_menu->get_children(); + static_cast(children[i])->set_active(); + } + // update region chooser and dimension region chooser + m_RegionChooser.set_instrument(instr); + break; + } + } } void MainWindow::on_loader_progress() @@ -2833,7 +2854,7 @@ // just in case a new sample is added later with exactly the same memory // address, which would lead to incorrect refcount if not deleted here for (std::list::const_iterator it = samples.begin(); - it != samples.end(); it != samples.end()) + it != samples.end(); ++it) { sample_ref_count.erase(*it); }