186 |
actionGroup->add(toggle_action, |
actionGroup->add(toggle_action, |
187 |
sigc::mem_fun( |
sigc::mem_fun( |
188 |
*this, &MainWindow::on_action_view_status_bar)); |
*this, &MainWindow::on_action_view_status_bar)); |
189 |
|
actionGroup->add( |
190 |
|
Gtk::Action::create("RefreshAll", _("_Refresh All")), |
191 |
|
sigc::mem_fun(*this, &MainWindow::on_action_refresh_all) |
192 |
|
); |
193 |
|
|
194 |
action = Gtk::Action::create("MenuHelp", Gtk::Stock::HELP); |
action = Gtk::Action::create("MenuHelp", Gtk::Stock::HELP); |
195 |
actionGroup->add(Gtk::Action::create("MenuHelp", |
actionGroup->add(Gtk::Action::create("MenuHelp", |
261 |
sigc::mem_fun(*this, &MainWindow::on_action_remove_sample) |
sigc::mem_fun(*this, &MainWindow::on_action_remove_sample) |
262 |
); |
); |
263 |
actionGroup->add( |
actionGroup->add( |
264 |
|
Gtk::Action::create("RemoveUnusedSamples", _("Remove _Unused Samples")), |
265 |
|
sigc::mem_fun(*this, &MainWindow::on_action_remove_unused_samples) |
266 |
|
); |
267 |
|
actionGroup->add( |
268 |
Gtk::Action::create("ShowSampleRefs", _("Show References...")), |
Gtk::Action::create("ShowSampleRefs", _("Show References...")), |
269 |
sigc::mem_fun(*this, &MainWindow::on_action_view_references) |
sigc::mem_fun(*this, &MainWindow::on_action_view_references) |
270 |
); |
); |
271 |
actionGroup->add( |
actionGroup->add( |
272 |
|
Gtk::Action::create("ReplaceSample", |
273 |
|
_("Replace Sample...")), |
274 |
|
sigc::mem_fun(*this, &MainWindow::on_action_replace_sample) |
275 |
|
); |
276 |
|
actionGroup->add( |
277 |
Gtk::Action::create("ReplaceAllSamplesInAllGroups", |
Gtk::Action::create("ReplaceAllSamplesInAllGroups", |
278 |
_("Replace All Samples in All Groups...")), |
_("Replace All Samples in All Groups...")), |
279 |
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) |
325 |
" <menuitem action='AddGroup'/>" |
" <menuitem action='AddGroup'/>" |
326 |
" <menuitem action='AddSample'/>" |
" <menuitem action='AddSample'/>" |
327 |
" <menuitem action='ShowSampleRefs'/>" |
" <menuitem action='ShowSampleRefs'/>" |
328 |
|
" <menuitem action='ReplaceSample' />" |
329 |
" <menuitem action='ReplaceAllSamplesInAllGroups' />" |
" <menuitem action='ReplaceAllSamplesInAllGroups' />" |
330 |
" <separator/>" |
" <separator/>" |
331 |
" <menuitem action='RemoveSample'/>" |
" <menuitem action='RemoveSample'/>" |
332 |
|
" <menuitem action='RemoveUnusedSamples'/>" |
333 |
" </menu>" |
" </menu>" |
334 |
" <menu action='MenuInstrument'>" |
" <menu action='MenuInstrument'>" |
335 |
" <menu action='AllInstruments'>" |
" <menu action='AllInstruments'>" |
352 |
" </menu>" |
" </menu>" |
353 |
" <menu action='MenuView'>" |
" <menu action='MenuView'>" |
354 |
" <menuitem action='Statusbar'/>" |
" <menuitem action='Statusbar'/>" |
355 |
|
" <separator/>" |
356 |
|
" <menuitem action='RefreshAll'/>" |
357 |
" </menu>" |
" </menu>" |
358 |
" <menu action='MenuTools'>" |
" <menu action='MenuTools'>" |
359 |
" <menuitem action='CombineInstruments'/>" |
" <menuitem action='CombineInstruments'/>" |
381 |
" <menuitem action='AddGroup'/>" |
" <menuitem action='AddGroup'/>" |
382 |
" <menuitem action='AddSample'/>" |
" <menuitem action='AddSample'/>" |
383 |
" <menuitem action='ShowSampleRefs'/>" |
" <menuitem action='ShowSampleRefs'/>" |
384 |
|
" <menuitem action='ReplaceSample' />" |
385 |
" <menuitem action='ReplaceAllSamplesInAllGroups' />" |
" <menuitem action='ReplaceAllSamplesInAllGroups' />" |
386 |
" <separator/>" |
" <separator/>" |
387 |
" <menuitem action='RemoveSample'/>" |
" <menuitem action='RemoveSample'/>" |
388 |
|
" <menuitem action='RemoveUnusedSamples'/>" |
389 |
" </popup>" |
" </popup>" |
390 |
" <popup name='ScriptPopupMenu'>" |
" <popup name='ScriptPopupMenu'>" |
391 |
" <menuitem action='AddScriptGroup'/>" |
" <menuitem action='AddScriptGroup'/>" |
430 |
} |
} |
431 |
{ |
{ |
432 |
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
433 |
|
uiManager->get_widget("/MenuBar/MenuSample/RemoveUnusedSamples")); |
434 |
|
item->set_tooltip_text(_("Removes all samples that are not referenced by any instrument (i.e. red ones).")); |
435 |
|
// copy tooltip to popup menu |
436 |
|
Gtk::MenuItem* item2 = dynamic_cast<Gtk::MenuItem*>( |
437 |
|
uiManager->get_widget("/SamplePopupMenu/RemoveUnusedSamples")); |
438 |
|
item2->set_tooltip_text(item->get_tooltip_text()); |
439 |
|
} |
440 |
|
{ |
441 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
442 |
|
uiManager->get_widget("/MenuBar/MenuView/RefreshAll")); |
443 |
|
item->set_tooltip_text(_("Reloads the currently open gig file and updates the entire graphical user interface.")); |
444 |
|
} |
445 |
|
{ |
446 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
447 |
uiManager->get_widget("/MenuBar/MenuTools/CombineInstruments")); |
uiManager->get_widget("/MenuBar/MenuTools/CombineInstruments")); |
448 |
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.")); |
449 |
} |
} |
481 |
// Create the Tree model: |
// Create the Tree model: |
482 |
m_refTreeModel = Gtk::ListStore::create(m_Columns); |
m_refTreeModel = Gtk::ListStore::create(m_Columns); |
483 |
m_TreeView.set_model(m_refTreeModel); |
m_TreeView.set_model(m_refTreeModel); |
484 |
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.")); |
485 |
instrument_name_connection = m_refTreeModel->signal_row_changed().connect( |
instrument_name_connection = m_refTreeModel->signal_row_changed().connect( |
486 |
sigc::mem_fun(*this, &MainWindow::instrument_name_changed) |
sigc::mem_fun(*this, &MainWindow::instrument_name_changed) |
487 |
); |
); |
489 |
// Add the TreeView's view columns: |
// Add the TreeView's view columns: |
490 |
m_TreeView.append_column_editable("Instrument", m_Columns.m_col_name); |
m_TreeView.append_column_editable("Instrument", m_Columns.m_col_name); |
491 |
m_TreeView.set_headers_visible(false); |
m_TreeView.set_headers_visible(false); |
492 |
|
|
493 |
|
// establish drag&drop within the instrument tree view, allowing to reorder |
494 |
|
// the sequence of instruments within the gig file |
495 |
|
{ |
496 |
|
std::vector<Gtk::TargetEntry> drag_target_instrument; |
497 |
|
drag_target_instrument.push_back(Gtk::TargetEntry("gig::Instrument")); |
498 |
|
m_TreeView.drag_source_set(drag_target_instrument); |
499 |
|
m_TreeView.drag_dest_set(drag_target_instrument); |
500 |
|
m_TreeView.signal_drag_begin().connect( |
501 |
|
sigc::mem_fun(*this, &MainWindow::on_instruments_treeview_drag_begin) |
502 |
|
); |
503 |
|
m_TreeView.signal_drag_data_get().connect( |
504 |
|
sigc::mem_fun(*this, &MainWindow::on_instruments_treeview_drag_data_get) |
505 |
|
); |
506 |
|
m_TreeView.signal_drag_data_received().connect( |
507 |
|
sigc::mem_fun(*this, &MainWindow::on_instruments_treeview_drop_drag_data_received) |
508 |
|
); |
509 |
|
} |
510 |
|
|
511 |
// create samples treeview (including its data model) |
// create samples treeview (including its data model) |
512 |
m_refSamplesTreeModel = SamplesTreeStore::create(m_SamplesModel); |
m_refSamplesTreeModel = SamplesTreeStore::create(m_SamplesModel); |
554 |
m_TreeViewScripts.signal_button_press_event().connect_notify( |
m_TreeViewScripts.signal_button_press_event().connect_notify( |
555 |
sigc::mem_fun(*this, &MainWindow::on_script_treeview_button_release) |
sigc::mem_fun(*this, &MainWindow::on_script_treeview_button_release) |
556 |
); |
); |
557 |
//FIXME: why the heck does this double click signal_row_activated() only fired while CTRL key is pressed ? |
//FIXME: why the heck does this double click signal_row_activated() only fire while CTRL key is pressed ? |
558 |
m_TreeViewScripts.signal_row_activated().connect( |
m_TreeViewScripts.signal_row_activated().connect( |
559 |
sigc::mem_fun(*this, &MainWindow::script_double_clicked) |
sigc::mem_fun(*this, &MainWindow::script_double_clicked) |
560 |
); |
); |
1220 |
|
|
1221 |
file_structure_changed_signal.emit(this->file); |
file_structure_changed_signal.emit(this->file); |
1222 |
|
|
1223 |
load_gig(this->file, this->filename.c_str()); |
__refreshEntireGUI(); |
1224 |
progress_dialog->hide(); |
progress_dialog->hide(); |
1225 |
} |
} |
1226 |
|
|
1715 |
file = 0; |
file = 0; |
1716 |
set_file_is_shared(isSharedInstrument); |
set_file_is_shared(isSharedInstrument); |
1717 |
|
|
1718 |
this->filename = filename ? filename : _("Unsaved Gig File"); |
this->filename = |
1719 |
|
(filename && strlen(filename) > 0) ? |
1720 |
|
filename : (!gig->GetFileName().empty()) ? |
1721 |
|
gig->GetFileName() : _("Unsaved Gig File"); |
1722 |
set_title(Glib::filename_display_basename(this->filename)); |
set_title(Glib::filename_display_basename(this->filename)); |
1723 |
file_has_name = filename; |
file_has_name = filename; |
1724 |
file_is_changed = false; |
file_is_changed = false; |
1872 |
window->show(); |
window->show(); |
1873 |
} |
} |
1874 |
|
|
1875 |
|
void MainWindow::on_action_refresh_all() { |
1876 |
|
__refreshEntireGUI(); |
1877 |
|
} |
1878 |
|
|
1879 |
void MainWindow::on_action_view_status_bar() { |
void MainWindow::on_action_view_status_bar() { |
1880 |
Gtk::CheckMenuItem* item = |
Gtk::CheckMenuItem* item = |
1881 |
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/Statusbar")); |
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/Statusbar")); |
1951 |
} |
} |
1952 |
} |
} |
1953 |
|
|
1954 |
|
void MainWindow::select_instrument(gig::Instrument* instrument) { |
1955 |
|
if (!instrument) return; |
1956 |
|
|
1957 |
|
Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model(); |
1958 |
|
for (int i = 0; i < model->children().size(); ++i) { |
1959 |
|
Gtk::TreeModel::Row row = model->children()[i]; |
1960 |
|
if (row[m_Columns.m_col_instr] == instrument) { |
1961 |
|
// select and show the respective instrument in the list view |
1962 |
|
show_intruments_tab(); |
1963 |
|
m_TreeView.get_selection()->select(model->children()[i]); |
1964 |
|
Gtk::TreePath path( |
1965 |
|
m_TreeView.get_selection()->get_selected() |
1966 |
|
); |
1967 |
|
m_TreeView.scroll_to_row(path); |
1968 |
|
on_sel_change(); // the regular instrument selection change callback |
1969 |
|
} |
1970 |
|
} |
1971 |
|
} |
1972 |
|
|
1973 |
|
/// Returns true if requested dimension region was successfully selected and scrolled to in the list view, false on error. |
1974 |
|
bool MainWindow::select_dimension_region(gig::DimensionRegion* dimRgn) { |
1975 |
|
gig::Region* pRegion = (gig::Region*) dimRgn->GetParent(); |
1976 |
|
gig::Instrument* pInstrument = (gig::Instrument*) pRegion->GetParent(); |
1977 |
|
|
1978 |
|
Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model(); |
1979 |
|
for (int i = 0; i < model->children().size(); ++i) { |
1980 |
|
Gtk::TreeModel::Row row = model->children()[i]; |
1981 |
|
if (row[m_Columns.m_col_instr] == pInstrument) { |
1982 |
|
// select and show the respective instrument in the list view |
1983 |
|
show_intruments_tab(); |
1984 |
|
m_TreeView.get_selection()->select(model->children()[i]); |
1985 |
|
Gtk::TreePath path( |
1986 |
|
m_TreeView.get_selection()->get_selected() |
1987 |
|
); |
1988 |
|
m_TreeView.scroll_to_row(path); |
1989 |
|
on_sel_change(); // the regular instrument selection change callback |
1990 |
|
|
1991 |
|
// select respective region in the region selector |
1992 |
|
m_RegionChooser.set_region(pRegion); |
1993 |
|
|
1994 |
|
// select and show the respective dimension region in the editor |
1995 |
|
//update_dimregs(); |
1996 |
|
if (!m_DimRegionChooser.select_dimregion(dimRgn)) return false; |
1997 |
|
//dimreg_edit.set_dim_region(dimRgn); |
1998 |
|
|
1999 |
|
return true; |
2000 |
|
} |
2001 |
|
} |
2002 |
|
|
2003 |
|
return false; |
2004 |
|
} |
2005 |
|
|
2006 |
void MainWindow::select_sample(gig::Sample* sample) { |
void MainWindow::select_sample(gig::Sample* sample) { |
2007 |
Glib::RefPtr<Gtk::TreeModel> model = m_TreeViewSamples.get_model(); |
Glib::RefPtr<Gtk::TreeModel> model = m_TreeViewSamples.get_model(); |
2008 |
for (int g = 0; g < model->children().size(); ++g) { |
for (int g = 0; g < model->children().size(); ++g) { |
2374 |
file_changed(); |
file_changed(); |
2375 |
} |
} |
2376 |
|
|
2377 |
|
void MainWindow::on_action_replace_sample() { |
2378 |
|
add_or_replace_sample(true); |
2379 |
|
} |
2380 |
|
|
2381 |
void MainWindow::on_action_add_sample() { |
void MainWindow::on_action_add_sample() { |
2382 |
|
add_or_replace_sample(false); |
2383 |
|
} |
2384 |
|
|
2385 |
|
void MainWindow::add_or_replace_sample(bool replace) { |
2386 |
if (!file) return; |
if (!file) return; |
2387 |
// get selected group |
|
2388 |
|
// get selected group (and probably selected sample) |
2389 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
2390 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
Gtk::TreeModel::iterator it = sel->get_selected(); |
2391 |
if (!it) return; |
if (!it) return; |
2392 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
2393 |
|
gig::Sample* sample = NULL; |
2394 |
gig::Group* group = row[m_SamplesModel.m_col_group]; |
gig::Group* group = row[m_SamplesModel.m_col_group]; |
2395 |
if (!group) { // not a group, but a sample is selected (probably) |
if (!group) { // not a group, but a sample is selected (probably) |
2396 |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
if (replace) sample = row[m_SamplesModel.m_col_sample]; |
2397 |
if (!sample) return; |
if (!row[m_SamplesModel.m_col_sample]) return; |
2398 |
it = row.parent(); // resolve parent (that is the sample's group) |
it = row.parent(); // resolve parent (that is the sample's group) |
2399 |
if (!it) return; |
if (!it) return; |
2400 |
row = *it; |
if (!replace) row = *it; |
2401 |
group = row[m_SamplesModel.m_col_group]; |
group = (*it)[m_SamplesModel.m_col_group]; |
2402 |
if (!group) return; |
if (!group) return; |
2403 |
} |
} |
2404 |
|
if (replace && !sample) return; |
2405 |
|
|
2406 |
// show 'browse for file' dialog |
// show 'browse for file' dialog |
2407 |
Gtk::FileChooserDialog dialog(*this, _("Add Sample(s)")); |
Gtk::FileChooserDialog dialog(*this, replace ? _("Replace Sample with") : _("Add Sample(s)")); |
2408 |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
2409 |
dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); |
dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); |
2410 |
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 |
2411 |
|
|
2412 |
// matches all file types supported by libsndfile |
// matches all file types supported by libsndfile |
2413 |
#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 |
2478 |
sf_close(hFile); // close sound file |
sf_close(hFile); // close sound file |
2479 |
throw std::string(_("format not supported")); // unsupported subformat (yet?) |
throw std::string(_("format not supported")); // unsupported subformat (yet?) |
2480 |
} |
} |
2481 |
// add a new sample to the .gig file |
// add a new sample to the .gig file (if adding is requested actually) |
2482 |
gig::Sample* sample = file->AddSample(); |
if (!replace) sample = file->AddSample(); |
2483 |
// file name without path |
// file name without path |
2484 |
Glib::ustring filename = Glib::filename_display_basename(*iter); |
Glib::ustring filename = Glib::filename_display_basename(*iter); |
2485 |
// remove file extension if there is one |
// remove file extension if there is one |
2530 |
// physically when File::Save() is called) |
// physically when File::Save() is called) |
2531 |
sample->Resize(info.frames); |
sample->Resize(info.frames); |
2532 |
// make sure sample is part of the selected group |
// make sure sample is part of the selected group |
2533 |
group->AddSample(sample); |
if (!replace) group->AddSample(sample); |
2534 |
// schedule that physical resize and sample import |
// schedule that physical resize and sample import |
2535 |
// (data copying), performed when "Save" is requested |
// (data copying), performed when "Save" is requested |
2536 |
SampleImportItem sched_item; |
SampleImportItem sched_item; |
2538 |
sched_item.sample_path = *iter; |
sched_item.sample_path = *iter; |
2539 |
m_SampleImportQueue.push_back(sched_item); |
m_SampleImportQueue.push_back(sched_item); |
2540 |
// add sample to the tree view |
// add sample to the tree view |
2541 |
Gtk::TreeModel::iterator iterSample = |
if (replace) { |
2542 |
m_refSamplesTreeModel->append(row.children()); |
row[m_SamplesModel.m_col_name] = gig_to_utf8(sample->pInfo->Name); |
2543 |
Gtk::TreeModel::Row rowSample = *iterSample; |
} else { |
2544 |
rowSample[m_SamplesModel.m_col_name] = |
Gtk::TreeModel::iterator iterSample = |
2545 |
gig_to_utf8(sample->pInfo->Name); |
m_refSamplesTreeModel->append(row.children()); |
2546 |
rowSample[m_SamplesModel.m_col_sample] = sample; |
Gtk::TreeModel::Row rowSample = *iterSample; |
2547 |
rowSample[m_SamplesModel.m_col_group] = NULL; |
rowSample[m_SamplesModel.m_col_name] = |
2548 |
|
gig_to_utf8(sample->pInfo->Name); |
2549 |
|
rowSample[m_SamplesModel.m_col_sample] = sample; |
2550 |
|
rowSample[m_SamplesModel.m_col_group] = NULL; |
2551 |
|
} |
2552 |
// close sound file |
// close sound file |
2553 |
sf_close(hFile); |
sf_close(hFile); |
2554 |
file_changed(); |
file_changed(); |
2559 |
} |
} |
2560 |
// 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 |
2561 |
if (!error_files.empty()) { |
if (!error_files.empty()) { |
2562 |
Glib::ustring txt = _("Could not add the following sample(s):\n") + error_files; |
Glib::ustring txt = |
2563 |
|
(replace |
2564 |
|
? _("Failed to replace sample with:\n") |
2565 |
|
: _("Could not add the following sample(s):\n")) |
2566 |
|
+ error_files; |
2567 |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
2568 |
msg.run(); |
msg.run(); |
2569 |
} |
} |
2747 |
} |
} |
2748 |
} |
} |
2749 |
|
|
2750 |
|
void MainWindow::on_action_remove_unused_samples() { |
2751 |
|
if (!file) return; |
2752 |
|
|
2753 |
|
// collect all samples that are not referenced by any instrument |
2754 |
|
std::list<gig::Sample*> lsamples; |
2755 |
|
for (int iSample = 0; file->GetSample(iSample); ++iSample) { |
2756 |
|
gig::Sample* sample = file->GetSample(iSample); |
2757 |
|
bool isUsed = false; |
2758 |
|
for (gig::Instrument* instrument = file->GetFirstInstrument(); instrument; |
2759 |
|
instrument = file->GetNextInstrument()) |
2760 |
|
{ |
2761 |
|
for (gig::Region* rgn = instrument->GetFirstRegion(); rgn; |
2762 |
|
rgn = instrument->GetNextRegion()) |
2763 |
|
{ |
2764 |
|
for (int i = 0; i < 256; ++i) { |
2765 |
|
if (!rgn->pDimensionRegions[i]) continue; |
2766 |
|
if (rgn->pDimensionRegions[i]->pSample != sample) continue; |
2767 |
|
isUsed = true; |
2768 |
|
goto endOfRefSearch; |
2769 |
|
} |
2770 |
|
} |
2771 |
|
} |
2772 |
|
endOfRefSearch: |
2773 |
|
if (!isUsed) lsamples.push_back(sample); |
2774 |
|
} |
2775 |
|
|
2776 |
|
if (lsamples.empty()) return; |
2777 |
|
|
2778 |
|
// notify everybody that we're going to remove these samples |
2779 |
|
samples_to_be_removed_signal.emit(lsamples); |
2780 |
|
|
2781 |
|
// remove collected samples |
2782 |
|
try { |
2783 |
|
for (std::list<gig::Sample*>::iterator itSample = lsamples.begin(); |
2784 |
|
itSample != lsamples.end(); ++itSample) |
2785 |
|
{ |
2786 |
|
gig::Sample* sample = *itSample; |
2787 |
|
// remove sample from the .gig file |
2788 |
|
file->DeleteSample(sample); |
2789 |
|
// if sample was just previously added, remove it fro the import queue |
2790 |
|
for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
2791 |
|
iter != m_SampleImportQueue.end(); ++iter) |
2792 |
|
{ |
2793 |
|
if ((*iter).gig_sample == sample) { |
2794 |
|
printf("Removing previously added sample '%s'\n", |
2795 |
|
(*iter).sample_path.c_str()); |
2796 |
|
m_SampleImportQueue.erase(iter); |
2797 |
|
break; |
2798 |
|
} |
2799 |
|
} |
2800 |
|
} |
2801 |
|
} catch (RIFF::Exception e) { |
2802 |
|
// show error message |
2803 |
|
Gtk::MessageDialog msg(*this, e.Message.c_str(), false, Gtk::MESSAGE_ERROR); |
2804 |
|
msg.run(); |
2805 |
|
} |
2806 |
|
|
2807 |
|
// notify everybody that we're done with removal |
2808 |
|
samples_removed_signal.emit(); |
2809 |
|
|
2810 |
|
dimreg_changed(); |
2811 |
|
file_changed(); |
2812 |
|
__refreshEntireGUI(); |
2813 |
|
} |
2814 |
|
|
2815 |
// see comment on on_sample_treeview_drag_begin() |
// see comment on on_sample_treeview_drag_begin() |
2816 |
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) |
2817 |
{ |
{ |
2838 |
sizeof(script)/*length of data in bytes*/); |
sizeof(script)/*length of data in bytes*/); |
2839 |
} |
} |
2840 |
|
|
2841 |
|
// see comment on on_sample_treeview_drag_begin() |
2842 |
|
void MainWindow::on_instruments_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context) |
2843 |
|
{ |
2844 |
|
first_call_to_drag_data_get = true; |
2845 |
|
} |
2846 |
|
|
2847 |
|
void MainWindow::on_instruments_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&, |
2848 |
|
Gtk::SelectionData& selection_data, guint, guint) |
2849 |
|
{ |
2850 |
|
if (!first_call_to_drag_data_get) return; |
2851 |
|
first_call_to_drag_data_get = false; |
2852 |
|
|
2853 |
|
// get selected source instrument |
2854 |
|
gig::Instrument* src = NULL; |
2855 |
|
{ |
2856 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
2857 |
|
Gtk::TreeModel::iterator it = sel->get_selected(); |
2858 |
|
if (it) { |
2859 |
|
Gtk::TreeModel::Row row = *it; |
2860 |
|
src = row[m_Columns.m_col_instr]; |
2861 |
|
} |
2862 |
|
} |
2863 |
|
if (!src) return; |
2864 |
|
|
2865 |
|
// pass the source gig::Instrument as pointer |
2866 |
|
selection_data.set(selection_data.get_target(), 0/*unused*/, (const guchar*)&src, |
2867 |
|
sizeof(src)/*length of data in bytes*/); |
2868 |
|
} |
2869 |
|
|
2870 |
|
void MainWindow::on_instruments_treeview_drop_drag_data_received( |
2871 |
|
const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, |
2872 |
|
const Gtk::SelectionData& selection_data, guint, guint time) |
2873 |
|
{ |
2874 |
|
gig::Instrument* src = *((gig::Instrument**) selection_data.get_data()); |
2875 |
|
if (!src || selection_data.get_length() != sizeof(gig::Instrument*)) |
2876 |
|
return; |
2877 |
|
|
2878 |
|
gig::Instrument* dst = NULL; |
2879 |
|
{ |
2880 |
|
Gtk::TreeModel::Path path; |
2881 |
|
const bool found = m_TreeView.get_path_at_pos(x, y, path); |
2882 |
|
if (!found) return; |
2883 |
|
|
2884 |
|
Gtk::TreeModel::iterator iter = m_refTreeModel->get_iter(path); |
2885 |
|
if (!iter) return; |
2886 |
|
Gtk::TreeModel::Row row = *iter; |
2887 |
|
dst = row[m_Columns.m_col_instr]; |
2888 |
|
} |
2889 |
|
if (!dst) return; |
2890 |
|
|
2891 |
|
//printf("dragdrop received src=%s dst=%s\n", src->pInfo->Name.c_str(), dst->pInfo->Name.c_str()); |
2892 |
|
src->MoveTo(dst); |
2893 |
|
__refreshEntireGUI(); |
2894 |
|
select_instrument(src); |
2895 |
|
} |
2896 |
|
|
2897 |
// For some reason drag_data_get gets called two times for each |
// For some reason drag_data_get gets called two times for each |
2898 |
// 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 |
2899 |
// 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 |
3116 |
|
|
3117 |
ReferencesView* d = new ReferencesView(*this); |
ReferencesView* d = new ReferencesView(*this); |
3118 |
d->setSample(sample); |
d->setSample(sample); |
3119 |
|
d->dimension_region_selected.connect( |
3120 |
|
sigc::mem_fun(*this, &MainWindow::select_dimension_region) |
3121 |
|
); |
3122 |
d->show_all(); |
d->show_all(); |
3123 |
d->resize(500, 400); |
d->resize(500, 400); |
3124 |
d->run(); |
d->run(); |
3284 |
} |
} |
3285 |
|
|
3286 |
// update GUI |
// update GUI |
3287 |
__refreshEntireGUI(); |
__refreshEntireGUI(); |
3288 |
} |
} |
3289 |
} |
} |
3290 |
|
|