1 |
/* |
/* |
2 |
* Copyright (C) 2006-2014 Andreas Persson |
* Copyright (C) 2006-2016 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 |
20 |
#include <iostream> |
#include <iostream> |
21 |
#include <cstring> |
#include <cstring> |
22 |
|
|
23 |
|
#include <glibmmconfig.h> |
24 |
|
// threads.h must be included first to be able to build with |
25 |
|
// G_DISABLE_DEPRECATED |
26 |
|
#if (GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION == 31 && GLIBMM_MICRO_VERSION >= 2) || \ |
27 |
|
(GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION > 31) || GLIBMM_MAJOR_VERSION > 2 |
28 |
|
#include <glibmm/threads.h> |
29 |
|
#endif |
30 |
|
|
31 |
#include <glibmm/convert.h> |
#include <glibmm/convert.h> |
32 |
#include <glibmm/dispatcher.h> |
#include <glibmm/dispatcher.h> |
33 |
#include <glibmm/miscutils.h> |
#include <glibmm/miscutils.h> |
35 |
#include <gtkmm/aboutdialog.h> |
#include <gtkmm/aboutdialog.h> |
36 |
#include <gtkmm/filechooserdialog.h> |
#include <gtkmm/filechooserdialog.h> |
37 |
#include <gtkmm/messagedialog.h> |
#include <gtkmm/messagedialog.h> |
|
#include <gtkmm/stock.h> |
|
38 |
#include <gtkmm/targetentry.h> |
#include <gtkmm/targetentry.h> |
39 |
#include <gtkmm/main.h> |
#include <gtkmm/main.h> |
40 |
#include <gtkmm/toggleaction.h> |
#include <gtkmm/toggleaction.h> |
60 |
|
|
61 |
|
|
62 |
MainWindow::MainWindow() : |
MainWindow::MainWindow() : |
63 |
|
m_DimRegionChooser(*this), |
64 |
dimreg_label(_("Changes apply to:")), |
dimreg_label(_("Changes apply to:")), |
65 |
dimreg_all_regions(_("all regions")), |
dimreg_all_regions(_("all regions")), |
66 |
dimreg_all_dimregs(_("all dimension splits")), |
dimreg_all_dimregs(_("all dimension splits")), |
117 |
actionGroup = Gtk::ActionGroup::create(); |
actionGroup = Gtk::ActionGroup::create(); |
118 |
|
|
119 |
actionGroup->add(Gtk::Action::create("MenuFile", _("_File"))); |
actionGroup->add(Gtk::Action::create("MenuFile", _("_File"))); |
120 |
actionGroup->add(Gtk::Action::create("New", Gtk::Stock::NEW), |
actionGroup->add(Gtk::Action::create("New", _("_New")), |
121 |
|
Gtk::AccelKey("<control>n"), |
122 |
sigc::mem_fun( |
sigc::mem_fun( |
123 |
*this, &MainWindow::on_action_file_new)); |
*this, &MainWindow::on_action_file_new)); |
124 |
Glib::RefPtr<Gtk::Action> action = |
actionGroup->add(Gtk::Action::create("Open", _("_Open...")), |
125 |
Gtk::Action::create("Open", Gtk::Stock::OPEN); |
Gtk::AccelKey("<control>o"), |
|
action->property_label() = action->property_label() + "..."; |
|
|
actionGroup->add(action, |
|
126 |
sigc::mem_fun( |
sigc::mem_fun( |
127 |
*this, &MainWindow::on_action_file_open)); |
*this, &MainWindow::on_action_file_open)); |
128 |
actionGroup->add(Gtk::Action::create("Save", Gtk::Stock::SAVE), |
actionGroup->add(Gtk::Action::create("Save", _("_Save")), |
129 |
|
Gtk::AccelKey("<control>s"), |
130 |
sigc::mem_fun( |
sigc::mem_fun( |
131 |
*this, &MainWindow::on_action_file_save)); |
*this, &MainWindow::on_action_file_save)); |
132 |
action = Gtk::Action::create("SaveAs", Gtk::Stock::SAVE_AS); |
actionGroup->add(Gtk::Action::create("SaveAs", _("Save _As...")), |
|
action->property_label() = action->property_label() + "..."; |
|
|
actionGroup->add(action, |
|
133 |
Gtk::AccelKey("<shift><control>s"), |
Gtk::AccelKey("<shift><control>s"), |
134 |
sigc::mem_fun( |
sigc::mem_fun( |
135 |
*this, &MainWindow::on_action_file_save_as)); |
*this, &MainWindow::on_action_file_save_as)); |
136 |
actionGroup->add(Gtk::Action::create("Properties", |
actionGroup->add(Gtk::Action::create("Properties", |
137 |
Gtk::Stock::PROPERTIES), |
_("_Properties")), |
138 |
sigc::mem_fun( |
sigc::mem_fun( |
139 |
*this, &MainWindow::on_action_file_properties)); |
*this, &MainWindow::on_action_file_properties)); |
140 |
actionGroup->add(Gtk::Action::create("InstrProperties", |
actionGroup->add(Gtk::Action::create("InstrProperties", |
141 |
Gtk::Stock::PROPERTIES), |
_("_Properties")), |
142 |
sigc::mem_fun( |
sigc::mem_fun( |
143 |
*this, &MainWindow::show_instr_props)); |
*this, &MainWindow::show_instr_props)); |
144 |
actionGroup->add(Gtk::Action::create("MidiRules", |
actionGroup->add(Gtk::Action::create("MidiRules", |
149 |
_("_Script Slots...")), |
_("_Script Slots...")), |
150 |
sigc::mem_fun( |
sigc::mem_fun( |
151 |
*this, &MainWindow::show_script_slots)); |
*this, &MainWindow::show_script_slots)); |
152 |
actionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT), |
actionGroup->add(Gtk::Action::create("Quit", _("_Quit")), |
153 |
|
Gtk::AccelKey("<control>q"), |
154 |
sigc::mem_fun( |
sigc::mem_fun( |
155 |
*this, &MainWindow::on_action_quit)); |
*this, &MainWindow::on_action_quit)); |
156 |
actionGroup->add(Gtk::Action::create("MenuInstrument", _("_Instrument"))); |
actionGroup->add( |
157 |
|
Gtk::Action::create("MenuSample", _("_Sample")), |
158 |
|
sigc::mem_fun(*this, &MainWindow::show_samples_tab) |
159 |
|
); |
160 |
|
actionGroup->add( |
161 |
|
Gtk::Action::create("MenuInstrument", _("_Instrument")), |
162 |
|
sigc::mem_fun(*this, &MainWindow::show_intruments_tab) |
163 |
|
); |
164 |
|
actionGroup->add( |
165 |
|
Gtk::Action::create("MenuScript", _("S_cript")), |
166 |
|
sigc::mem_fun(*this, &MainWindow::show_scripts_tab) |
167 |
|
); |
168 |
|
actionGroup->add(Gtk::Action::create("AllInstruments", _("_Select"))); |
169 |
|
|
170 |
actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit"))); |
actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit"))); |
171 |
|
|
193 |
sigc::mem_fun( |
sigc::mem_fun( |
194 |
*this, &MainWindow::on_action_view_status_bar)); |
*this, &MainWindow::on_action_view_status_bar)); |
195 |
|
|
196 |
action = Gtk::Action::create("MenuHelp", Gtk::Stock::HELP); |
toggle_action = |
197 |
actionGroup->add(Gtk::Action::create("MenuHelp", |
Gtk::ToggleAction::create("AutoRestoreWinDim", _("_Auto Restore Window Dimension")); |
198 |
action->property_label())); |
toggle_action->set_active(Settings::singleton()->autoRestoreWindowDimension); |
199 |
actionGroup->add(Gtk::Action::create("About", Gtk::Stock::ABOUT), |
actionGroup->add(toggle_action, |
200 |
|
sigc::mem_fun( |
201 |
|
*this, &MainWindow::on_auto_restore_win_dim)); |
202 |
|
|
203 |
|
actionGroup->add( |
204 |
|
Gtk::Action::create("RefreshAll", _("_Refresh All")), |
205 |
|
sigc::mem_fun(*this, &MainWindow::on_action_refresh_all) |
206 |
|
); |
207 |
|
|
208 |
|
actionGroup->add(Gtk::Action::create("MenuHelp", _("_Help"))); |
209 |
|
actionGroup->add(Gtk::Action::create("About", _("_About")), |
210 |
sigc::mem_fun( |
sigc::mem_fun( |
211 |
*this, &MainWindow::on_action_help_about)); |
*this, &MainWindow::on_action_help_about)); |
212 |
actionGroup->add( |
actionGroup->add( |
218 |
sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument) |
sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument) |
219 |
); |
); |
220 |
actionGroup->add( |
actionGroup->add( |
221 |
Gtk::Action::create("RemoveInstrument", Gtk::Stock::REMOVE), |
Gtk::Action::create("RemoveInstrument", _("_Remove")), |
222 |
sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument) |
sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument) |
223 |
); |
); |
224 |
|
|
233 |
sigc::mem_fun(*this, &MainWindow::on_action_warn_user_on_extensions) |
sigc::mem_fun(*this, &MainWindow::on_action_warn_user_on_extensions) |
234 |
); |
); |
235 |
|
|
236 |
|
toggle_action = |
237 |
|
Gtk::ToggleAction::create("SyncSamplerInstrumentSelection", _("Synchronize sampler's instrument selection")); |
238 |
|
toggle_action->set_active(Settings::singleton()->syncSamplerInstrumentSelection); |
239 |
|
actionGroup->add( |
240 |
|
toggle_action, |
241 |
|
sigc::mem_fun(*this, &MainWindow::on_action_sync_sampler_instrument_selection) |
242 |
|
); |
243 |
|
|
244 |
|
toggle_action = |
245 |
|
Gtk::ToggleAction::create("MoveRootNoteWithRegionMoved", _("Move root note with region moved")); |
246 |
|
toggle_action->set_active(Settings::singleton()->moveRootNoteWithRegionMoved); |
247 |
|
actionGroup->add( |
248 |
|
toggle_action, |
249 |
|
sigc::mem_fun(*this, &MainWindow::on_action_move_root_note_with_region_moved) |
250 |
|
); |
251 |
|
|
252 |
|
|
253 |
actionGroup->add(Gtk::Action::create("MenuTools", _("_Tools"))); |
actionGroup->add(Gtk::Action::create("MenuTools", _("_Tools"))); |
254 |
|
|
265 |
|
|
266 |
// sample right-click popup actions |
// sample right-click popup actions |
267 |
actionGroup->add( |
actionGroup->add( |
268 |
Gtk::Action::create("SampleProperties", Gtk::Stock::PROPERTIES), |
Gtk::Action::create("SampleProperties", _("_Properties")), |
269 |
sigc::mem_fun(*this, &MainWindow::on_action_sample_properties) |
sigc::mem_fun(*this, &MainWindow::on_action_sample_properties) |
270 |
); |
); |
271 |
actionGroup->add( |
actionGroup->add( |
277 |
sigc::mem_fun(*this, &MainWindow::on_action_add_sample) |
sigc::mem_fun(*this, &MainWindow::on_action_add_sample) |
278 |
); |
); |
279 |
actionGroup->add( |
actionGroup->add( |
280 |
Gtk::Action::create("RemoveSample", Gtk::Stock::REMOVE), |
Gtk::Action::create("RemoveSample", _("_Remove")), |
281 |
sigc::mem_fun(*this, &MainWindow::on_action_remove_sample) |
sigc::mem_fun(*this, &MainWindow::on_action_remove_sample) |
282 |
); |
); |
283 |
actionGroup->add( |
actionGroup->add( |
284 |
|
Gtk::Action::create("RemoveUnusedSamples", _("Remove _Unused Samples")), |
285 |
|
sigc::mem_fun(*this, &MainWindow::on_action_remove_unused_samples) |
286 |
|
); |
287 |
|
actionGroup->add( |
288 |
Gtk::Action::create("ShowSampleRefs", _("Show References...")), |
Gtk::Action::create("ShowSampleRefs", _("Show References...")), |
289 |
sigc::mem_fun(*this, &MainWindow::on_action_view_references) |
sigc::mem_fun(*this, &MainWindow::on_action_view_references) |
290 |
); |
); |
291 |
actionGroup->add( |
actionGroup->add( |
292 |
|
Gtk::Action::create("ReplaceSample", |
293 |
|
_("Replace Sample...")), |
294 |
|
sigc::mem_fun(*this, &MainWindow::on_action_replace_sample) |
295 |
|
); |
296 |
|
actionGroup->add( |
297 |
Gtk::Action::create("ReplaceAllSamplesInAllGroups", |
Gtk::Action::create("ReplaceAllSamplesInAllGroups", |
298 |
_("Replace All Samples in All Groups...")), |
_("Replace All Samples in All Groups...")), |
299 |
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) |
313 |
sigc::mem_fun(*this, &MainWindow::on_action_edit_script) |
sigc::mem_fun(*this, &MainWindow::on_action_edit_script) |
314 |
); |
); |
315 |
actionGroup->add( |
actionGroup->add( |
316 |
Gtk::Action::create("RemoveScript", Gtk::Stock::REMOVE), |
Gtk::Action::create("RemoveScript", _("_Remove")), |
317 |
sigc::mem_fun(*this, &MainWindow::on_action_remove_script) |
sigc::mem_fun(*this, &MainWindow::on_action_remove_script) |
318 |
); |
); |
319 |
|
|
340 |
" <menuitem action='CopySampleTune'/>" |
" <menuitem action='CopySampleTune'/>" |
341 |
" <menuitem action='CopySampleLoop'/>" |
" <menuitem action='CopySampleLoop'/>" |
342 |
" </menu>" |
" </menu>" |
343 |
|
" <menu action='MenuSample'>" |
344 |
|
" <menuitem action='SampleProperties'/>" |
345 |
|
" <menuitem action='AddGroup'/>" |
346 |
|
" <menuitem action='AddSample'/>" |
347 |
|
" <menuitem action='ShowSampleRefs'/>" |
348 |
|
" <menuitem action='ReplaceSample' />" |
349 |
|
" <menuitem action='ReplaceAllSamplesInAllGroups' />" |
350 |
|
" <separator/>" |
351 |
|
" <menuitem action='RemoveSample'/>" |
352 |
|
" <menuitem action='RemoveUnusedSamples'/>" |
353 |
|
" </menu>" |
354 |
" <menu action='MenuInstrument'>" |
" <menu action='MenuInstrument'>" |
355 |
|
" <menu action='AllInstruments'>" |
356 |
|
" </menu>" |
357 |
|
" <separator/>" |
358 |
|
" <menuitem action='InstrProperties'/>" |
359 |
|
" <menuitem action='MidiRules'/>" |
360 |
|
" <menuitem action='ScriptSlots'/>" |
361 |
|
" <menuitem action='AddInstrument'/>" |
362 |
|
" <menuitem action='DupInstrument'/>" |
363 |
|
" <separator/>" |
364 |
|
" <menuitem action='RemoveInstrument'/>" |
365 |
|
" </menu>" |
366 |
|
" <menu action='MenuScript'>" |
367 |
|
" <menuitem action='AddScriptGroup'/>" |
368 |
|
" <menuitem action='AddScript'/>" |
369 |
|
" <menuitem action='EditScript'/>" |
370 |
|
" <separator/>" |
371 |
|
" <menuitem action='RemoveScript'/>" |
372 |
" </menu>" |
" </menu>" |
373 |
" <menu action='MenuView'>" |
" <menu action='MenuView'>" |
374 |
" <menuitem action='Statusbar'/>" |
" <menuitem action='Statusbar'/>" |
375 |
|
" <menuitem action='AutoRestoreWinDim'/>" |
376 |
|
" <separator/>" |
377 |
|
" <menuitem action='RefreshAll'/>" |
378 |
" </menu>" |
" </menu>" |
379 |
" <menu action='MenuTools'>" |
" <menu action='MenuTools'>" |
380 |
" <menuitem action='CombineInstruments'/>" |
" <menuitem action='CombineInstruments'/>" |
382 |
" </menu>" |
" </menu>" |
383 |
" <menu action='MenuSettings'>" |
" <menu action='MenuSettings'>" |
384 |
" <menuitem action='WarnUserOnExtensions'/>" |
" <menuitem action='WarnUserOnExtensions'/>" |
385 |
|
" <menuitem action='SyncSamplerInstrumentSelection'/>" |
386 |
|
" <menuitem action='MoveRootNoteWithRegionMoved'/>" |
387 |
" </menu>" |
" </menu>" |
388 |
" <menu action='MenuHelp'>" |
" <menu action='MenuHelp'>" |
389 |
" <menuitem action='About'/>" |
" <menuitem action='About'/>" |
403 |
" <menuitem action='AddGroup'/>" |
" <menuitem action='AddGroup'/>" |
404 |
" <menuitem action='AddSample'/>" |
" <menuitem action='AddSample'/>" |
405 |
" <menuitem action='ShowSampleRefs'/>" |
" <menuitem action='ShowSampleRefs'/>" |
406 |
|
" <menuitem action='ReplaceSample' />" |
407 |
" <menuitem action='ReplaceAllSamplesInAllGroups' />" |
" <menuitem action='ReplaceAllSamplesInAllGroups' />" |
408 |
" <separator/>" |
" <separator/>" |
409 |
" <menuitem action='RemoveSample'/>" |
" <menuitem action='RemoveSample'/>" |
410 |
|
" <menuitem action='RemoveUnusedSamples'/>" |
411 |
" </popup>" |
" </popup>" |
412 |
" <popup name='ScriptPopupMenu'>" |
" <popup name='ScriptPopupMenu'>" |
413 |
" <menuitem action='AddScriptGroup'/>" |
" <menuitem action='AddScriptGroup'/>" |
447 |
} |
} |
448 |
{ |
{ |
449 |
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
450 |
|
uiManager->get_widget("/MenuBar/MenuSettings/SyncSamplerInstrumentSelection")); |
451 |
|
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).")); |
452 |
|
} |
453 |
|
{ |
454 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
455 |
|
uiManager->get_widget("/MenuBar/MenuSettings/MoveRootNoteWithRegionMoved")); |
456 |
|
item->set_tooltip_text(_("If checked, and when a region is moved by dragging it around on the virtual keyboard, the keybord position dependent pitch will move exactly with the amount of semi tones the region was moved around.")); |
457 |
|
} |
458 |
|
{ |
459 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
460 |
|
uiManager->get_widget("/MenuBar/MenuSample/RemoveUnusedSamples")); |
461 |
|
item->set_tooltip_text(_("Removes all samples that are not referenced by any instrument (i.e. red ones).")); |
462 |
|
// copy tooltip to popup menu |
463 |
|
Gtk::MenuItem* item2 = dynamic_cast<Gtk::MenuItem*>( |
464 |
|
uiManager->get_widget("/SamplePopupMenu/RemoveUnusedSamples")); |
465 |
|
item2->set_tooltip_text(item->get_tooltip_text()); |
466 |
|
} |
467 |
|
{ |
468 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
469 |
|
uiManager->get_widget("/MenuBar/MenuView/RefreshAll")); |
470 |
|
item->set_tooltip_text(_("Reloads the currently open gig file and updates the entire graphical user interface.")); |
471 |
|
} |
472 |
|
{ |
473 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
474 |
|
uiManager->get_widget("/MenuBar/MenuView/AutoRestoreWinDim")); |
475 |
|
item->set_tooltip_text(_("If checked, size and position of all windows will be saved and automatically restored next time.")); |
476 |
|
} |
477 |
|
{ |
478 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
479 |
uiManager->get_widget("/MenuBar/MenuTools/CombineInstruments")); |
uiManager->get_widget("/MenuBar/MenuTools/CombineInstruments")); |
480 |
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.")); |
481 |
} |
} |
487 |
|
|
488 |
|
|
489 |
instrument_menu = static_cast<Gtk::MenuItem*>( |
instrument_menu = static_cast<Gtk::MenuItem*>( |
490 |
uiManager->get_widget("/MenuBar/MenuInstrument"))->get_submenu(); |
uiManager->get_widget("/MenuBar/MenuInstrument/AllInstruments"))->get_submenu(); |
491 |
|
|
492 |
Gtk::Widget* menuBar = uiManager->get_widget("/MenuBar"); |
Gtk::Widget* menuBar = uiManager->get_widget("/MenuBar"); |
493 |
m_VBox.pack_start(*menuBar, Gtk::PACK_SHRINK); |
m_VBox.pack_start(*menuBar, Gtk::PACK_SHRINK); |
513 |
// Create the Tree model: |
// Create the Tree model: |
514 |
m_refTreeModel = Gtk::ListStore::create(m_Columns); |
m_refTreeModel = Gtk::ListStore::create(m_Columns); |
515 |
m_TreeView.set_model(m_refTreeModel); |
m_TreeView.set_model(m_refTreeModel); |
516 |
m_TreeView.set_tooltip_text(_("Right click here for actions on instruments & MIDI Rules.")); |
m_TreeView.set_tooltip_text(_("Right click here for actions on instruments & MIDI Rules. Drag & drop to change the order of instruments.")); |
517 |
instrument_name_connection = m_refTreeModel->signal_row_changed().connect( |
instrument_name_connection = m_refTreeModel->signal_row_changed().connect( |
518 |
sigc::mem_fun(*this, &MainWindow::instrument_name_changed) |
sigc::mem_fun(*this, &MainWindow::instrument_name_changed) |
519 |
); |
); |
521 |
// Add the TreeView's view columns: |
// Add the TreeView's view columns: |
522 |
m_TreeView.append_column_editable("Instrument", m_Columns.m_col_name); |
m_TreeView.append_column_editable("Instrument", m_Columns.m_col_name); |
523 |
m_TreeView.set_headers_visible(false); |
m_TreeView.set_headers_visible(false); |
524 |
|
|
525 |
|
// establish drag&drop within the instrument tree view, allowing to reorder |
526 |
|
// the sequence of instruments within the gig file |
527 |
|
{ |
528 |
|
std::vector<Gtk::TargetEntry> drag_target_instrument; |
529 |
|
drag_target_instrument.push_back(Gtk::TargetEntry("gig::Instrument")); |
530 |
|
m_TreeView.drag_source_set(drag_target_instrument); |
531 |
|
m_TreeView.drag_dest_set(drag_target_instrument); |
532 |
|
m_TreeView.signal_drag_begin().connect( |
533 |
|
sigc::mem_fun(*this, &MainWindow::on_instruments_treeview_drag_begin) |
534 |
|
); |
535 |
|
m_TreeView.signal_drag_data_get().connect( |
536 |
|
sigc::mem_fun(*this, &MainWindow::on_instruments_treeview_drag_data_get) |
537 |
|
); |
538 |
|
m_TreeView.signal_drag_data_received().connect( |
539 |
|
sigc::mem_fun(*this, &MainWindow::on_instruments_treeview_drop_drag_data_received) |
540 |
|
); |
541 |
|
} |
542 |
|
|
543 |
// create samples treeview (including its data model) |
// create samples treeview (including its data model) |
544 |
m_refSamplesTreeModel = SamplesTreeStore::create(m_SamplesModel); |
m_refSamplesTreeModel = SamplesTreeStore::create(m_SamplesModel); |
550 |
{ |
{ |
551 |
Gtk::TreeViewColumn* column = m_TreeViewSamples.get_column(0); |
Gtk::TreeViewColumn* column = m_TreeViewSamples.get_column(0); |
552 |
Gtk::CellRendererText* cellrenderer = |
Gtk::CellRendererText* cellrenderer = |
553 |
dynamic_cast<Gtk::CellRendererText*>(column->get_first_cell_renderer()); |
dynamic_cast<Gtk::CellRendererText*>(column->get_first_cell()); |
554 |
column->add_attribute( |
column->add_attribute( |
555 |
cellrenderer->property_foreground(), m_SamplesModel.m_color |
cellrenderer->property_foreground(), m_SamplesModel.m_color |
556 |
); |
); |
558 |
{ |
{ |
559 |
Gtk::TreeViewColumn* column = m_TreeViewSamples.get_column(1); |
Gtk::TreeViewColumn* column = m_TreeViewSamples.get_column(1); |
560 |
Gtk::CellRendererText* cellrenderer = |
Gtk::CellRendererText* cellrenderer = |
561 |
dynamic_cast<Gtk::CellRendererText*>(column->get_first_cell_renderer()); |
dynamic_cast<Gtk::CellRendererText*>(column->get_first_cell()); |
562 |
column->add_attribute( |
column->add_attribute( |
563 |
cellrenderer->property_foreground(), m_SamplesModel.m_color |
cellrenderer->property_foreground(), m_SamplesModel.m_color |
564 |
); |
); |
575 |
m_refScriptsTreeModel = ScriptsTreeStore::create(m_ScriptsModel); |
m_refScriptsTreeModel = ScriptsTreeStore::create(m_ScriptsModel); |
576 |
m_TreeViewScripts.set_model(m_refScriptsTreeModel); |
m_TreeViewScripts.set_model(m_refScriptsTreeModel); |
577 |
m_TreeViewScripts.set_tooltip_text(_( |
m_TreeViewScripts.set_tooltip_text(_( |
578 |
|
"Use CTRL + double click for editing a script." |
579 |
|
"\n\n" |
580 |
"Note: instrument scripts are a LinuxSampler extension of the gig " |
"Note: instrument scripts are a LinuxSampler extension of the gig " |
581 |
"format. This feature will not work with the GigaStudio software!" |
"format. This feature will not work with the GigaStudio software!" |
582 |
)); |
)); |
586 |
m_TreeViewScripts.signal_button_press_event().connect_notify( |
m_TreeViewScripts.signal_button_press_event().connect_notify( |
587 |
sigc::mem_fun(*this, &MainWindow::on_script_treeview_button_release) |
sigc::mem_fun(*this, &MainWindow::on_script_treeview_button_release) |
588 |
); |
); |
589 |
|
//FIXME: why the heck does this double click signal_row_activated() only fire while CTRL key is pressed ? |
590 |
|
m_TreeViewScripts.signal_row_activated().connect( |
591 |
|
sigc::mem_fun(*this, &MainWindow::script_double_clicked) |
592 |
|
); |
593 |
m_refScriptsTreeModel->signal_row_changed().connect( |
m_refScriptsTreeModel->signal_row_changed().connect( |
594 |
sigc::mem_fun(*this, &MainWindow::script_name_changed) |
sigc::mem_fun(*this, &MainWindow::script_name_changed) |
595 |
); |
); |
623 |
sigc::hide(sigc::mem_fun(*this, &MainWindow::file_changed))); |
sigc::hide(sigc::mem_fun(*this, &MainWindow::file_changed))); |
624 |
m_RegionChooser.signal_instrument_changed().connect( |
m_RegionChooser.signal_instrument_changed().connect( |
625 |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
626 |
|
m_RegionChooser.signal_instrument_changed().connect( |
627 |
|
sigc::mem_fun(*this, &MainWindow::region_changed)); |
628 |
m_DimRegionChooser.signal_region_changed().connect( |
m_DimRegionChooser.signal_region_changed().connect( |
629 |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
630 |
instrumentProps.signal_changed().connect( |
instrumentProps.signal_changed().connect( |
647 |
sigc::mem_fun(*this, &MainWindow::on_samples_to_be_removed) |
sigc::mem_fun(*this, &MainWindow::on_samples_to_be_removed) |
648 |
); |
); |
649 |
|
|
650 |
|
dimreg_edit.signal_select_sample().connect( |
651 |
|
sigc::mem_fun(*this, &MainWindow::select_sample) |
652 |
|
); |
653 |
|
|
654 |
m_RegionChooser.signal_instrument_struct_to_be_changed().connect( |
m_RegionChooser.signal_instrument_struct_to_be_changed().connect( |
655 |
sigc::hide( |
sigc::hide( |
656 |
sigc::bind( |
sigc::bind( |
775 |
void MainWindow::dimreg_changed() |
void MainWindow::dimreg_changed() |
776 |
{ |
{ |
777 |
update_dimregs(); |
update_dimregs(); |
778 |
dimreg_edit.set_dim_region(m_DimRegionChooser.get_dimregion()); |
dimreg_edit.set_dim_region(m_DimRegionChooser.get_main_dimregion()); |
779 |
} |
} |
780 |
|
|
781 |
void MainWindow::on_sel_change() |
void MainWindow::on_sel_change() |
791 |
} |
} |
792 |
|
|
793 |
m_RegionChooser.set_instrument(get_instrument()); |
m_RegionChooser.set_instrument(get_instrument()); |
794 |
|
|
795 |
|
if (Settings::singleton()->syncSamplerInstrumentSelection) { |
796 |
|
switch_sampler_instrument_signal.emit(get_instrument()); |
797 |
|
} |
798 |
} |
} |
799 |
|
|
800 |
void loader_progress_callback(gig::progress_t* progress) |
void loader_progress_callback(gig::progress_t* progress) |
814 |
|
|
815 |
void Loader::thread_function() |
void Loader::thread_function() |
816 |
{ |
{ |
817 |
printf("thread_function self=%x\n", Glib::Threads::Thread::self()); |
printf("thread_function self=%p\n", |
818 |
printf("Start %s\n", filename); |
static_cast<void*>(Glib::Threads::Thread::self())); |
819 |
RIFF::File* riff = new RIFF::File(filename); |
printf("Start %s\n", filename.c_str()); |
820 |
gig = new gig::File(riff); |
try { |
821 |
gig::progress_t progress; |
RIFF::File* riff = new RIFF::File(filename); |
822 |
progress.callback = loader_progress_callback; |
gig = new gig::File(riff); |
823 |
progress.custom = this; |
gig::progress_t progress; |
824 |
|
progress.callback = loader_progress_callback; |
825 |
gig->GetInstrument(0, &progress); |
progress.custom = this; |
826 |
printf("End\n"); |
|
827 |
finished_dispatcher(); |
gig->GetInstrument(0, &progress); |
828 |
|
printf("End\n"); |
829 |
|
finished_dispatcher(); |
830 |
|
} catch (RIFF::Exception e) { |
831 |
|
error_message = e.Message; |
832 |
|
error_dispatcher.emit(); |
833 |
|
} catch (...) { |
834 |
|
error_message = _("Unknown exception occurred"); |
835 |
|
error_dispatcher.emit(); |
836 |
|
} |
837 |
} |
} |
838 |
|
|
839 |
Loader::Loader(const char* filename) |
Loader::Loader(const char* filename) |
840 |
: filename(filename), thread(0) |
: filename(filename), gig(0), thread(0), progress(0.f) |
841 |
{ |
{ |
842 |
} |
} |
843 |
|
|
848 |
#else |
#else |
849 |
thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Loader::thread_function)); |
thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Loader::thread_function)); |
850 |
#endif |
#endif |
851 |
printf("launch thread=%x\n", thread); |
printf("launch thread=%p\n", static_cast<void*>(thread)); |
852 |
} |
} |
853 |
|
|
854 |
float Loader::get_progress() |
float Loader::get_progress() |
871 |
return finished_dispatcher; |
return finished_dispatcher; |
872 |
} |
} |
873 |
|
|
874 |
LoadDialog::LoadDialog(const Glib::ustring& title, Gtk::Window& parent) |
Glib::Dispatcher& Loader::signal_error() |
875 |
|
{ |
876 |
|
return error_dispatcher; |
877 |
|
} |
878 |
|
|
879 |
|
void saver_progress_callback(gig::progress_t* progress) |
880 |
|
{ |
881 |
|
Saver* saver = static_cast<Saver*>(progress->custom); |
882 |
|
saver->progress_callback(progress->factor); |
883 |
|
} |
884 |
|
|
885 |
|
void Saver::progress_callback(float fraction) |
886 |
|
{ |
887 |
|
{ |
888 |
|
Glib::Threads::Mutex::Lock lock(progressMutex); |
889 |
|
progress = fraction; |
890 |
|
} |
891 |
|
progress_dispatcher.emit(); |
892 |
|
} |
893 |
|
|
894 |
|
void Saver::thread_function() |
895 |
|
{ |
896 |
|
printf("thread_function self=%p\n", |
897 |
|
static_cast<void*>(Glib::Threads::Thread::self())); |
898 |
|
printf("Start %s\n", filename.c_str()); |
899 |
|
try { |
900 |
|
gig::progress_t progress; |
901 |
|
progress.callback = saver_progress_callback; |
902 |
|
progress.custom = this; |
903 |
|
|
904 |
|
// if no filename was provided, that means "save", if filename was provided means "save as" |
905 |
|
if (filename.empty()) { |
906 |
|
gig->Save(&progress); |
907 |
|
} else { |
908 |
|
gig->Save(filename, &progress); |
909 |
|
} |
910 |
|
|
911 |
|
printf("End\n"); |
912 |
|
finished_dispatcher.emit(); |
913 |
|
} catch (RIFF::Exception e) { |
914 |
|
error_message = e.Message; |
915 |
|
error_dispatcher.emit(); |
916 |
|
} catch (...) { |
917 |
|
error_message = _("Unknown exception occurred"); |
918 |
|
error_dispatcher.emit(); |
919 |
|
} |
920 |
|
} |
921 |
|
|
922 |
|
Saver::Saver(gig::File* file, Glib::ustring filename) |
923 |
|
: gig(file), filename(filename), thread(0), progress(0.f) |
924 |
|
{ |
925 |
|
} |
926 |
|
|
927 |
|
void Saver::launch() |
928 |
|
{ |
929 |
|
#ifdef OLD_THREADS |
930 |
|
thread = Glib::Thread::create(sigc::mem_fun(*this, &Saver::thread_function), true); |
931 |
|
#else |
932 |
|
thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Saver::thread_function)); |
933 |
|
#endif |
934 |
|
printf("launch thread=%p\n", static_cast<void*>(thread)); |
935 |
|
} |
936 |
|
|
937 |
|
float Saver::get_progress() |
938 |
|
{ |
939 |
|
float res; |
940 |
|
{ |
941 |
|
Glib::Threads::Mutex::Lock lock(progressMutex); |
942 |
|
res = progress; |
943 |
|
} |
944 |
|
return res; |
945 |
|
} |
946 |
|
|
947 |
|
Glib::Dispatcher& Saver::signal_progress() |
948 |
|
{ |
949 |
|
return progress_dispatcher; |
950 |
|
} |
951 |
|
|
952 |
|
Glib::Dispatcher& Saver::signal_finished() |
953 |
|
{ |
954 |
|
return finished_dispatcher; |
955 |
|
} |
956 |
|
|
957 |
|
Glib::Dispatcher& Saver::signal_error() |
958 |
|
{ |
959 |
|
return error_dispatcher; |
960 |
|
} |
961 |
|
|
962 |
|
ProgressDialog::ProgressDialog(const Glib::ustring& title, Gtk::Window& parent) |
963 |
: Gtk::Dialog(title, parent, true) |
: Gtk::Dialog(title, parent, true) |
964 |
{ |
{ |
965 |
get_vbox()->pack_start(progressBar); |
get_vbox()->pack_start(progressBar); |
966 |
show_all_children(); |
show_all_children(); |
967 |
|
resize(600,50); |
968 |
} |
} |
969 |
|
|
970 |
// Clear all GUI elements / controls. This method is typically called |
// Clear all GUI elements / controls. This method is typically called |
1028 |
g_free(msg); |
g_free(msg); |
1029 |
dialog.set_secondary_text(_("If you close without saving, your changes will be lost.")); |
dialog.set_secondary_text(_("If you close without saving, your changes will be lost.")); |
1030 |
dialog.add_button(_("Close _Without Saving"), Gtk::RESPONSE_NO); |
dialog.add_button(_("Close _Without Saving"), Gtk::RESPONSE_NO); |
1031 |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); |
1032 |
dialog.add_button(file_has_name ? Gtk::Stock::SAVE : Gtk::Stock::SAVE_AS, Gtk::RESPONSE_YES); |
dialog.add_button(file_has_name ? _("_Save") : _("Save _As"), Gtk::RESPONSE_YES); |
1033 |
dialog.set_default_response(Gtk::RESPONSE_YES); |
dialog.set_default_response(Gtk::RESPONSE_YES); |
1034 |
int response = dialog.run(); |
int response = dialog.run(); |
1035 |
dialog.hide(); |
dialog.hide(); |
1036 |
if (response == Gtk::RESPONSE_YES) return file_save(); |
|
1037 |
return response != Gtk::RESPONSE_CANCEL; |
// user decided to exit app without saving |
1038 |
|
if (response == Gtk::RESPONSE_NO) return true; |
1039 |
|
|
1040 |
|
// user cancelled dialog, thus don't close app |
1041 |
|
if (response == Gtk::RESPONSE_CANCEL) return false; |
1042 |
|
|
1043 |
|
// TODO: the following return valid is disabled and hard coded instead for |
1044 |
|
// now, due to the fact that saving with progress bar is now implemented |
1045 |
|
// asynchronously, as a result the app does not close automatically anymore |
1046 |
|
// after saving the file has completed |
1047 |
|
// |
1048 |
|
// if (response == Gtk::RESPONSE_YES) return file_save(); |
1049 |
|
// return response != Gtk::RESPONSE_CANCEL; |
1050 |
|
// |
1051 |
|
if (response == Gtk::RESPONSE_YES) file_save(); |
1052 |
|
return false; // always prevent closing the app for now (see comment above) |
1053 |
} |
} |
1054 |
|
|
1055 |
bool MainWindow::leaving_shared_mode_dialog() { |
bool MainWindow::leaving_shared_mode_dialog() { |
1060 |
"used by the sampler until you tell the sampler explicitly to " |
"used by the sampler until you tell the sampler explicitly to " |
1061 |
"load it.")); |
"load it.")); |
1062 |
dialog.add_button(_("_Yes, Detach"), Gtk::RESPONSE_YES); |
dialog.add_button(_("_Yes, Detach"), Gtk::RESPONSE_YES); |
1063 |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); |
1064 |
dialog.set_default_response(Gtk::RESPONSE_CANCEL); |
dialog.set_default_response(Gtk::RESPONSE_CANCEL); |
1065 |
int response = dialog.run(); |
int response = dialog.run(); |
1066 |
dialog.hide(); |
dialog.hide(); |
1074 |
if (file_is_shared && !leaving_shared_mode_dialog()) return; |
if (file_is_shared && !leaving_shared_mode_dialog()) return; |
1075 |
|
|
1076 |
Gtk::FileChooserDialog dialog(*this, _("Open file")); |
Gtk::FileChooserDialog dialog(*this, _("Open file")); |
1077 |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); |
1078 |
dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); |
dialog.add_button(_("_Open"), Gtk::RESPONSE_OK); |
1079 |
dialog.set_default_response(Gtk::RESPONSE_OK); |
dialog.set_default_response(Gtk::RESPONSE_OK); |
1080 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
1081 |
Gtk::FileFilter filter; |
Gtk::FileFilter filter; |
1091 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
1092 |
std::string filename = dialog.get_filename(); |
std::string filename = dialog.get_filename(); |
1093 |
printf("filename=%s\n", filename.c_str()); |
printf("filename=%s\n", filename.c_str()); |
1094 |
printf("on_action_file_open self=%x\n", Glib::Threads::Thread::self()); |
printf("on_action_file_open self=%p\n", |
1095 |
|
static_cast<void*>(Glib::Threads::Thread::self())); |
1096 |
load_file(filename.c_str()); |
load_file(filename.c_str()); |
1097 |
current_gig_dir = Glib::path_get_dirname(filename); |
current_gig_dir = Glib::path_get_dirname(filename); |
1098 |
} |
} |
1101 |
void MainWindow::load_file(const char* name) |
void MainWindow::load_file(const char* name) |
1102 |
{ |
{ |
1103 |
__clear(); |
__clear(); |
1104 |
load_dialog = new LoadDialog(_("Loading..."), *this); |
|
1105 |
load_dialog->show_all(); |
progress_dialog = new ProgressDialog( //FIXME: memory leak! |
1106 |
loader = new Loader(strdup(name)); |
_("Loading") + Glib::ustring(" '") + |
1107 |
|
Glib::filename_display_basename(name) + "' ...", |
1108 |
|
*this |
1109 |
|
); |
1110 |
|
progress_dialog->show_all(); |
1111 |
|
loader = new Loader(name); //FIXME: memory leak! |
1112 |
loader->signal_progress().connect( |
loader->signal_progress().connect( |
1113 |
sigc::mem_fun(*this, &MainWindow::on_loader_progress)); |
sigc::mem_fun(*this, &MainWindow::on_loader_progress)); |
1114 |
loader->signal_finished().connect( |
loader->signal_finished().connect( |
1115 |
sigc::mem_fun(*this, &MainWindow::on_loader_finished)); |
sigc::mem_fun(*this, &MainWindow::on_loader_finished)); |
1116 |
|
loader->signal_error().connect( |
1117 |
|
sigc::mem_fun(*this, &MainWindow::on_loader_error)); |
1118 |
loader->launch(); |
loader->launch(); |
1119 |
} |
} |
1120 |
|
|
1130 |
// load the instrument |
// load the instrument |
1131 |
gig::File* pFile = (gig::File*) instr->GetParent(); |
gig::File* pFile = (gig::File*) instr->GetParent(); |
1132 |
load_gig(pFile, 0 /*file name*/, true /*shared instrument*/); |
load_gig(pFile, 0 /*file name*/, true /*shared instrument*/); |
1133 |
//TODO: automatically select the given instrument |
// automatically select the given instrument |
1134 |
|
int i = 0; |
1135 |
|
for (gig::Instrument* instrument = pFile->GetFirstInstrument(); instrument; |
1136 |
|
instrument = pFile->GetNextInstrument(), ++i) |
1137 |
|
{ |
1138 |
|
if (instrument == instr) { |
1139 |
|
// select item in "instruments" tree view |
1140 |
|
m_TreeView.get_selection()->select(Gtk::TreePath(ToString(i))); |
1141 |
|
// make sure the selected item in the "instruments" tree view is |
1142 |
|
// visible (scroll to it) |
1143 |
|
m_TreeView.scroll_to_row(Gtk::TreePath(ToString(i))); |
1144 |
|
// select item in instrument menu |
1145 |
|
{ |
1146 |
|
const std::vector<Gtk::Widget*> children = |
1147 |
|
instrument_menu->get_children(); |
1148 |
|
static_cast<Gtk::RadioMenuItem*>(children[i])->set_active(); |
1149 |
|
} |
1150 |
|
// update region chooser and dimension region chooser |
1151 |
|
m_RegionChooser.set_instrument(instr); |
1152 |
|
break; |
1153 |
|
} |
1154 |
|
} |
1155 |
} |
} |
1156 |
|
|
1157 |
void MainWindow::on_loader_progress() |
void MainWindow::on_loader_progress() |
1158 |
{ |
{ |
1159 |
load_dialog->set_fraction(loader->get_progress()); |
progress_dialog->set_fraction(loader->get_progress()); |
1160 |
} |
} |
1161 |
|
|
1162 |
void MainWindow::on_loader_finished() |
void MainWindow::on_loader_finished() |
1163 |
{ |
{ |
1164 |
printf("Loader finished!\n"); |
printf("Loader finished!\n"); |
1165 |
printf("on_loader_finished self=%x\n", Glib::Threads::Thread::self()); |
printf("on_loader_finished self=%p\n", |
1166 |
load_gig(loader->gig, loader->filename); |
static_cast<void*>(Glib::Threads::Thread::self())); |
1167 |
load_dialog->hide(); |
load_gig(loader->gig, loader->filename.c_str()); |
1168 |
|
progress_dialog->hide(); |
1169 |
|
} |
1170 |
|
|
1171 |
|
void MainWindow::on_loader_error() |
1172 |
|
{ |
1173 |
|
Glib::ustring txt = _("Could not load file: ") + loader->error_message; |
1174 |
|
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
1175 |
|
msg.run(); |
1176 |
|
progress_dialog->hide(); |
1177 |
} |
} |
1178 |
|
|
1179 |
void MainWindow::on_action_file_save() |
void MainWindow::on_action_file_save() |
1212 |
|
|
1213 |
std::cout << "Saving file\n" << std::flush; |
std::cout << "Saving file\n" << std::flush; |
1214 |
file_structure_to_be_changed_signal.emit(this->file); |
file_structure_to_be_changed_signal.emit(this->file); |
1215 |
try { |
|
1216 |
file->Save(); |
progress_dialog = new ProgressDialog( //FIXME: memory leak! |
1217 |
if (file_is_changed) { |
_("Saving") + Glib::ustring(" '") + |
1218 |
set_title(get_title().substr(1)); |
Glib::filename_display_basename(this->filename) + "' ...", |
1219 |
file_is_changed = false; |
*this |
1220 |
} |
); |
1221 |
} catch (RIFF::Exception e) { |
progress_dialog->show_all(); |
1222 |
file_structure_changed_signal.emit(this->file); |
saver = new Saver(this->file); //FIXME: memory leak! |
1223 |
Glib::ustring txt = _("Could not save file: ") + e.Message; |
saver->signal_progress().connect( |
1224 |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
sigc::mem_fun(*this, &MainWindow::on_saver_progress)); |
1225 |
msg.run(); |
saver->signal_finished().connect( |
1226 |
return false; |
sigc::mem_fun(*this, &MainWindow::on_saver_finished)); |
1227 |
} |
saver->signal_error().connect( |
1228 |
std::cout << "Saving file done\n" << std::flush; |
sigc::mem_fun(*this, &MainWindow::on_saver_error)); |
1229 |
|
saver->launch(); |
1230 |
|
|
1231 |
|
return true; |
1232 |
|
} |
1233 |
|
|
1234 |
|
void MainWindow::on_saver_progress() |
1235 |
|
{ |
1236 |
|
progress_dialog->set_fraction(saver->get_progress()); |
1237 |
|
} |
1238 |
|
|
1239 |
|
void MainWindow::on_saver_error() |
1240 |
|
{ |
1241 |
|
file_structure_changed_signal.emit(this->file); |
1242 |
|
Glib::ustring txt = _("Could not save file: ") + saver->error_message; |
1243 |
|
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
1244 |
|
msg.run(); |
1245 |
|
} |
1246 |
|
|
1247 |
|
void MainWindow::on_saver_finished() |
1248 |
|
{ |
1249 |
|
this->file = saver->gig; |
1250 |
|
this->filename = saver->filename; |
1251 |
|
current_gig_dir = Glib::path_get_dirname(filename); |
1252 |
|
set_title(Glib::filename_display_basename(filename)); |
1253 |
|
file_has_name = true; |
1254 |
|
file_is_changed = false; |
1255 |
|
std::cout << "Saving file done. Importing queued samples now ...\n" << std::flush; |
1256 |
__import_queued_samples(); |
__import_queued_samples(); |
1257 |
|
std::cout << "Importing queued samples done.\n" << std::flush; |
1258 |
|
|
1259 |
file_structure_changed_signal.emit(this->file); |
file_structure_changed_signal.emit(this->file); |
1260 |
return true; |
|
1261 |
|
__refreshEntireGUI(); |
1262 |
|
progress_dialog->hide(); |
1263 |
} |
} |
1264 |
|
|
1265 |
void MainWindow::on_action_file_save_as() |
void MainWindow::on_action_file_save_as() |
1270 |
|
|
1271 |
bool MainWindow::file_save_as() |
bool MainWindow::file_save_as() |
1272 |
{ |
{ |
1273 |
Gtk::FileChooserDialog dialog(*this, _("Save as"), Gtk::FILE_CHOOSER_ACTION_SAVE); |
Gtk::FileChooserDialog dialog(*this, _("Save As"), Gtk::FILE_CHOOSER_ACTION_SAVE); |
1274 |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); |
1275 |
dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK); |
dialog.add_button(_("_Save"), Gtk::RESPONSE_OK); |
1276 |
dialog.set_default_response(Gtk::RESPONSE_OK); |
dialog.set_default_response(Gtk::RESPONSE_OK); |
1277 |
dialog.set_do_overwrite_confirmation(); |
dialog.set_do_overwrite_confirmation(); |
1278 |
|
|
1303 |
// show warning in the dialog |
// show warning in the dialog |
1304 |
Gtk::HBox descriptionArea; |
Gtk::HBox descriptionArea; |
1305 |
descriptionArea.set_spacing(15); |
descriptionArea.set_spacing(15); |
1306 |
Gtk::Image warningIcon(Gtk::Stock::DIALOG_WARNING, Gtk::IconSize(Gtk::ICON_SIZE_DIALOG)); |
Gtk::Image warningIcon; |
1307 |
|
warningIcon.set_from_icon_name("dialog-warning", |
1308 |
|
Gtk::IconSize(Gtk::ICON_SIZE_DIALOG)); |
1309 |
descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK); |
descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK); |
1310 |
#if GTKMM_MAJOR_VERSION < 3 |
#if GTKMM_MAJOR_VERSION < 3 |
1311 |
view::WrapLabel description; |
view::WrapLabel description; |
1326 |
descriptionArea.show_all(); |
descriptionArea.show_all(); |
1327 |
|
|
1328 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
1329 |
file_structure_to_be_changed_signal.emit(this->file); |
std::string filename = dialog.get_filename(); |
1330 |
try { |
if (!Glib::str_has_suffix(filename, ".gig")) { |
1331 |
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; |
|
1332 |
} |
} |
1333 |
__import_queued_samples(); |
printf("filename=%s\n", filename.c_str()); |
1334 |
file_structure_changed_signal.emit(this->file); |
|
1335 |
|
progress_dialog = new ProgressDialog( //FIXME: memory leak! |
1336 |
|
_("Saving") + Glib::ustring(" '") + |
1337 |
|
Glib::filename_display_basename(filename) + "' ...", |
1338 |
|
*this |
1339 |
|
); |
1340 |
|
progress_dialog->show_all(); |
1341 |
|
|
1342 |
|
saver = new Saver(file, filename); //FIXME: memory leak! |
1343 |
|
saver->signal_progress().connect( |
1344 |
|
sigc::mem_fun(*this, &MainWindow::on_saver_progress)); |
1345 |
|
saver->signal_finished().connect( |
1346 |
|
sigc::mem_fun(*this, &MainWindow::on_saver_finished)); |
1347 |
|
saver->signal_error().connect( |
1348 |
|
sigc::mem_fun(*this, &MainWindow::on_saver_error)); |
1349 |
|
saver->launch(); |
1350 |
|
|
1351 |
return true; |
return true; |
1352 |
} |
} |
1353 |
return false; |
return false; |
1357 |
void MainWindow::__import_queued_samples() { |
void MainWindow::__import_queued_samples() { |
1358 |
std::cout << "Starting sample import\n" << std::flush; |
std::cout << "Starting sample import\n" << std::flush; |
1359 |
Glib::ustring error_files; |
Glib::ustring error_files; |
1360 |
printf("Samples to import: %d\n", m_SampleImportQueue.size()); |
printf("Samples to import: %d\n", int(m_SampleImportQueue.size())); |
1361 |
for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
1362 |
iter != m_SampleImportQueue.end(); ) { |
iter != m_SampleImportQueue.end(); ) { |
1363 |
printf("Importing sample %s\n",(*iter).sample_path.c_str()); |
printf("Importing sample %s\n",(*iter).sample_path.c_str()); |
1458 |
!Settings::singleton()->warnUserOnExtensions; |
!Settings::singleton()->warnUserOnExtensions; |
1459 |
} |
} |
1460 |
|
|
1461 |
|
void MainWindow::on_action_sync_sampler_instrument_selection() { |
1462 |
|
Settings::singleton()->syncSamplerInstrumentSelection = |
1463 |
|
!Settings::singleton()->syncSamplerInstrumentSelection; |
1464 |
|
} |
1465 |
|
|
1466 |
|
void MainWindow::on_action_move_root_note_with_region_moved() { |
1467 |
|
Settings::singleton()->moveRootNoteWithRegionMoved = |
1468 |
|
!Settings::singleton()->moveRootNoteWithRegionMoved; |
1469 |
|
} |
1470 |
|
|
1471 |
void MainWindow::on_action_help_about() |
void MainWindow::on_action_help_about() |
1472 |
{ |
{ |
1473 |
Gtk::AboutDialog dialog; |
Gtk::AboutDialog dialog; |
1477 |
dialog.set_name("Gigedit"); |
dialog.set_name("Gigedit"); |
1478 |
#endif |
#endif |
1479 |
dialog.set_version(VERSION); |
dialog.set_version(VERSION); |
1480 |
dialog.set_copyright("Copyright (C) 2006-2014 Andreas Persson"); |
dialog.set_copyright("Copyright (C) 2006-2016 Andreas Persson"); |
1481 |
const std::string sComment = |
const std::string sComment = |
1482 |
_("Built " __DATE__ "\nUsing ") + |
_("Built " __DATE__ "\nUsing ") + |
1483 |
::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" + |
::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" + |
1484 |
_( |
_( |
1485 |
"Gigedit is released under the GNU General Public License.\n" |
"Gigedit is released under the GNU General Public License.\n" |
1486 |
"\n" |
"\n" |
1487 |
"Please notice that this is still a very young instrument editor. " |
"This program is distributed WITHOUT ANY WARRANTY; So better " |
1488 |
"So better backup your Gigasampler files before editing them with " |
"backup your Gigasampler/GigaStudio files before editing them with " |
1489 |
"this application.\n" |
"this application.\n" |
1490 |
"\n" |
"\n" |
1491 |
"Please report bugs to: http://bugs.linuxsampler.org" |
"Please report bugs to: http://bugs.linuxsampler.org" |
1514 |
eSourceForm(_("Source form")), |
eSourceForm(_("Source form")), |
1515 |
eCommissioned(_("Commissioned")), |
eCommissioned(_("Commissioned")), |
1516 |
eSubject(_("Subject")), |
eSubject(_("Subject")), |
1517 |
quitButton(Gtk::Stock::CLOSE), |
quitButton(_("_Close"), true), |
1518 |
table(2, 1), |
table(2, 1), |
1519 |
m_file(NULL) |
m_file(NULL) |
1520 |
{ |
{ |
1637 |
} |
} |
1638 |
|
|
1639 |
InstrumentProps::InstrumentProps() : |
InstrumentProps::InstrumentProps() : |
1640 |
quitButton(Gtk::Stock::CLOSE), |
quitButton(_("_Close"), true), |
1641 |
table(2,1), |
table(2,1), |
1642 |
eName(_("Name")), |
eName(_("Name")), |
1643 |
eIsDrum(_("Is drum")), |
eIsDrum(_("Is drum")), |
1760 |
file = 0; |
file = 0; |
1761 |
set_file_is_shared(isSharedInstrument); |
set_file_is_shared(isSharedInstrument); |
1762 |
|
|
1763 |
this->filename = filename ? filename : _("Unsaved Gig File"); |
this->filename = |
1764 |
|
(filename && strlen(filename) > 0) ? |
1765 |
|
filename : (!gig->GetFileName().empty()) ? |
1766 |
|
gig->GetFileName() : _("Unsaved Gig File"); |
1767 |
set_title(Glib::filename_display_basename(this->filename)); |
set_title(Glib::filename_display_basename(this->filename)); |
1768 |
file_has_name = filename; |
file_has_name = filename; |
1769 |
file_is_changed = false; |
file_is_changed = false; |
1784 |
add_instrument_to_menu(name); |
add_instrument_to_menu(name); |
1785 |
} |
} |
1786 |
instrument_name_connection.unblock(); |
instrument_name_connection.unblock(); |
1787 |
uiManager->get_widget("/MenuBar/MenuInstrument")->show(); |
uiManager->get_widget("/MenuBar/MenuInstrument/AllInstruments")->show(); |
1788 |
|
|
1789 |
updateSampleRefCountMap(gig); |
updateSampleRefCountMap(gig); |
1790 |
|
|
1806 |
rowSample[m_SamplesModel.m_col_group] = NULL; |
rowSample[m_SamplesModel.m_col_group] = NULL; |
1807 |
int refcount = sample_ref_count.count(sample) ? sample_ref_count[sample] : 0; |
int refcount = sample_ref_count.count(sample) ? sample_ref_count[sample] : 0; |
1808 |
rowSample[m_SamplesModel.m_col_refcount] = ToString(refcount) + " " + _("Refs."); |
rowSample[m_SamplesModel.m_col_refcount] = ToString(refcount) + " " + _("Refs."); |
1809 |
rowSample[m_SamplesModel.m_color] = refcount ? "black" : "gray"; |
rowSample[m_SamplesModel.m_color] = refcount ? "black" : "red"; |
1810 |
} |
} |
1811 |
} |
} |
1812 |
} |
} |
1917 |
window->show(); |
window->show(); |
1918 |
} |
} |
1919 |
|
|
1920 |
|
void MainWindow::on_action_refresh_all() { |
1921 |
|
__refreshEntireGUI(); |
1922 |
|
} |
1923 |
|
|
1924 |
void MainWindow::on_action_view_status_bar() { |
void MainWindow::on_action_view_status_bar() { |
1925 |
Gtk::CheckMenuItem* item = |
Gtk::CheckMenuItem* item = |
1926 |
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/Statusbar")); |
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/Statusbar")); |
1932 |
else m_StatusBar.hide(); |
else m_StatusBar.hide(); |
1933 |
} |
} |
1934 |
|
|
1935 |
|
void MainWindow::on_auto_restore_win_dim() { |
1936 |
|
Gtk::CheckMenuItem* item = |
1937 |
|
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/AutoRestoreWinDim")); |
1938 |
|
if (!item) { |
1939 |
|
std::cerr << "/MenuBar/MenuView/AutoRestoreWinDim == NULL\n"; |
1940 |
|
return; |
1941 |
|
} |
1942 |
|
Settings::singleton()->autoRestoreWindowDimension = item->get_active(); |
1943 |
|
} |
1944 |
|
|
1945 |
bool MainWindow::is_copy_samples_unity_note_enabled() const { |
bool MainWindow::is_copy_samples_unity_note_enabled() const { |
1946 |
Gtk::CheckMenuItem* item = |
Gtk::CheckMenuItem* item = |
1947 |
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleUnity")); |
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleUnity")); |
1978 |
show_instr_props(); |
show_instr_props(); |
1979 |
} else if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
} else if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
1980 |
// gig v2 files have no midi rules |
// gig v2 files have no midi rules |
1981 |
|
const bool bEnabled = !(file->pVersion && file->pVersion->major == 2); |
1982 |
|
static_cast<Gtk::MenuItem*>( |
1983 |
|
uiManager->get_widget("/MenuBar/MenuInstrument/MidiRules"))->set_sensitive( |
1984 |
|
bEnabled |
1985 |
|
); |
1986 |
static_cast<Gtk::MenuItem*>( |
static_cast<Gtk::MenuItem*>( |
1987 |
uiManager->get_widget("/PopupMenu/MidiRules"))->set_sensitive( |
uiManager->get_widget("/PopupMenu/MidiRules"))->set_sensitive( |
1988 |
!(file->pVersion && file->pVersion->major == 2)); |
bEnabled |
1989 |
|
); |
1990 |
popup_menu->popup(button->button, button->time); |
popup_menu->popup(button->button, button->time); |
1991 |
} |
} |
1992 |
} |
} |
2006 |
} |
} |
2007 |
} |
} |
2008 |
|
|
2009 |
|
void MainWindow::select_instrument(gig::Instrument* instrument) { |
2010 |
|
if (!instrument) return; |
2011 |
|
|
2012 |
|
Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model(); |
2013 |
|
for (int i = 0; i < model->children().size(); ++i) { |
2014 |
|
Gtk::TreeModel::Row row = model->children()[i]; |
2015 |
|
if (row[m_Columns.m_col_instr] == instrument) { |
2016 |
|
// select and show the respective instrument in the list view |
2017 |
|
show_intruments_tab(); |
2018 |
|
m_TreeView.get_selection()->select(model->children()[i]); |
2019 |
|
Gtk::TreePath path( |
2020 |
|
m_TreeView.get_selection()->get_selected() |
2021 |
|
); |
2022 |
|
m_TreeView.scroll_to_row(path); |
2023 |
|
on_sel_change(); // the regular instrument selection change callback |
2024 |
|
} |
2025 |
|
} |
2026 |
|
} |
2027 |
|
|
2028 |
|
/// Returns true if requested dimension region was successfully selected and scrolled to in the list view, false on error. |
2029 |
|
bool MainWindow::select_dimension_region(gig::DimensionRegion* dimRgn) { |
2030 |
|
gig::Region* pRegion = (gig::Region*) dimRgn->GetParent(); |
2031 |
|
gig::Instrument* pInstrument = (gig::Instrument*) pRegion->GetParent(); |
2032 |
|
|
2033 |
|
Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model(); |
2034 |
|
for (int i = 0; i < model->children().size(); ++i) { |
2035 |
|
Gtk::TreeModel::Row row = model->children()[i]; |
2036 |
|
if (row[m_Columns.m_col_instr] == pInstrument) { |
2037 |
|
// select and show the respective instrument in the list view |
2038 |
|
show_intruments_tab(); |
2039 |
|
m_TreeView.get_selection()->select(model->children()[i]); |
2040 |
|
Gtk::TreePath path( |
2041 |
|
m_TreeView.get_selection()->get_selected() |
2042 |
|
); |
2043 |
|
m_TreeView.scroll_to_row(path); |
2044 |
|
on_sel_change(); // the regular instrument selection change callback |
2045 |
|
|
2046 |
|
// select respective region in the region selector |
2047 |
|
m_RegionChooser.set_region(pRegion); |
2048 |
|
|
2049 |
|
// select and show the respective dimension region in the editor |
2050 |
|
//update_dimregs(); |
2051 |
|
if (!m_DimRegionChooser.select_dimregion(dimRgn)) return false; |
2052 |
|
//dimreg_edit.set_dim_region(dimRgn); |
2053 |
|
|
2054 |
|
return true; |
2055 |
|
} |
2056 |
|
} |
2057 |
|
|
2058 |
|
return false; |
2059 |
|
} |
2060 |
|
|
2061 |
|
void MainWindow::select_sample(gig::Sample* sample) { |
2062 |
|
Glib::RefPtr<Gtk::TreeModel> model = m_TreeViewSamples.get_model(); |
2063 |
|
for (int g = 0; g < model->children().size(); ++g) { |
2064 |
|
Gtk::TreeModel::Row rowGroup = model->children()[g]; |
2065 |
|
for (int s = 0; s < rowGroup.children().size(); ++s) { |
2066 |
|
Gtk::TreeModel::Row rowSample = rowGroup.children()[s]; |
2067 |
|
if (rowSample[m_SamplesModel.m_col_sample] == sample) { |
2068 |
|
show_samples_tab(); |
2069 |
|
m_TreeViewSamples.get_selection()->select(rowGroup.children()[s]); |
2070 |
|
Gtk::TreePath path( |
2071 |
|
m_TreeViewSamples.get_selection()->get_selected() |
2072 |
|
); |
2073 |
|
m_TreeViewSamples.scroll_to_row(path); |
2074 |
|
return; |
2075 |
|
} |
2076 |
|
} |
2077 |
|
} |
2078 |
|
} |
2079 |
|
|
2080 |
void MainWindow::on_sample_treeview_button_release(GdkEventButton* button) { |
void MainWindow::on_sample_treeview_button_release(GdkEventButton* button) { |
2081 |
if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
2082 |
Gtk::Menu* sample_popup = |
Gtk::Menu* sample_popup = |
2091 |
group_selected = row[m_SamplesModel.m_col_group]; |
group_selected = row[m_SamplesModel.m_col_group]; |
2092 |
sample_selected = row[m_SamplesModel.m_col_sample]; |
sample_selected = row[m_SamplesModel.m_col_sample]; |
2093 |
} |
} |
2094 |
|
|
2095 |
|
|
2096 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/SampleProperties"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/SampleProperties"))-> |
2097 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(group_selected || sample_selected); |
2098 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddSample"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddSample"))-> |
2105 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(group_selected || sample_selected); |
2106 |
// show sample popup |
// show sample popup |
2107 |
sample_popup->popup(button->button, button->time); |
sample_popup->popup(button->button, button->time); |
2108 |
|
|
2109 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/SampleProperties"))-> |
2110 |
|
set_sensitive(group_selected || sample_selected); |
2111 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddSample"))-> |
2112 |
|
set_sensitive(group_selected || sample_selected); |
2113 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddGroup"))-> |
2114 |
|
set_sensitive(file); |
2115 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/ShowSampleRefs"))-> |
2116 |
|
set_sensitive(sample_selected); |
2117 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/RemoveSample"))-> |
2118 |
|
set_sensitive(group_selected || sample_selected); |
2119 |
} |
} |
2120 |
} |
} |
2121 |
|
|
2143 |
set_sensitive(group_selected || script_selected); |
set_sensitive(group_selected || script_selected); |
2144 |
// show sample popup |
// show sample popup |
2145 |
script_popup->popup(button->button, button->time); |
script_popup->popup(button->button, button->time); |
2146 |
|
|
2147 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/AddScript"))-> |
2148 |
|
set_sensitive(group_selected || script_selected); |
2149 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/AddScriptGroup"))-> |
2150 |
|
set_sensitive(file); |
2151 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/EditScript"))-> |
2152 |
|
set_sensitive(script_selected); |
2153 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/RemoveScript"))-> |
2154 |
|
set_sensitive(group_selected || script_selected); |
2155 |
} |
} |
2156 |
} |
} |
2157 |
|
|
2364 |
if (!script) return; |
if (!script) return; |
2365 |
|
|
2366 |
ScriptEditor* editor = new ScriptEditor; |
ScriptEditor* editor = new ScriptEditor; |
2367 |
|
editor->signal_script_to_be_changed.connect( |
2368 |
|
signal_script_to_be_changed.make_slot() |
2369 |
|
); |
2370 |
|
editor->signal_script_changed.connect( |
2371 |
|
signal_script_changed.make_slot() |
2372 |
|
); |
2373 |
editor->setScript(script); |
editor->setScript(script); |
2374 |
//editor->reparent(*this); |
//editor->reparent(*this); |
2375 |
editor->show(); |
editor->show(); |
2435 |
file_changed(); |
file_changed(); |
2436 |
} |
} |
2437 |
|
|
2438 |
|
void MainWindow::on_action_replace_sample() { |
2439 |
|
add_or_replace_sample(true); |
2440 |
|
} |
2441 |
|
|
2442 |
void MainWindow::on_action_add_sample() { |
void MainWindow::on_action_add_sample() { |
2443 |
|
add_or_replace_sample(false); |
2444 |
|
} |
2445 |
|
|
2446 |
|
void MainWindow::add_or_replace_sample(bool replace) { |
2447 |
if (!file) return; |
if (!file) return; |
2448 |
// get selected group |
|
2449 |
|
// get selected group (and probably selected sample) |
2450 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
2451 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
Gtk::TreeModel::iterator it = sel->get_selected(); |
2452 |
if (!it) return; |
if (!it) return; |
2453 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
2454 |
|
gig::Sample* sample = NULL; |
2455 |
gig::Group* group = row[m_SamplesModel.m_col_group]; |
gig::Group* group = row[m_SamplesModel.m_col_group]; |
2456 |
if (!group) { // not a group, but a sample is selected (probably) |
if (!group) { // not a group, but a sample is selected (probably) |
2457 |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
if (replace) sample = row[m_SamplesModel.m_col_sample]; |
2458 |
if (!sample) return; |
if (!row[m_SamplesModel.m_col_sample]) return; |
2459 |
it = row.parent(); // resolve parent (that is the sample's group) |
it = row.parent(); // resolve parent (that is the sample's group) |
2460 |
if (!it) return; |
if (!it) return; |
2461 |
row = *it; |
if (!replace) row = *it; |
2462 |
group = row[m_SamplesModel.m_col_group]; |
group = (*it)[m_SamplesModel.m_col_group]; |
2463 |
if (!group) return; |
if (!group) return; |
2464 |
} |
} |
2465 |
|
if (replace && !sample) return; |
2466 |
|
|
2467 |
// show 'browse for file' dialog |
// show 'browse for file' dialog |
2468 |
Gtk::FileChooserDialog dialog(*this, _("Add Sample(s)")); |
Gtk::FileChooserDialog dialog(*this, replace ? _("Replace Sample with") : _("Add Sample(s)")); |
2469 |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); |
2470 |
dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); |
dialog.add_button(_("_Open"), Gtk::RESPONSE_OK); |
2471 |
dialog.set_select_multiple(true); |
dialog.set_select_multiple(!replace); // allow multi audio file selection only when adding new samples, does not make sense when replacing a specific sample |
2472 |
|
|
2473 |
// matches all file types supported by libsndfile |
// matches all file types supported by libsndfile |
2474 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
2539 |
sf_close(hFile); // close sound file |
sf_close(hFile); // close sound file |
2540 |
throw std::string(_("format not supported")); // unsupported subformat (yet?) |
throw std::string(_("format not supported")); // unsupported subformat (yet?) |
2541 |
} |
} |
2542 |
// add a new sample to the .gig file |
// add a new sample to the .gig file (if adding is requested actually) |
2543 |
gig::Sample* sample = file->AddSample(); |
if (!replace) sample = file->AddSample(); |
2544 |
// file name without path |
// file name without path |
2545 |
Glib::ustring filename = Glib::filename_display_basename(*iter); |
Glib::ustring filename = Glib::filename_display_basename(*iter); |
2546 |
// remove file extension if there is one |
// remove file extension if there is one |
2591 |
// physically when File::Save() is called) |
// physically when File::Save() is called) |
2592 |
sample->Resize(info.frames); |
sample->Resize(info.frames); |
2593 |
// make sure sample is part of the selected group |
// make sure sample is part of the selected group |
2594 |
group->AddSample(sample); |
if (!replace) group->AddSample(sample); |
2595 |
// schedule that physical resize and sample import |
// schedule that physical resize and sample import |
2596 |
// (data copying), performed when "Save" is requested |
// (data copying), performed when "Save" is requested |
2597 |
SampleImportItem sched_item; |
SampleImportItem sched_item; |
2599 |
sched_item.sample_path = *iter; |
sched_item.sample_path = *iter; |
2600 |
m_SampleImportQueue.push_back(sched_item); |
m_SampleImportQueue.push_back(sched_item); |
2601 |
// add sample to the tree view |
// add sample to the tree view |
2602 |
Gtk::TreeModel::iterator iterSample = |
if (replace) { |
2603 |
m_refSamplesTreeModel->append(row.children()); |
row[m_SamplesModel.m_col_name] = gig_to_utf8(sample->pInfo->Name); |
2604 |
Gtk::TreeModel::Row rowSample = *iterSample; |
} else { |
2605 |
rowSample[m_SamplesModel.m_col_name] = |
Gtk::TreeModel::iterator iterSample = |
2606 |
gig_to_utf8(sample->pInfo->Name); |
m_refSamplesTreeModel->append(row.children()); |
2607 |
rowSample[m_SamplesModel.m_col_sample] = sample; |
Gtk::TreeModel::Row rowSample = *iterSample; |
2608 |
rowSample[m_SamplesModel.m_col_group] = NULL; |
rowSample[m_SamplesModel.m_col_name] = |
2609 |
|
gig_to_utf8(sample->pInfo->Name); |
2610 |
|
rowSample[m_SamplesModel.m_col_sample] = sample; |
2611 |
|
rowSample[m_SamplesModel.m_col_group] = NULL; |
2612 |
|
} |
2613 |
// close sound file |
// close sound file |
2614 |
sf_close(hFile); |
sf_close(hFile); |
2615 |
file_changed(); |
file_changed(); |
2620 |
} |
} |
2621 |
// show error message box when some file(s) could not be opened / added |
// show error message box when some file(s) could not be opened / added |
2622 |
if (!error_files.empty()) { |
if (!error_files.empty()) { |
2623 |
Glib::ustring txt = _("Could not add the following sample(s):\n") + error_files; |
Glib::ustring txt = |
2624 |
|
(replace |
2625 |
|
? _("Failed to replace sample with:\n") |
2626 |
|
: _("Could not add the following sample(s):\n")) |
2627 |
|
+ error_files; |
2628 |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
2629 |
msg.run(); |
msg.run(); |
2630 |
} |
} |
2667 |
dialog.get_vbox()->pack_start(entryArea, Gtk::PACK_SHRINK); |
dialog.get_vbox()->pack_start(entryArea, Gtk::PACK_SHRINK); |
2668 |
description.show(); |
description.show(); |
2669 |
entryArea.show_all(); |
entryArea.show_all(); |
2670 |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); |
2671 |
dialog.add_button(_("Select"), Gtk::RESPONSE_OK); |
dialog.add_button(_("Select"), Gtk::RESPONSE_OK); |
2672 |
dialog.set_select_multiple(false); |
dialog.set_select_multiple(false); |
2673 |
if (current_sample_dir != "") { |
if (current_sample_dir != "") { |
2691 |
try |
try |
2692 |
{ |
{ |
2693 |
if (!hFile) throw std::string(_("could not open file")); |
if (!hFile) throw std::string(_("could not open file")); |
|
int bitdepth; |
|
2694 |
switch (info.format & 0xff) { |
switch (info.format & 0xff) { |
2695 |
case SF_FORMAT_PCM_S8: |
case SF_FORMAT_PCM_S8: |
2696 |
case SF_FORMAT_PCM_16: |
case SF_FORMAT_PCM_16: |
2697 |
case SF_FORMAT_PCM_U8: |
case SF_FORMAT_PCM_U8: |
|
bitdepth = 16; |
|
|
break; |
|
2698 |
case SF_FORMAT_PCM_24: |
case SF_FORMAT_PCM_24: |
2699 |
case SF_FORMAT_PCM_32: |
case SF_FORMAT_PCM_32: |
2700 |
case SF_FORMAT_FLOAT: |
case SF_FORMAT_FLOAT: |
2701 |
case SF_FORMAT_DOUBLE: |
case SF_FORMAT_DOUBLE: |
|
bitdepth = 24; |
|
2702 |
break; |
break; |
2703 |
default: |
default: |
2704 |
sf_close(hFile); |
sf_close(hFile); |
2804 |
} |
} |
2805 |
} |
} |
2806 |
|
|
2807 |
|
void MainWindow::on_action_remove_unused_samples() { |
2808 |
|
if (!file) return; |
2809 |
|
|
2810 |
|
// collect all samples that are not referenced by any instrument |
2811 |
|
std::list<gig::Sample*> lsamples; |
2812 |
|
for (int iSample = 0; file->GetSample(iSample); ++iSample) { |
2813 |
|
gig::Sample* sample = file->GetSample(iSample); |
2814 |
|
bool isUsed = false; |
2815 |
|
for (gig::Instrument* instrument = file->GetFirstInstrument(); instrument; |
2816 |
|
instrument = file->GetNextInstrument()) |
2817 |
|
{ |
2818 |
|
for (gig::Region* rgn = instrument->GetFirstRegion(); rgn; |
2819 |
|
rgn = instrument->GetNextRegion()) |
2820 |
|
{ |
2821 |
|
for (int i = 0; i < 256; ++i) { |
2822 |
|
if (!rgn->pDimensionRegions[i]) continue; |
2823 |
|
if (rgn->pDimensionRegions[i]->pSample != sample) continue; |
2824 |
|
isUsed = true; |
2825 |
|
goto endOfRefSearch; |
2826 |
|
} |
2827 |
|
} |
2828 |
|
} |
2829 |
|
endOfRefSearch: |
2830 |
|
if (!isUsed) lsamples.push_back(sample); |
2831 |
|
} |
2832 |
|
|
2833 |
|
if (lsamples.empty()) return; |
2834 |
|
|
2835 |
|
// notify everybody that we're going to remove these samples |
2836 |
|
samples_to_be_removed_signal.emit(lsamples); |
2837 |
|
|
2838 |
|
// remove collected samples |
2839 |
|
try { |
2840 |
|
for (std::list<gig::Sample*>::iterator itSample = lsamples.begin(); |
2841 |
|
itSample != lsamples.end(); ++itSample) |
2842 |
|
{ |
2843 |
|
gig::Sample* sample = *itSample; |
2844 |
|
// remove sample from the .gig file |
2845 |
|
file->DeleteSample(sample); |
2846 |
|
// if sample was just previously added, remove it fro the import queue |
2847 |
|
for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
2848 |
|
iter != m_SampleImportQueue.end(); ++iter) |
2849 |
|
{ |
2850 |
|
if ((*iter).gig_sample == sample) { |
2851 |
|
printf("Removing previously added sample '%s'\n", |
2852 |
|
(*iter).sample_path.c_str()); |
2853 |
|
m_SampleImportQueue.erase(iter); |
2854 |
|
break; |
2855 |
|
} |
2856 |
|
} |
2857 |
|
} |
2858 |
|
} catch (RIFF::Exception e) { |
2859 |
|
// show error message |
2860 |
|
Gtk::MessageDialog msg(*this, e.Message.c_str(), false, Gtk::MESSAGE_ERROR); |
2861 |
|
msg.run(); |
2862 |
|
} |
2863 |
|
|
2864 |
|
// notify everybody that we're done with removal |
2865 |
|
samples_removed_signal.emit(); |
2866 |
|
|
2867 |
|
dimreg_changed(); |
2868 |
|
file_changed(); |
2869 |
|
__refreshEntireGUI(); |
2870 |
|
} |
2871 |
|
|
2872 |
// see comment on on_sample_treeview_drag_begin() |
// see comment on on_sample_treeview_drag_begin() |
2873 |
void MainWindow::on_scripts_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context) |
void MainWindow::on_scripts_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context) |
2874 |
{ |
{ |
2895 |
sizeof(script)/*length of data in bytes*/); |
sizeof(script)/*length of data in bytes*/); |
2896 |
} |
} |
2897 |
|
|
2898 |
|
// see comment on on_sample_treeview_drag_begin() |
2899 |
|
void MainWindow::on_instruments_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context) |
2900 |
|
{ |
2901 |
|
first_call_to_drag_data_get = true; |
2902 |
|
} |
2903 |
|
|
2904 |
|
void MainWindow::on_instruments_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&, |
2905 |
|
Gtk::SelectionData& selection_data, guint, guint) |
2906 |
|
{ |
2907 |
|
if (!first_call_to_drag_data_get) return; |
2908 |
|
first_call_to_drag_data_get = false; |
2909 |
|
|
2910 |
|
// get selected source instrument |
2911 |
|
gig::Instrument* src = NULL; |
2912 |
|
{ |
2913 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
2914 |
|
Gtk::TreeModel::iterator it = sel->get_selected(); |
2915 |
|
if (it) { |
2916 |
|
Gtk::TreeModel::Row row = *it; |
2917 |
|
src = row[m_Columns.m_col_instr]; |
2918 |
|
} |
2919 |
|
} |
2920 |
|
if (!src) return; |
2921 |
|
|
2922 |
|
// pass the source gig::Instrument as pointer |
2923 |
|
selection_data.set(selection_data.get_target(), 0/*unused*/, (const guchar*)&src, |
2924 |
|
sizeof(src)/*length of data in bytes*/); |
2925 |
|
} |
2926 |
|
|
2927 |
|
void MainWindow::on_instruments_treeview_drop_drag_data_received( |
2928 |
|
const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, |
2929 |
|
const Gtk::SelectionData& selection_data, guint, guint time) |
2930 |
|
{ |
2931 |
|
gig::Instrument* src = *((gig::Instrument**) selection_data.get_data()); |
2932 |
|
if (!src || selection_data.get_length() != sizeof(gig::Instrument*)) |
2933 |
|
return; |
2934 |
|
|
2935 |
|
gig::Instrument* dst = NULL; |
2936 |
|
{ |
2937 |
|
Gtk::TreeModel::Path path; |
2938 |
|
const bool found = m_TreeView.get_path_at_pos(x, y, path); |
2939 |
|
if (!found) return; |
2940 |
|
|
2941 |
|
Gtk::TreeModel::iterator iter = m_refTreeModel->get_iter(path); |
2942 |
|
if (!iter) return; |
2943 |
|
Gtk::TreeModel::Row row = *iter; |
2944 |
|
dst = row[m_Columns.m_col_instr]; |
2945 |
|
} |
2946 |
|
if (!dst) return; |
2947 |
|
|
2948 |
|
//printf("dragdrop received src=%s dst=%s\n", src->pInfo->Name.c_str(), dst->pInfo->Name.c_str()); |
2949 |
|
src->MoveTo(dst); |
2950 |
|
__refreshEntireGUI(); |
2951 |
|
select_instrument(src); |
2952 |
|
} |
2953 |
|
|
2954 |
// For some reason drag_data_get gets called two times for each |
// For some reason drag_data_get gets called two times for each |
2955 |
// 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 |
2956 |
// 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 |
3102 |
} |
} |
3103 |
} |
} |
3104 |
|
|
3105 |
|
void MainWindow::script_double_clicked(const Gtk::TreeModel::Path& path, |
3106 |
|
Gtk::TreeViewColumn* column) |
3107 |
|
{ |
3108 |
|
Gtk::TreeModel::iterator iter = m_refScriptsTreeModel->get_iter(path); |
3109 |
|
if (!iter) return; |
3110 |
|
Gtk::TreeModel::Row row = *iter; |
3111 |
|
gig::Script* script = row[m_ScriptsModel.m_col_script]; |
3112 |
|
if (!script) return; |
3113 |
|
|
3114 |
|
ScriptEditor* editor = new ScriptEditor; |
3115 |
|
editor->signal_script_to_be_changed.connect( |
3116 |
|
signal_script_to_be_changed.make_slot() |
3117 |
|
); |
3118 |
|
editor->signal_script_changed.connect( |
3119 |
|
signal_script_changed.make_slot() |
3120 |
|
); |
3121 |
|
editor->setScript(script); |
3122 |
|
//editor->reparent(*this); |
3123 |
|
editor->show(); |
3124 |
|
} |
3125 |
|
|
3126 |
void MainWindow::instrument_name_changed(const Gtk::TreeModel::Path& path, |
void MainWindow::instrument_name_changed(const Gtk::TreeModel::Path& path, |
3127 |
const Gtk::TreeModel::iterator& iter) { |
const Gtk::TreeModel::iterator& iter) { |
3128 |
if (!iter) return; |
if (!iter) return; |
3179 |
|
|
3180 |
ReferencesView* d = new ReferencesView(*this); |
ReferencesView* d = new ReferencesView(*this); |
3181 |
d->setSample(sample); |
d->setSample(sample); |
3182 |
|
d->dimension_region_selected.connect( |
3183 |
|
sigc::mem_fun(*this, &MainWindow::select_dimension_region) |
3184 |
|
); |
3185 |
d->show_all(); |
d->show_all(); |
3186 |
d->resize(500, 400); |
d->resize(500, 400); |
3187 |
d->run(); |
d->run(); |
3255 |
); |
); |
3256 |
} |
} |
3257 |
|
|
3258 |
// Note: requires that this file already has a filename ! |
// Finally save gig file persistently to disk ... |
3259 |
this->file->Save(); |
//NOTE: requires that this gig file already has a filename ! |
3260 |
|
{ |
3261 |
|
std::cout << "Saving file\n" << std::flush; |
3262 |
|
file_structure_to_be_changed_signal.emit(this->file); |
3263 |
|
|
3264 |
|
progress_dialog = new ProgressDialog( //FIXME: memory leak! |
3265 |
|
_("Saving") + Glib::ustring(" '") + |
3266 |
|
Glib::filename_display_basename(this->filename) + "' ...", |
3267 |
|
*this |
3268 |
|
); |
3269 |
|
progress_dialog->show_all(); |
3270 |
|
saver = new Saver(this->file); //FIXME: memory leak! |
3271 |
|
saver->signal_progress().connect( |
3272 |
|
sigc::mem_fun(*this, &MainWindow::on_saver_progress)); |
3273 |
|
saver->signal_finished().connect( |
3274 |
|
sigc::mem_fun(*this, &MainWindow::on_saver_finished)); |
3275 |
|
saver->signal_error().connect( |
3276 |
|
sigc::mem_fun(*this, &MainWindow::on_saver_error)); |
3277 |
|
saver->launch(); |
3278 |
|
} |
3279 |
} |
} |
3280 |
|
|
3281 |
void MainWindow::on_action_merge_files() { |
void MainWindow::on_action_merge_files() { |
3293 |
} |
} |
3294 |
|
|
3295 |
Gtk::FileChooserDialog dialog(*this, _("Merge .gig files")); |
Gtk::FileChooserDialog dialog(*this, _("Merge .gig files")); |
3296 |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); |
3297 |
dialog.add_button(_("Merge"), Gtk::RESPONSE_OK); |
dialog.add_button(_("Merge"), Gtk::RESPONSE_OK); |
3298 |
dialog.set_default_response(Gtk::RESPONSE_CANCEL); |
dialog.set_default_response(Gtk::RESPONSE_CANCEL); |
3299 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
3312 |
// show warning in the file picker dialog |
// show warning in the file picker dialog |
3313 |
Gtk::HBox descriptionArea; |
Gtk::HBox descriptionArea; |
3314 |
descriptionArea.set_spacing(15); |
descriptionArea.set_spacing(15); |
3315 |
Gtk::Image warningIcon(Gtk::Stock::DIALOG_WARNING, Gtk::IconSize(Gtk::ICON_SIZE_DIALOG)); |
Gtk::Image warningIcon; |
3316 |
|
warningIcon.set_from_icon_name("dialog-warning", |
3317 |
|
Gtk::IconSize(Gtk::ICON_SIZE_DIALOG)); |
3318 |
descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK); |
descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK); |
3319 |
#if GTKMM_MAJOR_VERSION < 3 |
#if GTKMM_MAJOR_VERSION < 3 |
3320 |
view::WrapLabel description; |
view::WrapLabel description; |
3337 |
descriptionArea.show_all(); |
descriptionArea.show_all(); |
3338 |
|
|
3339 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
3340 |
printf("on_action_merge_files self=%x\n", Glib::Threads::Thread::self()); |
printf("on_action_merge_files self=%p\n", |
3341 |
|
static_cast<void*>(Glib::Threads::Thread::self())); |
3342 |
std::vector<std::string> filenames = dialog.get_filenames(); |
std::vector<std::string> filenames = dialog.get_filenames(); |
3343 |
|
|
3344 |
// merge the selected files to the currently open .gig file |
// merge the selected files to the currently open .gig file |
3350 |
} |
} |
3351 |
|
|
3352 |
// update GUI |
// update GUI |
3353 |
__refreshEntireGUI(); |
__refreshEntireGUI(); |
3354 |
} |
} |
3355 |
} |
} |
3356 |
|
|
3368 |
Gdk::Pixbuf::create_from_xpm_data(status_detached_xpm) |
Gdk::Pixbuf::create_from_xpm_data(status_detached_xpm) |
3369 |
); |
); |
3370 |
} |
} |
3371 |
|
|
3372 |
|
{ |
3373 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
3374 |
|
uiManager->get_widget("/MenuBar/MenuSettings/SyncSamplerInstrumentSelection")); |
3375 |
|
if (item) item->set_sensitive(b); |
3376 |
|
} |
3377 |
} |
} |
3378 |
|
|
3379 |
void MainWindow::on_sample_ref_count_incremented(gig::Sample* sample, int offset) { |
void MainWindow::on_sample_ref_count_incremented(gig::Sample* sample, int offset) { |
3388 |
Gtk::TreeModel::Row rowSample = rowGroup.children()[s]; |
Gtk::TreeModel::Row rowSample = rowGroup.children()[s]; |
3389 |
if (rowSample[m_SamplesModel.m_col_sample] != sample) continue; |
if (rowSample[m_SamplesModel.m_col_sample] != sample) continue; |
3390 |
rowSample[m_SamplesModel.m_col_refcount] = ToString(refcount) + " " + _("Refs."); |
rowSample[m_SamplesModel.m_col_refcount] = ToString(refcount) + " " + _("Refs."); |
3391 |
rowSample[m_SamplesModel.m_color] = refcount ? "black" : "gray"; |
rowSample[m_SamplesModel.m_color] = refcount ? "black" : "red"; |
3392 |
} |
} |
3393 |
} |
} |
3394 |
} |
} |
3402 |
// just in case a new sample is added later with exactly the same memory |
// just in case a new sample is added later with exactly the same memory |
3403 |
// address, which would lead to incorrect refcount if not deleted here |
// address, which would lead to incorrect refcount if not deleted here |
3404 |
for (std::list<gig::Sample*>::const_iterator it = samples.begin(); |
for (std::list<gig::Sample*>::const_iterator it = samples.begin(); |
3405 |
it != samples.end(); it != samples.end()) |
it != samples.end(); ++it) |
3406 |
{ |
{ |
3407 |
sample_ref_count.erase(*it); |
sample_ref_count.erase(*it); |
3408 |
} |
} |
3409 |
} |
} |
3410 |
|
|
3411 |
|
void MainWindow::show_samples_tab() { |
3412 |
|
m_TreeViewNotebook.set_current_page(0); |
3413 |
|
} |
3414 |
|
|
3415 |
|
void MainWindow::show_intruments_tab() { |
3416 |
|
m_TreeViewNotebook.set_current_page(1); |
3417 |
|
} |
3418 |
|
|
3419 |
|
void MainWindow::show_scripts_tab() { |
3420 |
|
m_TreeViewNotebook.set_current_page(2); |
3421 |
|
} |
3422 |
|
|
3423 |
sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() { |
sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() { |
3424 |
return file_structure_to_be_changed_signal; |
return file_structure_to_be_changed_signal; |
3425 |
} |
} |
3475 |
sigc::signal<void, int/*key*/, int/*velocity*/>& MainWindow::signal_keyboard_key_released() { |
sigc::signal<void, int/*key*/, int/*velocity*/>& MainWindow::signal_keyboard_key_released() { |
3476 |
return m_RegionChooser.signal_keyboard_key_released(); |
return m_RegionChooser.signal_keyboard_key_released(); |
3477 |
} |
} |
3478 |
|
|
3479 |
|
sigc::signal<void, gig::Instrument*>& MainWindow::signal_switch_sampler_instrument() { |
3480 |
|
return switch_sampler_instrument_signal; |
3481 |
|
} |