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 |
45 |
#include "mainwindow.h" |
#include "mainwindow.h" |
46 |
#include "Settings.h" |
#include "Settings.h" |
47 |
#include "CombineInstrumentsDialog.h" |
#include "CombineInstrumentsDialog.h" |
48 |
|
#include "scripteditor.h" |
49 |
|
#include "scriptslots.h" |
50 |
|
#include "ReferencesView.h" |
51 |
#include "../../gfx/status_attached.xpm" |
#include "../../gfx/status_attached.xpm" |
52 |
#include "../../gfx/status_detached.xpm" |
#include "../../gfx/status_detached.xpm" |
53 |
|
|
54 |
|
|
55 |
MainWindow::MainWindow() : |
MainWindow::MainWindow() : |
56 |
|
m_DimRegionChooser(*this), |
57 |
dimreg_label(_("Changes apply to:")), |
dimreg_label(_("Changes apply to:")), |
58 |
dimreg_all_regions(_("all regions")), |
dimreg_all_regions(_("all regions")), |
59 |
dimreg_all_dimregs(_("all dimension splits")), |
dimreg_all_dimregs(_("all dimension splits")), |
82 |
m_ScrolledWindowSamples.add(m_TreeViewSamples); |
m_ScrolledWindowSamples.add(m_TreeViewSamples); |
83 |
m_ScrolledWindowSamples.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); |
m_ScrolledWindowSamples.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); |
84 |
|
|
85 |
|
m_ScrolledWindowScripts.add(m_TreeViewScripts); |
86 |
|
m_ScrolledWindowScripts.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); |
87 |
|
|
88 |
|
|
89 |
m_TreeViewNotebook.set_size_request(300); |
m_TreeViewNotebook.set_size_request(300); |
90 |
|
|
105 |
|
|
106 |
m_TreeViewNotebook.append_page(m_ScrolledWindowSamples, _("Samples")); |
m_TreeViewNotebook.append_page(m_ScrolledWindowSamples, _("Samples")); |
107 |
m_TreeViewNotebook.append_page(m_ScrolledWindow, _("Instruments")); |
m_TreeViewNotebook.append_page(m_ScrolledWindow, _("Instruments")); |
108 |
|
m_TreeViewNotebook.append_page(m_ScrolledWindowScripts, _("Scripts")); |
109 |
|
|
110 |
actionGroup = Gtk::ActionGroup::create(); |
actionGroup = Gtk::ActionGroup::create(); |
111 |
|
|
137 |
sigc::mem_fun( |
sigc::mem_fun( |
138 |
*this, &MainWindow::show_instr_props)); |
*this, &MainWindow::show_instr_props)); |
139 |
actionGroup->add(Gtk::Action::create("MidiRules", |
actionGroup->add(Gtk::Action::create("MidiRules", |
140 |
_("_Midi Rules")), |
_("_Midi Rules...")), |
141 |
sigc::mem_fun( |
sigc::mem_fun( |
142 |
*this, &MainWindow::show_midi_rules)); |
*this, &MainWindow::show_midi_rules)); |
143 |
|
actionGroup->add(Gtk::Action::create("ScriptSlots", |
144 |
|
_("_Script Slots...")), |
145 |
|
sigc::mem_fun( |
146 |
|
*this, &MainWindow::show_script_slots)); |
147 |
actionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT), |
actionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT), |
148 |
sigc::mem_fun( |
sigc::mem_fun( |
149 |
*this, &MainWindow::on_action_quit)); |
*this, &MainWindow::on_action_quit)); |
150 |
actionGroup->add(Gtk::Action::create("MenuInstrument", _("_Instrument"))); |
actionGroup->add( |
151 |
|
Gtk::Action::create("MenuSample", _("_Sample")), |
152 |
|
sigc::mem_fun(*this, &MainWindow::show_samples_tab) |
153 |
|
); |
154 |
|
actionGroup->add( |
155 |
|
Gtk::Action::create("MenuInstrument", _("_Instrument")), |
156 |
|
sigc::mem_fun(*this, &MainWindow::show_intruments_tab) |
157 |
|
); |
158 |
|
actionGroup->add( |
159 |
|
Gtk::Action::create("MenuScript", _("S_cript")), |
160 |
|
sigc::mem_fun(*this, &MainWindow::show_scripts_tab) |
161 |
|
); |
162 |
|
actionGroup->add(Gtk::Action::create("AllInstruments", _("_Select"))); |
163 |
|
|
164 |
actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit"))); |
actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit"))); |
165 |
|
|
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 |
|
|
257 |
sigc::mem_fun(*this, &MainWindow::on_action_remove_sample) |
sigc::mem_fun(*this, &MainWindow::on_action_remove_sample) |
258 |
); |
); |
259 |
actionGroup->add( |
actionGroup->add( |
260 |
|
Gtk::Action::create("ShowSampleRefs", _("Show References...")), |
261 |
|
sigc::mem_fun(*this, &MainWindow::on_action_view_references) |
262 |
|
); |
263 |
|
actionGroup->add( |
264 |
Gtk::Action::create("ReplaceAllSamplesInAllGroups", |
Gtk::Action::create("ReplaceAllSamplesInAllGroups", |
265 |
_("Replace All Samples in All Groups...")), |
_("Replace All Samples in All Groups...")), |
266 |
sigc::mem_fun(*this, &MainWindow::on_action_replace_all_samples_in_all_groups) |
sigc::mem_fun(*this, &MainWindow::on_action_replace_all_samples_in_all_groups) |
267 |
); |
); |
268 |
|
|
269 |
|
// script right-click popup actions |
270 |
|
actionGroup->add( |
271 |
|
Gtk::Action::create("AddScriptGroup", _("Add _Group")), |
272 |
|
sigc::mem_fun(*this, &MainWindow::on_action_add_script_group) |
273 |
|
); |
274 |
|
actionGroup->add( |
275 |
|
Gtk::Action::create("AddScript", _("Add _Script")), |
276 |
|
sigc::mem_fun(*this, &MainWindow::on_action_add_script) |
277 |
|
); |
278 |
|
actionGroup->add( |
279 |
|
Gtk::Action::create("EditScript", _("_Edit Script...")), |
280 |
|
sigc::mem_fun(*this, &MainWindow::on_action_edit_script) |
281 |
|
); |
282 |
|
actionGroup->add( |
283 |
|
Gtk::Action::create("RemoveScript", Gtk::Stock::REMOVE), |
284 |
|
sigc::mem_fun(*this, &MainWindow::on_action_remove_script) |
285 |
|
); |
286 |
|
|
287 |
uiManager = Gtk::UIManager::create(); |
uiManager = Gtk::UIManager::create(); |
288 |
uiManager->insert_action_group(actionGroup); |
uiManager->insert_action_group(actionGroup); |
307 |
" <menuitem action='CopySampleTune'/>" |
" <menuitem action='CopySampleTune'/>" |
308 |
" <menuitem action='CopySampleLoop'/>" |
" <menuitem action='CopySampleLoop'/>" |
309 |
" </menu>" |
" </menu>" |
310 |
|
" <menu action='MenuSample'>" |
311 |
|
" <menuitem action='SampleProperties'/>" |
312 |
|
" <menuitem action='AddGroup'/>" |
313 |
|
" <menuitem action='AddSample'/>" |
314 |
|
" <menuitem action='ShowSampleRefs'/>" |
315 |
|
" <menuitem action='ReplaceAllSamplesInAllGroups' />" |
316 |
|
" <separator/>" |
317 |
|
" <menuitem action='RemoveSample'/>" |
318 |
|
" </menu>" |
319 |
" <menu action='MenuInstrument'>" |
" <menu action='MenuInstrument'>" |
320 |
|
" <menu action='AllInstruments'>" |
321 |
|
" </menu>" |
322 |
|
" <separator/>" |
323 |
|
" <menuitem action='InstrProperties'/>" |
324 |
|
" <menuitem action='MidiRules'/>" |
325 |
|
" <menuitem action='ScriptSlots'/>" |
326 |
|
" <menuitem action='AddInstrument'/>" |
327 |
|
" <menuitem action='DupInstrument'/>" |
328 |
|
" <separator/>" |
329 |
|
" <menuitem action='RemoveInstrument'/>" |
330 |
|
" </menu>" |
331 |
|
" <menu action='MenuScript'>" |
332 |
|
" <menuitem action='AddScriptGroup'/>" |
333 |
|
" <menuitem action='AddScript'/>" |
334 |
|
" <menuitem action='EditScript'/>" |
335 |
|
" <separator/>" |
336 |
|
" <menuitem action='RemoveScript'/>" |
337 |
" </menu>" |
" </menu>" |
338 |
" <menu action='MenuView'>" |
" <menu action='MenuView'>" |
339 |
" <menuitem action='Statusbar'/>" |
" <menuitem action='Statusbar'/>" |
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'/>" |
353 |
" <popup name='PopupMenu'>" |
" <popup name='PopupMenu'>" |
354 |
" <menuitem action='InstrProperties'/>" |
" <menuitem action='InstrProperties'/>" |
355 |
" <menuitem action='MidiRules'/>" |
" <menuitem action='MidiRules'/>" |
356 |
|
" <menuitem action='ScriptSlots'/>" |
357 |
" <menuitem action='AddInstrument'/>" |
" <menuitem action='AddInstrument'/>" |
358 |
" <menuitem action='DupInstrument'/>" |
" <menuitem action='DupInstrument'/>" |
359 |
" <separator/>" |
" <separator/>" |
363 |
" <menuitem action='SampleProperties'/>" |
" <menuitem action='SampleProperties'/>" |
364 |
" <menuitem action='AddGroup'/>" |
" <menuitem action='AddGroup'/>" |
365 |
" <menuitem action='AddSample'/>" |
" <menuitem action='AddSample'/>" |
366 |
|
" <menuitem action='ShowSampleRefs'/>" |
367 |
" <menuitem action='ReplaceAllSamplesInAllGroups' />" |
" <menuitem action='ReplaceAllSamplesInAllGroups' />" |
368 |
" <separator/>" |
" <separator/>" |
369 |
" <menuitem action='RemoveSample'/>" |
" <menuitem action='RemoveSample'/>" |
370 |
" </popup>" |
" </popup>" |
371 |
|
" <popup name='ScriptPopupMenu'>" |
372 |
|
" <menuitem action='AddScriptGroup'/>" |
373 |
|
" <menuitem action='AddScript'/>" |
374 |
|
" <menuitem action='EditScript'/>" |
375 |
|
" <separator/>" |
376 |
|
" <menuitem action='RemoveScript'/>" |
377 |
|
" </popup>" |
378 |
"</ui>"; |
"</ui>"; |
379 |
uiManager->add_ui_from_string(ui_info); |
uiManager->add_ui_from_string(ui_info); |
380 |
|
|
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 |
} |
} |
422 |
|
|
423 |
|
|
424 |
instrument_menu = static_cast<Gtk::MenuItem*>( |
instrument_menu = static_cast<Gtk::MenuItem*>( |
425 |
uiManager->get_widget("/MenuBar/MenuInstrument"))->get_submenu(); |
uiManager->get_widget("/MenuBar/MenuInstrument/AllInstruments"))->get_submenu(); |
426 |
|
|
427 |
Gtk::Widget* menuBar = uiManager->get_widget("/MenuBar"); |
Gtk::Widget* menuBar = uiManager->get_widget("/MenuBar"); |
428 |
m_VBox.pack_start(*menuBar, Gtk::PACK_SHRINK); |
m_VBox.pack_start(*menuBar, Gtk::PACK_SHRINK); |
462 |
m_TreeViewSamples.set_model(m_refSamplesTreeModel); |
m_TreeViewSamples.set_model(m_refSamplesTreeModel); |
463 |
m_TreeViewSamples.set_tooltip_text(_("To actually use a sample, drag it from this list view to \"Sample\" -> \"Sample:\" on the region's settings pane on the right.\n\nRight click here for more actions on samples.")); |
m_TreeViewSamples.set_tooltip_text(_("To actually use a sample, drag it from this list view to \"Sample\" -> \"Sample:\" on the region's settings pane on the right.\n\nRight click here for more actions on samples.")); |
464 |
// m_TreeViewSamples.set_reorderable(); |
// m_TreeViewSamples.set_reorderable(); |
465 |
m_TreeViewSamples.append_column_editable("Samples", m_SamplesModel.m_col_name); |
m_TreeViewSamples.append_column_editable(_("Name"), m_SamplesModel.m_col_name); |
466 |
m_TreeViewSamples.set_headers_visible(false); |
m_TreeViewSamples.append_column(_("Referenced"), m_SamplesModel.m_col_refcount); |
467 |
|
{ |
468 |
|
Gtk::TreeViewColumn* column = m_TreeViewSamples.get_column(0); |
469 |
|
Gtk::CellRendererText* cellrenderer = |
470 |
|
dynamic_cast<Gtk::CellRendererText*>(column->get_first_cell()); |
471 |
|
column->add_attribute( |
472 |
|
cellrenderer->property_foreground(), m_SamplesModel.m_color |
473 |
|
); |
474 |
|
} |
475 |
|
{ |
476 |
|
Gtk::TreeViewColumn* column = m_TreeViewSamples.get_column(1); |
477 |
|
Gtk::CellRendererText* cellrenderer = |
478 |
|
dynamic_cast<Gtk::CellRendererText*>(column->get_first_cell()); |
479 |
|
column->add_attribute( |
480 |
|
cellrenderer->property_foreground(), m_SamplesModel.m_color |
481 |
|
); |
482 |
|
} |
483 |
|
m_TreeViewSamples.set_headers_visible(true); |
484 |
m_TreeViewSamples.signal_button_press_event().connect_notify( |
m_TreeViewSamples.signal_button_press_event().connect_notify( |
485 |
sigc::mem_fun(*this, &MainWindow::on_sample_treeview_button_release) |
sigc::mem_fun(*this, &MainWindow::on_sample_treeview_button_release) |
486 |
); |
); |
488 |
sigc::mem_fun(*this, &MainWindow::sample_name_changed) |
sigc::mem_fun(*this, &MainWindow::sample_name_changed) |
489 |
); |
); |
490 |
|
|
491 |
|
// create scripts treeview (including its data model) |
492 |
|
m_refScriptsTreeModel = ScriptsTreeStore::create(m_ScriptsModel); |
493 |
|
m_TreeViewScripts.set_model(m_refScriptsTreeModel); |
494 |
|
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 " |
498 |
|
"format. This feature will not work with the GigaStudio software!" |
499 |
|
)); |
500 |
|
// m_TreeViewScripts.set_reorderable(); |
501 |
|
m_TreeViewScripts.append_column_editable("Samples", m_ScriptsModel.m_col_name); |
502 |
|
m_TreeViewScripts.set_headers_visible(false); |
503 |
|
m_TreeViewScripts.signal_button_press_event().connect_notify( |
504 |
|
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( |
511 |
|
sigc::mem_fun(*this, &MainWindow::script_name_changed) |
512 |
|
); |
513 |
|
|
514 |
|
// establish drag&drop between scripts tree view and ScriptSlots window |
515 |
|
std::vector<Gtk::TargetEntry> drag_target_gig_script; |
516 |
|
drag_target_gig_script.push_back(Gtk::TargetEntry("gig::Script")); |
517 |
|
m_TreeViewScripts.drag_source_set(drag_target_gig_script); |
518 |
|
m_TreeViewScripts.signal_drag_begin().connect( |
519 |
|
sigc::mem_fun(*this, &MainWindow::on_scripts_treeview_drag_begin) |
520 |
|
); |
521 |
|
m_TreeViewScripts.signal_drag_data_get().connect( |
522 |
|
sigc::mem_fun(*this, &MainWindow::on_scripts_treeview_drag_data_get) |
523 |
|
); |
524 |
|
|
525 |
// establish drag&drop between samples tree view and dimension region 'Sample' text entry |
// establish drag&drop between samples tree view and dimension region 'Sample' text entry |
526 |
std::vector<Gtk::TargetEntry> drag_target_gig_sample; |
std::vector<Gtk::TargetEntry> drag_target_gig_sample; |
527 |
drag_target_gig_sample.push_back(Gtk::TargetEntry("gig::Sample")); |
drag_target_gig_sample.push_back(Gtk::TargetEntry("gig::Sample")); |
555 |
dimreg_changed_signal.make_slot()); |
dimreg_changed_signal.make_slot()); |
556 |
dimreg_edit.signal_sample_ref_changed().connect( |
dimreg_edit.signal_sample_ref_changed().connect( |
557 |
sample_ref_changed_signal.make_slot()); |
sample_ref_changed_signal.make_slot()); |
558 |
|
sample_ref_changed_signal.connect( |
559 |
|
sigc::mem_fun(*this, &MainWindow::on_sample_ref_changed) |
560 |
|
); |
561 |
|
samples_to_be_removed_signal.connect( |
562 |
|
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( |
690 |
void MainWindow::dimreg_changed() |
void MainWindow::dimreg_changed() |
691 |
{ |
{ |
692 |
update_dimregs(); |
update_dimregs(); |
693 |
dimreg_edit.set_dim_region(m_DimRegionChooser.get_dimregion()); |
dimreg_edit.set_dim_region(m_DimRegionChooser.get_main_dimregion()); |
694 |
} |
} |
695 |
|
|
696 |
void MainWindow::on_sel_change() |
void MainWindow::on_sel_change() |
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 |
888 |
// clear the samples and instruments tree views |
// clear the samples and instruments tree views |
889 |
m_refTreeModel->clear(); |
m_refTreeModel->clear(); |
890 |
m_refSamplesTreeModel->clear(); |
m_refSamplesTreeModel->clear(); |
891 |
|
m_refScriptsTreeModel->clear(); |
892 |
// remove all entries from "Instrument" menu |
// remove all entries from "Instrument" menu |
893 |
while (!instrument_menu->get_children().empty()) { |
while (!instrument_menu->get_children().empty()) { |
894 |
remove_instrument_from_menu(0); |
remove_instrument_from_menu(0); |
903 |
// clear the samples and instruments tree views |
// clear the samples and instruments tree views |
904 |
m_refTreeModel->clear(); |
m_refTreeModel->clear(); |
905 |
m_refSamplesTreeModel->clear(); |
m_refSamplesTreeModel->clear(); |
906 |
|
m_refScriptsTreeModel->clear(); |
907 |
// remove all entries from "Instrument" menu |
// remove all entries from "Instrument" menu |
908 |
while (!instrument_menu->get_children().empty()) { |
while (!instrument_menu->get_children().empty()) { |
909 |
remove_instrument_from_menu(0); |
remove_instrument_from_menu(0); |
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 |
|
__refreshEntireGUI(); |
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" + |
1388 |
_( |
_( |
1389 |
"Gigedit is released under the GNU General Public License.\n" |
"Gigedit is released under the GNU General Public License.\n" |
1390 |
"\n" |
"\n" |
1391 |
"Please notice that this is still a very young instrument editor. " |
"This program is distributed WITHOUT ANY WARRANTY; So better " |
1392 |
"So better backup your Gigasampler files before editing them with " |
"backup your Gigasampler/GigaStudio files before editing them with " |
1393 |
"this application.\n" |
"this application.\n" |
1394 |
"\n" |
"\n" |
1395 |
"Please report bugs to: http://bugs.linuxsampler.org" |
"Please report bugs to: http://bugs.linuxsampler.org" |
1491 |
std::vector<std::string> txts; |
std::vector<std::string> txts; |
1492 |
std::vector<int> values; |
std::vector<int> values; |
1493 |
txts.push_back(sGiga + "2"); values.push_back(2); |
txts.push_back(sGiga + "2"); values.push_back(2); |
1494 |
txts.push_back(sGiga + "3"); values.push_back(3); |
txts.push_back(sGiga + "3/v4"); values.push_back(3); |
1495 |
if (major != 2 && major != 3) { |
if (major != 2 && major != 3) { |
1496 |
txts.push_back(sGiga + ToString(major)); values.push_back(major); |
txts.push_back(sGiga + ToString(major)); values.push_back(major); |
1497 |
} |
} |
1498 |
std::vector<const char*> texts; |
std::vector<const char*> texts; |
1499 |
for (int i = 0; i < txts.size(); ++i) texts.push_back(txts[i].c_str()); |
for (int i = 0; i < txts.size(); ++i) texts.push_back(txts[i].c_str()); |
1500 |
texts.push_back(NULL); values.push_back(NULL); |
texts.push_back(NULL); values.push_back(0); |
1501 |
eFileFormat.set_choices(&texts[0], &values[0]); |
eFileFormat.set_choices(&texts[0], &values[0]); |
1502 |
eFileFormat.set_value(major); |
eFileFormat.set_value(major); |
1503 |
} |
} |
1638 |
} |
} |
1639 |
} |
} |
1640 |
|
|
1641 |
|
void MainWindow::updateSampleRefCountMap(gig::File* gig) { |
1642 |
|
sample_ref_count.clear(); |
1643 |
|
|
1644 |
|
if (!gig) return; |
1645 |
|
|
1646 |
|
for (gig::Instrument* instrument = gig->GetFirstInstrument(); instrument; |
1647 |
|
instrument = gig->GetNextInstrument()) |
1648 |
|
{ |
1649 |
|
for (gig::Region* rgn = instrument->GetFirstRegion(); rgn; |
1650 |
|
rgn = instrument->GetNextRegion()) |
1651 |
|
{ |
1652 |
|
for (int i = 0; i < 256; ++i) { |
1653 |
|
if (!rgn->pDimensionRegions[i]) continue; |
1654 |
|
if (rgn->pDimensionRegions[i]->pSample) { |
1655 |
|
sample_ref_count[rgn->pDimensionRegions[i]->pSample]++; |
1656 |
|
} |
1657 |
|
} |
1658 |
|
} |
1659 |
|
} |
1660 |
|
} |
1661 |
|
|
1662 |
void MainWindow::load_gig(gig::File* gig, const char* filename, bool isSharedInstrument) |
void MainWindow::load_gig(gig::File* gig, const char* filename, bool isSharedInstrument) |
1663 |
{ |
{ |
1664 |
file = 0; |
file = 0; |
1685 |
add_instrument_to_menu(name); |
add_instrument_to_menu(name); |
1686 |
} |
} |
1687 |
instrument_name_connection.unblock(); |
instrument_name_connection.unblock(); |
1688 |
uiManager->get_widget("/MenuBar/MenuInstrument")->show(); |
uiManager->get_widget("/MenuBar/MenuInstrument/AllInstruments")->show(); |
1689 |
|
|
1690 |
|
updateSampleRefCountMap(gig); |
1691 |
|
|
1692 |
for (gig::Group* group = gig->GetFirstGroup(); group; group = gig->GetNextGroup()) { |
for (gig::Group* group = gig->GetFirstGroup(); group; group = gig->GetNextGroup()) { |
1693 |
if (group->Name != "") { |
if (group->Name != "") { |
1705 |
gig_to_utf8(sample->pInfo->Name); |
gig_to_utf8(sample->pInfo->Name); |
1706 |
rowSample[m_SamplesModel.m_col_sample] = sample; |
rowSample[m_SamplesModel.m_col_sample] = sample; |
1707 |
rowSample[m_SamplesModel.m_col_group] = NULL; |
rowSample[m_SamplesModel.m_col_group] = NULL; |
1708 |
|
int refcount = sample_ref_count.count(sample) ? sample_ref_count[sample] : 0; |
1709 |
|
rowSample[m_SamplesModel.m_col_refcount] = ToString(refcount) + " " + _("Refs."); |
1710 |
|
rowSample[m_SamplesModel.m_color] = refcount ? "black" : "red"; |
1711 |
} |
} |
1712 |
} |
} |
1713 |
} |
} |
1714 |
|
|
1715 |
|
for (int i = 0; gig->GetScriptGroup(i); ++i) { |
1716 |
|
gig::ScriptGroup* group = gig->GetScriptGroup(i); |
1717 |
|
|
1718 |
|
Gtk::TreeModel::iterator iterGroup = m_refScriptsTreeModel->append(); |
1719 |
|
Gtk::TreeModel::Row rowGroup = *iterGroup; |
1720 |
|
rowGroup[m_ScriptsModel.m_col_name] = gig_to_utf8(group->Name); |
1721 |
|
rowGroup[m_ScriptsModel.m_col_group] = group; |
1722 |
|
rowGroup[m_ScriptsModel.m_col_script] = NULL; |
1723 |
|
for (int s = 0; group->GetScript(s); ++s) { |
1724 |
|
gig::Script* script = group->GetScript(s); |
1725 |
|
|
1726 |
|
Gtk::TreeModel::iterator iterScript = |
1727 |
|
m_refScriptsTreeModel->append(rowGroup.children()); |
1728 |
|
Gtk::TreeModel::Row rowScript = *iterScript; |
1729 |
|
rowScript[m_ScriptsModel.m_col_name] = gig_to_utf8(script->Name); |
1730 |
|
rowScript[m_ScriptsModel.m_col_script] = script; |
1731 |
|
rowScript[m_ScriptsModel.m_col_group] = NULL; |
1732 |
|
} |
1733 |
|
} |
1734 |
|
// unfold all sample groups & script groups by default |
1735 |
|
m_TreeViewSamples.expand_all(); |
1736 |
|
m_TreeViewScripts.expand_all(); |
1737 |
|
|
1738 |
file = gig; |
file = gig; |
1739 |
|
|
1802 |
} |
} |
1803 |
} |
} |
1804 |
|
|
1805 |
|
void MainWindow::show_script_slots() { |
1806 |
|
if (!file) return; |
1807 |
|
// get selected instrument |
1808 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
1809 |
|
Gtk::TreeModel::iterator it = sel->get_selected(); |
1810 |
|
if (!it) return; |
1811 |
|
Gtk::TreeModel::Row row = *it; |
1812 |
|
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
1813 |
|
if (!instrument) return; |
1814 |
|
|
1815 |
|
ScriptSlots* window = new ScriptSlots; |
1816 |
|
window->setInstrument(instrument); |
1817 |
|
//window->reparent(*this); |
1818 |
|
window->show(); |
1819 |
|
} |
1820 |
|
|
1821 |
void MainWindow::on_action_view_status_bar() { |
void MainWindow::on_action_view_status_bar() { |
1822 |
Gtk::CheckMenuItem* item = |
Gtk::CheckMenuItem* item = |
1823 |
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/Statusbar")); |
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/Statusbar")); |
1865 |
show_instr_props(); |
show_instr_props(); |
1866 |
} else if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
} else if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
1867 |
// gig v2 files have no midi rules |
// gig v2 files have no midi rules |
1868 |
|
const bool bEnabled = !(file->pVersion && file->pVersion->major == 2); |
1869 |
|
static_cast<Gtk::MenuItem*>( |
1870 |
|
uiManager->get_widget("/MenuBar/MenuInstrument/MidiRules"))->set_sensitive( |
1871 |
|
bEnabled |
1872 |
|
); |
1873 |
static_cast<Gtk::MenuItem*>( |
static_cast<Gtk::MenuItem*>( |
1874 |
uiManager->get_widget("/PopupMenu/MidiRules"))->set_sensitive( |
uiManager->get_widget("/PopupMenu/MidiRules"))->set_sensitive( |
1875 |
!(file->pVersion && file->pVersion->major == 2)); |
bEnabled |
1876 |
|
); |
1877 |
popup_menu->popup(button->button, button->time); |
popup_menu->popup(button->button, button->time); |
1878 |
} |
} |
1879 |
} |
} |
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 = |
1959 |
group_selected = row[m_SamplesModel.m_col_group]; |
group_selected = row[m_SamplesModel.m_col_group]; |
1960 |
sample_selected = row[m_SamplesModel.m_col_sample]; |
sample_selected = row[m_SamplesModel.m_col_sample]; |
1961 |
} |
} |
1962 |
|
|
1963 |
|
|
1964 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/SampleProperties"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/SampleProperties"))-> |
1965 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(group_selected || sample_selected); |
1966 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddSample"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddSample"))-> |
1967 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(group_selected || sample_selected); |
1968 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddGroup"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddGroup"))-> |
1969 |
set_sensitive(file); |
set_sensitive(file); |
1970 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/ShowSampleRefs"))-> |
1971 |
|
set_sensitive(sample_selected); |
1972 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/RemoveSample"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/RemoveSample"))-> |
1973 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(group_selected || sample_selected); |
1974 |
// show sample popup |
// show sample popup |
1975 |
sample_popup->popup(button->button, button->time); |
sample_popup->popup(button->button, button->time); |
1976 |
|
|
1977 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/SampleProperties"))-> |
1978 |
|
set_sensitive(group_selected || sample_selected); |
1979 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddSample"))-> |
1980 |
|
set_sensitive(group_selected || sample_selected); |
1981 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddGroup"))-> |
1982 |
|
set_sensitive(file); |
1983 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/ShowSampleRefs"))-> |
1984 |
|
set_sensitive(sample_selected); |
1985 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/RemoveSample"))-> |
1986 |
|
set_sensitive(group_selected || sample_selected); |
1987 |
} |
} |
1988 |
} |
} |
1989 |
|
|
1990 |
|
void MainWindow::on_script_treeview_button_release(GdkEventButton* button) { |
1991 |
|
if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
1992 |
|
Gtk::Menu* script_popup = |
1993 |
|
dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/ScriptPopupMenu")); |
1994 |
|
// update enabled/disabled state of sample popup items |
1995 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewScripts.get_selection(); |
1996 |
|
Gtk::TreeModel::iterator it = sel->get_selected(); |
1997 |
|
bool group_selected = false; |
1998 |
|
bool script_selected = false; |
1999 |
|
if (it) { |
2000 |
|
Gtk::TreeModel::Row row = *it; |
2001 |
|
group_selected = row[m_ScriptsModel.m_col_group]; |
2002 |
|
script_selected = row[m_ScriptsModel.m_col_script]; |
2003 |
|
} |
2004 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/ScriptPopupMenu/AddScript"))-> |
2005 |
|
set_sensitive(group_selected || script_selected); |
2006 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/ScriptPopupMenu/AddScriptGroup"))-> |
2007 |
|
set_sensitive(file); |
2008 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/ScriptPopupMenu/EditScript"))-> |
2009 |
|
set_sensitive(script_selected); |
2010 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/ScriptPopupMenu/RemoveScript"))-> |
2011 |
|
set_sensitive(group_selected || script_selected); |
2012 |
|
// show sample popup |
2013 |
|
script_popup->popup(button->button, button->time); |
2014 |
|
|
2015 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/AddScript"))-> |
2016 |
|
set_sensitive(group_selected || script_selected); |
2017 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/AddScriptGroup"))-> |
2018 |
|
set_sensitive(file); |
2019 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/EditScript"))-> |
2020 |
|
set_sensitive(script_selected); |
2021 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/RemoveScript"))-> |
2022 |
|
set_sensitive(group_selected || script_selected); |
2023 |
|
} |
2024 |
|
} |
2025 |
|
|
2026 |
Gtk::RadioMenuItem* MainWindow::add_instrument_to_menu( |
Gtk::RadioMenuItem* MainWindow::add_instrument_to_menu( |
2027 |
const Glib::ustring& name, int position) { |
const Glib::ustring& name, int position) { |
2169 |
msg.run(); |
msg.run(); |
2170 |
} |
} |
2171 |
|
|
2172 |
|
void MainWindow::on_action_add_script_group() { |
2173 |
|
static int __script_indexer = 0; |
2174 |
|
if (!file) return; |
2175 |
|
gig::ScriptGroup* group = file->AddScriptGroup(); |
2176 |
|
group->Name = gig_from_utf8(_("Unnamed Group")); |
2177 |
|
if (__script_indexer) group->Name += " " + ToString(__script_indexer); |
2178 |
|
__script_indexer++; |
2179 |
|
// update sample tree view |
2180 |
|
Gtk::TreeModel::iterator iterGroup = m_refScriptsTreeModel->append(); |
2181 |
|
Gtk::TreeModel::Row rowGroup = *iterGroup; |
2182 |
|
rowGroup[m_ScriptsModel.m_col_name] = gig_to_utf8(group->Name); |
2183 |
|
rowGroup[m_ScriptsModel.m_col_script] = NULL; |
2184 |
|
rowGroup[m_ScriptsModel.m_col_group] = group; |
2185 |
|
file_changed(); |
2186 |
|
} |
2187 |
|
|
2188 |
|
void MainWindow::on_action_add_script() { |
2189 |
|
if (!file) return; |
2190 |
|
// get selected group |
2191 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewScripts.get_selection(); |
2192 |
|
Gtk::TreeModel::iterator it = sel->get_selected(); |
2193 |
|
if (!it) return; |
2194 |
|
Gtk::TreeModel::Row row = *it; |
2195 |
|
gig::ScriptGroup* group = row[m_ScriptsModel.m_col_group]; |
2196 |
|
if (!group) { // not a group, but a script is selected (probably) |
2197 |
|
gig::Script* script = row[m_ScriptsModel.m_col_script]; |
2198 |
|
if (!script) return; |
2199 |
|
it = row.parent(); // resolve parent (that is the script's group) |
2200 |
|
if (!it) return; |
2201 |
|
row = *it; |
2202 |
|
group = row[m_ScriptsModel.m_col_group]; |
2203 |
|
if (!group) return; |
2204 |
|
} |
2205 |
|
|
2206 |
|
// add a new script to the .gig file |
2207 |
|
gig::Script* script = group->AddScript(); |
2208 |
|
Glib::ustring name = _("Unnamed Script"); |
2209 |
|
script->Name = gig_from_utf8(name); |
2210 |
|
|
2211 |
|
// add script to the tree view |
2212 |
|
Gtk::TreeModel::iterator iterScript = |
2213 |
|
m_refScriptsTreeModel->append(row.children()); |
2214 |
|
Gtk::TreeModel::Row rowScript = *iterScript; |
2215 |
|
rowScript[m_ScriptsModel.m_col_name] = name; |
2216 |
|
rowScript[m_ScriptsModel.m_col_script] = script; |
2217 |
|
rowScript[m_ScriptsModel.m_col_group] = NULL; |
2218 |
|
|
2219 |
|
// unfold group of new script item in treeview |
2220 |
|
Gtk::TreeModel::Path path(iterScript); |
2221 |
|
m_TreeViewScripts.expand_to_path(path); |
2222 |
|
} |
2223 |
|
|
2224 |
|
void MainWindow::on_action_edit_script() { |
2225 |
|
if (!file) return; |
2226 |
|
// get selected script |
2227 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewScripts.get_selection(); |
2228 |
|
Gtk::TreeModel::iterator it = sel->get_selected(); |
2229 |
|
if (!it) return; |
2230 |
|
Gtk::TreeModel::Row row = *it; |
2231 |
|
gig::Script* script = row[m_ScriptsModel.m_col_script]; |
2232 |
|
if (!script) return; |
2233 |
|
|
2234 |
|
ScriptEditor* editor = new ScriptEditor; |
2235 |
|
editor->setScript(script); |
2236 |
|
//editor->reparent(*this); |
2237 |
|
editor->show(); |
2238 |
|
} |
2239 |
|
|
2240 |
|
void MainWindow::on_action_remove_script() { |
2241 |
|
if (!file) return; |
2242 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewScripts.get_selection(); |
2243 |
|
Gtk::TreeModel::iterator it = sel->get_selected(); |
2244 |
|
if (it) { |
2245 |
|
Gtk::TreeModel::Row row = *it; |
2246 |
|
gig::ScriptGroup* group = row[m_ScriptsModel.m_col_group]; |
2247 |
|
gig::Script* script = row[m_ScriptsModel.m_col_script]; |
2248 |
|
Glib::ustring name = row[m_ScriptsModel.m_col_name]; |
2249 |
|
try { |
2250 |
|
// remove script group or script from the gig file |
2251 |
|
if (group) { |
2252 |
|
// notify everybody that we're going to remove these samples |
2253 |
|
//TODO: scripts_to_be_removed_signal.emit(members); |
2254 |
|
// delete the group in the .gig file including the |
2255 |
|
// samples that belong to the group |
2256 |
|
file->DeleteScriptGroup(group); |
2257 |
|
// notify that we're done with removal |
2258 |
|
//TODO: scripts_removed_signal.emit(); |
2259 |
|
file_changed(); |
2260 |
|
} else if (script) { |
2261 |
|
// notify everybody that we're going to remove this sample |
2262 |
|
//TODO: std::list<gig::Script*> lscripts; |
2263 |
|
//TODO: lscripts.push_back(script); |
2264 |
|
//TODO: scripts_to_be_removed_signal.emit(lscripts); |
2265 |
|
// remove sample from the .gig file |
2266 |
|
script->GetGroup()->DeleteScript(script); |
2267 |
|
// notify that we're done with removal |
2268 |
|
//TODO: scripts_removed_signal.emit(); |
2269 |
|
dimreg_changed(); |
2270 |
|
file_changed(); |
2271 |
|
} |
2272 |
|
// remove respective row(s) from samples tree view |
2273 |
|
m_refScriptsTreeModel->erase(it); |
2274 |
|
} catch (RIFF::Exception e) { |
2275 |
|
// pretend we're done with removal (i.e. to avoid dead locks) |
2276 |
|
//TODO: scripts_removed_signal.emit(); |
2277 |
|
// show error message |
2278 |
|
Gtk::MessageDialog msg(*this, e.Message.c_str(), false, Gtk::MESSAGE_ERROR); |
2279 |
|
msg.run(); |
2280 |
|
} |
2281 |
|
} |
2282 |
|
} |
2283 |
|
|
2284 |
void MainWindow::on_action_add_group() { |
void MainWindow::on_action_add_group() { |
2285 |
static int __sample_indexer = 0; |
static int __sample_indexer = 0; |
2286 |
if (!file) return; |
if (!file) return; |
2650 |
} |
} |
2651 |
} |
} |
2652 |
|
|
2653 |
|
// see comment on on_sample_treeview_drag_begin() |
2654 |
|
void MainWindow::on_scripts_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context) |
2655 |
|
{ |
2656 |
|
first_call_to_drag_data_get = true; |
2657 |
|
} |
2658 |
|
|
2659 |
|
void MainWindow::on_scripts_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&, |
2660 |
|
Gtk::SelectionData& selection_data, guint, guint) |
2661 |
|
{ |
2662 |
|
if (!first_call_to_drag_data_get) return; |
2663 |
|
first_call_to_drag_data_get = false; |
2664 |
|
|
2665 |
|
// get selected script |
2666 |
|
gig::Script* script = NULL; |
2667 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewScripts.get_selection(); |
2668 |
|
Gtk::TreeModel::iterator it = sel->get_selected(); |
2669 |
|
if (it) { |
2670 |
|
Gtk::TreeModel::Row row = *it; |
2671 |
|
script = row[m_ScriptsModel.m_col_script]; |
2672 |
|
} |
2673 |
|
// pass the gig::Script as pointer |
2674 |
|
selection_data.set(selection_data.get_target(), 0/*unused*/, |
2675 |
|
(const guchar*)&script, |
2676 |
|
sizeof(script)/*length of data in bytes*/); |
2677 |
|
} |
2678 |
|
|
2679 |
// For some reason drag_data_get gets called two times for each |
// For some reason drag_data_get gets called two times for each |
2680 |
// drag'n'drop (at least when target is an Entry). This work-around |
// drag'n'drop (at least when target is an Entry). This work-around |
2681 |
// makes sure the code in drag_data_get and drop_drag_data_received is |
// makes sure the code in drag_data_get and drop_drag_data_received is |
2804 |
} |
} |
2805 |
} |
} |
2806 |
|
|
2807 |
|
void MainWindow::script_name_changed(const Gtk::TreeModel::Path& path, |
2808 |
|
const Gtk::TreeModel::iterator& iter) { |
2809 |
|
if (!iter) return; |
2810 |
|
Gtk::TreeModel::Row row = *iter; |
2811 |
|
Glib::ustring name = row[m_ScriptsModel.m_col_name]; |
2812 |
|
gig::ScriptGroup* group = row[m_ScriptsModel.m_col_group]; |
2813 |
|
gig::Script* script = row[m_ScriptsModel.m_col_script]; |
2814 |
|
gig::String gigname(gig_from_utf8(name)); |
2815 |
|
if (group) { |
2816 |
|
if (group->Name != gigname) { |
2817 |
|
group->Name = gigname; |
2818 |
|
printf("script group name changed\n"); |
2819 |
|
file_changed(); |
2820 |
|
} |
2821 |
|
} else if (script) { |
2822 |
|
if (script->Name != gigname) { |
2823 |
|
script->Name = gigname; |
2824 |
|
printf("script name changed\n"); |
2825 |
|
file_changed(); |
2826 |
|
} |
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; |
2888 |
delete d; |
delete d; |
2889 |
} |
} |
2890 |
|
|
2891 |
|
void MainWindow::on_action_view_references() { |
2892 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
2893 |
|
Gtk::TreeModel::iterator it = sel->get_selected(); |
2894 |
|
if (!it) return; |
2895 |
|
Gtk::TreeModel::Row row = *it; |
2896 |
|
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
2897 |
|
if (!sample) return; |
2898 |
|
|
2899 |
|
ReferencesView* d = new ReferencesView(*this); |
2900 |
|
d->setSample(sample); |
2901 |
|
d->dimension_region_selected.connect( |
2902 |
|
sigc::mem_fun(*this, &MainWindow::select_dimension_region) |
2903 |
|
); |
2904 |
|
d->show_all(); |
2905 |
|
d->resize(500, 400); |
2906 |
|
d->run(); |
2907 |
|
delete d; |
2908 |
|
} |
2909 |
|
|
2910 |
void MainWindow::mergeFiles(const std::vector<std::string>& filenames) { |
void MainWindow::mergeFiles(const std::vector<std::string>& filenames) { |
2911 |
struct _Source { |
struct _Source { |
2912 |
std::vector<RIFF::File*> riffs; |
std::vector<RIFF::File*> riffs; |
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) { |
3096 |
|
if (!sample) return; |
3097 |
|
sample_ref_count[sample] += offset; |
3098 |
|
const int refcount = sample_ref_count[sample]; |
3099 |
|
|
3100 |
|
Glib::RefPtr<Gtk::TreeModel> model = m_TreeViewSamples.get_model(); |
3101 |
|
for (int g = 0; g < model->children().size(); ++g) { |
3102 |
|
Gtk::TreeModel::Row rowGroup = model->children()[g]; |
3103 |
|
for (int s = 0; s < rowGroup.children().size(); ++s) { |
3104 |
|
Gtk::TreeModel::Row rowSample = rowGroup.children()[s]; |
3105 |
|
if (rowSample[m_SamplesModel.m_col_sample] != sample) continue; |
3106 |
|
rowSample[m_SamplesModel.m_col_refcount] = ToString(refcount) + " " + _("Refs."); |
3107 |
|
rowSample[m_SamplesModel.m_color] = refcount ? "black" : "red"; |
3108 |
|
} |
3109 |
|
} |
3110 |
|
} |
3111 |
|
|
3112 |
|
void MainWindow::on_sample_ref_changed(gig::Sample* oldSample, gig::Sample* newSample) { |
3113 |
|
on_sample_ref_count_incremented(oldSample, -1); |
3114 |
|
on_sample_ref_count_incremented(newSample, +1); |
3115 |
|
} |
3116 |
|
|
3117 |
|
void MainWindow::on_samples_to_be_removed(std::list<gig::Sample*> samples) { |
3118 |
|
// 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 |
3120 |
|
for (std::list<gig::Sample*>::const_iterator it = samples.begin(); |
3121 |
|
it != samples.end(); ++it) |
3122 |
|
{ |
3123 |
|
sample_ref_count.erase(*it); |
3124 |
|
} |
3125 |
|
} |
3126 |
|
|
3127 |
|
void MainWindow::show_samples_tab() { |
3128 |
|
m_TreeViewNotebook.set_current_page(0); |
3129 |
|
} |
3130 |
|
|
3131 |
|
void MainWindow::show_intruments_tab() { |
3132 |
|
m_TreeViewNotebook.set_current_page(1); |
3133 |
|
} |
3134 |
|
|
3135 |
|
void MainWindow::show_scripts_tab() { |
3136 |
|
m_TreeViewNotebook.set_current_page(2); |
3137 |
} |
} |
3138 |
|
|
3139 |
sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() { |
sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() { |
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 |
|
} |