1 |
/* |
/* |
2 |
* Copyright (C) 2006-2014 Andreas Persson |
* Copyright (C) 2006-2015 Andreas Persson |
3 |
* |
* |
4 |
* This program is free software; you can redistribute it and/or |
* This program is free software; you can redistribute it and/or |
5 |
* modify it under the terms of the GNU General Public License as |
* modify it under the terms of the GNU General Public License as |
217 |
sigc::mem_fun(*this, &MainWindow::on_action_warn_user_on_extensions) |
sigc::mem_fun(*this, &MainWindow::on_action_warn_user_on_extensions) |
218 |
); |
); |
219 |
|
|
220 |
|
toggle_action = |
221 |
|
Gtk::ToggleAction::create("SyncSamplerInstrumentSelection", _("Synchronize sampler's instrument selection")); |
222 |
|
toggle_action->set_active(Settings::singleton()->syncSamplerInstrumentSelection); |
223 |
|
actionGroup->add( |
224 |
|
toggle_action, |
225 |
|
sigc::mem_fun(*this, &MainWindow::on_action_sync_sampler_instrument_selection) |
226 |
|
); |
227 |
|
|
228 |
|
|
229 |
actionGroup->add(Gtk::Action::create("MenuTools", _("_Tools"))); |
actionGroup->add(Gtk::Action::create("MenuTools", _("_Tools"))); |
230 |
|
|
344 |
" </menu>" |
" </menu>" |
345 |
" <menu action='MenuSettings'>" |
" <menu action='MenuSettings'>" |
346 |
" <menuitem action='WarnUserOnExtensions'/>" |
" <menuitem action='WarnUserOnExtensions'/>" |
347 |
|
" <menuitem action='SyncSamplerInstrumentSelection'/>" |
348 |
" </menu>" |
" </menu>" |
349 |
" <menu action='MenuHelp'>" |
" <menu action='MenuHelp'>" |
350 |
" <menuitem action='About'/>" |
" <menuitem action='About'/>" |
406 |
} |
} |
407 |
{ |
{ |
408 |
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
409 |
|
uiManager->get_widget("/MenuBar/MenuSettings/SyncSamplerInstrumentSelection")); |
410 |
|
item->set_tooltip_text(_("If checked, the sampler's current instrument will automatically be switched whenever another instrument was selected in gigedit (only available in live-mode).")); |
411 |
|
} |
412 |
|
{ |
413 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
414 |
uiManager->get_widget("/MenuBar/MenuTools/CombineInstruments")); |
uiManager->get_widget("/MenuBar/MenuTools/CombineInstruments")); |
415 |
item->set_tooltip_text(_("Create combi sounds out of individual sounds of this .gig file.")); |
item->set_tooltip_text(_("Create combi sounds out of individual sounds of this .gig file.")); |
416 |
} |
} |
467 |
{ |
{ |
468 |
Gtk::TreeViewColumn* column = m_TreeViewSamples.get_column(0); |
Gtk::TreeViewColumn* column = m_TreeViewSamples.get_column(0); |
469 |
Gtk::CellRendererText* cellrenderer = |
Gtk::CellRendererText* cellrenderer = |
470 |
dynamic_cast<Gtk::CellRendererText*>(column->get_first_cell_renderer()); |
dynamic_cast<Gtk::CellRendererText*>(column->get_first_cell()); |
471 |
column->add_attribute( |
column->add_attribute( |
472 |
cellrenderer->property_foreground(), m_SamplesModel.m_color |
cellrenderer->property_foreground(), m_SamplesModel.m_color |
473 |
); |
); |
475 |
{ |
{ |
476 |
Gtk::TreeViewColumn* column = m_TreeViewSamples.get_column(1); |
Gtk::TreeViewColumn* column = m_TreeViewSamples.get_column(1); |
477 |
Gtk::CellRendererText* cellrenderer = |
Gtk::CellRendererText* cellrenderer = |
478 |
dynamic_cast<Gtk::CellRendererText*>(column->get_first_cell_renderer()); |
dynamic_cast<Gtk::CellRendererText*>(column->get_first_cell()); |
479 |
column->add_attribute( |
column->add_attribute( |
480 |
cellrenderer->property_foreground(), m_SamplesModel.m_color |
cellrenderer->property_foreground(), m_SamplesModel.m_color |
481 |
); |
); |
492 |
m_refScriptsTreeModel = ScriptsTreeStore::create(m_ScriptsModel); |
m_refScriptsTreeModel = ScriptsTreeStore::create(m_ScriptsModel); |
493 |
m_TreeViewScripts.set_model(m_refScriptsTreeModel); |
m_TreeViewScripts.set_model(m_refScriptsTreeModel); |
494 |
m_TreeViewScripts.set_tooltip_text(_( |
m_TreeViewScripts.set_tooltip_text(_( |
495 |
|
"Use CTRL + double click for editing a script." |
496 |
|
"\n\n" |
497 |
"Note: instrument scripts are a LinuxSampler extension of the gig " |
"Note: instrument scripts are a LinuxSampler extension of the gig " |
498 |
"format. This feature will not work with the GigaStudio software!" |
"format. This feature will not work with the GigaStudio software!" |
499 |
)); |
)); |
503 |
m_TreeViewScripts.signal_button_press_event().connect_notify( |
m_TreeViewScripts.signal_button_press_event().connect_notify( |
504 |
sigc::mem_fun(*this, &MainWindow::on_script_treeview_button_release) |
sigc::mem_fun(*this, &MainWindow::on_script_treeview_button_release) |
505 |
); |
); |
506 |
|
//FIXME: why the heck does this double click signal_row_activated() only fire while CTRL key is pressed ? |
507 |
|
m_TreeViewScripts.signal_row_activated().connect( |
508 |
|
sigc::mem_fun(*this, &MainWindow::script_double_clicked) |
509 |
|
); |
510 |
m_refScriptsTreeModel->signal_row_changed().connect( |
m_refScriptsTreeModel->signal_row_changed().connect( |
511 |
sigc::mem_fun(*this, &MainWindow::script_name_changed) |
sigc::mem_fun(*this, &MainWindow::script_name_changed) |
512 |
); |
); |
562 |
sigc::mem_fun(*this, &MainWindow::on_samples_to_be_removed) |
sigc::mem_fun(*this, &MainWindow::on_samples_to_be_removed) |
563 |
); |
); |
564 |
|
|
565 |
|
dimreg_edit.signal_select_sample().connect( |
566 |
|
sigc::mem_fun(*this, &MainWindow::select_sample) |
567 |
|
); |
568 |
|
|
569 |
m_RegionChooser.signal_instrument_struct_to_be_changed().connect( |
m_RegionChooser.signal_instrument_struct_to_be_changed().connect( |
570 |
sigc::hide( |
sigc::hide( |
571 |
sigc::bind( |
sigc::bind( |
706 |
} |
} |
707 |
|
|
708 |
m_RegionChooser.set_instrument(get_instrument()); |
m_RegionChooser.set_instrument(get_instrument()); |
709 |
|
|
710 |
|
if (Settings::singleton()->syncSamplerInstrumentSelection) { |
711 |
|
switch_sampler_instrument_signal.emit(get_instrument()); |
712 |
|
} |
713 |
} |
} |
714 |
|
|
715 |
void loader_progress_callback(gig::progress_t* progress) |
void loader_progress_callback(gig::progress_t* progress) |
730 |
void Loader::thread_function() |
void Loader::thread_function() |
731 |
{ |
{ |
732 |
printf("thread_function self=%x\n", Glib::Threads::Thread::self()); |
printf("thread_function self=%x\n", Glib::Threads::Thread::self()); |
733 |
printf("Start %s\n", filename); |
printf("Start %s\n", filename.c_str()); |
734 |
RIFF::File* riff = new RIFF::File(filename); |
try { |
735 |
gig = new gig::File(riff); |
RIFF::File* riff = new RIFF::File(filename); |
736 |
gig::progress_t progress; |
gig = new gig::File(riff); |
737 |
progress.callback = loader_progress_callback; |
gig::progress_t progress; |
738 |
progress.custom = this; |
progress.callback = loader_progress_callback; |
739 |
|
progress.custom = this; |
740 |
gig->GetInstrument(0, &progress); |
|
741 |
printf("End\n"); |
gig->GetInstrument(0, &progress); |
742 |
finished_dispatcher(); |
printf("End\n"); |
743 |
|
finished_dispatcher(); |
744 |
|
} catch (RIFF::Exception e) { |
745 |
|
error_message = e.Message; |
746 |
|
error_dispatcher.emit(); |
747 |
|
} catch (...) { |
748 |
|
error_message = _("Unknown exception occurred"); |
749 |
|
error_dispatcher.emit(); |
750 |
|
} |
751 |
} |
} |
752 |
|
|
753 |
Loader::Loader(const char* filename) |
Loader::Loader(const char* filename) |
754 |
: filename(filename), thread(0) |
: filename(filename), thread(0), progress(0.f) |
755 |
{ |
{ |
756 |
} |
} |
757 |
|
|
785 |
return finished_dispatcher; |
return finished_dispatcher; |
786 |
} |
} |
787 |
|
|
788 |
LoadDialog::LoadDialog(const Glib::ustring& title, Gtk::Window& parent) |
Glib::Dispatcher& Loader::signal_error() |
789 |
|
{ |
790 |
|
return error_dispatcher; |
791 |
|
} |
792 |
|
|
793 |
|
void saver_progress_callback(gig::progress_t* progress) |
794 |
|
{ |
795 |
|
Saver* saver = static_cast<Saver*>(progress->custom); |
796 |
|
saver->progress_callback(progress->factor); |
797 |
|
} |
798 |
|
|
799 |
|
void Saver::progress_callback(float fraction) |
800 |
|
{ |
801 |
|
{ |
802 |
|
Glib::Threads::Mutex::Lock lock(progressMutex); |
803 |
|
progress = fraction; |
804 |
|
} |
805 |
|
progress_dispatcher.emit(); |
806 |
|
} |
807 |
|
|
808 |
|
void Saver::thread_function() |
809 |
|
{ |
810 |
|
printf("thread_function self=%x\n", Glib::Threads::Thread::self()); |
811 |
|
printf("Start %s\n", filename.c_str()); |
812 |
|
try { |
813 |
|
gig::progress_t progress; |
814 |
|
progress.callback = saver_progress_callback; |
815 |
|
progress.custom = this; |
816 |
|
|
817 |
|
// if no filename was provided, that means "save", if filename was provided means "save as" |
818 |
|
if (filename.empty()) { |
819 |
|
gig->Save(&progress); |
820 |
|
} else { |
821 |
|
gig->Save(filename, &progress); |
822 |
|
} |
823 |
|
|
824 |
|
printf("End\n"); |
825 |
|
finished_dispatcher.emit(); |
826 |
|
} catch (RIFF::Exception e) { |
827 |
|
error_message = e.Message; |
828 |
|
error_dispatcher.emit(); |
829 |
|
} catch (...) { |
830 |
|
error_message = _("Unknown exception occurred"); |
831 |
|
error_dispatcher.emit(); |
832 |
|
} |
833 |
|
} |
834 |
|
|
835 |
|
Saver::Saver(gig::File* file, Glib::ustring filename) |
836 |
|
: gig(file), filename(filename), thread(0), progress(0.f) |
837 |
|
{ |
838 |
|
} |
839 |
|
|
840 |
|
void Saver::launch() |
841 |
|
{ |
842 |
|
#ifdef OLD_THREADS |
843 |
|
thread = Glib::Thread::create(sigc::mem_fun(*this, &Saver::thread_function), true); |
844 |
|
#else |
845 |
|
thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Saver::thread_function)); |
846 |
|
#endif |
847 |
|
printf("launch thread=%x\n", thread); |
848 |
|
} |
849 |
|
|
850 |
|
float Saver::get_progress() |
851 |
|
{ |
852 |
|
float res; |
853 |
|
{ |
854 |
|
Glib::Threads::Mutex::Lock lock(progressMutex); |
855 |
|
res = progress; |
856 |
|
} |
857 |
|
return res; |
858 |
|
} |
859 |
|
|
860 |
|
Glib::Dispatcher& Saver::signal_progress() |
861 |
|
{ |
862 |
|
return progress_dispatcher; |
863 |
|
} |
864 |
|
|
865 |
|
Glib::Dispatcher& Saver::signal_finished() |
866 |
|
{ |
867 |
|
return finished_dispatcher; |
868 |
|
} |
869 |
|
|
870 |
|
Glib::Dispatcher& Saver::signal_error() |
871 |
|
{ |
872 |
|
return error_dispatcher; |
873 |
|
} |
874 |
|
|
875 |
|
ProgressDialog::ProgressDialog(const Glib::ustring& title, Gtk::Window& parent) |
876 |
: Gtk::Dialog(title, parent, true) |
: Gtk::Dialog(title, parent, true) |
877 |
{ |
{ |
878 |
get_vbox()->pack_start(progressBar); |
get_vbox()->pack_start(progressBar); |
879 |
show_all_children(); |
show_all_children(); |
880 |
|
resize(600,50); |
881 |
} |
} |
882 |
|
|
883 |
// Clear all GUI elements / controls. This method is typically called |
// Clear all GUI elements / controls. This method is typically called |
946 |
dialog.set_default_response(Gtk::RESPONSE_YES); |
dialog.set_default_response(Gtk::RESPONSE_YES); |
947 |
int response = dialog.run(); |
int response = dialog.run(); |
948 |
dialog.hide(); |
dialog.hide(); |
949 |
if (response == Gtk::RESPONSE_YES) return file_save(); |
|
950 |
return response != Gtk::RESPONSE_CANCEL; |
// user decided to exit app without saving |
951 |
|
if (response == Gtk::RESPONSE_NO) return true; |
952 |
|
|
953 |
|
// user cancelled dialog, thus don't close app |
954 |
|
if (response == Gtk::RESPONSE_CANCEL) return false; |
955 |
|
|
956 |
|
// TODO: the following return valid is disabled and hard coded instead for |
957 |
|
// now, due to the fact that saving with progress bar is now implemented |
958 |
|
// asynchronously, as a result the app does not close automatically anymore |
959 |
|
// after saving the file has completed |
960 |
|
// |
961 |
|
// if (response == Gtk::RESPONSE_YES) return file_save(); |
962 |
|
// return response != Gtk::RESPONSE_CANCEL; |
963 |
|
// |
964 |
|
if (response == Gtk::RESPONSE_YES) file_save(); |
965 |
|
return false; // always prevent closing the app for now (see comment above) |
966 |
} |
} |
967 |
|
|
968 |
bool MainWindow::leaving_shared_mode_dialog() { |
bool MainWindow::leaving_shared_mode_dialog() { |
1013 |
void MainWindow::load_file(const char* name) |
void MainWindow::load_file(const char* name) |
1014 |
{ |
{ |
1015 |
__clear(); |
__clear(); |
1016 |
load_dialog = new LoadDialog(_("Loading..."), *this); |
|
1017 |
load_dialog->show_all(); |
progress_dialog = new ProgressDialog( //FIXME: memory leak! |
1018 |
loader = new Loader(strdup(name)); |
_("Loading") + Glib::ustring(" '") + |
1019 |
|
Glib::filename_display_basename(name) + "' ...", |
1020 |
|
*this |
1021 |
|
); |
1022 |
|
progress_dialog->show_all(); |
1023 |
|
loader = new Loader(name); //FIXME: memory leak! |
1024 |
loader->signal_progress().connect( |
loader->signal_progress().connect( |
1025 |
sigc::mem_fun(*this, &MainWindow::on_loader_progress)); |
sigc::mem_fun(*this, &MainWindow::on_loader_progress)); |
1026 |
loader->signal_finished().connect( |
loader->signal_finished().connect( |
1027 |
sigc::mem_fun(*this, &MainWindow::on_loader_finished)); |
sigc::mem_fun(*this, &MainWindow::on_loader_finished)); |
1028 |
|
loader->signal_error().connect( |
1029 |
|
sigc::mem_fun(*this, &MainWindow::on_loader_error)); |
1030 |
loader->launch(); |
loader->launch(); |
1031 |
} |
} |
1032 |
|
|
1042 |
// load the instrument |
// load the instrument |
1043 |
gig::File* pFile = (gig::File*) instr->GetParent(); |
gig::File* pFile = (gig::File*) instr->GetParent(); |
1044 |
load_gig(pFile, 0 /*file name*/, true /*shared instrument*/); |
load_gig(pFile, 0 /*file name*/, true /*shared instrument*/); |
1045 |
//TODO: automatically select the given instrument |
// automatically select the given instrument |
1046 |
|
int i = 0; |
1047 |
|
for (gig::Instrument* instrument = pFile->GetFirstInstrument(); instrument; |
1048 |
|
instrument = pFile->GetNextInstrument(), ++i) |
1049 |
|
{ |
1050 |
|
if (instrument == instr) { |
1051 |
|
// select item in "instruments" tree view |
1052 |
|
m_TreeView.get_selection()->select(Gtk::TreePath(ToString(i))); |
1053 |
|
// make sure the selected item in the "instruments" tree view is |
1054 |
|
// visible (scroll to it) |
1055 |
|
m_TreeView.scroll_to_row(Gtk::TreePath(ToString(i))); |
1056 |
|
// select item in instrument menu |
1057 |
|
{ |
1058 |
|
const std::vector<Gtk::Widget*> children = |
1059 |
|
instrument_menu->get_children(); |
1060 |
|
static_cast<Gtk::RadioMenuItem*>(children[i])->set_active(); |
1061 |
|
} |
1062 |
|
// update region chooser and dimension region chooser |
1063 |
|
m_RegionChooser.set_instrument(instr); |
1064 |
|
break; |
1065 |
|
} |
1066 |
|
} |
1067 |
} |
} |
1068 |
|
|
1069 |
void MainWindow::on_loader_progress() |
void MainWindow::on_loader_progress() |
1070 |
{ |
{ |
1071 |
load_dialog->set_fraction(loader->get_progress()); |
progress_dialog->set_fraction(loader->get_progress()); |
1072 |
} |
} |
1073 |
|
|
1074 |
void MainWindow::on_loader_finished() |
void MainWindow::on_loader_finished() |
1075 |
{ |
{ |
1076 |
printf("Loader finished!\n"); |
printf("Loader finished!\n"); |
1077 |
printf("on_loader_finished self=%x\n", Glib::Threads::Thread::self()); |
printf("on_loader_finished self=%x\n", Glib::Threads::Thread::self()); |
1078 |
load_gig(loader->gig, loader->filename); |
load_gig(loader->gig, loader->filename.c_str()); |
1079 |
load_dialog->hide(); |
progress_dialog->hide(); |
1080 |
|
} |
1081 |
|
|
1082 |
|
void MainWindow::on_loader_error() |
1083 |
|
{ |
1084 |
|
Glib::ustring txt = _("Could not load file: ") + loader->error_message; |
1085 |
|
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
1086 |
|
msg.run(); |
1087 |
|
progress_dialog->hide(); |
1088 |
} |
} |
1089 |
|
|
1090 |
void MainWindow::on_action_file_save() |
void MainWindow::on_action_file_save() |
1123 |
|
|
1124 |
std::cout << "Saving file\n" << std::flush; |
std::cout << "Saving file\n" << std::flush; |
1125 |
file_structure_to_be_changed_signal.emit(this->file); |
file_structure_to_be_changed_signal.emit(this->file); |
1126 |
try { |
|
1127 |
file->Save(); |
progress_dialog = new ProgressDialog( //FIXME: memory leak! |
1128 |
if (file_is_changed) { |
_("Saving") + Glib::ustring(" '") + |
1129 |
set_title(get_title().substr(1)); |
Glib::filename_display_basename(this->filename) + "' ...", |
1130 |
file_is_changed = false; |
*this |
1131 |
} |
); |
1132 |
} catch (RIFF::Exception e) { |
progress_dialog->show_all(); |
1133 |
file_structure_changed_signal.emit(this->file); |
saver = new Saver(this->file); //FIXME: memory leak! |
1134 |
Glib::ustring txt = _("Could not save file: ") + e.Message; |
saver->signal_progress().connect( |
1135 |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
sigc::mem_fun(*this, &MainWindow::on_saver_progress)); |
1136 |
msg.run(); |
saver->signal_finished().connect( |
1137 |
return false; |
sigc::mem_fun(*this, &MainWindow::on_saver_finished)); |
1138 |
} |
saver->signal_error().connect( |
1139 |
std::cout << "Saving file done\n" << std::flush; |
sigc::mem_fun(*this, &MainWindow::on_saver_error)); |
1140 |
|
saver->launch(); |
1141 |
|
|
1142 |
|
return true; |
1143 |
|
} |
1144 |
|
|
1145 |
|
void MainWindow::on_saver_progress() |
1146 |
|
{ |
1147 |
|
progress_dialog->set_fraction(saver->get_progress()); |
1148 |
|
} |
1149 |
|
|
1150 |
|
void MainWindow::on_saver_error() |
1151 |
|
{ |
1152 |
|
file_structure_changed_signal.emit(this->file); |
1153 |
|
Glib::ustring txt = _("Could not save file: ") + saver->error_message; |
1154 |
|
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
1155 |
|
msg.run(); |
1156 |
|
} |
1157 |
|
|
1158 |
|
void MainWindow::on_saver_finished() |
1159 |
|
{ |
1160 |
|
this->file = saver->gig; |
1161 |
|
this->filename = saver->filename; |
1162 |
|
current_gig_dir = Glib::path_get_dirname(filename); |
1163 |
|
set_title(Glib::filename_display_basename(filename)); |
1164 |
|
file_has_name = true; |
1165 |
|
file_is_changed = false; |
1166 |
|
std::cout << "Saving file done. Importing queued samples now ...\n" << std::flush; |
1167 |
__import_queued_samples(); |
__import_queued_samples(); |
1168 |
|
std::cout << "Importing queued samples done.\n" << std::flush; |
1169 |
|
|
1170 |
file_structure_changed_signal.emit(this->file); |
file_structure_changed_signal.emit(this->file); |
1171 |
return true; |
|
1172 |
|
load_gig(this->file, this->filename.c_str()); |
1173 |
|
progress_dialog->hide(); |
1174 |
} |
} |
1175 |
|
|
1176 |
void MainWindow::on_action_file_save_as() |
void MainWindow::on_action_file_save_as() |
1235 |
descriptionArea.show_all(); |
descriptionArea.show_all(); |
1236 |
|
|
1237 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
1238 |
file_structure_to_be_changed_signal.emit(this->file); |
std::string filename = dialog.get_filename(); |
1239 |
try { |
if (!Glib::str_has_suffix(filename, ".gig")) { |
1240 |
std::string filename = dialog.get_filename(); |
filename += ".gig"; |
|
if (!Glib::str_has_suffix(filename, ".gig")) { |
|
|
filename += ".gig"; |
|
|
} |
|
|
printf("filename=%s\n", filename.c_str()); |
|
|
file->Save(filename); |
|
|
this->filename = filename; |
|
|
current_gig_dir = Glib::path_get_dirname(filename); |
|
|
set_title(Glib::filename_display_basename(filename)); |
|
|
file_has_name = true; |
|
|
file_is_changed = false; |
|
|
} catch (RIFF::Exception e) { |
|
|
file_structure_changed_signal.emit(this->file); |
|
|
Glib::ustring txt = _("Could not save file: ") + e.Message; |
|
|
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
|
|
msg.run(); |
|
|
return false; |
|
1241 |
} |
} |
1242 |
__import_queued_samples(); |
printf("filename=%s\n", filename.c_str()); |
1243 |
file_structure_changed_signal.emit(this->file); |
|
1244 |
|
progress_dialog = new ProgressDialog( //FIXME: memory leak! |
1245 |
|
_("Saving") + Glib::ustring(" '") + |
1246 |
|
Glib::filename_display_basename(filename) + "' ...", |
1247 |
|
*this |
1248 |
|
); |
1249 |
|
progress_dialog->show_all(); |
1250 |
|
|
1251 |
|
saver = new Saver(file, filename); //FIXME: memory leak! |
1252 |
|
saver->signal_progress().connect( |
1253 |
|
sigc::mem_fun(*this, &MainWindow::on_saver_progress)); |
1254 |
|
saver->signal_finished().connect( |
1255 |
|
sigc::mem_fun(*this, &MainWindow::on_saver_finished)); |
1256 |
|
saver->signal_error().connect( |
1257 |
|
sigc::mem_fun(*this, &MainWindow::on_saver_error)); |
1258 |
|
saver->launch(); |
1259 |
|
|
1260 |
return true; |
return true; |
1261 |
} |
} |
1262 |
return false; |
return false; |
1367 |
!Settings::singleton()->warnUserOnExtensions; |
!Settings::singleton()->warnUserOnExtensions; |
1368 |
} |
} |
1369 |
|
|
1370 |
|
void MainWindow::on_action_sync_sampler_instrument_selection() { |
1371 |
|
Settings::singleton()->syncSamplerInstrumentSelection = |
1372 |
|
!Settings::singleton()->syncSamplerInstrumentSelection; |
1373 |
|
} |
1374 |
|
|
1375 |
void MainWindow::on_action_help_about() |
void MainWindow::on_action_help_about() |
1376 |
{ |
{ |
1377 |
Gtk::AboutDialog dialog; |
Gtk::AboutDialog dialog; |
1381 |
dialog.set_name("Gigedit"); |
dialog.set_name("Gigedit"); |
1382 |
#endif |
#endif |
1383 |
dialog.set_version(VERSION); |
dialog.set_version(VERSION); |
1384 |
dialog.set_copyright("Copyright (C) 2006-2014 Andreas Persson"); |
dialog.set_copyright("Copyright (C) 2006-2015 Andreas Persson"); |
1385 |
const std::string sComment = |
const std::string sComment = |
1386 |
_("Built " __DATE__ "\nUsing ") + |
_("Built " __DATE__ "\nUsing ") + |
1387 |
::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" + |
::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" + |
1893 |
} |
} |
1894 |
} |
} |
1895 |
|
|
1896 |
|
/// Returns true if requested dimension region was successfully selected and scrolled to in the list view, false on error. |
1897 |
|
bool MainWindow::select_dimension_region(gig::DimensionRegion* dimRgn) { |
1898 |
|
gig::Region* pRegion = (gig::Region*) dimRgn->GetParent(); |
1899 |
|
gig::Instrument* pInstrument = (gig::Instrument*) pRegion->GetParent(); |
1900 |
|
|
1901 |
|
Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model(); |
1902 |
|
for (int i = 0; i < model->children().size(); ++i) { |
1903 |
|
Gtk::TreeModel::Row row = model->children()[i]; |
1904 |
|
if (row[m_Columns.m_col_instr] == pInstrument) { |
1905 |
|
// select and show the respective instrument in the list view |
1906 |
|
show_intruments_tab(); |
1907 |
|
m_TreeView.get_selection()->select(model->children()[i]); |
1908 |
|
Gtk::TreePath path( |
1909 |
|
m_TreeView.get_selection()->get_selected() |
1910 |
|
); |
1911 |
|
m_TreeView.scroll_to_row(path); |
1912 |
|
on_sel_change(); // the regular instrument selection change callback |
1913 |
|
|
1914 |
|
// select respective region in the region selector |
1915 |
|
m_RegionChooser.set_region(pRegion); |
1916 |
|
|
1917 |
|
// select and show the respective dimension region in the editor |
1918 |
|
//update_dimregs(); |
1919 |
|
if (!m_DimRegionChooser.select_dimregion(dimRgn)) return false; |
1920 |
|
//dimreg_edit.set_dim_region(dimRgn); |
1921 |
|
|
1922 |
|
return true; |
1923 |
|
} |
1924 |
|
} |
1925 |
|
|
1926 |
|
return false; |
1927 |
|
} |
1928 |
|
|
1929 |
|
void MainWindow::select_sample(gig::Sample* sample) { |
1930 |
|
Glib::RefPtr<Gtk::TreeModel> model = m_TreeViewSamples.get_model(); |
1931 |
|
for (int g = 0; g < model->children().size(); ++g) { |
1932 |
|
Gtk::TreeModel::Row rowGroup = model->children()[g]; |
1933 |
|
for (int s = 0; s < rowGroup.children().size(); ++s) { |
1934 |
|
Gtk::TreeModel::Row rowSample = rowGroup.children()[s]; |
1935 |
|
if (rowSample[m_SamplesModel.m_col_sample] == sample) { |
1936 |
|
show_samples_tab(); |
1937 |
|
m_TreeViewSamples.get_selection()->select(rowGroup.children()[s]); |
1938 |
|
Gtk::TreePath path( |
1939 |
|
m_TreeViewSamples.get_selection()->get_selected() |
1940 |
|
); |
1941 |
|
m_TreeViewSamples.scroll_to_row(path); |
1942 |
|
return; |
1943 |
|
} |
1944 |
|
} |
1945 |
|
} |
1946 |
|
} |
1947 |
|
|
1948 |
void MainWindow::on_sample_treeview_button_release(GdkEventButton* button) { |
void MainWindow::on_sample_treeview_button_release(GdkEventButton* button) { |
1949 |
if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
1950 |
Gtk::Menu* sample_popup = |
Gtk::Menu* sample_popup = |
2827 |
} |
} |
2828 |
} |
} |
2829 |
|
|
2830 |
|
void MainWindow::script_double_clicked(const Gtk::TreeModel::Path& path, |
2831 |
|
Gtk::TreeViewColumn* column) |
2832 |
|
{ |
2833 |
|
Gtk::TreeModel::iterator iter = m_refScriptsTreeModel->get_iter(path); |
2834 |
|
if (!iter) return; |
2835 |
|
Gtk::TreeModel::Row row = *iter; |
2836 |
|
gig::Script* script = row[m_ScriptsModel.m_col_script]; |
2837 |
|
if (!script) return; |
2838 |
|
|
2839 |
|
ScriptEditor* editor = new ScriptEditor; |
2840 |
|
editor->setScript(script); |
2841 |
|
//editor->reparent(*this); |
2842 |
|
editor->show(); |
2843 |
|
} |
2844 |
|
|
2845 |
void MainWindow::instrument_name_changed(const Gtk::TreeModel::Path& path, |
void MainWindow::instrument_name_changed(const Gtk::TreeModel::Path& path, |
2846 |
const Gtk::TreeModel::iterator& iter) { |
const Gtk::TreeModel::iterator& iter) { |
2847 |
if (!iter) return; |
if (!iter) return; |
2898 |
|
|
2899 |
ReferencesView* d = new ReferencesView(*this); |
ReferencesView* d = new ReferencesView(*this); |
2900 |
d->setSample(sample); |
d->setSample(sample); |
2901 |
|
d->dimension_region_selected.connect( |
2902 |
|
sigc::mem_fun(*this, &MainWindow::select_dimension_region) |
2903 |
|
); |
2904 |
d->show_all(); |
d->show_all(); |
2905 |
d->resize(500, 400); |
d->resize(500, 400); |
2906 |
d->run(); |
d->run(); |
2974 |
); |
); |
2975 |
} |
} |
2976 |
|
|
2977 |
// Note: requires that this file already has a filename ! |
// Finally save gig file persistently to disk ... |
2978 |
this->file->Save(); |
//NOTE: requires that this gig file already has a filename ! |
2979 |
|
{ |
2980 |
|
std::cout << "Saving file\n" << std::flush; |
2981 |
|
file_structure_to_be_changed_signal.emit(this->file); |
2982 |
|
|
2983 |
|
progress_dialog = new ProgressDialog( //FIXME: memory leak! |
2984 |
|
_("Saving") + Glib::ustring(" '") + |
2985 |
|
Glib::filename_display_basename(this->filename) + "' ...", |
2986 |
|
*this |
2987 |
|
); |
2988 |
|
progress_dialog->show_all(); |
2989 |
|
saver = new Saver(this->file); //FIXME: memory leak! |
2990 |
|
saver->signal_progress().connect( |
2991 |
|
sigc::mem_fun(*this, &MainWindow::on_saver_progress)); |
2992 |
|
saver->signal_finished().connect( |
2993 |
|
sigc::mem_fun(*this, &MainWindow::on_saver_finished)); |
2994 |
|
saver->signal_error().connect( |
2995 |
|
sigc::mem_fun(*this, &MainWindow::on_saver_error)); |
2996 |
|
saver->launch(); |
2997 |
|
} |
2998 |
} |
} |
2999 |
|
|
3000 |
void MainWindow::on_action_merge_files() { |
void MainWindow::on_action_merge_files() { |
3084 |
Gdk::Pixbuf::create_from_xpm_data(status_detached_xpm) |
Gdk::Pixbuf::create_from_xpm_data(status_detached_xpm) |
3085 |
); |
); |
3086 |
} |
} |
3087 |
|
|
3088 |
|
{ |
3089 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
3090 |
|
uiManager->get_widget("/MenuBar/MenuSettings/SyncSamplerInstrumentSelection")); |
3091 |
|
if (item) item->set_sensitive(b); |
3092 |
|
} |
3093 |
} |
} |
3094 |
|
|
3095 |
void MainWindow::on_sample_ref_count_incremented(gig::Sample* sample, int offset) { |
void MainWindow::on_sample_ref_count_incremented(gig::Sample* sample, int offset) { |
3118 |
// just in case a new sample is added later with exactly the same memory |
// just in case a new sample is added later with exactly the same memory |
3119 |
// address, which would lead to incorrect refcount if not deleted here |
// address, which would lead to incorrect refcount if not deleted here |
3120 |
for (std::list<gig::Sample*>::const_iterator it = samples.begin(); |
for (std::list<gig::Sample*>::const_iterator it = samples.begin(); |
3121 |
it != samples.end(); it != samples.end()) |
it != samples.end(); ++it) |
3122 |
{ |
{ |
3123 |
sample_ref_count.erase(*it); |
sample_ref_count.erase(*it); |
3124 |
} |
} |
3191 |
sigc::signal<void, int/*key*/, int/*velocity*/>& MainWindow::signal_keyboard_key_released() { |
sigc::signal<void, int/*key*/, int/*velocity*/>& MainWindow::signal_keyboard_key_released() { |
3192 |
return m_RegionChooser.signal_keyboard_key_released(); |
return m_RegionChooser.signal_keyboard_key_released(); |
3193 |
} |
} |
3194 |
|
|
3195 |
|
sigc::signal<void, gig::Instrument*>& MainWindow::signal_switch_sampler_instrument() { |
3196 |
|
return switch_sampler_instrument_signal; |
3197 |
|
} |