1945 |
// select item in instrument menu |
// select item in instrument menu |
1946 |
std::vector<Gtk::TreeModel::Path> rows = m_TreeViewInstruments.get_selection()->get_selected_rows(); |
std::vector<Gtk::TreeModel::Path> rows = m_TreeViewInstruments.get_selection()->get_selected_rows(); |
1947 |
if (!rows.empty()) { |
if (!rows.empty()) { |
1948 |
Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(rows[0]); |
// convert index of visual selection (i.e. if filtered) to index of model |
1949 |
|
Gtk::TreeModel::Path row = m_refInstrumentsModelFilter->convert_path_to_child_path(rows[0]); |
1950 |
|
Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(row); |
1951 |
if (it) { |
if (it) { |
1952 |
Gtk::TreePath path(it); |
Gtk::TreePath path(it); |
1953 |
int index = path[0]; |
int index = path[0]; |
3614 |
{ |
{ |
3615 |
instrumentProps.signal_name_changed().clear(); |
instrumentProps.signal_name_changed().clear(); |
3616 |
|
|
3617 |
|
// get visual selection |
3618 |
std::vector<Gtk::TreeModel::Path> rows = m_TreeViewInstruments.get_selection()->get_selected_rows(); |
std::vector<Gtk::TreeModel::Path> rows = m_TreeViewInstruments.get_selection()->get_selected_rows(); |
3619 |
if (rows.empty()) { |
if (rows.empty()) { |
3620 |
instrumentProps.hide(); |
instrumentProps.hide(); |
3621 |
return false; |
return false; |
3622 |
} |
} |
3623 |
|
|
3624 |
|
// convert index of visual selection (i.e. if filtered) to index of model |
3625 |
|
Gtk::TreeModel::Path path = m_refInstrumentsModelFilter->convert_path_to_child_path(rows[0]); |
3626 |
|
|
3627 |
//NOTE: was const_iterator before, which did not compile with GTKMM4 development branch, probably going to be fixed before final GTKMM4 release though. |
//NOTE: was const_iterator before, which did not compile with GTKMM4 development branch, probably going to be fixed before final GTKMM4 release though. |
3628 |
Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(rows[0]); |
Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(path); |
3629 |
if (it) { |
if (it) { |
3630 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
3631 |
gig::Instrument* instrument = row[m_InstrumentsModel.m_col_instr]; |
gig::Instrument* instrument = row[m_InstrumentsModel.m_col_instr]; |
3976 |
find(children.begin(), children.end(), item); |
find(children.begin(), children.end(), item); |
3977 |
if (it != children.end()) { |
if (it != children.end()) { |
3978 |
int index = it - children.begin(); |
int index = it - children.begin(); |
3979 |
m_TreeViewInstruments.get_selection()->select(Gtk::TreePath(ToString(index))); |
|
3980 |
|
// convert index of model to index of visual presentation (i.e. if filtered) |
3981 |
|
Gtk::TreeModel::Path path = m_refInstrumentsModelFilter->convert_child_path_to_path(Gtk::TreePath(ToString(index))); |
3982 |
|
|
3983 |
|
if (path) |
3984 |
|
m_TreeViewInstruments.get_selection()->select(path); |
3985 |
|
else |
3986 |
|
m_TreeViewInstruments.get_selection()->unselect_all(); |
3987 |
|
|
3988 |
m_RegionChooser.set_instrument(file->GetInstrument(index)); |
m_RegionChooser.set_instrument(file->GetInstrument(index)); |
3989 |
} |
} |
4426 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewInstruments.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewInstruments.get_selection(); |
4427 |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
4428 |
for (int r = 0; r < rows.size(); ++r) { |
for (int r = 0; r < rows.size(); ++r) { |
4429 |
Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(rows[r]); |
// convert index of visual selection (i.e. if filtered) to index of model |
4430 |
|
Gtk::TreeModel::Path path = m_refInstrumentsModelFilter->convert_path_to_child_path(rows[r]); |
4431 |
|
Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(path); |
4432 |
if (it) { |
if (it) { |
4433 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
4434 |
gig::Instrument* instrOrig = row[m_InstrumentsModel.m_col_instr]; |
gig::Instrument* instrOrig = row[m_InstrumentsModel.m_col_instr]; |
4459 |
} |
} |
4460 |
|
|
4461 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewInstruments.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewInstruments.get_selection(); |
4462 |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
std::vector<Gtk::TreeModel::Path> rowsVisual = sel->get_selected_rows(); |
4463 |
|
|
4464 |
|
// convert indeces of visual selection (i.e. if filtered) to indeces of model |
4465 |
|
std::vector<Gtk::TreeModel::Path> rows; |
4466 |
|
for (int rv = 0; rv < rowsVisual.size(); ++rv) { |
4467 |
|
Gtk::TreeModel::Path path = m_refInstrumentsModelFilter->convert_path_to_child_path(rowsVisual[rv]); |
4468 |
|
if (path) |
4469 |
|
rows.push_back(path); |
4470 |
|
} |
4471 |
|
|
4472 |
for (int r = rows.size() - 1; r >= 0; --r) { |
for (int r = rows.size() - 1; r >= 0; --r) { |
4473 |
Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(rows[r]); |
Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(rows[r]); |
4474 |
if (!it) continue; |
if (!it) continue; |
5063 |
if (!file) return; |
if (!file) return; |
5064 |
|
|
5065 |
// collect all samples that are not referenced by any instrument |
// collect all samples that are not referenced by any instrument |
5066 |
std::list<gig::Sample*> lsamples; |
std::list<gig::Sample*> lsamples = unusedSamples(file); |
|
for (int iSample = 0; file->GetSample(iSample); ++iSample) { |
|
|
gig::Sample* sample = file->GetSample(iSample); |
|
|
bool isUsed = false; |
|
|
for (gig::Instrument* instrument = file->GetFirstInstrument(); instrument; |
|
|
instrument = file->GetNextInstrument()) |
|
|
{ |
|
|
for (gig::Region* rgn = instrument->GetFirstRegion(); rgn; |
|
|
rgn = instrument->GetNextRegion()) |
|
|
{ |
|
|
for (int i = 0; i < 256; ++i) { |
|
|
if (!rgn->pDimensionRegions[i]) continue; |
|
|
if (rgn->pDimensionRegions[i]->pSample != sample) continue; |
|
|
isUsed = true; |
|
|
goto endOfRefSearch; |
|
|
} |
|
|
} |
|
|
} |
|
|
endOfRefSearch: |
|
|
if (!isUsed) lsamples.push_back(sample); |
|
|
} |
|
|
|
|
5067 |
if (lsamples.empty()) return; |
if (lsamples.empty()) return; |
5068 |
|
|
5069 |
// notify everybody that we're going to remove these samples |
// notify everybody that we're going to remove these samples |
5142 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewInstruments.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewInstruments.get_selection(); |
5143 |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
5144 |
if (!rows.empty()) { |
if (!rows.empty()) { |
5145 |
Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(rows[0]); |
// convert index of visual selection (i.e. if filtered) to index of model |
5146 |
|
Gtk::TreeModel::Path path = m_refInstrumentsModelFilter->convert_path_to_child_path(rows[0]); |
5147 |
|
Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(path); |
5148 |
if (it) { |
if (it) { |
5149 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
5150 |
src = row[m_InstrumentsModel.m_col_instr]; |
src = row[m_InstrumentsModel.m_col_instr]; |
5172 |
const bool found = m_TreeViewInstruments.get_path_at_pos(x, y, path); |
const bool found = m_TreeViewInstruments.get_path_at_pos(x, y, path); |
5173 |
if (!found) return; |
if (!found) return; |
5174 |
|
|
5175 |
|
// convert index of visual selection (i.e. if filtered) to index of model |
5176 |
|
path = m_refInstrumentsModelFilter->convert_path_to_child_path(path); |
5177 |
|
if (!path) return; |
5178 |
|
|
5179 |
Gtk::TreeModel::iterator iter = m_refInstrumentsTreeModel->get_iter(path); |
Gtk::TreeModel::iterator iter = m_refInstrumentsTreeModel->get_iter(path); |
5180 |
if (!iter) return; |
if (!iter) return; |
5181 |
Gtk::TreeModel::Row row = *iter; |
Gtk::TreeModel::Row row = *iter; |
5428 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewInstruments.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewInstruments.get_selection(); |
5429 |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
5430 |
for (int r = 0; r < rows.size(); ++r) { |
for (int r = 0; r < rows.size(); ++r) { |
5431 |
Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(rows[r]); |
// convert index of visual selection (i.e. if filtered) to index of model |
5432 |
|
Gtk::TreeModel::Path path = m_refInstrumentsModelFilter->convert_path_to_child_path(rows[r]); |
5433 |
|
Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(path); |
5434 |
if (it) { |
if (it) { |
5435 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
5436 |
int index = row[m_InstrumentsModel.m_col_nr]; |
int index = row[m_InstrumentsModel.m_col_nr]; |