545 |
gig::File* pFile = new gig::File; |
gig::File* pFile = new gig::File; |
546 |
// already add one new instrument by default |
// already add one new instrument by default |
547 |
gig::Instrument* pInstrument = pFile->AddInstrument(); |
gig::Instrument* pInstrument = pFile->AddInstrument(); |
548 |
pInstrument->pInfo->Name = _("Unnamed Instrument"); |
pInstrument->pInfo->Name = gig_from_utf8(_("Unnamed Instrument")); |
549 |
// update GUI with that new gig::File |
// update GUI with that new gig::File |
550 |
load_gig(pFile, 0 /*no file name yet*/); |
load_gig(pFile, 0 /*no file name yet*/); |
551 |
} |
} |
1143 |
instrument_name_connection.block(); |
instrument_name_connection.block(); |
1144 |
for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ; |
for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ; |
1145 |
instrument = gig->GetNextInstrument()) { |
instrument = gig->GetNextInstrument()) { |
1146 |
Glib::ustring name(instrument->pInfo->Name); |
Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); |
1147 |
|
|
1148 |
Gtk::TreeModel::iterator iter = m_refTreeModel->append(); |
Gtk::TreeModel::iterator iter = m_refTreeModel->append(); |
1149 |
Gtk::TreeModel::Row row = *iter; |
Gtk::TreeModel::Row row = *iter; |
1159 |
if (group->Name != "") { |
if (group->Name != "") { |
1160 |
Gtk::TreeModel::iterator iterGroup = m_refSamplesTreeModel->append(); |
Gtk::TreeModel::iterator iterGroup = m_refSamplesTreeModel->append(); |
1161 |
Gtk::TreeModel::Row rowGroup = *iterGroup; |
Gtk::TreeModel::Row rowGroup = *iterGroup; |
1162 |
rowGroup[m_SamplesModel.m_col_name] = group->Name.c_str(); |
rowGroup[m_SamplesModel.m_col_name] = gig_to_utf8(group->Name); |
1163 |
rowGroup[m_SamplesModel.m_col_group] = group; |
rowGroup[m_SamplesModel.m_col_group] = group; |
1164 |
rowGroup[m_SamplesModel.m_col_sample] = NULL; |
rowGroup[m_SamplesModel.m_col_sample] = NULL; |
1165 |
for (gig::Sample* sample = group->GetFirstSample(); |
for (gig::Sample* sample = group->GetFirstSample(); |
1167 |
Gtk::TreeModel::iterator iterSample = |
Gtk::TreeModel::iterator iterSample = |
1168 |
m_refSamplesTreeModel->append(rowGroup.children()); |
m_refSamplesTreeModel->append(rowGroup.children()); |
1169 |
Gtk::TreeModel::Row rowSample = *iterSample; |
Gtk::TreeModel::Row rowSample = *iterSample; |
1170 |
rowSample[m_SamplesModel.m_col_name] = sample->pInfo->Name.c_str(); |
rowSample[m_SamplesModel.m_col_name] = |
1171 |
|
gig_to_utf8(sample->pInfo->Name); |
1172 |
rowSample[m_SamplesModel.m_col_sample] = sample; |
rowSample[m_SamplesModel.m_col_sample] = sample; |
1173 |
rowSample[m_SamplesModel.m_col_group] = NULL; |
rowSample[m_SamplesModel.m_col_group] = NULL; |
1174 |
} |
} |
1222 |
Glib::ustring name = row[m_Columns.m_col_name]; |
Glib::ustring name = row[m_Columns.m_col_name]; |
1223 |
|
|
1224 |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
1225 |
if (instrument->pInfo->Name != name) { |
Glib::ustring gigname(gig_to_utf8(instrument->pInfo->Name)); |
1226 |
row[m_Columns.m_col_name] = instrument->pInfo->Name; |
if (gigname != name) { |
1227 |
|
row[m_Columns.m_col_name] = gigname; |
1228 |
} |
} |
1229 |
} |
} |
1230 |
|
|
1324 |
} |
} |
1325 |
|
|
1326 |
void MainWindow::add_instrument(gig::Instrument* instrument) { |
void MainWindow::add_instrument(gig::Instrument* instrument) { |
1327 |
const char* name = instrument->pInfo->Name.c_str(); |
const Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); |
1328 |
|
|
1329 |
// update instrument tree view |
// update instrument tree view |
1330 |
instrument_name_connection.block(); |
instrument_name_connection.block(); |
1346 |
if (!file) return; |
if (!file) return; |
1347 |
gig::Instrument* instrument = file->AddInstrument(); |
gig::Instrument* instrument = file->AddInstrument(); |
1348 |
__instrument_indexer++; |
__instrument_indexer++; |
1349 |
instrument->pInfo->Name = |
instrument->pInfo->Name = gig_from_utf8(_("Unnamed Instrument ") + |
1350 |
_("Unnamed Instrument ") + ToString(__instrument_indexer); |
ToString(__instrument_indexer)); |
1351 |
|
|
1352 |
add_instrument(instrument); |
add_instrument(instrument); |
1353 |
} |
} |
1367 |
// duplicate the orginal instrument |
// duplicate the orginal instrument |
1368 |
gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig); |
gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig); |
1369 |
instrNew->pInfo->Name = |
instrNew->pInfo->Name = |
1370 |
instrOrig->pInfo->Name + " (" + _("Copy") + ")"; |
instrOrig->pInfo->Name + |
1371 |
|
gig_from_utf8(Glib::ustring(" (") + _("Copy") + ")"); |
1372 |
|
|
1373 |
add_instrument(instrNew); |
add_instrument(instrNew); |
1374 |
} |
} |
1435 |
static int __sample_indexer = 0; |
static int __sample_indexer = 0; |
1436 |
if (!file) return; |
if (!file) return; |
1437 |
gig::Group* group = file->AddGroup(); |
gig::Group* group = file->AddGroup(); |
1438 |
group->Name = _("Unnamed Group"); |
group->Name = gig_from_utf8(_("Unnamed Group")); |
1439 |
if (__sample_indexer) group->Name += " " + ToString(__sample_indexer); |
if (__sample_indexer) group->Name += " " + ToString(__sample_indexer); |
1440 |
__sample_indexer++; |
__sample_indexer++; |
1441 |
// update sample tree view |
// update sample tree view |
1442 |
Gtk::TreeModel::iterator iterGroup = m_refSamplesTreeModel->append(); |
Gtk::TreeModel::iterator iterGroup = m_refSamplesTreeModel->append(); |
1443 |
Gtk::TreeModel::Row rowGroup = *iterGroup; |
Gtk::TreeModel::Row rowGroup = *iterGroup; |
1444 |
rowGroup[m_SamplesModel.m_col_name] = group->Name.c_str(); |
rowGroup[m_SamplesModel.m_col_name] = gig_to_utf8(group->Name); |
1445 |
rowGroup[m_SamplesModel.m_col_sample] = NULL; |
rowGroup[m_SamplesModel.m_col_sample] = NULL; |
1446 |
rowGroup[m_SamplesModel.m_col_group] = group; |
rowGroup[m_SamplesModel.m_col_group] = group; |
1447 |
file_changed(); |
file_changed(); |
1550 |
break; |
break; |
1551 |
} |
} |
1552 |
} |
} |
1553 |
sample->pInfo->Name = filename; |
sample->pInfo->Name = gig_from_utf8(filename); |
1554 |
sample->Channels = info.channels; |
sample->Channels = info.channels; |
1555 |
sample->BitDepth = bitdepth; |
sample->BitDepth = bitdepth; |
1556 |
sample->FrameSize = bitdepth / 8/*1 byte are 8 bits*/ * info.channels; |
sample->FrameSize = bitdepth / 8/*1 byte are 8 bits*/ * info.channels; |
1601 |
Gtk::TreeModel::iterator iterSample = |
Gtk::TreeModel::iterator iterSample = |
1602 |
m_refSamplesTreeModel->append(row.children()); |
m_refSamplesTreeModel->append(row.children()); |
1603 |
Gtk::TreeModel::Row rowSample = *iterSample; |
Gtk::TreeModel::Row rowSample = *iterSample; |
1604 |
rowSample[m_SamplesModel.m_col_name] = filename; |
rowSample[m_SamplesModel.m_col_name] = |
1605 |
|
gig_to_utf8(sample->pInfo->Name); |
1606 |
rowSample[m_SamplesModel.m_col_sample] = sample; |
rowSample[m_SamplesModel.m_col_sample] = sample; |
1607 |
rowSample[m_SamplesModel.m_col_group] = NULL; |
rowSample[m_SamplesModel.m_col_group] = NULL; |
1608 |
// close sound file |
// close sound file |
1673 |
sample; sample = file->GetNextSample()) |
sample; sample = file->GetNextSample()) |
1674 |
{ |
{ |
1675 |
std::string filename = |
std::string filename = |
1676 |
folder + G_DIR_SEPARATOR_S + sample->pInfo->Name + |
folder + G_DIR_SEPARATOR_S + |
1677 |
postfixEntryBox.get_text().raw(); |
Glib::filename_from_utf8(gig_to_utf8(sample->pInfo->Name) + |
1678 |
|
postfixEntryBox.get_text()); |
1679 |
SF_INFO info; |
SF_INFO info; |
1680 |
info.format = 0; |
info.format = 0; |
1681 |
SNDFILE* hFile = sf_open(filename.c_str(), SFM_READ, &info); |
SNDFILE* hFile = sf_open(filename.c_str(), SFM_READ, &info); |
1709 |
catch (std::string what) |
catch (std::string what) |
1710 |
{ |
{ |
1711 |
if (!error_files.empty()) error_files += "\n"; |
if (!error_files.empty()) error_files += "\n"; |
1712 |
error_files += filename += " (" + what + ")"; |
error_files += Glib::filename_to_utf8(filename) + |
1713 |
|
" (" + what + ")"; |
1714 |
} |
} |
1715 |
} |
} |
1716 |
// show error message box when some file(s) could not be opened / added |
// show error message box when some file(s) could not be opened / added |
1735 |
try { |
try { |
1736 |
// remove group or sample from the gig file |
// remove group or sample from the gig file |
1737 |
if (group) { |
if (group) { |
1738 |
// temporarily remember the samples that bolong to |
// temporarily remember the samples that belong to |
1739 |
// that group (we need that to clean the queue) |
// that group (we need that to clean the queue) |
1740 |
std::list<gig::Sample*> members; |
std::list<gig::Sample*> members; |
1741 |
for (gig::Sample* pSample = group->GetFirstSample(); |
for (gig::Sample* pSample = group->GetFirstSample(); |
1904 |
Glib::ustring name = row[m_SamplesModel.m_col_name]; |
Glib::ustring name = row[m_SamplesModel.m_col_name]; |
1905 |
gig::Group* group = row[m_SamplesModel.m_col_group]; |
gig::Group* group = row[m_SamplesModel.m_col_group]; |
1906 |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
1907 |
|
gig::String gigname(gig_from_utf8(name)); |
1908 |
if (group) { |
if (group) { |
1909 |
if (group->Name != name) { |
if (group->Name != gigname) { |
1910 |
group->Name = name; |
group->Name = gigname; |
1911 |
printf("group name changed\n"); |
printf("group name changed\n"); |
1912 |
file_changed(); |
file_changed(); |
1913 |
} |
} |
1914 |
} else if (sample) { |
} else if (sample) { |
1915 |
if (sample->pInfo->Name != name.raw()) { |
if (sample->pInfo->Name != gigname) { |
1916 |
sample->pInfo->Name = name.raw(); |
sample->pInfo->Name = gigname; |
1917 |
printf("sample name changed\n"); |
printf("sample name changed\n"); |
1918 |
file_changed(); |
file_changed(); |
1919 |
} |
} |
1941 |
|
|
1942 |
// change name in gig |
// change name in gig |
1943 |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
1944 |
if (instrument && instrument->pInfo->Name != name.raw()) { |
gig::String gigname(gig_from_utf8(name)); |
1945 |
instrument->pInfo->Name = name.raw(); |
if (instrument && instrument->pInfo->Name != gigname) { |
1946 |
|
instrument->pInfo->Name = gigname; |
1947 |
|
|
1948 |
// change name in the instrument properties window |
// change name in the instrument properties window |
1949 |
if (instrumentProps.get_instrument() == instrument) { |
if (instrumentProps.get_instrument() == instrument) { |