257 |
sigc::mem_fun(*this, &MainWindow::on_sample_label_drop_drag_data_received) |
sigc::mem_fun(*this, &MainWindow::on_sample_label_drop_drag_data_received) |
258 |
); |
); |
259 |
dimreg_edit.signal_dimreg_changed().connect( |
dimreg_edit.signal_dimreg_changed().connect( |
260 |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
sigc::hide(sigc::mem_fun(*this, &MainWindow::file_changed))); |
261 |
m_RegionChooser.signal_instrument_changed().connect( |
m_RegionChooser.signal_instrument_changed().connect( |
262 |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
263 |
m_DimRegionChooser.signal_region_changed().connect( |
m_DimRegionChooser.signal_region_changed().connect( |
264 |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
265 |
instrumentProps.signal_instrument_changed().connect( |
instrumentProps.signal_instrument_changed().connect( |
266 |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
267 |
|
|
268 |
|
dimreg_edit.signal_dimreg_to_be_changed().connect( |
269 |
|
dimreg_to_be_changed_signal.make_slot()); |
270 |
|
dimreg_edit.signal_dimreg_changed().connect( |
271 |
|
dimreg_changed_signal.make_slot()); |
272 |
|
dimreg_edit.signal_sample_ref_changed().connect( |
273 |
|
sample_ref_changed_signal.make_slot()); |
274 |
|
|
275 |
|
m_RegionChooser.signal_instrument_struct_to_be_changed().connect( |
276 |
|
sigc::hide( |
277 |
|
sigc::bind( |
278 |
|
file_structure_to_be_changed_signal.make_slot(), |
279 |
|
sigc::ref(this->file) |
280 |
|
) |
281 |
|
) |
282 |
|
); |
283 |
|
m_RegionChooser.signal_instrument_struct_changed().connect( |
284 |
|
sigc::hide( |
285 |
|
sigc::bind( |
286 |
|
file_structure_changed_signal.make_slot(), |
287 |
|
sigc::ref(this->file) |
288 |
|
) |
289 |
|
) |
290 |
|
); |
291 |
|
m_RegionChooser.signal_region_to_be_changed().connect( |
292 |
|
region_to_be_changed_signal.make_slot()); |
293 |
|
m_RegionChooser.signal_region_changed_signal().connect( |
294 |
|
region_changed_signal.make_slot()); |
295 |
|
|
296 |
file = 0; |
file = 0; |
297 |
file_is_changed = false; |
file_is_changed = false; |
298 |
|
file_is_shared = false; |
299 |
|
|
300 |
show_all_children(); |
show_all_children(); |
301 |
|
|
309 |
|
|
310 |
bool MainWindow::on_delete_event(GdkEventAny* event) |
bool MainWindow::on_delete_event(GdkEventAny* event) |
311 |
{ |
{ |
312 |
return file_is_changed && !close_confirmation_dialog(); |
return !file_is_shared && file_is_changed && !close_confirmation_dialog(); |
313 |
} |
} |
314 |
|
|
315 |
void MainWindow::on_action_quit() |
void MainWindow::on_action_quit() |
316 |
{ |
{ |
317 |
if (file_is_changed && !close_confirmation_dialog()) return; |
if (!file_is_shared && file_is_changed && !close_confirmation_dialog()) return; |
318 |
hide(); |
hide(); |
319 |
} |
} |
320 |
|
|
428 |
m_refTreeModel->clear(); |
m_refTreeModel->clear(); |
429 |
m_refSamplesTreeModel->clear(); |
m_refSamplesTreeModel->clear(); |
430 |
// free libgig's gig::File instance |
// free libgig's gig::File instance |
431 |
if (file) { |
if (file && !file_is_shared) delete file; |
432 |
delete file; |
file = NULL; |
433 |
file = NULL; |
file_is_shared = false; |
|
} |
|
434 |
} |
} |
435 |
|
|
436 |
void MainWindow::on_action_file_new() |
void MainWindow::on_action_file_new() |
437 |
{ |
{ |
438 |
if (file_is_changed && !close_confirmation_dialog()) return; |
if (!file_is_shared && file_is_changed && !close_confirmation_dialog()) return; |
439 |
|
|
440 |
|
if (file_is_shared && !leaving_shared_mode_dialog()) return; |
441 |
|
|
442 |
// clear all GUI elements |
// clear all GUI elements |
443 |
__clear(); |
__clear(); |
469 |
return response != Gtk::RESPONSE_CANCEL; |
return response != Gtk::RESPONSE_CANCEL; |
470 |
} |
} |
471 |
|
|
472 |
|
bool MainWindow::leaving_shared_mode_dialog() { |
473 |
|
Glib::ustring msg = _("Detach from sampler and proceed working stand-alone?"); |
474 |
|
Gtk::MessageDialog dialog(*this, msg, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE); |
475 |
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION >= 6) || GTKMM_MAJOR_VERSION > 2 |
476 |
|
dialog.set_secondary_text( |
477 |
|
_("If you proceed to work on another instrument file, it won't be " |
478 |
|
"used by the sampler until you tell the sampler explicitly to " |
479 |
|
"load it.") |
480 |
|
); |
481 |
|
#endif |
482 |
|
dialog.add_button(_("_Yes, Detach"), Gtk::RESPONSE_YES); |
483 |
|
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
484 |
|
dialog.set_default_response(Gtk::RESPONSE_CANCEL); |
485 |
|
int response = dialog.run(); |
486 |
|
dialog.hide(); |
487 |
|
return response == Gtk::RESPONSE_YES; |
488 |
|
} |
489 |
|
|
490 |
void MainWindow::on_action_file_open() |
void MainWindow::on_action_file_open() |
491 |
{ |
{ |
492 |
if (file_is_changed && !close_confirmation_dialog()) return; |
if (!file_is_shared && file_is_changed && !close_confirmation_dialog()) return; |
493 |
|
|
494 |
|
if (file_is_shared && !leaving_shared_mode_dialog()) return; |
495 |
|
|
496 |
Gtk::FileChooserDialog dialog(*this, _("Open file")); |
Gtk::FileChooserDialog dialog(*this, _("Open file")); |
497 |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
532 |
msg.run(); |
msg.run(); |
533 |
Gtk::Main::quit(); |
Gtk::Main::quit(); |
534 |
} |
} |
535 |
|
// clear all GUI elements |
536 |
|
__clear(); |
537 |
|
// load the instrument |
538 |
gig::File* pFile = (gig::File*) instr->GetParent(); |
gig::File* pFile = (gig::File*) instr->GetParent(); |
539 |
load_gig(pFile, 0 /*file name*/); |
load_gig(pFile, 0 /*file name*/, true /*shared instrument*/); |
540 |
//TODO: automatically select the given instrument |
//TODO: automatically select the given instrument |
541 |
} |
} |
542 |
|
|
585 |
bool MainWindow::file_save() |
bool MainWindow::file_save() |
586 |
{ |
{ |
587 |
if (!check_if_savable()) return false; |
if (!check_if_savable()) return false; |
588 |
if (!file_has_name) return file_save_as(); |
if (!file_is_shared && !file_has_name) return file_save_as(); |
589 |
|
|
590 |
std::cout << "Saving file\n" << std::flush; |
std::cout << "Saving file\n" << std::flush; |
591 |
|
file_structure_to_be_changed_signal.emit(this->file); |
592 |
try { |
try { |
593 |
file->Save(); |
file->Save(); |
594 |
if (file_is_changed) { |
if (file_is_changed) { |
596 |
file_is_changed = false; |
file_is_changed = false; |
597 |
} |
} |
598 |
} catch (RIFF::Exception e) { |
} catch (RIFF::Exception e) { |
599 |
Glib::ustring txt = "Could not save file: " + e.Message; |
file_structure_changed_signal.emit(this->file); |
600 |
|
Glib::ustring txt = _("Could not save file: ") + e.Message; |
601 |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
602 |
msg.run(); |
msg.run(); |
603 |
return false; |
return false; |
604 |
} |
} |
605 |
std::cout << "Saving file done\n" << std::flush; |
std::cout << "Saving file done\n" << std::flush; |
606 |
__import_queued_samples(); |
__import_queued_samples(); |
607 |
|
file_structure_changed_signal.emit(this->file); |
608 |
return true; |
return true; |
609 |
} |
} |
610 |
|
|
637 |
dialog.set_current_name(Glib::filename_display_basename(filename)); |
dialog.set_current_name(Glib::filename_display_basename(filename)); |
638 |
|
|
639 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
640 |
|
file_structure_to_be_changed_signal.emit(this->file); |
641 |
try { |
try { |
642 |
std::string filename = dialog.get_filename(); |
std::string filename = dialog.get_filename(); |
643 |
if (!Glib::str_has_suffix(filename, ".gig")) { |
if (!Glib::str_has_suffix(filename, ".gig")) { |
651 |
file_has_name = true; |
file_has_name = true; |
652 |
file_is_changed = false; |
file_is_changed = false; |
653 |
} catch (RIFF::Exception e) { |
} catch (RIFF::Exception e) { |
654 |
Glib::ustring txt = "Could not save file: " + e.Message; |
file_structure_changed_signal.emit(this->file); |
655 |
|
Glib::ustring txt = _("Could not save file: ") + e.Message; |
656 |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
657 |
msg.run(); |
msg.run(); |
658 |
return false; |
return false; |
659 |
} |
} |
660 |
__import_queued_samples(); |
__import_queued_samples(); |
661 |
|
file_structure_changed_signal.emit(this->file); |
662 |
return true; |
return true; |
663 |
} |
} |
664 |
return false; |
return false; |
749 |
} |
} |
750 |
// show error message box when some sample(s) could not be imported |
// show error message box when some sample(s) could not be imported |
751 |
if (error_files.size()) { |
if (error_files.size()) { |
752 |
Glib::ustring txt = "Could not import the following sample(s):\n" + error_files; |
Glib::ustring txt = _("Could not import the following sample(s):\n") + error_files; |
753 |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
754 |
msg.run(); |
msg.run(); |
755 |
} |
} |
943 |
if (h < l) eDimensionKeyRangeLow.set_value(h); |
if (h < l) eDimensionKeyRangeLow.set_value(h); |
944 |
} |
} |
945 |
|
|
946 |
sigc::signal<void> InstrumentProps::signal_instrument_changed() |
sigc::signal<void>& InstrumentProps::signal_instrument_changed() |
947 |
{ |
{ |
948 |
return instrument_changed; |
return instrument_changed; |
949 |
} |
} |
956 |
} |
} |
957 |
} |
} |
958 |
|
|
959 |
void MainWindow::load_gig(gig::File* gig, const char* filename) |
void MainWindow::load_gig(gig::File* gig, const char* filename, bool isSharedInstrument) |
960 |
{ |
{ |
961 |
file = 0; |
file = 0; |
962 |
|
file_is_shared = isSharedInstrument; |
963 |
|
|
964 |
this->filename = filename ? filename : _("Unsaved Gig File"); |
this->filename = filename ? filename : _("Unsaved Gig File"); |
965 |
set_title(Glib::filename_display_basename(this->filename)); |
set_title(Glib::filename_display_basename(this->filename)); |
1093 |
|
|
1094 |
void MainWindow::on_action_remove_instrument() { |
void MainWindow::on_action_remove_instrument() { |
1095 |
if (!file) return; |
if (!file) return; |
1096 |
|
if (file_is_shared) { |
1097 |
|
Gtk::MessageDialog msg( |
1098 |
|
*this, |
1099 |
|
_("You cannot delete an instrument from this file, since it's " |
1100 |
|
"currently used by the sampler."), |
1101 |
|
false, Gtk::MESSAGE_INFO |
1102 |
|
); |
1103 |
|
msg.run(); |
1104 |
|
return; |
1105 |
|
} |
1106 |
|
|
1107 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
1108 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
Gtk::TreeModel::iterator it = sel->get_selected(); |
1109 |
if (it) { |
if (it) { |
1290 |
} |
} |
1291 |
// 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 |
1292 |
if (error_files.size()) { |
if (error_files.size()) { |
1293 |
Glib::ustring txt = "Could not add the following sample(s):\n" + error_files; |
Glib::ustring txt = _("Could not add the following sample(s):\n") + error_files; |
1294 |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
1295 |
msg.run(); |
msg.run(); |
1296 |
} |
} |
1316 |
pSample; pSample = group->GetNextSample()) { |
pSample; pSample = group->GetNextSample()) { |
1317 |
members.push_back(pSample); |
members.push_back(pSample); |
1318 |
} |
} |
1319 |
|
// notify everybody that we're going to remove these samples |
1320 |
|
samples_to_be_removed_signal.emit(members); |
1321 |
// delete the group in the .gig file including the |
// delete the group in the .gig file including the |
1322 |
// samples that belong to the group |
// samples that belong to the group |
1323 |
file->DeleteGroup(group); |
file->DeleteGroup(group); |
1324 |
|
// notify that we're done with removal |
1325 |
|
samples_removed_signal.emit(); |
1326 |
// if sample(s) were just previously added, remove |
// if sample(s) were just previously added, remove |
1327 |
// them from the import queue |
// them from the import queue |
1328 |
for (std::list<gig::Sample*>::iterator member = members.begin(); |
for (std::list<gig::Sample*>::iterator member = members.begin(); |
1339 |
} |
} |
1340 |
file_changed(); |
file_changed(); |
1341 |
} else if (sample) { |
} else if (sample) { |
1342 |
|
// notify everybody that we're going to remove this sample |
1343 |
|
std::list<gig::Sample*> lsamples; |
1344 |
|
lsamples.push_back(sample); |
1345 |
|
samples_to_be_removed_signal.emit(lsamples); |
1346 |
// remove sample from the .gig file |
// remove sample from the .gig file |
1347 |
file->DeleteSample(sample); |
file->DeleteSample(sample); |
1348 |
|
// notify that we're done with removal |
1349 |
|
samples_removed_signal.emit(); |
1350 |
// if sample was just previously added, remove it from |
// if sample was just previously added, remove it from |
1351 |
// the import queue |
// the import queue |
1352 |
for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
1364 |
// remove respective row(s) from samples tree view |
// remove respective row(s) from samples tree view |
1365 |
m_refSamplesTreeModel->erase(it); |
m_refSamplesTreeModel->erase(it); |
1366 |
} catch (RIFF::Exception e) { |
} catch (RIFF::Exception e) { |
1367 |
|
// pretend we're done with removal (i.e. to avoid dead locks) |
1368 |
|
samples_removed_signal.emit(); |
1369 |
|
// show error message |
1370 |
Gtk::MessageDialog msg(*this, e.Message.c_str(), false, Gtk::MESSAGE_ERROR); |
Gtk::MessageDialog msg(*this, e.Message.c_str(), false, Gtk::MESSAGE_ERROR); |
1371 |
msg.run(); |
msg.run(); |
1372 |
} |
} |
1413 |
// drop success |
// drop success |
1414 |
context->drop_reply(true, time); |
context->drop_reply(true, time); |
1415 |
|
|
1416 |
// find the samplechannel dimension |
//TODO: we should better move most of the following code to DimRegionEdit::set_sample() |
1417 |
|
|
1418 |
|
// notify everybody that we're going to alter the region |
1419 |
gig::Region* region = m_RegionChooser.get_region(); |
gig::Region* region = m_RegionChooser.get_region(); |
1420 |
|
region_to_be_changed_signal.emit(region); |
1421 |
|
|
1422 |
|
// find the samplechannel dimension |
1423 |
gig::dimension_def_t* stereo_dimension = 0; |
gig::dimension_def_t* stereo_dimension = 0; |
1424 |
for (int i = 0 ; i < region->Dimensions ; i++) { |
for (int i = 0 ; i < region->Dimensions ; i++) { |
1425 |
if (region->pDimensionDefinitions[i].dimension == |
if (region->pDimensionDefinitions[i].dimension == |
1453 |
for (int i = 0 ; i < region->DimensionRegions ; i++) { |
for (int i = 0 ; i < region->DimensionRegions ; i++) { |
1454 |
gig::DimensionRegion* d = region->pDimensionRegions[i]; |
gig::DimensionRegion* d = region->pDimensionRegions[i]; |
1455 |
if (d->pSample && d->pSample->Channels != sample->Channels) { |
if (d->pSample && d->pSample->Channels != sample->Channels) { |
1456 |
d->pSample = 0; |
gig::Sample* oldref = d->pSample; |
1457 |
|
d->pSample = NULL; |
1458 |
|
sample_ref_changed_signal.emit(oldref, NULL); |
1459 |
} |
} |
1460 |
} |
} |
1461 |
} |
} |
1462 |
|
|
1463 |
|
// notify we're done with altering |
1464 |
|
region_changed_signal.emit(region); |
1465 |
|
|
1466 |
return; |
return; |
1467 |
} |
} |
1468 |
// drop failed |
// drop failed |
1502 |
file_changed(); |
file_changed(); |
1503 |
} |
} |
1504 |
} |
} |
1505 |
|
|
1506 |
|
sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() { |
1507 |
|
return file_structure_to_be_changed_signal; |
1508 |
|
} |
1509 |
|
|
1510 |
|
sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_changed() { |
1511 |
|
return file_structure_changed_signal; |
1512 |
|
} |
1513 |
|
|
1514 |
|
sigc::signal<void, std::list<gig::Sample*> >& MainWindow::signal_samples_to_be_removed() { |
1515 |
|
return samples_to_be_removed_signal; |
1516 |
|
} |
1517 |
|
|
1518 |
|
sigc::signal<void>& MainWindow::signal_samples_removed() { |
1519 |
|
return samples_removed_signal; |
1520 |
|
} |
1521 |
|
|
1522 |
|
sigc::signal<void, gig::Region*>& MainWindow::signal_region_to_be_changed() { |
1523 |
|
return region_to_be_changed_signal; |
1524 |
|
} |
1525 |
|
|
1526 |
|
sigc::signal<void, gig::Region*>& MainWindow::signal_region_changed() { |
1527 |
|
return region_changed_signal; |
1528 |
|
} |
1529 |
|
|
1530 |
|
sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/>& MainWindow::signal_sample_ref_changed() { |
1531 |
|
return sample_ref_changed_signal; |
1532 |
|
} |
1533 |
|
|
1534 |
|
sigc::signal<void, gig::DimensionRegion*>& MainWindow::signal_dimreg_to_be_changed() { |
1535 |
|
return dimreg_to_be_changed_signal; |
1536 |
|
} |
1537 |
|
|
1538 |
|
sigc::signal<void, gig::DimensionRegion*>& MainWindow::signal_dimreg_changed() { |
1539 |
|
return dimreg_changed_signal; |
1540 |
|
} |