46 |
#include "Settings.h" |
#include "Settings.h" |
47 |
#include "CombineInstrumentsDialog.h" |
#include "CombineInstrumentsDialog.h" |
48 |
#include "scripteditor.h" |
#include "scripteditor.h" |
49 |
|
#include "scriptslots.h" |
50 |
|
#include "ReferencesView.h" |
51 |
#include "../../gfx/status_attached.xpm" |
#include "../../gfx/status_attached.xpm" |
52 |
#include "../../gfx/status_detached.xpm" |
#include "../../gfx/status_detached.xpm" |
53 |
|
|
136 |
sigc::mem_fun( |
sigc::mem_fun( |
137 |
*this, &MainWindow::show_instr_props)); |
*this, &MainWindow::show_instr_props)); |
138 |
actionGroup->add(Gtk::Action::create("MidiRules", |
actionGroup->add(Gtk::Action::create("MidiRules", |
139 |
_("_Midi Rules")), |
_("_Midi Rules...")), |
140 |
sigc::mem_fun( |
sigc::mem_fun( |
141 |
*this, &MainWindow::show_midi_rules)); |
*this, &MainWindow::show_midi_rules)); |
142 |
|
actionGroup->add(Gtk::Action::create("ScriptSlots", |
143 |
|
_("_Script Slots...")), |
144 |
|
sigc::mem_fun( |
145 |
|
*this, &MainWindow::show_script_slots)); |
146 |
actionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT), |
actionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT), |
147 |
sigc::mem_fun( |
sigc::mem_fun( |
148 |
*this, &MainWindow::on_action_quit)); |
*this, &MainWindow::on_action_quit)); |
149 |
actionGroup->add(Gtk::Action::create("MenuInstrument", _("_Instrument"))); |
actionGroup->add( |
150 |
|
Gtk::Action::create("MenuSample", _("_Sample")), |
151 |
|
sigc::mem_fun(*this, &MainWindow::show_samples_tab) |
152 |
|
); |
153 |
|
actionGroup->add( |
154 |
|
Gtk::Action::create("MenuInstrument", _("_Instrument")), |
155 |
|
sigc::mem_fun(*this, &MainWindow::show_intruments_tab) |
156 |
|
); |
157 |
|
actionGroup->add( |
158 |
|
Gtk::Action::create("MenuScript", _("S_cript")), |
159 |
|
sigc::mem_fun(*this, &MainWindow::show_scripts_tab) |
160 |
|
); |
161 |
|
actionGroup->add(Gtk::Action::create("AllInstruments", _("_Select"))); |
162 |
|
|
163 |
actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit"))); |
actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit"))); |
164 |
|
|
248 |
sigc::mem_fun(*this, &MainWindow::on_action_remove_sample) |
sigc::mem_fun(*this, &MainWindow::on_action_remove_sample) |
249 |
); |
); |
250 |
actionGroup->add( |
actionGroup->add( |
251 |
|
Gtk::Action::create("ShowSampleRefs", _("Show References...")), |
252 |
|
sigc::mem_fun(*this, &MainWindow::on_action_view_references) |
253 |
|
); |
254 |
|
actionGroup->add( |
255 |
Gtk::Action::create("ReplaceAllSamplesInAllGroups", |
Gtk::Action::create("ReplaceAllSamplesInAllGroups", |
256 |
_("Replace All Samples in All Groups...")), |
_("Replace All Samples in All Groups...")), |
257 |
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) |
298 |
" <menuitem action='CopySampleTune'/>" |
" <menuitem action='CopySampleTune'/>" |
299 |
" <menuitem action='CopySampleLoop'/>" |
" <menuitem action='CopySampleLoop'/>" |
300 |
" </menu>" |
" </menu>" |
301 |
|
" <menu action='MenuSample'>" |
302 |
|
" <menuitem action='SampleProperties'/>" |
303 |
|
" <menuitem action='AddGroup'/>" |
304 |
|
" <menuitem action='AddSample'/>" |
305 |
|
" <menuitem action='ShowSampleRefs'/>" |
306 |
|
" <menuitem action='ReplaceAllSamplesInAllGroups' />" |
307 |
|
" <separator/>" |
308 |
|
" <menuitem action='RemoveSample'/>" |
309 |
|
" </menu>" |
310 |
" <menu action='MenuInstrument'>" |
" <menu action='MenuInstrument'>" |
311 |
|
" <menu action='AllInstruments'>" |
312 |
|
" </menu>" |
313 |
|
" <separator/>" |
314 |
|
" <menuitem action='InstrProperties'/>" |
315 |
|
" <menuitem action='MidiRules'/>" |
316 |
|
" <menuitem action='ScriptSlots'/>" |
317 |
|
" <menuitem action='AddInstrument'/>" |
318 |
|
" <menuitem action='DupInstrument'/>" |
319 |
|
" <separator/>" |
320 |
|
" <menuitem action='RemoveInstrument'/>" |
321 |
|
" </menu>" |
322 |
|
" <menu action='MenuScript'>" |
323 |
|
" <menuitem action='AddScriptGroup'/>" |
324 |
|
" <menuitem action='AddScript'/>" |
325 |
|
" <menuitem action='EditScript'/>" |
326 |
|
" <separator/>" |
327 |
|
" <menuitem action='RemoveScript'/>" |
328 |
" </menu>" |
" </menu>" |
329 |
" <menu action='MenuView'>" |
" <menu action='MenuView'>" |
330 |
" <menuitem action='Statusbar'/>" |
" <menuitem action='Statusbar'/>" |
343 |
" <popup name='PopupMenu'>" |
" <popup name='PopupMenu'>" |
344 |
" <menuitem action='InstrProperties'/>" |
" <menuitem action='InstrProperties'/>" |
345 |
" <menuitem action='MidiRules'/>" |
" <menuitem action='MidiRules'/>" |
346 |
|
" <menuitem action='ScriptSlots'/>" |
347 |
" <menuitem action='AddInstrument'/>" |
" <menuitem action='AddInstrument'/>" |
348 |
" <menuitem action='DupInstrument'/>" |
" <menuitem action='DupInstrument'/>" |
349 |
" <separator/>" |
" <separator/>" |
353 |
" <menuitem action='SampleProperties'/>" |
" <menuitem action='SampleProperties'/>" |
354 |
" <menuitem action='AddGroup'/>" |
" <menuitem action='AddGroup'/>" |
355 |
" <menuitem action='AddSample'/>" |
" <menuitem action='AddSample'/>" |
356 |
|
" <menuitem action='ShowSampleRefs'/>" |
357 |
" <menuitem action='ReplaceAllSamplesInAllGroups' />" |
" <menuitem action='ReplaceAllSamplesInAllGroups' />" |
358 |
" <separator/>" |
" <separator/>" |
359 |
" <menuitem action='RemoveSample'/>" |
" <menuitem action='RemoveSample'/>" |
407 |
|
|
408 |
|
|
409 |
instrument_menu = static_cast<Gtk::MenuItem*>( |
instrument_menu = static_cast<Gtk::MenuItem*>( |
410 |
uiManager->get_widget("/MenuBar/MenuInstrument"))->get_submenu(); |
uiManager->get_widget("/MenuBar/MenuInstrument/AllInstruments"))->get_submenu(); |
411 |
|
|
412 |
Gtk::Widget* menuBar = uiManager->get_widget("/MenuBar"); |
Gtk::Widget* menuBar = uiManager->get_widget("/MenuBar"); |
413 |
m_VBox.pack_start(*menuBar, Gtk::PACK_SHRINK); |
m_VBox.pack_start(*menuBar, Gtk::PACK_SHRINK); |
447 |
m_TreeViewSamples.set_model(m_refSamplesTreeModel); |
m_TreeViewSamples.set_model(m_refSamplesTreeModel); |
448 |
m_TreeViewSamples.set_tooltip_text(_("To actually use a sample, drag it from this list view to \"Sample\" -> \"Sample:\" on the region's settings pane on the right.\n\nRight click here for more actions on samples.")); |
m_TreeViewSamples.set_tooltip_text(_("To actually use a sample, drag it from this list view to \"Sample\" -> \"Sample:\" on the region's settings pane on the right.\n\nRight click here for more actions on samples.")); |
449 |
// m_TreeViewSamples.set_reorderable(); |
// m_TreeViewSamples.set_reorderable(); |
450 |
m_TreeViewSamples.append_column_editable("Samples", m_SamplesModel.m_col_name); |
m_TreeViewSamples.append_column_editable(_("Name"), m_SamplesModel.m_col_name); |
451 |
m_TreeViewSamples.set_headers_visible(false); |
m_TreeViewSamples.append_column(_("Referenced"), m_SamplesModel.m_col_refcount); |
452 |
|
{ |
453 |
|
Gtk::TreeViewColumn* column = m_TreeViewSamples.get_column(0); |
454 |
|
Gtk::CellRendererText* cellrenderer = |
455 |
|
dynamic_cast<Gtk::CellRendererText*>(column->get_first_cell_renderer()); |
456 |
|
column->add_attribute( |
457 |
|
cellrenderer->property_foreground(), m_SamplesModel.m_color |
458 |
|
); |
459 |
|
} |
460 |
|
{ |
461 |
|
Gtk::TreeViewColumn* column = m_TreeViewSamples.get_column(1); |
462 |
|
Gtk::CellRendererText* cellrenderer = |
463 |
|
dynamic_cast<Gtk::CellRendererText*>(column->get_first_cell_renderer()); |
464 |
|
column->add_attribute( |
465 |
|
cellrenderer->property_foreground(), m_SamplesModel.m_color |
466 |
|
); |
467 |
|
} |
468 |
|
m_TreeViewSamples.set_headers_visible(true); |
469 |
m_TreeViewSamples.signal_button_press_event().connect_notify( |
m_TreeViewSamples.signal_button_press_event().connect_notify( |
470 |
sigc::mem_fun(*this, &MainWindow::on_sample_treeview_button_release) |
sigc::mem_fun(*this, &MainWindow::on_sample_treeview_button_release) |
471 |
); |
); |
490 |
sigc::mem_fun(*this, &MainWindow::script_name_changed) |
sigc::mem_fun(*this, &MainWindow::script_name_changed) |
491 |
); |
); |
492 |
|
|
493 |
|
// establish drag&drop between scripts tree view and ScriptSlots window |
494 |
|
std::vector<Gtk::TargetEntry> drag_target_gig_script; |
495 |
|
drag_target_gig_script.push_back(Gtk::TargetEntry("gig::Script")); |
496 |
|
m_TreeViewScripts.drag_source_set(drag_target_gig_script); |
497 |
|
m_TreeViewScripts.signal_drag_begin().connect( |
498 |
|
sigc::mem_fun(*this, &MainWindow::on_scripts_treeview_drag_begin) |
499 |
|
); |
500 |
|
m_TreeViewScripts.signal_drag_data_get().connect( |
501 |
|
sigc::mem_fun(*this, &MainWindow::on_scripts_treeview_drag_data_get) |
502 |
|
); |
503 |
|
|
504 |
// establish drag&drop between samples tree view and dimension region 'Sample' text entry |
// establish drag&drop between samples tree view and dimension region 'Sample' text entry |
505 |
std::vector<Gtk::TargetEntry> drag_target_gig_sample; |
std::vector<Gtk::TargetEntry> drag_target_gig_sample; |
506 |
drag_target_gig_sample.push_back(Gtk::TargetEntry("gig::Sample")); |
drag_target_gig_sample.push_back(Gtk::TargetEntry("gig::Sample")); |
534 |
dimreg_changed_signal.make_slot()); |
dimreg_changed_signal.make_slot()); |
535 |
dimreg_edit.signal_sample_ref_changed().connect( |
dimreg_edit.signal_sample_ref_changed().connect( |
536 |
sample_ref_changed_signal.make_slot()); |
sample_ref_changed_signal.make_slot()); |
537 |
|
sample_ref_changed_signal.connect( |
538 |
|
sigc::mem_fun(*this, &MainWindow::on_sample_ref_changed) |
539 |
|
); |
540 |
|
samples_to_be_removed_signal.connect( |
541 |
|
sigc::mem_fun(*this, &MainWindow::on_samples_to_be_removed) |
542 |
|
); |
543 |
|
|
544 |
m_RegionChooser.signal_instrument_struct_to_be_changed().connect( |
m_RegionChooser.signal_instrument_struct_to_be_changed().connect( |
545 |
sigc::hide( |
sigc::hide( |
763 |
// clear the samples and instruments tree views |
// clear the samples and instruments tree views |
764 |
m_refTreeModel->clear(); |
m_refTreeModel->clear(); |
765 |
m_refSamplesTreeModel->clear(); |
m_refSamplesTreeModel->clear(); |
766 |
|
m_refScriptsTreeModel->clear(); |
767 |
// remove all entries from "Instrument" menu |
// remove all entries from "Instrument" menu |
768 |
while (!instrument_menu->get_children().empty()) { |
while (!instrument_menu->get_children().empty()) { |
769 |
remove_instrument_from_menu(0); |
remove_instrument_from_menu(0); |
778 |
// clear the samples and instruments tree views |
// clear the samples and instruments tree views |
779 |
m_refTreeModel->clear(); |
m_refTreeModel->clear(); |
780 |
m_refSamplesTreeModel->clear(); |
m_refSamplesTreeModel->clear(); |
781 |
|
m_refScriptsTreeModel->clear(); |
782 |
// remove all entries from "Instrument" menu |
// remove all entries from "Instrument" menu |
783 |
while (!instrument_menu->get_children().empty()) { |
while (!instrument_menu->get_children().empty()) { |
784 |
remove_instrument_from_menu(0); |
remove_instrument_from_menu(0); |
1426 |
} |
} |
1427 |
} |
} |
1428 |
|
|
1429 |
|
void MainWindow::updateSampleRefCountMap(gig::File* gig) { |
1430 |
|
sample_ref_count.clear(); |
1431 |
|
|
1432 |
|
if (!gig) return; |
1433 |
|
|
1434 |
|
for (gig::Instrument* instrument = gig->GetFirstInstrument(); instrument; |
1435 |
|
instrument = gig->GetNextInstrument()) |
1436 |
|
{ |
1437 |
|
for (gig::Region* rgn = instrument->GetFirstRegion(); rgn; |
1438 |
|
rgn = instrument->GetNextRegion()) |
1439 |
|
{ |
1440 |
|
for (int i = 0; i < 256; ++i) { |
1441 |
|
if (!rgn->pDimensionRegions[i]) continue; |
1442 |
|
if (rgn->pDimensionRegions[i]->pSample) { |
1443 |
|
sample_ref_count[rgn->pDimensionRegions[i]->pSample]++; |
1444 |
|
} |
1445 |
|
} |
1446 |
|
} |
1447 |
|
} |
1448 |
|
} |
1449 |
|
|
1450 |
void MainWindow::load_gig(gig::File* gig, const char* filename, bool isSharedInstrument) |
void MainWindow::load_gig(gig::File* gig, const char* filename, bool isSharedInstrument) |
1451 |
{ |
{ |
1452 |
file = 0; |
file = 0; |
1473 |
add_instrument_to_menu(name); |
add_instrument_to_menu(name); |
1474 |
} |
} |
1475 |
instrument_name_connection.unblock(); |
instrument_name_connection.unblock(); |
1476 |
uiManager->get_widget("/MenuBar/MenuInstrument")->show(); |
uiManager->get_widget("/MenuBar/MenuInstrument/AllInstruments")->show(); |
1477 |
|
|
1478 |
|
updateSampleRefCountMap(gig); |
1479 |
|
|
1480 |
for (gig::Group* group = gig->GetFirstGroup(); group; group = gig->GetNextGroup()) { |
for (gig::Group* group = gig->GetFirstGroup(); group; group = gig->GetNextGroup()) { |
1481 |
if (group->Name != "") { |
if (group->Name != "") { |
1493 |
gig_to_utf8(sample->pInfo->Name); |
gig_to_utf8(sample->pInfo->Name); |
1494 |
rowSample[m_SamplesModel.m_col_sample] = sample; |
rowSample[m_SamplesModel.m_col_sample] = sample; |
1495 |
rowSample[m_SamplesModel.m_col_group] = NULL; |
rowSample[m_SamplesModel.m_col_group] = NULL; |
1496 |
|
int refcount = sample_ref_count.count(sample) ? sample_ref_count[sample] : 0; |
1497 |
|
rowSample[m_SamplesModel.m_col_refcount] = ToString(refcount) + " " + _("Refs."); |
1498 |
|
rowSample[m_SamplesModel.m_color] = refcount ? "black" : "red"; |
1499 |
} |
} |
1500 |
} |
} |
1501 |
} |
} |
1519 |
rowScript[m_ScriptsModel.m_col_group] = NULL; |
rowScript[m_ScriptsModel.m_col_group] = NULL; |
1520 |
} |
} |
1521 |
} |
} |
1522 |
// unfold all script groups by default |
// unfold all sample groups & script groups by default |
1523 |
|
m_TreeViewSamples.expand_all(); |
1524 |
m_TreeViewScripts.expand_all(); |
m_TreeViewScripts.expand_all(); |
1525 |
|
|
1526 |
file = gig; |
file = gig; |
1590 |
} |
} |
1591 |
} |
} |
1592 |
|
|
1593 |
|
void MainWindow::show_script_slots() { |
1594 |
|
if (!file) return; |
1595 |
|
// get selected instrument |
1596 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
1597 |
|
Gtk::TreeModel::iterator it = sel->get_selected(); |
1598 |
|
if (!it) return; |
1599 |
|
Gtk::TreeModel::Row row = *it; |
1600 |
|
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
1601 |
|
if (!instrument) return; |
1602 |
|
|
1603 |
|
ScriptSlots* window = new ScriptSlots; |
1604 |
|
window->setInstrument(instrument); |
1605 |
|
//window->reparent(*this); |
1606 |
|
window->show(); |
1607 |
|
} |
1608 |
|
|
1609 |
void MainWindow::on_action_view_status_bar() { |
void MainWindow::on_action_view_status_bar() { |
1610 |
Gtk::CheckMenuItem* item = |
Gtk::CheckMenuItem* item = |
1611 |
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/Statusbar")); |
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/Statusbar")); |
1653 |
show_instr_props(); |
show_instr_props(); |
1654 |
} else if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
} else if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
1655 |
// gig v2 files have no midi rules |
// gig v2 files have no midi rules |
1656 |
|
const bool bEnabled = !(file->pVersion && file->pVersion->major == 2); |
1657 |
|
static_cast<Gtk::MenuItem*>( |
1658 |
|
uiManager->get_widget("/MenuBar/MenuInstrument/MidiRules"))->set_sensitive( |
1659 |
|
bEnabled |
1660 |
|
); |
1661 |
static_cast<Gtk::MenuItem*>( |
static_cast<Gtk::MenuItem*>( |
1662 |
uiManager->get_widget("/PopupMenu/MidiRules"))->set_sensitive( |
uiManager->get_widget("/PopupMenu/MidiRules"))->set_sensitive( |
1663 |
!(file->pVersion && file->pVersion->major == 2)); |
bEnabled |
1664 |
|
); |
1665 |
popup_menu->popup(button->button, button->time); |
popup_menu->popup(button->button, button->time); |
1666 |
} |
} |
1667 |
} |
} |
1695 |
group_selected = row[m_SamplesModel.m_col_group]; |
group_selected = row[m_SamplesModel.m_col_group]; |
1696 |
sample_selected = row[m_SamplesModel.m_col_sample]; |
sample_selected = row[m_SamplesModel.m_col_sample]; |
1697 |
} |
} |
1698 |
|
|
1699 |
|
|
1700 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/SampleProperties"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/SampleProperties"))-> |
1701 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(group_selected || sample_selected); |
1702 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddSample"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddSample"))-> |
1703 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(group_selected || sample_selected); |
1704 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddGroup"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddGroup"))-> |
1705 |
set_sensitive(file); |
set_sensitive(file); |
1706 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/ShowSampleRefs"))-> |
1707 |
|
set_sensitive(sample_selected); |
1708 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/RemoveSample"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/RemoveSample"))-> |
1709 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(group_selected || sample_selected); |
1710 |
// show sample popup |
// show sample popup |
1711 |
sample_popup->popup(button->button, button->time); |
sample_popup->popup(button->button, button->time); |
1712 |
|
|
1713 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/SampleProperties"))-> |
1714 |
|
set_sensitive(group_selected || sample_selected); |
1715 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddSample"))-> |
1716 |
|
set_sensitive(group_selected || sample_selected); |
1717 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddGroup"))-> |
1718 |
|
set_sensitive(file); |
1719 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/ShowSampleRefs"))-> |
1720 |
|
set_sensitive(sample_selected); |
1721 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/RemoveSample"))-> |
1722 |
|
set_sensitive(group_selected || sample_selected); |
1723 |
} |
} |
1724 |
} |
} |
1725 |
|
|
1747 |
set_sensitive(group_selected || script_selected); |
set_sensitive(group_selected || script_selected); |
1748 |
// show sample popup |
// show sample popup |
1749 |
script_popup->popup(button->button, button->time); |
script_popup->popup(button->button, button->time); |
1750 |
|
|
1751 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/AddScript"))-> |
1752 |
|
set_sensitive(group_selected || script_selected); |
1753 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/AddScriptGroup"))-> |
1754 |
|
set_sensitive(file); |
1755 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/EditScript"))-> |
1756 |
|
set_sensitive(script_selected); |
1757 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/RemoveScript"))-> |
1758 |
|
set_sensitive(group_selected || script_selected); |
1759 |
} |
} |
1760 |
} |
} |
1761 |
|
|
2386 |
} |
} |
2387 |
} |
} |
2388 |
|
|
2389 |
|
// see comment on on_sample_treeview_drag_begin() |
2390 |
|
void MainWindow::on_scripts_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context) |
2391 |
|
{ |
2392 |
|
first_call_to_drag_data_get = true; |
2393 |
|
} |
2394 |
|
|
2395 |
|
void MainWindow::on_scripts_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&, |
2396 |
|
Gtk::SelectionData& selection_data, guint, guint) |
2397 |
|
{ |
2398 |
|
if (!first_call_to_drag_data_get) return; |
2399 |
|
first_call_to_drag_data_get = false; |
2400 |
|
|
2401 |
|
// get selected script |
2402 |
|
gig::Script* script = NULL; |
2403 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewScripts.get_selection(); |
2404 |
|
Gtk::TreeModel::iterator it = sel->get_selected(); |
2405 |
|
if (it) { |
2406 |
|
Gtk::TreeModel::Row row = *it; |
2407 |
|
script = row[m_ScriptsModel.m_col_script]; |
2408 |
|
} |
2409 |
|
// pass the gig::Script as pointer |
2410 |
|
selection_data.set(selection_data.get_target(), 0/*unused*/, |
2411 |
|
(const guchar*)&script, |
2412 |
|
sizeof(script)/*length of data in bytes*/); |
2413 |
|
} |
2414 |
|
|
2415 |
// For some reason drag_data_get gets called two times for each |
// For some reason drag_data_get gets called two times for each |
2416 |
// 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 |
2417 |
// 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 |
2609 |
delete d; |
delete d; |
2610 |
} |
} |
2611 |
|
|
2612 |
|
void MainWindow::on_action_view_references() { |
2613 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
2614 |
|
Gtk::TreeModel::iterator it = sel->get_selected(); |
2615 |
|
if (!it) return; |
2616 |
|
Gtk::TreeModel::Row row = *it; |
2617 |
|
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
2618 |
|
if (!sample) return; |
2619 |
|
|
2620 |
|
ReferencesView* d = new ReferencesView(*this); |
2621 |
|
d->setSample(sample); |
2622 |
|
d->show_all(); |
2623 |
|
d->resize(500, 400); |
2624 |
|
d->run(); |
2625 |
|
delete d; |
2626 |
|
} |
2627 |
|
|
2628 |
void MainWindow::mergeFiles(const std::vector<std::string>& filenames) { |
void MainWindow::mergeFiles(const std::vector<std::string>& filenames) { |
2629 |
struct _Source { |
struct _Source { |
2630 |
std::vector<RIFF::File*> riffs; |
std::vector<RIFF::File*> riffs; |
2785 |
} |
} |
2786 |
} |
} |
2787 |
|
|
2788 |
|
void MainWindow::on_sample_ref_count_incremented(gig::Sample* sample, int offset) { |
2789 |
|
if (!sample) return; |
2790 |
|
sample_ref_count[sample] += offset; |
2791 |
|
const int refcount = sample_ref_count[sample]; |
2792 |
|
|
2793 |
|
Glib::RefPtr<Gtk::TreeModel> model = m_TreeViewSamples.get_model(); |
2794 |
|
for (int g = 0; g < model->children().size(); ++g) { |
2795 |
|
Gtk::TreeModel::Row rowGroup = model->children()[g]; |
2796 |
|
for (int s = 0; s < rowGroup.children().size(); ++s) { |
2797 |
|
Gtk::TreeModel::Row rowSample = rowGroup.children()[s]; |
2798 |
|
if (rowSample[m_SamplesModel.m_col_sample] != sample) continue; |
2799 |
|
rowSample[m_SamplesModel.m_col_refcount] = ToString(refcount) + " " + _("Refs."); |
2800 |
|
rowSample[m_SamplesModel.m_color] = refcount ? "black" : "red"; |
2801 |
|
} |
2802 |
|
} |
2803 |
|
} |
2804 |
|
|
2805 |
|
void MainWindow::on_sample_ref_changed(gig::Sample* oldSample, gig::Sample* newSample) { |
2806 |
|
on_sample_ref_count_incremented(oldSample, -1); |
2807 |
|
on_sample_ref_count_incremented(newSample, +1); |
2808 |
|
} |
2809 |
|
|
2810 |
|
void MainWindow::on_samples_to_be_removed(std::list<gig::Sample*> samples) { |
2811 |
|
// just in case a new sample is added later with exactly the same memory |
2812 |
|
// address, which would lead to incorrect refcount if not deleted here |
2813 |
|
for (std::list<gig::Sample*>::const_iterator it = samples.begin(); |
2814 |
|
it != samples.end(); it != samples.end()) |
2815 |
|
{ |
2816 |
|
sample_ref_count.erase(*it); |
2817 |
|
} |
2818 |
|
} |
2819 |
|
|
2820 |
|
void MainWindow::show_samples_tab() { |
2821 |
|
m_TreeViewNotebook.set_current_page(0); |
2822 |
|
} |
2823 |
|
|
2824 |
|
void MainWindow::show_intruments_tab() { |
2825 |
|
m_TreeViewNotebook.set_current_page(1); |
2826 |
|
} |
2827 |
|
|
2828 |
|
void MainWindow::show_scripts_tab() { |
2829 |
|
m_TreeViewNotebook.set_current_page(2); |
2830 |
|
} |
2831 |
|
|
2832 |
sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() { |
sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() { |
2833 |
return file_structure_to_be_changed_signal; |
return file_structure_to_be_changed_signal; |
2834 |
} |
} |