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); |
536 |
__clear(); |
__clear(); |
537 |
// load the instrument |
// 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); |
file_structure_to_be_changed_signal.emit(this->file); |
597 |
} |
} |
598 |
} catch (RIFF::Exception e) { |
} catch (RIFF::Exception e) { |
599 |
file_structure_changed_signal.emit(this->file); |
file_structure_changed_signal.emit(this->file); |
600 |
Glib::ustring txt = "Could not save file: " + e.Message; |
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; |
652 |
file_is_changed = false; |
file_is_changed = false; |
653 |
} catch (RIFF::Exception e) { |
} catch (RIFF::Exception e) { |
654 |
file_structure_changed_signal.emit(this->file); |
file_structure_changed_signal.emit(this->file); |
655 |
Glib::ustring txt = "Could not save file: " + e.Message; |
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; |
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 |
} |
} |
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 |
} |
} |