40 |
|
|
41 |
#include <stdio.h> |
#include <stdio.h> |
42 |
#include <sndfile.h> |
#include <sndfile.h> |
43 |
|
#include <assert.h> |
44 |
|
|
45 |
#include "mainwindow.h" |
#include "mainwindow.h" |
46 |
|
#include "Settings.h" |
47 |
|
#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 |
|
|
81 |
m_ScrolledWindowSamples.add(m_TreeViewSamples); |
m_ScrolledWindowSamples.add(m_TreeViewSamples); |
82 |
m_ScrolledWindowSamples.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); |
m_ScrolledWindowSamples.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); |
83 |
|
|
84 |
|
m_ScrolledWindowScripts.add(m_TreeViewScripts); |
85 |
|
m_ScrolledWindowScripts.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); |
86 |
|
|
87 |
|
|
88 |
m_TreeViewNotebook.set_size_request(300); |
m_TreeViewNotebook.set_size_request(300); |
89 |
|
|
97 |
dimreg_vbox.pack_start(dimreg_hbox, Gtk::PACK_SHRINK); |
dimreg_vbox.pack_start(dimreg_hbox, Gtk::PACK_SHRINK); |
98 |
m_HPaned.add2(dimreg_vbox); |
m_HPaned.add2(dimreg_vbox); |
99 |
|
|
100 |
|
dimreg_label.set_tooltip_text(_("To automatically apply your changes above globally to the entire instrument, check all 3 check boxes on the right.")); |
101 |
|
dimreg_all_regions.set_tooltip_text(_("If checked: all changes you perform above will automatically be applied to all regions of this instrument as well.")); |
102 |
|
dimreg_all_dimregs.set_tooltip_text(_("If checked: all changes you perform above will automatically be applied as well to all dimension splits of the region selected below.")); |
103 |
|
dimreg_stereo.set_tooltip_text(_("If checked: all changes you perform above will automatically be applied to both audio channel splits (only if a \"stereo\" dimension is defined below).")); |
104 |
|
|
105 |
m_TreeViewNotebook.append_page(m_ScrolledWindowSamples, _("Samples")); |
m_TreeViewNotebook.append_page(m_ScrolledWindowSamples, _("Samples")); |
106 |
m_TreeViewNotebook.append_page(m_ScrolledWindow, _("Instruments")); |
m_TreeViewNotebook.append_page(m_ScrolledWindow, _("Instruments")); |
107 |
|
m_TreeViewNotebook.append_page(m_ScrolledWindowScripts, _("Scripts")); |
108 |
|
|
109 |
actionGroup = Gtk::ActionGroup::create(); |
actionGroup = Gtk::ActionGroup::create(); |
110 |
|
|
136 |
sigc::mem_fun( |
sigc::mem_fun( |
137 |
*this, &MainWindow::show_instr_props)); |
*this, &MainWindow::show_instr_props)); |
138 |
actionGroup->add(Gtk::Action::create("MidiRules", |
actionGroup->add(Gtk::Action::create("MidiRules", |
139 |
_("_Midi Rules")), |
_("_Midi Rules...")), |
140 |
sigc::mem_fun( |
sigc::mem_fun( |
141 |
*this, &MainWindow::show_midi_rules)); |
*this, &MainWindow::show_midi_rules)); |
142 |
|
actionGroup->add(Gtk::Action::create("ScriptSlots", |
143 |
|
_("_Script Slots...")), |
144 |
|
sigc::mem_fun( |
145 |
|
*this, &MainWindow::show_script_slots)); |
146 |
actionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT), |
actionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT), |
147 |
sigc::mem_fun( |
sigc::mem_fun( |
148 |
*this, &MainWindow::on_action_quit)); |
*this, &MainWindow::on_action_quit)); |
152 |
actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit"))); |
actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit"))); |
153 |
|
|
154 |
Glib::RefPtr<Gtk::ToggleAction> toggle_action = |
Glib::RefPtr<Gtk::ToggleAction> toggle_action = |
155 |
Gtk::ToggleAction::create("CopySampleUnity", _("Copy Sample's _Unity Note"), "ffaga"); |
Gtk::ToggleAction::create("CopySampleUnity", _("Copy Sample's _Unity Note")); |
156 |
toggle_action->set_active(true); |
toggle_action->set_active(true); |
|
//FIXME: doesn't work, why? |
|
|
toggle_action->set_tooltip(_("Used when dragging a sample to a region's sample reference field.")); |
|
157 |
actionGroup->add(toggle_action); |
actionGroup->add(toggle_action); |
158 |
|
|
159 |
toggle_action = |
toggle_action = |
160 |
Gtk::ToggleAction::create("CopySampleTune", _("Copy Sample's _Fine Tune")); |
Gtk::ToggleAction::create("CopySampleTune", _("Copy Sample's _Fine Tune")); |
161 |
toggle_action->set_active(true); |
toggle_action->set_active(true); |
|
//FIXME: doesn't work, why? |
|
|
toggle_action->set_tooltip(_("Used when dragging a sample to a region's sample reference field.")); |
|
162 |
actionGroup->add(toggle_action); |
actionGroup->add(toggle_action); |
163 |
|
|
164 |
toggle_action = |
toggle_action = |
165 |
Gtk::ToggleAction::create("CopySampleLoop", _("Copy Sample's _Loop Points")); |
Gtk::ToggleAction::create("CopySampleLoop", _("Copy Sample's _Loop Points")); |
166 |
toggle_action->set_active(true); |
toggle_action->set_active(true); |
|
//FIXME: doesn't work, why? |
|
|
toggle_action->set_tooltip(_("Used when dragging a sample to a region's sample reference field.")); |
|
167 |
actionGroup->add(toggle_action); |
actionGroup->add(toggle_action); |
168 |
|
|
169 |
|
|
194 |
sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument) |
sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument) |
195 |
); |
); |
196 |
|
|
197 |
|
|
198 |
|
actionGroup->add(Gtk::Action::create("MenuSettings", _("_Settings"))); |
199 |
|
|
200 |
|
toggle_action = |
201 |
|
Gtk::ToggleAction::create("WarnUserOnExtensions", _("Show warning on format _extensions")); |
202 |
|
toggle_action->set_active(Settings::singleton()->warnUserOnExtensions); |
203 |
|
actionGroup->add( |
204 |
|
toggle_action, |
205 |
|
sigc::mem_fun(*this, &MainWindow::on_action_warn_user_on_extensions) |
206 |
|
); |
207 |
|
|
208 |
|
|
209 |
|
actionGroup->add(Gtk::Action::create("MenuTools", _("_Tools"))); |
210 |
|
|
211 |
|
actionGroup->add( |
212 |
|
Gtk::Action::create("CombineInstruments", _("_Combine Instruments...")), |
213 |
|
sigc::mem_fun(*this, &MainWindow::on_action_combine_instruments) |
214 |
|
); |
215 |
|
|
216 |
|
actionGroup->add( |
217 |
|
Gtk::Action::create("MergeFiles", _("_Merge Files...")), |
218 |
|
sigc::mem_fun(*this, &MainWindow::on_action_merge_files) |
219 |
|
); |
220 |
|
|
221 |
|
|
222 |
// sample right-click popup actions |
// sample right-click popup actions |
223 |
actionGroup->add( |
actionGroup->add( |
224 |
Gtk::Action::create("SampleProperties", Gtk::Stock::PROPERTIES), |
Gtk::Action::create("SampleProperties", Gtk::Stock::PROPERTIES), |
237 |
sigc::mem_fun(*this, &MainWindow::on_action_remove_sample) |
sigc::mem_fun(*this, &MainWindow::on_action_remove_sample) |
238 |
); |
); |
239 |
actionGroup->add( |
actionGroup->add( |
240 |
|
Gtk::Action::create("ShowSampleRefs", _("Show References...")), |
241 |
|
sigc::mem_fun(*this, &MainWindow::on_action_view_references) |
242 |
|
); |
243 |
|
actionGroup->add( |
244 |
Gtk::Action::create("ReplaceAllSamplesInAllGroups", |
Gtk::Action::create("ReplaceAllSamplesInAllGroups", |
245 |
_("Replace All Samples in All Groups...")), |
_("Replace All Samples in All Groups...")), |
246 |
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) |
247 |
); |
); |
248 |
|
|
249 |
|
// script right-click popup actions |
250 |
|
actionGroup->add( |
251 |
|
Gtk::Action::create("AddScriptGroup", _("Add _Group")), |
252 |
|
sigc::mem_fun(*this, &MainWindow::on_action_add_script_group) |
253 |
|
); |
254 |
|
actionGroup->add( |
255 |
|
Gtk::Action::create("AddScript", _("Add _Script")), |
256 |
|
sigc::mem_fun(*this, &MainWindow::on_action_add_script) |
257 |
|
); |
258 |
|
actionGroup->add( |
259 |
|
Gtk::Action::create("EditScript", _("_Edit Script...")), |
260 |
|
sigc::mem_fun(*this, &MainWindow::on_action_edit_script) |
261 |
|
); |
262 |
|
actionGroup->add( |
263 |
|
Gtk::Action::create("RemoveScript", Gtk::Stock::REMOVE), |
264 |
|
sigc::mem_fun(*this, &MainWindow::on_action_remove_script) |
265 |
|
); |
266 |
|
|
267 |
uiManager = Gtk::UIManager::create(); |
uiManager = Gtk::UIManager::create(); |
268 |
uiManager->insert_action_group(actionGroup); |
uiManager->insert_action_group(actionGroup); |
292 |
" <menu action='MenuView'>" |
" <menu action='MenuView'>" |
293 |
" <menuitem action='Statusbar'/>" |
" <menuitem action='Statusbar'/>" |
294 |
" </menu>" |
" </menu>" |
295 |
|
" <menu action='MenuTools'>" |
296 |
|
" <menuitem action='CombineInstruments'/>" |
297 |
|
" <menuitem action='MergeFiles'/>" |
298 |
|
" </menu>" |
299 |
|
" <menu action='MenuSettings'>" |
300 |
|
" <menuitem action='WarnUserOnExtensions'/>" |
301 |
|
" </menu>" |
302 |
" <menu action='MenuHelp'>" |
" <menu action='MenuHelp'>" |
303 |
" <menuitem action='About'/>" |
" <menuitem action='About'/>" |
304 |
" </menu>" |
" </menu>" |
306 |
" <popup name='PopupMenu'>" |
" <popup name='PopupMenu'>" |
307 |
" <menuitem action='InstrProperties'/>" |
" <menuitem action='InstrProperties'/>" |
308 |
" <menuitem action='MidiRules'/>" |
" <menuitem action='MidiRules'/>" |
309 |
|
" <menuitem action='ScriptSlots'/>" |
310 |
" <menuitem action='AddInstrument'/>" |
" <menuitem action='AddInstrument'/>" |
311 |
" <menuitem action='DupInstrument'/>" |
" <menuitem action='DupInstrument'/>" |
312 |
" <separator/>" |
" <separator/>" |
316 |
" <menuitem action='SampleProperties'/>" |
" <menuitem action='SampleProperties'/>" |
317 |
" <menuitem action='AddGroup'/>" |
" <menuitem action='AddGroup'/>" |
318 |
" <menuitem action='AddSample'/>" |
" <menuitem action='AddSample'/>" |
319 |
|
" <menuitem action='ShowSampleRefs'/>" |
320 |
" <menuitem action='ReplaceAllSamplesInAllGroups' />" |
" <menuitem action='ReplaceAllSamplesInAllGroups' />" |
321 |
" <separator/>" |
" <separator/>" |
322 |
" <menuitem action='RemoveSample'/>" |
" <menuitem action='RemoveSample'/>" |
323 |
" </popup>" |
" </popup>" |
324 |
|
" <popup name='ScriptPopupMenu'>" |
325 |
|
" <menuitem action='AddScriptGroup'/>" |
326 |
|
" <menuitem action='AddScript'/>" |
327 |
|
" <menuitem action='EditScript'/>" |
328 |
|
" <separator/>" |
329 |
|
" <menuitem action='RemoveScript'/>" |
330 |
|
" </popup>" |
331 |
"</ui>"; |
"</ui>"; |
332 |
uiManager->add_ui_from_string(ui_info); |
uiManager->add_ui_from_string(ui_info); |
333 |
|
|
334 |
popup_menu = dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/PopupMenu")); |
popup_menu = dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/PopupMenu")); |
335 |
|
|
336 |
|
// Set tooltips for menu items (for some reason, setting a tooltip on the |
337 |
|
// respective Gtk::Action objects above will simply be ignored, no matter |
338 |
|
// if using Gtk::Action::set_tooltip() or passing the tooltip string on |
339 |
|
// Gtk::Action::create()). |
340 |
|
{ |
341 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
342 |
|
uiManager->get_widget("/MenuBar/MenuEdit/CopySampleUnity")); |
343 |
|
item->set_tooltip_text(_("Used when dragging a sample to a region's sample reference field. You may disable this for example if you want to replace an existing sample in a region with a new sample, but don't want that the region's current unity note setting will be altered by this action.")); |
344 |
|
} |
345 |
|
{ |
346 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
347 |
|
uiManager->get_widget("/MenuBar/MenuEdit/CopySampleTune")); |
348 |
|
item->set_tooltip_text(_("Used when dragging a sample to a region's sample reference field. You may disable this for example if you want to replace an existing sample in a region with a new sample, but don't want that the region's current sample playback tuning will be altered by this action.")); |
349 |
|
} |
350 |
|
{ |
351 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
352 |
|
uiManager->get_widget("/MenuBar/MenuEdit/CopySampleLoop")); |
353 |
|
item->set_tooltip_text(_("Used when dragging a sample to a region's sample reference field. You may disable this for example if you want to replace an existing sample in a region with a new sample, but don't want that the region's current loop informations to be altered by this action.")); |
354 |
|
} |
355 |
|
{ |
356 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
357 |
|
uiManager->get_widget("/MenuBar/MenuSettings/WarnUserOnExtensions")); |
358 |
|
item->set_tooltip_text(_("If checked, a warning will be shown whenever you try to use a feature which is based on a LinuxSampler extension ontop of the original gig format, which would not work with the Gigasampler/GigaStudio application.")); |
359 |
|
} |
360 |
|
{ |
361 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
362 |
|
uiManager->get_widget("/MenuBar/MenuTools/CombineInstruments")); |
363 |
|
item->set_tooltip_text(_("Create combi sounds out of individual sounds of this .gig file.")); |
364 |
|
} |
365 |
|
{ |
366 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
367 |
|
uiManager->get_widget("/MenuBar/MenuTools/MergeFiles")); |
368 |
|
item->set_tooltip_text(_("Add instruments and samples of other .gig files to this .gig file.")); |
369 |
|
} |
370 |
|
|
371 |
|
|
372 |
instrument_menu = static_cast<Gtk::MenuItem*>( |
instrument_menu = static_cast<Gtk::MenuItem*>( |
373 |
uiManager->get_widget("/MenuBar/MenuInstrument"))->get_submenu(); |
uiManager->get_widget("/MenuBar/MenuInstrument"))->get_submenu(); |
396 |
// Create the Tree model: |
// Create the Tree model: |
397 |
m_refTreeModel = Gtk::ListStore::create(m_Columns); |
m_refTreeModel = Gtk::ListStore::create(m_Columns); |
398 |
m_TreeView.set_model(m_refTreeModel); |
m_TreeView.set_model(m_refTreeModel); |
399 |
|
m_TreeView.set_tooltip_text(_("Right click here for actions on instruments & MIDI Rules.")); |
400 |
instrument_name_connection = m_refTreeModel->signal_row_changed().connect( |
instrument_name_connection = m_refTreeModel->signal_row_changed().connect( |
401 |
sigc::mem_fun(*this, &MainWindow::instrument_name_changed) |
sigc::mem_fun(*this, &MainWindow::instrument_name_changed) |
402 |
); |
); |
408 |
// create samples treeview (including its data model) |
// create samples treeview (including its data model) |
409 |
m_refSamplesTreeModel = SamplesTreeStore::create(m_SamplesModel); |
m_refSamplesTreeModel = SamplesTreeStore::create(m_SamplesModel); |
410 |
m_TreeViewSamples.set_model(m_refSamplesTreeModel); |
m_TreeViewSamples.set_model(m_refSamplesTreeModel); |
411 |
|
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.")); |
412 |
// m_TreeViewSamples.set_reorderable(); |
// m_TreeViewSamples.set_reorderable(); |
413 |
m_TreeViewSamples.append_column_editable("Samples", m_SamplesModel.m_col_name); |
m_TreeViewSamples.append_column_editable(_("Name"), m_SamplesModel.m_col_name); |
414 |
m_TreeViewSamples.set_headers_visible(false); |
m_TreeViewSamples.append_column(_("Referenced"), m_SamplesModel.m_col_refcount); |
415 |
|
{ |
416 |
|
Gtk::TreeViewColumn* column = m_TreeViewSamples.get_column(0); |
417 |
|
Gtk::CellRendererText* cellrenderer = |
418 |
|
dynamic_cast<Gtk::CellRendererText*>(column->get_first_cell_renderer()); |
419 |
|
column->add_attribute( |
420 |
|
cellrenderer->property_foreground(), m_SamplesModel.m_color |
421 |
|
); |
422 |
|
} |
423 |
|
{ |
424 |
|
Gtk::TreeViewColumn* column = m_TreeViewSamples.get_column(1); |
425 |
|
Gtk::CellRendererText* cellrenderer = |
426 |
|
dynamic_cast<Gtk::CellRendererText*>(column->get_first_cell_renderer()); |
427 |
|
column->add_attribute( |
428 |
|
cellrenderer->property_foreground(), m_SamplesModel.m_color |
429 |
|
); |
430 |
|
} |
431 |
|
m_TreeViewSamples.set_headers_visible(true); |
432 |
m_TreeViewSamples.signal_button_press_event().connect_notify( |
m_TreeViewSamples.signal_button_press_event().connect_notify( |
433 |
sigc::mem_fun(*this, &MainWindow::on_sample_treeview_button_release) |
sigc::mem_fun(*this, &MainWindow::on_sample_treeview_button_release) |
434 |
); |
); |
436 |
sigc::mem_fun(*this, &MainWindow::sample_name_changed) |
sigc::mem_fun(*this, &MainWindow::sample_name_changed) |
437 |
); |
); |
438 |
|
|
439 |
|
// create scripts treeview (including its data model) |
440 |
|
m_refScriptsTreeModel = ScriptsTreeStore::create(m_ScriptsModel); |
441 |
|
m_TreeViewScripts.set_model(m_refScriptsTreeModel); |
442 |
|
m_TreeViewScripts.set_tooltip_text(_( |
443 |
|
"Note: instrument scripts are a LinuxSampler extension of the gig " |
444 |
|
"format. This feature will not work with the GigaStudio software!" |
445 |
|
)); |
446 |
|
// m_TreeViewScripts.set_reorderable(); |
447 |
|
m_TreeViewScripts.append_column_editable("Samples", m_ScriptsModel.m_col_name); |
448 |
|
m_TreeViewScripts.set_headers_visible(false); |
449 |
|
m_TreeViewScripts.signal_button_press_event().connect_notify( |
450 |
|
sigc::mem_fun(*this, &MainWindow::on_script_treeview_button_release) |
451 |
|
); |
452 |
|
m_refScriptsTreeModel->signal_row_changed().connect( |
453 |
|
sigc::mem_fun(*this, &MainWindow::script_name_changed) |
454 |
|
); |
455 |
|
|
456 |
|
// establish drag&drop between scripts tree view and ScriptSlots window |
457 |
|
std::vector<Gtk::TargetEntry> drag_target_gig_script; |
458 |
|
drag_target_gig_script.push_back(Gtk::TargetEntry("gig::Script")); |
459 |
|
m_TreeViewScripts.drag_source_set(drag_target_gig_script); |
460 |
|
m_TreeViewScripts.signal_drag_begin().connect( |
461 |
|
sigc::mem_fun(*this, &MainWindow::on_scripts_treeview_drag_begin) |
462 |
|
); |
463 |
|
m_TreeViewScripts.signal_drag_data_get().connect( |
464 |
|
sigc::mem_fun(*this, &MainWindow::on_scripts_treeview_drag_data_get) |
465 |
|
); |
466 |
|
|
467 |
// 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 |
468 |
std::vector<Gtk::TargetEntry> drag_target_gig_sample; |
std::vector<Gtk::TargetEntry> drag_target_gig_sample; |
469 |
drag_target_gig_sample.push_back(Gtk::TargetEntry("gig::Sample")); |
drag_target_gig_sample.push_back(Gtk::TargetEntry("gig::Sample")); |
497 |
dimreg_changed_signal.make_slot()); |
dimreg_changed_signal.make_slot()); |
498 |
dimreg_edit.signal_sample_ref_changed().connect( |
dimreg_edit.signal_sample_ref_changed().connect( |
499 |
sample_ref_changed_signal.make_slot()); |
sample_ref_changed_signal.make_slot()); |
500 |
|
sample_ref_changed_signal.connect( |
501 |
|
sigc::mem_fun(*this, &MainWindow::on_sample_ref_changed) |
502 |
|
); |
503 |
|
samples_to_be_removed_signal.connect( |
504 |
|
sigc::mem_fun(*this, &MainWindow::on_samples_to_be_removed) |
505 |
|
); |
506 |
|
|
507 |
m_RegionChooser.signal_instrument_struct_to_be_changed().connect( |
m_RegionChooser.signal_instrument_struct_to_be_changed().connect( |
508 |
sigc::hide( |
sigc::hide( |
544 |
|
|
545 |
// start with a new gig file by default |
// start with a new gig file by default |
546 |
on_action_file_new(); |
on_action_file_new(); |
547 |
|
|
548 |
|
// select 'Instruments' tab by default |
549 |
|
// (gtk allows this only if the tab childs are visible, thats why it's here) |
550 |
|
m_TreeViewNotebook.set_current_page(1); |
551 |
} |
} |
552 |
|
|
553 |
MainWindow::~MainWindow() |
MainWindow::~MainWindow() |
726 |
// clear the samples and instruments tree views |
// clear the samples and instruments tree views |
727 |
m_refTreeModel->clear(); |
m_refTreeModel->clear(); |
728 |
m_refSamplesTreeModel->clear(); |
m_refSamplesTreeModel->clear(); |
729 |
|
m_refScriptsTreeModel->clear(); |
730 |
// remove all entries from "Instrument" menu |
// remove all entries from "Instrument" menu |
731 |
while (!instrument_menu->get_children().empty()) { |
while (!instrument_menu->get_children().empty()) { |
732 |
remove_instrument_from_menu(0); |
remove_instrument_from_menu(0); |
737 |
set_file_is_shared(false); |
set_file_is_shared(false); |
738 |
} |
} |
739 |
|
|
740 |
|
void MainWindow::__refreshEntireGUI() { |
741 |
|
// clear the samples and instruments tree views |
742 |
|
m_refTreeModel->clear(); |
743 |
|
m_refSamplesTreeModel->clear(); |
744 |
|
m_refScriptsTreeModel->clear(); |
745 |
|
// remove all entries from "Instrument" menu |
746 |
|
while (!instrument_menu->get_children().empty()) { |
747 |
|
remove_instrument_from_menu(0); |
748 |
|
} |
749 |
|
|
750 |
|
if (!this->file) return; |
751 |
|
|
752 |
|
load_gig( |
753 |
|
this->file, this->file->pInfo->Name.c_str(), this->file_is_shared |
754 |
|
); |
755 |
|
} |
756 |
|
|
757 |
void MainWindow::on_action_file_new() |
void MainWindow::on_action_file_new() |
758 |
{ |
{ |
759 |
if (!file_is_shared && file_is_changed && !close_confirmation_dialog()) return; |
if (!file_is_shared && file_is_changed && !close_confirmation_dialog()) return; |
1118 |
propDialog.deiconify(); |
propDialog.deiconify(); |
1119 |
} |
} |
1120 |
|
|
1121 |
|
void MainWindow::on_action_warn_user_on_extensions() { |
1122 |
|
Settings::singleton()->warnUserOnExtensions = |
1123 |
|
!Settings::singleton()->warnUserOnExtensions; |
1124 |
|
} |
1125 |
|
|
1126 |
void MainWindow::on_action_help_about() |
void MainWindow::on_action_help_about() |
1127 |
{ |
{ |
1128 |
Gtk::AboutDialog dialog; |
Gtk::AboutDialog dialog; |
1152 |
} |
} |
1153 |
|
|
1154 |
PropDialog::PropDialog() |
PropDialog::PropDialog() |
1155 |
: eName(_("Name")), |
: eFileFormat(_("File Format")), |
1156 |
|
eName(_("Name")), |
1157 |
eCreationDate(_("Creation date")), |
eCreationDate(_("Creation date")), |
1158 |
eComments(_("Comments")), |
eComments(_("Comments")), |
1159 |
eProduct(_("Product")), |
eProduct(_("Product")), |
1170 |
eCommissioned(_("Commissioned")), |
eCommissioned(_("Commissioned")), |
1171 |
eSubject(_("Subject")), |
eSubject(_("Subject")), |
1172 |
quitButton(Gtk::Stock::CLOSE), |
quitButton(Gtk::Stock::CLOSE), |
1173 |
table(2, 1) |
table(2, 1), |
1174 |
|
m_file(NULL) |
1175 |
{ |
{ |
1176 |
set_title(_("File Properties")); |
set_title(_("File Properties")); |
1177 |
eName.set_width_chars(50); |
eName.set_width_chars(50); |
1193 |
connect(eCommissioned, &DLS::Info::Commissioned); |
connect(eCommissioned, &DLS::Info::Commissioned); |
1194 |
connect(eSubject, &DLS::Info::Subject); |
connect(eSubject, &DLS::Info::Subject); |
1195 |
|
|
1196 |
|
table.add(eFileFormat); |
1197 |
table.add(eName); |
table.add(eName); |
1198 |
table.add(eCreationDate); |
table.add(eCreationDate); |
1199 |
table.add(eComments); |
table.add(eComments); |
1224 |
quitButton.grab_focus(); |
quitButton.grab_focus(); |
1225 |
quitButton.signal_clicked().connect( |
quitButton.signal_clicked().connect( |
1226 |
sigc::mem_fun(*this, &PropDialog::hide)); |
sigc::mem_fun(*this, &PropDialog::hide)); |
1227 |
|
eFileFormat.signal_value_changed().connect( |
1228 |
|
sigc::mem_fun(*this, &PropDialog::onFileFormatChanged)); |
1229 |
|
|
1230 |
quitButton.show(); |
quitButton.show(); |
1231 |
vbox.show(); |
vbox.show(); |
1232 |
show_all_children(); |
show_all_children(); |
1233 |
} |
} |
1234 |
|
|
1235 |
|
void PropDialog::set_file(gig::File* file) |
1236 |
|
{ |
1237 |
|
m_file = file; |
1238 |
|
|
1239 |
|
// update file format version combo box |
1240 |
|
const std::string sGiga = "Gigasampler/GigaStudio v"; |
1241 |
|
const int major = file->pVersion->major; |
1242 |
|
std::vector<std::string> txts; |
1243 |
|
std::vector<int> values; |
1244 |
|
txts.push_back(sGiga + "2"); values.push_back(2); |
1245 |
|
txts.push_back(sGiga + "3/v4"); values.push_back(3); |
1246 |
|
if (major != 2 && major != 3) { |
1247 |
|
txts.push_back(sGiga + ToString(major)); values.push_back(major); |
1248 |
|
} |
1249 |
|
std::vector<const char*> texts; |
1250 |
|
for (int i = 0; i < txts.size(); ++i) texts.push_back(txts[i].c_str()); |
1251 |
|
texts.push_back(NULL); values.push_back(0); |
1252 |
|
eFileFormat.set_choices(&texts[0], &values[0]); |
1253 |
|
eFileFormat.set_value(major); |
1254 |
|
} |
1255 |
|
|
1256 |
|
void PropDialog::onFileFormatChanged() { |
1257 |
|
const int major = eFileFormat.get_value(); |
1258 |
|
if (m_file) m_file->pVersion->major = major; |
1259 |
|
} |
1260 |
|
|
1261 |
void PropDialog::set_info(DLS::Info* info) |
void PropDialog::set_info(DLS::Info* info) |
1262 |
{ |
{ |
1263 |
update(info); |
update(info); |
1389 |
} |
} |
1390 |
} |
} |
1391 |
|
|
1392 |
|
void MainWindow::updateSampleRefCountMap(gig::File* gig) { |
1393 |
|
sample_ref_count.clear(); |
1394 |
|
|
1395 |
|
if (!gig) return; |
1396 |
|
|
1397 |
|
for (gig::Instrument* instrument = gig->GetFirstInstrument(); instrument; |
1398 |
|
instrument = gig->GetNextInstrument()) |
1399 |
|
{ |
1400 |
|
for (gig::Region* rgn = instrument->GetFirstRegion(); rgn; |
1401 |
|
rgn = instrument->GetNextRegion()) |
1402 |
|
{ |
1403 |
|
for (int i = 0; i < 256; ++i) { |
1404 |
|
if (!rgn->pDimensionRegions[i]) continue; |
1405 |
|
if (rgn->pDimensionRegions[i]->pSample) { |
1406 |
|
sample_ref_count[rgn->pDimensionRegions[i]->pSample]++; |
1407 |
|
} |
1408 |
|
} |
1409 |
|
} |
1410 |
|
} |
1411 |
|
} |
1412 |
|
|
1413 |
void MainWindow::load_gig(gig::File* gig, const char* filename, bool isSharedInstrument) |
void MainWindow::load_gig(gig::File* gig, const char* filename, bool isSharedInstrument) |
1414 |
{ |
{ |
1415 |
file = 0; |
file = 0; |
1420 |
file_has_name = filename; |
file_has_name = filename; |
1421 |
file_is_changed = false; |
file_is_changed = false; |
1422 |
|
|
1423 |
|
propDialog.set_file(gig); |
1424 |
propDialog.set_info(gig->pInfo); |
propDialog.set_info(gig->pInfo); |
1425 |
|
|
1426 |
instrument_name_connection.block(); |
instrument_name_connection.block(); |
1438 |
instrument_name_connection.unblock(); |
instrument_name_connection.unblock(); |
1439 |
uiManager->get_widget("/MenuBar/MenuInstrument")->show(); |
uiManager->get_widget("/MenuBar/MenuInstrument")->show(); |
1440 |
|
|
1441 |
|
updateSampleRefCountMap(gig); |
1442 |
|
|
1443 |
for (gig::Group* group = gig->GetFirstGroup(); group; group = gig->GetNextGroup()) { |
for (gig::Group* group = gig->GetFirstGroup(); group; group = gig->GetNextGroup()) { |
1444 |
if (group->Name != "") { |
if (group->Name != "") { |
1445 |
Gtk::TreeModel::iterator iterGroup = m_refSamplesTreeModel->append(); |
Gtk::TreeModel::iterator iterGroup = m_refSamplesTreeModel->append(); |
1456 |
gig_to_utf8(sample->pInfo->Name); |
gig_to_utf8(sample->pInfo->Name); |
1457 |
rowSample[m_SamplesModel.m_col_sample] = sample; |
rowSample[m_SamplesModel.m_col_sample] = sample; |
1458 |
rowSample[m_SamplesModel.m_col_group] = NULL; |
rowSample[m_SamplesModel.m_col_group] = NULL; |
1459 |
|
int refcount = sample_ref_count.count(sample) ? sample_ref_count[sample] : 0; |
1460 |
|
rowSample[m_SamplesModel.m_col_refcount] = ToString(refcount) + " " + _("Refs."); |
1461 |
|
rowSample[m_SamplesModel.m_color] = refcount ? "black" : "gray"; |
1462 |
} |
} |
1463 |
} |
} |
1464 |
} |
} |
1465 |
|
|
1466 |
|
for (int i = 0; gig->GetScriptGroup(i); ++i) { |
1467 |
|
gig::ScriptGroup* group = gig->GetScriptGroup(i); |
1468 |
|
|
1469 |
|
Gtk::TreeModel::iterator iterGroup = m_refScriptsTreeModel->append(); |
1470 |
|
Gtk::TreeModel::Row rowGroup = *iterGroup; |
1471 |
|
rowGroup[m_ScriptsModel.m_col_name] = gig_to_utf8(group->Name); |
1472 |
|
rowGroup[m_ScriptsModel.m_col_group] = group; |
1473 |
|
rowGroup[m_ScriptsModel.m_col_script] = NULL; |
1474 |
|
for (int s = 0; group->GetScript(s); ++s) { |
1475 |
|
gig::Script* script = group->GetScript(s); |
1476 |
|
|
1477 |
|
Gtk::TreeModel::iterator iterScript = |
1478 |
|
m_refScriptsTreeModel->append(rowGroup.children()); |
1479 |
|
Gtk::TreeModel::Row rowScript = *iterScript; |
1480 |
|
rowScript[m_ScriptsModel.m_col_name] = gig_to_utf8(script->Name); |
1481 |
|
rowScript[m_ScriptsModel.m_col_script] = script; |
1482 |
|
rowScript[m_ScriptsModel.m_col_group] = NULL; |
1483 |
|
} |
1484 |
|
} |
1485 |
|
// unfold all sample groups & script groups by default |
1486 |
|
m_TreeViewSamples.expand_all(); |
1487 |
|
m_TreeViewScripts.expand_all(); |
1488 |
|
|
1489 |
file = gig; |
file = gig; |
1490 |
|
|
1553 |
} |
} |
1554 |
} |
} |
1555 |
|
|
1556 |
|
void MainWindow::show_script_slots() { |
1557 |
|
if (!file) return; |
1558 |
|
// get selected instrument |
1559 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
1560 |
|
Gtk::TreeModel::iterator it = sel->get_selected(); |
1561 |
|
if (!it) return; |
1562 |
|
Gtk::TreeModel::Row row = *it; |
1563 |
|
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
1564 |
|
if (!instrument) return; |
1565 |
|
|
1566 |
|
ScriptSlots* window = new ScriptSlots; |
1567 |
|
window->setInstrument(instrument); |
1568 |
|
//window->reparent(*this); |
1569 |
|
window->show(); |
1570 |
|
} |
1571 |
|
|
1572 |
void MainWindow::on_action_view_status_bar() { |
void MainWindow::on_action_view_status_bar() { |
1573 |
Gtk::CheckMenuItem* item = |
Gtk::CheckMenuItem* item = |
1574 |
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/Statusbar")); |
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/Statusbar")); |
1658 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(group_selected || sample_selected); |
1659 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddGroup"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddGroup"))-> |
1660 |
set_sensitive(file); |
set_sensitive(file); |
1661 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/ShowSampleRefs"))-> |
1662 |
|
set_sensitive(sample_selected); |
1663 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/RemoveSample"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/RemoveSample"))-> |
1664 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(group_selected || sample_selected); |
1665 |
// show sample popup |
// show sample popup |
1667 |
} |
} |
1668 |
} |
} |
1669 |
|
|
1670 |
|
void MainWindow::on_script_treeview_button_release(GdkEventButton* button) { |
1671 |
|
if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
1672 |
|
Gtk::Menu* script_popup = |
1673 |
|
dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/ScriptPopupMenu")); |
1674 |
|
// update enabled/disabled state of sample popup items |
1675 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewScripts.get_selection(); |
1676 |
|
Gtk::TreeModel::iterator it = sel->get_selected(); |
1677 |
|
bool group_selected = false; |
1678 |
|
bool script_selected = false; |
1679 |
|
if (it) { |
1680 |
|
Gtk::TreeModel::Row row = *it; |
1681 |
|
group_selected = row[m_ScriptsModel.m_col_group]; |
1682 |
|
script_selected = row[m_ScriptsModel.m_col_script]; |
1683 |
|
} |
1684 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/ScriptPopupMenu/AddScript"))-> |
1685 |
|
set_sensitive(group_selected || script_selected); |
1686 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/ScriptPopupMenu/AddScriptGroup"))-> |
1687 |
|
set_sensitive(file); |
1688 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/ScriptPopupMenu/EditScript"))-> |
1689 |
|
set_sensitive(script_selected); |
1690 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/ScriptPopupMenu/RemoveScript"))-> |
1691 |
|
set_sensitive(group_selected || script_selected); |
1692 |
|
// show sample popup |
1693 |
|
script_popup->popup(button->button, button->time); |
1694 |
|
} |
1695 |
|
} |
1696 |
|
|
1697 |
Gtk::RadioMenuItem* MainWindow::add_instrument_to_menu( |
Gtk::RadioMenuItem* MainWindow::add_instrument_to_menu( |
1698 |
const Glib::ustring& name, int position) { |
const Glib::ustring& name, int position) { |
1840 |
msg.run(); |
msg.run(); |
1841 |
} |
} |
1842 |
|
|
1843 |
|
void MainWindow::on_action_add_script_group() { |
1844 |
|
static int __script_indexer = 0; |
1845 |
|
if (!file) return; |
1846 |
|
gig::ScriptGroup* group = file->AddScriptGroup(); |
1847 |
|
group->Name = gig_from_utf8(_("Unnamed Group")); |
1848 |
|
if (__script_indexer) group->Name += " " + ToString(__script_indexer); |
1849 |
|
__script_indexer++; |
1850 |
|
// update sample tree view |
1851 |
|
Gtk::TreeModel::iterator iterGroup = m_refScriptsTreeModel->append(); |
1852 |
|
Gtk::TreeModel::Row rowGroup = *iterGroup; |
1853 |
|
rowGroup[m_ScriptsModel.m_col_name] = gig_to_utf8(group->Name); |
1854 |
|
rowGroup[m_ScriptsModel.m_col_script] = NULL; |
1855 |
|
rowGroup[m_ScriptsModel.m_col_group] = group; |
1856 |
|
file_changed(); |
1857 |
|
} |
1858 |
|
|
1859 |
|
void MainWindow::on_action_add_script() { |
1860 |
|
if (!file) return; |
1861 |
|
// get selected group |
1862 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewScripts.get_selection(); |
1863 |
|
Gtk::TreeModel::iterator it = sel->get_selected(); |
1864 |
|
if (!it) return; |
1865 |
|
Gtk::TreeModel::Row row = *it; |
1866 |
|
gig::ScriptGroup* group = row[m_ScriptsModel.m_col_group]; |
1867 |
|
if (!group) { // not a group, but a script is selected (probably) |
1868 |
|
gig::Script* script = row[m_ScriptsModel.m_col_script]; |
1869 |
|
if (!script) return; |
1870 |
|
it = row.parent(); // resolve parent (that is the script's group) |
1871 |
|
if (!it) return; |
1872 |
|
row = *it; |
1873 |
|
group = row[m_ScriptsModel.m_col_group]; |
1874 |
|
if (!group) return; |
1875 |
|
} |
1876 |
|
|
1877 |
|
// add a new script to the .gig file |
1878 |
|
gig::Script* script = group->AddScript(); |
1879 |
|
Glib::ustring name = _("Unnamed Script"); |
1880 |
|
script->Name = gig_from_utf8(name); |
1881 |
|
|
1882 |
|
// add script to the tree view |
1883 |
|
Gtk::TreeModel::iterator iterScript = |
1884 |
|
m_refScriptsTreeModel->append(row.children()); |
1885 |
|
Gtk::TreeModel::Row rowScript = *iterScript; |
1886 |
|
rowScript[m_ScriptsModel.m_col_name] = name; |
1887 |
|
rowScript[m_ScriptsModel.m_col_script] = script; |
1888 |
|
rowScript[m_ScriptsModel.m_col_group] = NULL; |
1889 |
|
|
1890 |
|
// unfold group of new script item in treeview |
1891 |
|
Gtk::TreeModel::Path path(iterScript); |
1892 |
|
m_TreeViewScripts.expand_to_path(path); |
1893 |
|
} |
1894 |
|
|
1895 |
|
void MainWindow::on_action_edit_script() { |
1896 |
|
if (!file) return; |
1897 |
|
// get selected script |
1898 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewScripts.get_selection(); |
1899 |
|
Gtk::TreeModel::iterator it = sel->get_selected(); |
1900 |
|
if (!it) return; |
1901 |
|
Gtk::TreeModel::Row row = *it; |
1902 |
|
gig::Script* script = row[m_ScriptsModel.m_col_script]; |
1903 |
|
if (!script) return; |
1904 |
|
|
1905 |
|
ScriptEditor* editor = new ScriptEditor; |
1906 |
|
editor->setScript(script); |
1907 |
|
//editor->reparent(*this); |
1908 |
|
editor->show(); |
1909 |
|
} |
1910 |
|
|
1911 |
|
void MainWindow::on_action_remove_script() { |
1912 |
|
if (!file) return; |
1913 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewScripts.get_selection(); |
1914 |
|
Gtk::TreeModel::iterator it = sel->get_selected(); |
1915 |
|
if (it) { |
1916 |
|
Gtk::TreeModel::Row row = *it; |
1917 |
|
gig::ScriptGroup* group = row[m_ScriptsModel.m_col_group]; |
1918 |
|
gig::Script* script = row[m_ScriptsModel.m_col_script]; |
1919 |
|
Glib::ustring name = row[m_ScriptsModel.m_col_name]; |
1920 |
|
try { |
1921 |
|
// remove script group or script from the gig file |
1922 |
|
if (group) { |
1923 |
|
// notify everybody that we're going to remove these samples |
1924 |
|
//TODO: scripts_to_be_removed_signal.emit(members); |
1925 |
|
// delete the group in the .gig file including the |
1926 |
|
// samples that belong to the group |
1927 |
|
file->DeleteScriptGroup(group); |
1928 |
|
// notify that we're done with removal |
1929 |
|
//TODO: scripts_removed_signal.emit(); |
1930 |
|
file_changed(); |
1931 |
|
} else if (script) { |
1932 |
|
// notify everybody that we're going to remove this sample |
1933 |
|
//TODO: std::list<gig::Script*> lscripts; |
1934 |
|
//TODO: lscripts.push_back(script); |
1935 |
|
//TODO: scripts_to_be_removed_signal.emit(lscripts); |
1936 |
|
// remove sample from the .gig file |
1937 |
|
script->GetGroup()->DeleteScript(script); |
1938 |
|
// notify that we're done with removal |
1939 |
|
//TODO: scripts_removed_signal.emit(); |
1940 |
|
dimreg_changed(); |
1941 |
|
file_changed(); |
1942 |
|
} |
1943 |
|
// remove respective row(s) from samples tree view |
1944 |
|
m_refScriptsTreeModel->erase(it); |
1945 |
|
} catch (RIFF::Exception e) { |
1946 |
|
// pretend we're done with removal (i.e. to avoid dead locks) |
1947 |
|
//TODO: scripts_removed_signal.emit(); |
1948 |
|
// show error message |
1949 |
|
Gtk::MessageDialog msg(*this, e.Message.c_str(), false, Gtk::MESSAGE_ERROR); |
1950 |
|
msg.run(); |
1951 |
|
} |
1952 |
|
} |
1953 |
|
} |
1954 |
|
|
1955 |
void MainWindow::on_action_add_group() { |
void MainWindow::on_action_add_group() { |
1956 |
static int __sample_indexer = 0; |
static int __sample_indexer = 0; |
1957 |
if (!file) return; |
if (!file) return; |
2321 |
} |
} |
2322 |
} |
} |
2323 |
|
|
2324 |
|
// see comment on on_sample_treeview_drag_begin() |
2325 |
|
void MainWindow::on_scripts_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context) |
2326 |
|
{ |
2327 |
|
first_call_to_drag_data_get = true; |
2328 |
|
} |
2329 |
|
|
2330 |
|
void MainWindow::on_scripts_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&, |
2331 |
|
Gtk::SelectionData& selection_data, guint, guint) |
2332 |
|
{ |
2333 |
|
if (!first_call_to_drag_data_get) return; |
2334 |
|
first_call_to_drag_data_get = false; |
2335 |
|
|
2336 |
|
// get selected script |
2337 |
|
gig::Script* script = NULL; |
2338 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewScripts.get_selection(); |
2339 |
|
Gtk::TreeModel::iterator it = sel->get_selected(); |
2340 |
|
if (it) { |
2341 |
|
Gtk::TreeModel::Row row = *it; |
2342 |
|
script = row[m_ScriptsModel.m_col_script]; |
2343 |
|
} |
2344 |
|
// pass the gig::Script as pointer |
2345 |
|
selection_data.set(selection_data.get_target(), 0/*unused*/, |
2346 |
|
(const guchar*)&script, |
2347 |
|
sizeof(script)/*length of data in bytes*/); |
2348 |
|
} |
2349 |
|
|
2350 |
// For some reason drag_data_get gets called two times for each |
// For some reason drag_data_get gets called two times for each |
2351 |
// 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 |
2352 |
// 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 |
2405 |
bool channels_changed = false; |
bool channels_changed = false; |
2406 |
if (sample->Channels == 1 && stereo_dimension) { |
if (sample->Channels == 1 && stereo_dimension) { |
2407 |
// remove the samplechannel dimension |
// remove the samplechannel dimension |
2408 |
|
/* commented out, because it makes it impossible building up an instrument from scratch using two separate L/R samples |
2409 |
region->DeleteDimension(stereo_dimension); |
region->DeleteDimension(stereo_dimension); |
2410 |
channels_changed = true; |
channels_changed = true; |
2411 |
region_changed(); |
region_changed(); |
2412 |
|
*/ |
2413 |
} |
} |
2414 |
dimreg_edit.set_sample( |
dimreg_edit.set_sample( |
2415 |
sample, |
sample, |
2475 |
} |
} |
2476 |
} |
} |
2477 |
|
|
2478 |
|
void MainWindow::script_name_changed(const Gtk::TreeModel::Path& path, |
2479 |
|
const Gtk::TreeModel::iterator& iter) { |
2480 |
|
if (!iter) return; |
2481 |
|
Gtk::TreeModel::Row row = *iter; |
2482 |
|
Glib::ustring name = row[m_ScriptsModel.m_col_name]; |
2483 |
|
gig::ScriptGroup* group = row[m_ScriptsModel.m_col_group]; |
2484 |
|
gig::Script* script = row[m_ScriptsModel.m_col_script]; |
2485 |
|
gig::String gigname(gig_from_utf8(name)); |
2486 |
|
if (group) { |
2487 |
|
if (group->Name != gigname) { |
2488 |
|
group->Name = gigname; |
2489 |
|
printf("script group name changed\n"); |
2490 |
|
file_changed(); |
2491 |
|
} |
2492 |
|
} else if (script) { |
2493 |
|
if (script->Name != gigname) { |
2494 |
|
script->Name = gigname; |
2495 |
|
printf("script name changed\n"); |
2496 |
|
file_changed(); |
2497 |
|
} |
2498 |
|
} |
2499 |
|
} |
2500 |
|
|
2501 |
void MainWindow::instrument_name_changed(const Gtk::TreeModel::Path& path, |
void MainWindow::instrument_name_changed(const Gtk::TreeModel::Path& path, |
2502 |
const Gtk::TreeModel::iterator& iter) { |
const Gtk::TreeModel::iterator& iter) { |
2503 |
if (!iter) return; |
if (!iter) return; |
2532 |
} |
} |
2533 |
} |
} |
2534 |
|
|
2535 |
|
void MainWindow::on_action_combine_instruments() { |
2536 |
|
CombineInstrumentsDialog* d = new CombineInstrumentsDialog(*this, file); |
2537 |
|
d->show_all(); |
2538 |
|
d->resize(500, 400); |
2539 |
|
d->run(); |
2540 |
|
if (d->fileWasChanged()) { |
2541 |
|
// update GUI with new instrument just created |
2542 |
|
add_instrument(d->newCombinedInstrument()); |
2543 |
|
} |
2544 |
|
delete d; |
2545 |
|
} |
2546 |
|
|
2547 |
|
void MainWindow::on_action_view_references() { |
2548 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
2549 |
|
Gtk::TreeModel::iterator it = sel->get_selected(); |
2550 |
|
if (!it) return; |
2551 |
|
Gtk::TreeModel::Row row = *it; |
2552 |
|
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
2553 |
|
if (!sample) return; |
2554 |
|
|
2555 |
|
ReferencesView* d = new ReferencesView(*this); |
2556 |
|
d->setSample(sample); |
2557 |
|
d->show_all(); |
2558 |
|
d->resize(500, 400); |
2559 |
|
d->run(); |
2560 |
|
delete d; |
2561 |
|
} |
2562 |
|
|
2563 |
|
void MainWindow::mergeFiles(const std::vector<std::string>& filenames) { |
2564 |
|
struct _Source { |
2565 |
|
std::vector<RIFF::File*> riffs; |
2566 |
|
std::vector<gig::File*> gigs; |
2567 |
|
|
2568 |
|
~_Source() { |
2569 |
|
for (int k = 0; k < gigs.size(); ++k) delete gigs[k]; |
2570 |
|
for (int k = 0; k < riffs.size(); ++k) delete riffs[k]; |
2571 |
|
riffs.clear(); |
2572 |
|
gigs.clear(); |
2573 |
|
} |
2574 |
|
} sources; |
2575 |
|
|
2576 |
|
if (filenames.empty()) |
2577 |
|
throw RIFF::Exception(_("No files selected, so nothing done.")); |
2578 |
|
|
2579 |
|
// first open all input files (to avoid output file corruption) |
2580 |
|
int i; |
2581 |
|
try { |
2582 |
|
for (i = 0; i < filenames.size(); ++i) { |
2583 |
|
const std::string& filename = filenames[i]; |
2584 |
|
printf("opening file=%s\n", filename.c_str()); |
2585 |
|
|
2586 |
|
RIFF::File* riff = new RIFF::File(filename); |
2587 |
|
sources.riffs.push_back(riff); |
2588 |
|
|
2589 |
|
gig::File* gig = new gig::File(riff); |
2590 |
|
sources.gigs.push_back(gig); |
2591 |
|
} |
2592 |
|
} catch (RIFF::Exception e) { |
2593 |
|
throw RIFF::Exception( |
2594 |
|
_("Error occurred while opening '") + |
2595 |
|
filenames[i] + |
2596 |
|
"': " + |
2597 |
|
e.Message |
2598 |
|
); |
2599 |
|
} catch (...) { |
2600 |
|
throw RIFF::Exception( |
2601 |
|
_("Unknown exception occurred while opening '") + |
2602 |
|
filenames[i] + "'" |
2603 |
|
); |
2604 |
|
} |
2605 |
|
|
2606 |
|
// now merge the opened .gig files to the main .gig file currently being |
2607 |
|
// open in gigedit |
2608 |
|
try { |
2609 |
|
for (i = 0; i < filenames.size(); ++i) { |
2610 |
|
const std::string& filename = filenames[i]; |
2611 |
|
printf("merging file=%s\n", filename.c_str()); |
2612 |
|
assert(i < sources.gigs.size()); |
2613 |
|
|
2614 |
|
this->file->AddContentOf(sources.gigs[i]); |
2615 |
|
} |
2616 |
|
} catch (RIFF::Exception e) { |
2617 |
|
throw RIFF::Exception( |
2618 |
|
_("Error occurred while merging '") + |
2619 |
|
filenames[i] + |
2620 |
|
"': " + |
2621 |
|
e.Message |
2622 |
|
); |
2623 |
|
} catch (...) { |
2624 |
|
throw RIFF::Exception( |
2625 |
|
_("Unknown exception occurred while merging '") + |
2626 |
|
filenames[i] + "'" |
2627 |
|
); |
2628 |
|
} |
2629 |
|
|
2630 |
|
// Note: requires that this file already has a filename ! |
2631 |
|
this->file->Save(); |
2632 |
|
} |
2633 |
|
|
2634 |
|
void MainWindow::on_action_merge_files() { |
2635 |
|
if (this->file->GetFileName().empty()) { |
2636 |
|
Glib::ustring txt = _( |
2637 |
|
"You seem to have a new .gig file open that has not been saved " |
2638 |
|
"yet. You must save it somewhere before starting to merge it with " |
2639 |
|
"other .gig files though, because during the merge operation the " |
2640 |
|
"other files' sample data must be written on file level to the " |
2641 |
|
"target .gig file." |
2642 |
|
); |
2643 |
|
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
2644 |
|
msg.run(); |
2645 |
|
return; |
2646 |
|
} |
2647 |
|
|
2648 |
|
Gtk::FileChooserDialog dialog(*this, _("Merge .gig files")); |
2649 |
|
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
2650 |
|
dialog.add_button(_("Merge"), Gtk::RESPONSE_OK); |
2651 |
|
dialog.set_default_response(Gtk::RESPONSE_CANCEL); |
2652 |
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
2653 |
|
Gtk::FileFilter filter; |
2654 |
|
filter.add_pattern("*.gig"); |
2655 |
|
#else |
2656 |
|
Glib::RefPtr<Gtk::FileFilter> filter = Gtk::FileFilter::create(); |
2657 |
|
filter->add_pattern("*.gig"); |
2658 |
|
#endif |
2659 |
|
dialog.set_filter(filter); |
2660 |
|
if (current_gig_dir != "") { |
2661 |
|
dialog.set_current_folder(current_gig_dir); |
2662 |
|
} |
2663 |
|
dialog.set_select_multiple(true); |
2664 |
|
|
2665 |
|
// show warning in the file picker dialog |
2666 |
|
Gtk::HBox descriptionArea; |
2667 |
|
descriptionArea.set_spacing(15); |
2668 |
|
Gtk::Image warningIcon(Gtk::Stock::DIALOG_WARNING, Gtk::IconSize(Gtk::ICON_SIZE_DIALOG)); |
2669 |
|
descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK); |
2670 |
|
#if GTKMM_MAJOR_VERSION < 3 |
2671 |
|
view::WrapLabel description; |
2672 |
|
#else |
2673 |
|
Gtk::Label description; |
2674 |
|
description.set_line_wrap(); |
2675 |
|
#endif |
2676 |
|
description.set_markup(_( |
2677 |
|
"\nSelect at least one .gig file that shall be merged to the .gig file " |
2678 |
|
"currently being open in gigedit.\n\n" |
2679 |
|
"<b>Please Note:</b> Merging with other files will modify your " |
2680 |
|
"currently open .gig file on file level! And be aware that the current " |
2681 |
|
"merge algorithm does not detect duplicate samples yet. So if you are " |
2682 |
|
"merging files which are using equivalent sample data, those " |
2683 |
|
"equivalent samples will currently be treated as separate samples and " |
2684 |
|
"will accordingly be stored separately in the target .gig file!" |
2685 |
|
)); |
2686 |
|
descriptionArea.pack_start(description); |
2687 |
|
dialog.get_vbox()->pack_start(descriptionArea, Gtk::PACK_SHRINK); |
2688 |
|
descriptionArea.show_all(); |
2689 |
|
|
2690 |
|
if (dialog.run() == Gtk::RESPONSE_OK) { |
2691 |
|
printf("on_action_merge_files self=%x\n", Glib::Threads::Thread::self()); |
2692 |
|
std::vector<std::string> filenames = dialog.get_filenames(); |
2693 |
|
|
2694 |
|
// merge the selected files to the currently open .gig file |
2695 |
|
try { |
2696 |
|
mergeFiles(filenames); |
2697 |
|
} catch (RIFF::Exception e) { |
2698 |
|
Gtk::MessageDialog msg(*this, e.Message, false, Gtk::MESSAGE_ERROR); |
2699 |
|
msg.run(); |
2700 |
|
} |
2701 |
|
|
2702 |
|
// update GUI |
2703 |
|
__refreshEntireGUI(); |
2704 |
|
} |
2705 |
|
} |
2706 |
|
|
2707 |
void MainWindow::set_file_is_shared(bool b) { |
void MainWindow::set_file_is_shared(bool b) { |
2708 |
this->file_is_shared = b; |
this->file_is_shared = b; |
2709 |
|
|
2720 |
} |
} |
2721 |
} |
} |
2722 |
|
|
2723 |
|
void MainWindow::on_sample_ref_count_incremented(gig::Sample* sample, int offset) { |
2724 |
|
if (!sample) return; |
2725 |
|
sample_ref_count[sample] += offset; |
2726 |
|
const int refcount = sample_ref_count[sample]; |
2727 |
|
|
2728 |
|
Glib::RefPtr<Gtk::TreeModel> model = m_TreeViewSamples.get_model(); |
2729 |
|
for (int g = 0; g < model->children().size(); ++g) { |
2730 |
|
Gtk::TreeModel::Row rowGroup = model->children()[g]; |
2731 |
|
for (int s = 0; s < rowGroup.children().size(); ++s) { |
2732 |
|
Gtk::TreeModel::Row rowSample = rowGroup.children()[s]; |
2733 |
|
if (rowSample[m_SamplesModel.m_col_sample] != sample) continue; |
2734 |
|
rowSample[m_SamplesModel.m_col_refcount] = ToString(refcount) + " " + _("Refs."); |
2735 |
|
rowSample[m_SamplesModel.m_color] = refcount ? "black" : "gray"; |
2736 |
|
} |
2737 |
|
} |
2738 |
|
} |
2739 |
|
|
2740 |
|
void MainWindow::on_sample_ref_changed(gig::Sample* oldSample, gig::Sample* newSample) { |
2741 |
|
on_sample_ref_count_incremented(oldSample, -1); |
2742 |
|
on_sample_ref_count_incremented(newSample, +1); |
2743 |
|
} |
2744 |
|
|
2745 |
|
void MainWindow::on_samples_to_be_removed(std::list<gig::Sample*> samples) { |
2746 |
|
// just in case a new sample is added later with exactly the same memory |
2747 |
|
// address, which would lead to incorrect refcount if not deleted here |
2748 |
|
for (std::list<gig::Sample*>::const_iterator it = samples.begin(); |
2749 |
|
it != samples.end(); it != samples.end()) |
2750 |
|
{ |
2751 |
|
sample_ref_count.erase(*it); |
2752 |
|
} |
2753 |
|
} |
2754 |
|
|
2755 |
sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() { |
sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() { |
2756 |
return file_structure_to_be_changed_signal; |
return file_structure_to_be_changed_signal; |
2757 |
} |
} |