1 |
/* |
/* |
2 |
* Copyright (C) 2006-2019 Andreas Persson |
* Copyright (C) 2006-2020 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 |
21 |
#include <cstring> |
#include <cstring> |
22 |
|
|
23 |
#include "compat.h" |
#include "compat.h" |
|
// threads.h must be included first to be able to build with |
|
|
// G_DISABLE_DEPRECATED |
|
|
#if (GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION == 31 && GLIBMM_MICRO_VERSION >= 2) || \ |
|
|
(GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION > 31) || GLIBMM_MAJOR_VERSION > 2 |
|
|
#include <glibmm/threads.h> |
|
|
#endif |
|
24 |
|
|
25 |
#include <glibmm/convert.h> |
#include <glibmm/convert.h> |
26 |
#include <glibmm/dispatcher.h> |
#include <glibmm/dispatcher.h> |
96 |
|
|
97 |
if (!Settings::singleton()->autoRestoreWindowDimension) { |
if (!Settings::singleton()->autoRestoreWindowDimension) { |
98 |
#if GTKMM_MAJOR_VERSION >= 3 |
#if GTKMM_MAJOR_VERSION >= 3 |
99 |
set_default_size(895, 600); |
set_default_size(1010, -1); |
100 |
#else |
#else |
101 |
set_default_size(800, 600); |
set_default_size(915, -1); |
102 |
#endif |
#endif |
103 |
set_position(Gtk::WIN_POS_CENTER); |
set_position(Gtk::WIN_POS_CENTER); |
104 |
} |
} |
106 |
add(m_VBox); |
add(m_VBox); |
107 |
|
|
108 |
// Handle selection |
// Handle selection |
109 |
m_TreeView.get_selection()->signal_changed().connect( |
m_TreeViewInstruments.get_selection()->signal_changed().connect( |
110 |
sigc::mem_fun(*this, &MainWindow::on_sel_change)); |
sigc::mem_fun(*this, &MainWindow::on_sel_change)); |
111 |
|
|
112 |
// m_TreeView.set_reorderable(); |
// m_TreeViewInstruments.set_reorderable(); |
113 |
|
|
114 |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2 |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2 |
115 |
m_TreeView.signal_button_press_event().connect( |
m_TreeViewInstruments.signal_button_press_event().connect( |
116 |
sigc::mem_fun(*this, &MainWindow::on_button_release)); |
sigc::mem_fun(*this, &MainWindow::on_button_release)); |
117 |
#else |
#else |
118 |
m_TreeView.signal_button_press_event().connect_notify( |
m_TreeViewInstruments.signal_button_press_event().connect_notify( |
119 |
sigc::mem_fun(*this, &MainWindow::on_button_release)); |
sigc::mem_fun(*this, &MainWindow::on_button_release)); |
120 |
#endif |
#endif |
121 |
|
|
122 |
// Add the TreeView tab, inside a ScrolledWindow, with the button underneath: |
// Add the TreeView tab, inside a ScrolledWindow, with the button underneath: |
123 |
m_ScrolledWindow.add(m_TreeView); |
m_ScrolledWindow.add(m_TreeViewInstruments); |
124 |
// m_ScrolledWindow.set_size_request(200, 600); |
// m_ScrolledWindow.set_size_request(200, 600); |
125 |
m_ScrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); |
m_ScrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); |
126 |
|
|
451 |
m_actionGroup->add_action_bool("Statusbar", sigc::mem_fun(*this, &MainWindow::on_action_view_status_bar), true); |
m_actionGroup->add_action_bool("Statusbar", sigc::mem_fun(*this, &MainWindow::on_action_view_status_bar), true); |
452 |
m_actionToggleRestoreWinDim = |
m_actionToggleRestoreWinDim = |
453 |
m_actionGroup->add_action_bool("AutoRestoreWinDim", sigc::mem_fun(*this, &MainWindow::on_auto_restore_win_dim), Settings::singleton()->autoRestoreWindowDimension); |
m_actionGroup->add_action_bool("AutoRestoreWinDim", sigc::mem_fun(*this, &MainWindow::on_auto_restore_win_dim), Settings::singleton()->autoRestoreWindowDimension); |
454 |
|
m_actionInstrDoubleClickOpensProps = |
455 |
|
m_actionGroup->add_action_bool( |
456 |
|
"OpenInstrPropsByDoubleClick", |
457 |
|
sigc::mem_fun(*this, &MainWindow::on_instr_double_click_opens_props), |
458 |
|
Settings::singleton()->instrumentDoubleClickOpensProps |
459 |
|
); |
460 |
m_actionToggleShowTooltips = m_actionGroup->add_action_bool( |
m_actionToggleShowTooltips = m_actionGroup->add_action_bool( |
461 |
"ShowTooltips", sigc::mem_fun(*this, &MainWindow::on_action_show_tooltips), |
"ShowTooltips", sigc::mem_fun(*this, &MainWindow::on_action_show_tooltips), |
462 |
Settings::singleton()->showTooltips |
Settings::singleton()->showTooltips |
484 |
*this, &MainWindow::on_auto_restore_win_dim)); |
*this, &MainWindow::on_auto_restore_win_dim)); |
485 |
|
|
486 |
toggle_action = |
toggle_action = |
487 |
|
Gtk::ToggleAction::create("OpenInstrPropsByDoubleClick", _("Instrument Properties by Double Click")); |
488 |
|
toggle_action->set_active(Settings::singleton()->instrumentDoubleClickOpensProps); |
489 |
|
actionGroup->add(toggle_action, |
490 |
|
sigc::mem_fun( |
491 |
|
*this, &MainWindow::on_instr_double_click_opens_props)); |
492 |
|
|
493 |
|
toggle_action = |
494 |
Gtk::ToggleAction::create("ShowTooltips", _("Tooltips for Beginners")); |
Gtk::ToggleAction::create("ShowTooltips", _("Tooltips for Beginners")); |
495 |
toggle_action->set_active(Settings::singleton()->showTooltips); |
toggle_action->set_active(Settings::singleton()->showTooltips); |
496 |
actionGroup->add( |
actionGroup->add( |
522 |
"DupInstrument", sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument) |
"DupInstrument", sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument) |
523 |
); |
); |
524 |
m_actionGroup->add_action( |
m_actionGroup->add_action( |
525 |
|
"MoveInstrument", sigc::mem_fun(*this, &MainWindow::on_action_move_instr) |
526 |
|
); |
527 |
|
m_actionGroup->add_action( |
528 |
"CombInstruments", sigc::mem_fun(*this, &MainWindow::on_action_combine_instruments) |
"CombInstruments", sigc::mem_fun(*this, &MainWindow::on_action_combine_instruments) |
529 |
); |
); |
530 |
m_actionGroup->add_action( |
m_actionGroup->add_action( |
546 |
sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument) |
sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument) |
547 |
); |
); |
548 |
actionGroup->add( |
actionGroup->add( |
549 |
|
Gtk::Action::create("MoveInstrument", _("Move _Instrument To ...")), |
550 |
|
Gtk::AccelKey(GDK_KEY_i, primaryModifierKey), |
551 |
|
sigc::mem_fun(*this, &MainWindow::on_action_move_instr) |
552 |
|
); |
553 |
|
actionGroup->add( |
554 |
Gtk::Action::create("CombInstruments", _("_Combine Instruments ...")), |
Gtk::Action::create("CombInstruments", _("_Combine Instruments ...")), |
555 |
Gtk::AccelKey(GDK_KEY_j, primaryModifierKey), |
Gtk::AccelKey(GDK_KEY_j, primaryModifierKey), |
556 |
sigc::mem_fun(*this, &MainWindow::on_action_combine_instruments) |
sigc::mem_fun(*this, &MainWindow::on_action_combine_instruments) |
906 |
" <attribute name='label' translatable='yes'>Duplicate Instrument</attribute>" |
" <attribute name='label' translatable='yes'>Duplicate Instrument</attribute>" |
907 |
" <attribute name='action'>AppMenu.DupInstrument</attribute>" |
" <attribute name='action'>AppMenu.DupInstrument</attribute>" |
908 |
" </item>" |
" </item>" |
909 |
|
" <item id='MoveInstrument'>" |
910 |
|
" <attribute name='label' translatable='yes'>Move Instrument To ...</attribute>" |
911 |
|
" <attribute name='action'>AppMenu.MoveInstrument</attribute>" |
912 |
|
" </item>" |
913 |
" <item id='CombInstruments'>" |
" <item id='CombInstruments'>" |
914 |
" <attribute name='label' translatable='yes'>Combine Instrument</attribute>" |
" <attribute name='label' translatable='yes'>Combine Instrument</attribute>" |
915 |
" <attribute name='action'>AppMenu.CombInstruments</attribute>" |
" <attribute name='action'>AppMenu.CombInstruments</attribute>" |
960 |
" <attribute name='label' translatable='yes'>Auto restore Window Dimensions</attribute>" |
" <attribute name='label' translatable='yes'>Auto restore Window Dimensions</attribute>" |
961 |
" <attribute name='action'>AppMenu.AutoRestoreWinDim</attribute>" |
" <attribute name='action'>AppMenu.AutoRestoreWinDim</attribute>" |
962 |
" </item>" |
" </item>" |
963 |
|
" <item id='OpenInstrPropsByDoubleClick'>" |
964 |
|
" <attribute name='label' translatable='yes'>Instrument Properties by Double Click</attribute>" |
965 |
|
" <attribute name='action'>AppMenu.OpenInstrPropsByDoubleClick</attribute>" |
966 |
|
" </item>" |
967 |
" </section>" |
" </section>" |
968 |
" <section>" |
" <section>" |
969 |
" <item id='RefreshAll'>" |
" <item id='RefreshAll'>" |
1039 |
" <attribute name='label' translatable='yes'>Duplicate Instrument</attribute>" |
" <attribute name='label' translatable='yes'>Duplicate Instrument</attribute>" |
1040 |
" <attribute name='action'>AppMenu.DupInstrument</attribute>" |
" <attribute name='action'>AppMenu.DupInstrument</attribute>" |
1041 |
" </item>" |
" </item>" |
1042 |
|
" <item id='MoveInstrument'>" |
1043 |
|
" <attribute name='label' translatable='yes'>Move Instrument To ...</attribute>" |
1044 |
|
" <attribute name='action'>AppMenu.MoveInstrument</attribute>" |
1045 |
|
" </item>" |
1046 |
" <item id='CombInstruments'>" |
" <item id='CombInstruments'>" |
1047 |
" <attribute name='label' translatable='yes'>Combine Instruments</attribute>" |
" <attribute name='label' translatable='yes'>Combine Instruments</attribute>" |
1048 |
" <attribute name='action'>AppMenu.CombInstruments</attribute>" |
" <attribute name='action'>AppMenu.CombInstruments</attribute>" |
1181 |
" <menu action='AssignScripts'/>" |
" <menu action='AssignScripts'/>" |
1182 |
" <menuitem action='AddInstrument'/>" |
" <menuitem action='AddInstrument'/>" |
1183 |
" <menuitem action='DupInstrument'/>" |
" <menuitem action='DupInstrument'/>" |
1184 |
|
" <menuitem action='MoveInstrument'/>" |
1185 |
" <menuitem action='CombInstruments'/>" |
" <menuitem action='CombInstruments'/>" |
1186 |
" <separator/>" |
" <separator/>" |
1187 |
" <menuitem action='RemoveInstrument'/>" |
" <menuitem action='RemoveInstrument'/>" |
1197 |
" <menuitem action='Statusbar'/>" |
" <menuitem action='Statusbar'/>" |
1198 |
" <menuitem action='ShowTooltips'/>" |
" <menuitem action='ShowTooltips'/>" |
1199 |
" <menuitem action='AutoRestoreWinDim'/>" |
" <menuitem action='AutoRestoreWinDim'/>" |
1200 |
|
" <menuitem action='OpenInstrPropsByDoubleClick'/>" |
1201 |
" <separator/>" |
" <separator/>" |
1202 |
" <menuitem action='RefreshAll'/>" |
" <menuitem action='RefreshAll'/>" |
1203 |
" </menu>" |
" </menu>" |
1221 |
" <menuitem action='ScriptSlots'/>" |
" <menuitem action='ScriptSlots'/>" |
1222 |
" <menuitem action='AddInstrument'/>" |
" <menuitem action='AddInstrument'/>" |
1223 |
" <menuitem action='DupInstrument'/>" |
" <menuitem action='DupInstrument'/>" |
1224 |
|
" <menuitem action='MoveInstrument'/>" |
1225 |
" <menuitem action='CombInstruments'/>" |
" <menuitem action='CombInstruments'/>" |
1226 |
" <separator/>" |
" <separator/>" |
1227 |
" <menuitem action='RemoveInstrument'/>" |
" <menuitem action='RemoveInstrument'/>" |
1322 |
} |
} |
1323 |
{ |
{ |
1324 |
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
1325 |
|
uiManager->get_widget("/MenuBar/MenuView/OpenInstrPropsByDoubleClick")); |
1326 |
|
item->set_tooltip_text(_("If checked, double clicking an instrument opens its properties dialog.")); |
1327 |
|
} |
1328 |
|
{ |
1329 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
1330 |
uiManager->get_widget("/MenuBar/MenuTools/CombineInstruments")); |
uiManager->get_widget("/MenuBar/MenuTools/CombineInstruments")); |
1331 |
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.")); |
1332 |
} |
} |
1383 |
|
|
1384 |
|
|
1385 |
// Create the Tree model: |
// Create the Tree model: |
1386 |
m_refTreeModel = Gtk::ListStore::create(m_Columns); |
m_refInstrumentsTreeModel = Gtk::ListStore::create(m_InstrumentsModel); |
1387 |
m_refTreeModelFilter = Gtk::TreeModelFilter::create(m_refTreeModel); |
m_refInstrumentsModelFilter = Gtk::TreeModelFilter::create(m_refInstrumentsTreeModel); |
1388 |
m_refTreeModelFilter->set_visible_func( |
m_refInstrumentsModelFilter->set_visible_func( |
1389 |
sigc::mem_fun(*this, &MainWindow::instrument_row_visible) |
sigc::mem_fun(*this, &MainWindow::instrument_row_visible) |
1390 |
); |
); |
1391 |
m_TreeView.set_model(m_refTreeModelFilter); |
m_TreeViewInstruments.set_model(m_refInstrumentsModelFilter); |
1392 |
|
|
1393 |
m_TreeView.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE); |
m_TreeViewInstruments.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE); |
1394 |
m_TreeView.set_has_tooltip(true); |
m_TreeViewInstruments.set_has_tooltip(true); |
1395 |
m_TreeView.signal_query_tooltip().connect( |
m_TreeViewInstruments.signal_query_tooltip().connect( |
1396 |
sigc::mem_fun(*this, &MainWindow::onQueryTreeViewTooltip) |
sigc::mem_fun(*this, &MainWindow::onQueryTreeViewTooltip) |
1397 |
); |
); |
1398 |
instrument_name_connection = m_refTreeModel->signal_row_changed().connect( |
instrument_name_connection = m_refInstrumentsTreeModel->signal_row_changed().connect( |
1399 |
sigc::mem_fun(*this, &MainWindow::instrument_name_changed) |
sigc::mem_fun(*this, &MainWindow::instrument_name_changed) |
1400 |
); |
); |
1401 |
|
|
1402 |
// Add the TreeView's view columns: |
// Add the TreeView's view columns: |
1403 |
m_TreeView.append_column(_("Nr"), m_Columns.m_col_nr); |
m_TreeViewInstruments.append_column(_("Nr"), m_InstrumentsModel.m_col_nr); |
1404 |
m_TreeView.append_column_editable(_("Instrument"), m_Columns.m_col_name); |
m_TreeViewInstruments.append_column_editable(_("Instrument"), m_InstrumentsModel.m_col_name); |
1405 |
m_TreeView.append_column(_("Scripts"), m_Columns.m_col_scripts); |
m_TreeViewInstruments.append_column(_("Scripts"), m_InstrumentsModel.m_col_scripts); |
1406 |
m_TreeView.set_headers_visible(true); |
m_TreeViewInstruments.set_headers_visible(true); |
1407 |
|
|
1408 |
// establish drag&drop within the instrument tree view, allowing to reorder |
// establish drag&drop within the instrument tree view, allowing to reorder |
1409 |
// the sequence of instruments within the gig file |
// the sequence of instruments within the gig file |
1410 |
{ |
{ |
1411 |
std::vector<Gtk::TargetEntry> drag_target_instrument; |
std::vector<Gtk::TargetEntry> drag_target_instrument; |
1412 |
drag_target_instrument.push_back(Gtk::TargetEntry("gig::Instrument")); |
drag_target_instrument.push_back(Gtk::TargetEntry("gig::Instrument")); |
1413 |
m_TreeView.drag_source_set(drag_target_instrument); |
m_TreeViewInstruments.drag_source_set(drag_target_instrument); |
1414 |
m_TreeView.drag_dest_set(drag_target_instrument); |
m_TreeViewInstruments.drag_dest_set(drag_target_instrument); |
1415 |
m_TreeView.signal_drag_begin().connect( |
m_TreeViewInstruments.signal_drag_begin().connect( |
1416 |
sigc::mem_fun(*this, &MainWindow::on_instruments_treeview_drag_begin) |
sigc::mem_fun(*this, &MainWindow::on_instruments_treeview_drag_begin) |
1417 |
); |
); |
1418 |
m_TreeView.signal_drag_data_get().connect( |
m_TreeViewInstruments.signal_drag_data_get().connect( |
1419 |
sigc::mem_fun(*this, &MainWindow::on_instruments_treeview_drag_data_get) |
sigc::mem_fun(*this, &MainWindow::on_instruments_treeview_drag_data_get) |
1420 |
); |
); |
1421 |
m_TreeView.signal_drag_data_received().connect( |
m_TreeViewInstruments.signal_drag_data_received().connect( |
1422 |
sigc::mem_fun(*this, &MainWindow::on_instruments_treeview_drop_drag_data_received) |
sigc::mem_fun(*this, &MainWindow::on_instruments_treeview_drop_drag_data_received) |
1423 |
); |
); |
1424 |
} |
} |
1525 |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
1526 |
instrumentProps.signal_changed().connect( |
instrumentProps.signal_changed().connect( |
1527 |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
1528 |
propDialog.signal_changed().connect( |
sampleProps.signal_changed().connect( |
1529 |
|
sigc::mem_fun(*this, &MainWindow::file_changed)); |
1530 |
|
fileProps.signal_changed().connect( |
1531 |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
1532 |
midiRules.signal_changed().connect( |
midiRules.signal_changed().connect( |
1533 |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
1549 |
sigc::mem_fun(*this, &MainWindow::select_sample) |
sigc::mem_fun(*this, &MainWindow::select_sample) |
1550 |
); |
); |
1551 |
|
|
1552 |
|
dimreg_edit.editScriptSlotsButton.signal_clicked().connect( |
1553 |
|
sigc::mem_fun(*this, &MainWindow::show_script_slots) |
1554 |
|
); |
1555 |
|
// simply sending the same signal (pair) to the sampler on 'patch' variable |
1556 |
|
// changes as the already existing signal (pair) when the user edits the |
1557 |
|
// script's source code, because the sampler would reload the source code |
1558 |
|
// and the 'patch' variables from the instrument on this signal anyway |
1559 |
|
dimreg_edit.scriptVars.signal_vars_to_be_changed.connect( |
1560 |
|
[this](gig::Instrument* instr) { |
1561 |
|
for (int i = 0; i < instr->ScriptSlotCount(); ++i) { |
1562 |
|
gig::Script* script = instr->GetScriptOfSlot(i); |
1563 |
|
signal_script_to_be_changed.emit(script); |
1564 |
|
} |
1565 |
|
} |
1566 |
|
); |
1567 |
|
dimreg_edit.scriptVars.signal_vars_changed.connect( |
1568 |
|
[this](gig::Instrument* instr) { |
1569 |
|
for (int i = 0; i < instr->ScriptSlotCount(); ++i) { |
1570 |
|
gig::Script* script = instr->GetScriptOfSlot(i); |
1571 |
|
signal_script_changed.emit(script); |
1572 |
|
} |
1573 |
|
} |
1574 |
|
); |
1575 |
|
dimreg_edit.scriptVars.signal_edit_script.connect( |
1576 |
|
[this](gig::Script* script) { |
1577 |
|
editScript(script); |
1578 |
|
} |
1579 |
|
); |
1580 |
|
|
1581 |
m_RegionChooser.signal_instrument_struct_to_be_changed().connect( |
m_RegionChooser.signal_instrument_struct_to_be_changed().connect( |
1582 |
sigc::hide( |
sigc::hide( |
1583 |
sigc::bind( |
sigc::bind( |
1584 |
file_structure_to_be_changed_signal.make_slot(), |
file_structure_to_be_changed_signal.make_slot(), |
1585 |
|
#if SIGCXX_MAJOR_VERSION > 2 || (SIGCXX_MAJOR_VERSION == 2 && SIGCXX_MINOR_VERSION >= 8) |
1586 |
|
std::ref(this->file) |
1587 |
|
#else |
1588 |
sigc::ref(this->file) |
sigc::ref(this->file) |
1589 |
|
#endif |
1590 |
) |
) |
1591 |
) |
) |
1592 |
); |
); |
1594 |
sigc::hide( |
sigc::hide( |
1595 |
sigc::bind( |
sigc::bind( |
1596 |
file_structure_changed_signal.make_slot(), |
file_structure_changed_signal.make_slot(), |
1597 |
|
#if SIGCXX_MAJOR_VERSION > 2 || (SIGCXX_MAJOR_VERSION == 2 && SIGCXX_MINOR_VERSION >= 8) |
1598 |
|
std::ref(this->file) |
1599 |
|
#else |
1600 |
sigc::ref(this->file) |
sigc::ref(this->file) |
1601 |
|
#endif |
1602 |
) |
) |
1603 |
) |
) |
1604 |
); |
); |
1620 |
sigc::mem_fun(*this, &MainWindow::update_dimregs)); |
sigc::mem_fun(*this, &MainWindow::update_dimregs)); |
1621 |
|
|
1622 |
m_searchText.signal_changed().connect( |
m_searchText.signal_changed().connect( |
1623 |
sigc::mem_fun(m_refTreeModelFilter.operator->(), &Gtk::TreeModelFilter::refilter) |
sigc::mem_fun(*m_refInstrumentsModelFilter.operator->(), &Gtk::TreeModelFilter::refilter) |
1624 |
); |
); |
1625 |
|
|
1626 |
file = 0; |
file = 0; |
1734 |
#endif |
#endif |
1735 |
raise(); |
raise(); |
1736 |
present(); |
present(); |
1737 |
|
|
1738 |
|
// restore user specified splitter position |
1739 |
|
if (Settings::singleton()->mainWindowSplitterPosX >= 0 && |
1740 |
|
Settings::singleton()->autoRestoreWindowDimension) |
1741 |
|
{ |
1742 |
|
const int pos = Settings::singleton()->mainWindowSplitterPosX; |
1743 |
|
printf("Restoring user's preferred splitter position=%d\n", pos); |
1744 |
|
m_HPaned.set_position(pos); |
1745 |
|
} |
1746 |
|
// this signal handler is late-connected after the UI build-up has settled |
1747 |
|
// to prevent the UI build-up from overwriting user's setting for splitter |
1748 |
|
// position unintentionally |
1749 |
|
m_HPaned.property_position().signal_changed().connect([this]{ |
1750 |
|
if (!Settings::singleton()->autoRestoreWindowDimension) return; |
1751 |
|
const int pos = m_HPaned.get_position(); |
1752 |
|
printf("Saving user's preferred splitter position=%d\n", pos); |
1753 |
|
Settings::singleton()->mainWindowSplitterPosX = pos; |
1754 |
|
}); |
1755 |
} |
} |
1756 |
|
|
1757 |
void MainWindow::updateMacroMenu() { |
void MainWindow::updateMacroMenu() { |
1882 |
|
|
1883 |
gig::Instrument* MainWindow::get_instrument() |
gig::Instrument* MainWindow::get_instrument() |
1884 |
{ |
{ |
1885 |
gig::Instrument* instrument = 0; |
gig::Instrument* instrument = NULL; |
1886 |
std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows(); |
|
1887 |
|
// get indeces of visual selection |
1888 |
|
std::vector<Gtk::TreeModel::Path> rows = m_TreeViewInstruments.get_selection()->get_selected_rows(); |
1889 |
if (rows.empty()) return NULL; |
if (rows.empty()) return NULL; |
1890 |
|
|
1891 |
|
// convert index of visual selection (i.e. if filtered) to index of model |
1892 |
|
Gtk::TreeModel::Path path = m_refInstrumentsModelFilter->convert_path_to_child_path(rows[0]); |
1893 |
|
if (!path) return NULL; |
1894 |
|
|
1895 |
//NOTE: was const_iterator before, which did not compile with GTKMM4 development branch, probably going to be fixed before final GTKMM4 release though. |
//NOTE: was const_iterator before, which did not compile with GTKMM4 development branch, probably going to be fixed before final GTKMM4 release though. |
1896 |
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]); |
Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(path); |
1897 |
if (it) { |
if (it) { |
1898 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
1899 |
instrument = row[m_Columns.m_col_instr]; |
instrument = row[m_InstrumentsModel.m_col_instr]; |
1900 |
} |
} |
1901 |
return instrument; |
return instrument; |
1902 |
} |
} |
1961 |
{ |
{ |
1962 |
#if !USE_GTKMM_BUILDER |
#if !USE_GTKMM_BUILDER |
1963 |
// select item in instrument menu |
// select item in instrument menu |
1964 |
std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows(); |
std::vector<Gtk::TreeModel::Path> rows = m_TreeViewInstruments.get_selection()->get_selected_rows(); |
1965 |
if (!rows.empty()) { |
if (!rows.empty()) { |
1966 |
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]); |
// convert index of visual selection (i.e. if filtered) to index of model |
1967 |
|
Gtk::TreeModel::Path row = m_refInstrumentsModelFilter->convert_path_to_child_path(rows[0]); |
1968 |
|
Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(row); |
1969 |
if (it) { |
if (it) { |
1970 |
Gtk::TreePath path(it); |
Gtk::TreePath path(it); |
1971 |
int index = path[0]; |
int index = path[0]; |
1978 |
|
|
1979 |
updateScriptListOfMenu(); |
updateScriptListOfMenu(); |
1980 |
|
|
1981 |
m_RegionChooser.set_instrument(get_instrument()); |
gig::Instrument* instr = get_instrument(); |
1982 |
|
|
1983 |
|
m_RegionChooser.set_instrument(instr); |
1984 |
|
dimreg_edit.scriptVars.setInstrument(instr, true/*force update*/); |
1985 |
|
|
1986 |
if (Settings::singleton()->syncSamplerInstrumentSelection) { |
if (Settings::singleton()->syncSamplerInstrumentSelection) { |
1987 |
switch_sampler_instrument_signal.emit(get_instrument()); |
switch_sampler_instrument_signal.emit(get_instrument()); |
1988 |
} |
} |
1989 |
} |
} |
1990 |
|
|
1991 |
|
|
1992 |
|
LoaderSaverBase::LoaderSaverBase(const Glib::ustring filename, gig::File* gig) : |
1993 |
|
filename(filename), gig(gig), |
1994 |
|
#ifdef GLIB_THREADS |
1995 |
|
thread(0), |
1996 |
|
#endif |
1997 |
|
progress(0.f) |
1998 |
|
{ |
1999 |
|
} |
2000 |
|
|
2001 |
void loader_progress_callback(gig::progress_t* progress) |
void loader_progress_callback(gig::progress_t* progress) |
2002 |
{ |
{ |
2003 |
Loader* loader = static_cast<Loader*>(progress->custom); |
LoaderSaverBase* loader = static_cast<LoaderSaverBase*>(progress->custom); |
2004 |
loader->progress_callback(progress->factor); |
loader->progress_callback(progress->factor); |
2005 |
} |
} |
2006 |
|
|
2007 |
void Loader::progress_callback(float fraction) |
void LoaderSaverBase::progress_callback(float fraction) |
2008 |
{ |
{ |
2009 |
{ |
{ |
2010 |
|
#ifdef GLIB_THREADS |
2011 |
Glib::Threads::Mutex::Lock lock(progressMutex); |
Glib::Threads::Mutex::Lock lock(progressMutex); |
2012 |
|
#else |
2013 |
|
std::lock_guard<std::mutex> lock(progressMutex); |
2014 |
|
#endif |
2015 |
progress = fraction; |
progress = fraction; |
2016 |
} |
} |
2017 |
progress_dispatcher(); |
progress_dispatcher(); |
2021 |
// make sure stack is 16-byte aligned for SSE instructions |
// make sure stack is 16-byte aligned for SSE instructions |
2022 |
__attribute__((force_align_arg_pointer)) |
__attribute__((force_align_arg_pointer)) |
2023 |
#endif |
#endif |
2024 |
void Loader::thread_function() |
void LoaderSaverBase::thread_function() |
2025 |
{ |
{ |
2026 |
|
#ifdef GLIB_THREADS |
2027 |
printf("thread_function self=%p\n", |
printf("thread_function self=%p\n", |
2028 |
static_cast<void*>(Glib::Threads::Thread::self())); |
static_cast<void*>(Glib::Threads::Thread::self())); |
2029 |
|
#else |
2030 |
|
std::cout << "thread_function self=" << std::this_thread::get_id() << "\n"; |
2031 |
|
#endif |
2032 |
printf("Start %s\n", filename.c_str()); |
printf("Start %s\n", filename.c_str()); |
2033 |
try { |
try { |
|
RIFF::File* riff = new RIFF::File(filename); |
|
|
gig = new gig::File(riff); |
|
2034 |
gig::progress_t progress; |
gig::progress_t progress; |
2035 |
progress.callback = loader_progress_callback; |
progress.callback = loader_progress_callback; |
2036 |
progress.custom = this; |
progress.custom = this; |
2037 |
|
|
2038 |
gig->GetInstrument(0, &progress); |
thread_function_sub(progress); |
2039 |
printf("End\n"); |
printf("End\n"); |
2040 |
finished_dispatcher(); |
finished_dispatcher(); |
2041 |
} catch (RIFF::Exception e) { |
} catch (RIFF::Exception e) { |
2047 |
} |
} |
2048 |
} |
} |
2049 |
|
|
2050 |
Loader::Loader(const char* filename) |
void LoaderSaverBase::launch() |
|
: filename(filename), gig(0), thread(0), progress(0.f) |
|
|
{ |
|
|
} |
|
|
|
|
|
void Loader::launch() |
|
2051 |
{ |
{ |
2052 |
|
#ifdef GLIB_THREADS |
2053 |
#ifdef OLD_THREADS |
#ifdef OLD_THREADS |
2054 |
thread = Glib::Thread::create(sigc::mem_fun(*this, &Loader::thread_function), true); |
thread = Glib::Thread::create(sigc::mem_fun(*this, &LoaderSaverBase::thread_function), true); |
2055 |
#else |
#else |
2056 |
thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Loader::thread_function)); |
thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &LoaderSaverBase::thread_function)); |
2057 |
#endif |
#endif |
2058 |
printf("launch thread=%p\n", static_cast<void*>(thread)); |
printf("launch thread=%p\n", static_cast<void*>(thread)); |
2059 |
|
#else |
2060 |
|
thread = std::thread([this](){ thread_function(); }); |
2061 |
|
std::cout << "launch thread=" << thread.get_id() << "\n"; |
2062 |
|
#endif |
2063 |
} |
} |
2064 |
|
|
2065 |
float Loader::get_progress() |
float LoaderSaverBase::get_progress() |
2066 |
{ |
{ |
2067 |
float res; |
#ifdef GLIB_THREADS |
2068 |
{ |
Glib::Threads::Mutex::Lock lock(progressMutex); |
2069 |
Glib::Threads::Mutex::Lock lock(progressMutex); |
#else |
2070 |
res = progress; |
std::lock_guard<std::mutex> lock(progressMutex); |
2071 |
} |
#endif |
2072 |
return res; |
return progress; |
2073 |
} |
} |
2074 |
|
|
2075 |
Glib::Dispatcher& Loader::signal_progress() |
Glib::Dispatcher& LoaderSaverBase::signal_progress() |
2076 |
{ |
{ |
2077 |
return progress_dispatcher; |
return progress_dispatcher; |
2078 |
} |
} |
2079 |
|
|
2080 |
Glib::Dispatcher& Loader::signal_finished() |
Glib::Dispatcher& LoaderSaverBase::signal_finished() |
2081 |
{ |
{ |
2082 |
return finished_dispatcher; |
return finished_dispatcher; |
2083 |
} |
} |
2084 |
|
|
2085 |
Glib::Dispatcher& Loader::signal_error() |
Glib::Dispatcher& LoaderSaverBase::signal_error() |
2086 |
{ |
{ |
2087 |
return error_dispatcher; |
return error_dispatcher; |
2088 |
} |
} |
2089 |
|
|
2090 |
void saver_progress_callback(gig::progress_t* progress) |
void LoaderSaverBase::join() { |
2091 |
{ |
#ifdef GLIB_THREADS |
2092 |
Saver* saver = static_cast<Saver*>(progress->custom); |
thread->join(); |
2093 |
saver->progress_callback(progress->factor); |
#else |
2094 |
|
thread.join(); |
2095 |
|
#endif |
2096 |
} |
} |
2097 |
|
|
2098 |
void Saver::progress_callback(float fraction) |
|
2099 |
|
Loader::Loader(const char* filename) : |
2100 |
|
LoaderSaverBase(filename, 0) |
2101 |
{ |
{ |
|
{ |
|
|
Glib::Threads::Mutex::Lock lock(progressMutex); |
|
|
progress = fraction; |
|
|
} |
|
|
progress_dispatcher.emit(); |
|
2102 |
} |
} |
2103 |
|
|
2104 |
#if defined(WIN32) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)) |
void Loader::thread_function_sub(gig::progress_t& progress) |
|
// make sure stack is 16-byte aligned for SSE instructions |
|
|
__attribute__((force_align_arg_pointer)) |
|
|
#endif |
|
|
void Saver::thread_function() |
|
2105 |
{ |
{ |
2106 |
printf("thread_function self=%p\n", |
RIFF::File* riff = new RIFF::File(filename); |
2107 |
static_cast<void*>(Glib::Threads::Thread::self())); |
gig = new gig::File(riff); |
|
printf("Start %s\n", filename.c_str()); |
|
|
try { |
|
|
gig::progress_t progress; |
|
|
progress.callback = saver_progress_callback; |
|
|
progress.custom = this; |
|
|
|
|
|
// if no filename was provided, that means "save", if filename was provided means "save as" |
|
|
if (filename.empty()) { |
|
|
if (!Settings::singleton()->saveWithTemporaryFile) { |
|
|
// save directly over the existing .gig file |
|
|
// (requires less disk space than solution below |
|
|
// but may be slower) |
|
|
gig->Save(&progress); |
|
|
} else { |
|
|
// save the file as separate temporary file first, |
|
|
// then move the saved file over the old file |
|
|
// (may result in performance speedup during save) |
|
|
gig::String tmpname = filename + ".TMP"; |
|
|
gig->Save(tmpname, &progress); |
|
|
#if defined(WIN32) |
|
|
if (!DeleteFile(filename.c_str())) { |
|
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file)."); |
|
|
} |
|
|
#else // POSIX ... |
|
|
if (unlink(filename.c_str())) { |
|
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file): " + gig::String(strerror(errno))); |
|
|
} |
|
|
#endif |
|
|
if (rename(tmpname.c_str(), filename.c_str())) { |
|
|
#if defined(WIN32) |
|
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file)."); |
|
|
#else |
|
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file): " + gig::String(strerror(errno))); |
|
|
#endif |
|
|
} |
|
|
} |
|
|
} else { |
|
|
gig->Save(filename, &progress); |
|
|
} |
|
2108 |
|
|
2109 |
printf("End\n"); |
gig->GetInstrument(0, &progress); |
|
finished_dispatcher.emit(); |
|
|
} catch (RIFF::Exception e) { |
|
|
error_message = e.Message; |
|
|
error_dispatcher.emit(); |
|
|
} catch (...) { |
|
|
error_message = _("Unknown exception occurred"); |
|
|
error_dispatcher.emit(); |
|
|
} |
|
2110 |
} |
} |
2111 |
|
|
2112 |
Saver::Saver(gig::File* file, Glib::ustring filename) |
|
2113 |
: gig(file), filename(filename), thread(0), progress(0.f) |
Saver::Saver(gig::File* file, Glib::ustring filename) : |
2114 |
|
LoaderSaverBase(filename, file) |
2115 |
{ |
{ |
2116 |
} |
} |
2117 |
|
|
2118 |
void Saver::launch() |
void Saver::thread_function_sub(gig::progress_t& progress) |
2119 |
{ |
{ |
2120 |
#ifdef OLD_THREADS |
// if no filename was provided, that means "save", if filename was provided means "save as" |
2121 |
thread = Glib::Thread::create(sigc::mem_fun(*this, &Saver::thread_function), true); |
if (filename.empty()) { |
2122 |
|
if (!Settings::singleton()->saveWithTemporaryFile) { |
2123 |
|
// save directly over the existing .gig file |
2124 |
|
// (requires less disk space than solution below |
2125 |
|
// but may be slower) |
2126 |
|
gig->Save(&progress); |
2127 |
|
} else { |
2128 |
|
// save the file as separate temporary file first, |
2129 |
|
// then move the saved file over the old file |
2130 |
|
// (may result in performance speedup during save) |
2131 |
|
gig::String tmpname = filename + ".TMP"; |
2132 |
|
gig->Save(tmpname, &progress); |
2133 |
|
#if defined(WIN32) |
2134 |
|
if (!DeleteFile(filename.c_str())) { |
2135 |
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file)."); |
2136 |
|
} |
2137 |
|
#else // POSIX ... |
2138 |
|
if (unlink(filename.c_str())) { |
2139 |
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file): " + gig::String(strerror(errno))); |
2140 |
|
} |
2141 |
|
#endif |
2142 |
|
if (rename(tmpname.c_str(), filename.c_str())) { |
2143 |
|
#if defined(WIN32) |
2144 |
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file)."); |
2145 |
#else |
#else |
2146 |
thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Saver::thread_function)); |
throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file): " + gig::String(strerror(errno))); |
2147 |
#endif |
#endif |
2148 |
printf("launch thread=%p\n", static_cast<void*>(thread)); |
} |
2149 |
} |
} |
2150 |
|
} else { |
2151 |
float Saver::get_progress() |
gig->Save(filename, &progress); |
|
{ |
|
|
float res; |
|
|
{ |
|
|
Glib::Threads::Mutex::Lock lock(progressMutex); |
|
|
res = progress; |
|
2152 |
} |
} |
|
return res; |
|
2153 |
} |
} |
2154 |
|
|
|
Glib::Dispatcher& Saver::signal_progress() |
|
|
{ |
|
|
return progress_dispatcher; |
|
|
} |
|
|
|
|
|
Glib::Dispatcher& Saver::signal_finished() |
|
|
{ |
|
|
return finished_dispatcher; |
|
|
} |
|
|
|
|
|
Glib::Dispatcher& Saver::signal_error() |
|
|
{ |
|
|
return error_dispatcher; |
|
|
} |
|
2155 |
|
|
2156 |
ProgressDialog::ProgressDialog(const Glib::ustring& title, Gtk::Window& parent) |
ProgressDialog::ProgressDialog(const Glib::ustring& title, Gtk::Window& parent) |
2157 |
: Gtk::Dialog(title, parent, true) |
: Gtk::Dialog(title, parent, true) |
2173 |
// forget all samples that ought to be imported |
// forget all samples that ought to be imported |
2174 |
m_SampleImportQueue.clear(); |
m_SampleImportQueue.clear(); |
2175 |
// clear the samples and instruments tree views |
// clear the samples and instruments tree views |
2176 |
m_refTreeModel->clear(); |
m_refInstrumentsTreeModel->clear(); |
2177 |
m_refSamplesTreeModel->clear(); |
m_refSamplesTreeModel->clear(); |
2178 |
m_refScriptsTreeModel->clear(); |
m_refScriptsTreeModel->clear(); |
2179 |
#if !USE_GTKMM_BUILDER |
#if !USE_GTKMM_BUILDER |
2190 |
|
|
2191 |
void MainWindow::__refreshEntireGUI() { |
void MainWindow::__refreshEntireGUI() { |
2192 |
// clear the samples and instruments tree views |
// clear the samples and instruments tree views |
2193 |
m_refTreeModel->clear(); |
m_refInstrumentsTreeModel->clear(); |
2194 |
m_refSamplesTreeModel->clear(); |
m_refSamplesTreeModel->clear(); |
2195 |
m_refScriptsTreeModel->clear(); |
m_refScriptsTreeModel->clear(); |
2196 |
#if !USE_GTKMM_BUILDER |
#if !USE_GTKMM_BUILDER |
2307 |
dialog.set_current_folder(current_gig_dir); |
dialog.set_current_folder(current_gig_dir); |
2308 |
} |
} |
2309 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
2310 |
|
dialog.hide(); |
2311 |
std::string filename = dialog.get_filename(); |
std::string filename = dialog.get_filename(); |
2312 |
printf("filename=%s\n", filename.c_str()); |
printf("filename=%s\n", filename.c_str()); |
2313 |
|
#ifdef GLIB_THREADS |
2314 |
printf("on_action_file_open self=%p\n", |
printf("on_action_file_open self=%p\n", |
2315 |
static_cast<void*>(Glib::Threads::Thread::self())); |
static_cast<void*>(Glib::Threads::Thread::self())); |
2316 |
|
#else |
2317 |
|
std::cout << "on_action_file_open self=" << |
2318 |
|
std::this_thread::get_id() << "\n"; |
2319 |
|
#endif |
2320 |
load_file(filename.c_str()); |
load_file(filename.c_str()); |
2321 |
current_gig_dir = Glib::path_get_dirname(filename); |
current_gig_dir = Glib::path_get_dirname(filename); |
2322 |
} |
} |
2363 |
{ |
{ |
2364 |
if (instrument == instr) { |
if (instrument == instr) { |
2365 |
// select item in "instruments" tree view |
// select item in "instruments" tree view |
2366 |
m_TreeView.get_selection()->select(Gtk::TreePath(ToString(i))); |
m_TreeViewInstruments.get_selection()->select(Gtk::TreePath(ToString(i))); |
2367 |
// make sure the selected item in the "instruments" tree view is |
// make sure the selected item in the "instruments" tree view is |
2368 |
// visible (scroll to it) |
// visible (scroll to it) |
2369 |
m_TreeView.scroll_to_row(Gtk::TreePath(ToString(i))); |
m_TreeViewInstruments.scroll_to_row(Gtk::TreePath(ToString(i))); |
2370 |
#if !USE_GTKMM_BUILDER |
#if !USE_GTKMM_BUILDER |
2371 |
// select item in instrument menu |
// select item in instrument menu |
2372 |
{ |
{ |
2389 |
|
|
2390 |
void MainWindow::on_loader_finished() |
void MainWindow::on_loader_finished() |
2391 |
{ |
{ |
2392 |
|
loader->join(); |
2393 |
printf("Loader finished!\n"); |
printf("Loader finished!\n"); |
2394 |
|
#ifdef GLIB_THREADS |
2395 |
printf("on_loader_finished self=%p\n", |
printf("on_loader_finished self=%p\n", |
2396 |
static_cast<void*>(Glib::Threads::Thread::self())); |
static_cast<void*>(Glib::Threads::Thread::self())); |
2397 |
|
#else |
2398 |
|
std::cout << "on_loader_finished self=" << |
2399 |
|
std::this_thread::get_id() << "\n"; |
2400 |
|
#endif |
2401 |
load_gig(loader->gig, loader->filename.c_str()); |
load_gig(loader->gig, loader->filename.c_str()); |
2402 |
progress_dialog->hide(); |
progress_dialog->hide(); |
2403 |
} |
} |
2404 |
|
|
2405 |
void MainWindow::on_loader_error() |
void MainWindow::on_loader_error() |
2406 |
{ |
{ |
2407 |
|
loader->join(); |
2408 |
Glib::ustring txt = _("Could not load file: ") + loader->error_message; |
Glib::ustring txt = _("Could not load file: ") + loader->error_message; |
2409 |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
2410 |
msg.run(); |
msg.run(); |
2475 |
|
|
2476 |
void MainWindow::on_saver_error() |
void MainWindow::on_saver_error() |
2477 |
{ |
{ |
2478 |
|
saver->join(); |
2479 |
file_structure_changed_signal.emit(this->file); |
file_structure_changed_signal.emit(this->file); |
2480 |
Glib::ustring txt = _("Could not save file: ") + saver->error_message; |
Glib::ustring txt = _("Could not save file: ") + saver->error_message; |
2481 |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
2484 |
|
|
2485 |
void MainWindow::on_saver_finished() |
void MainWindow::on_saver_finished() |
2486 |
{ |
{ |
2487 |
|
saver->join(); |
2488 |
this->file = saver->gig; |
this->file = saver->gig; |
2489 |
this->filename = saver->filename; |
this->filename = saver->filename; |
2490 |
current_gig_dir = Glib::path_get_dirname(filename); |
current_gig_dir = Glib::path_get_dirname(filename); |
2576 |
#endif |
#endif |
2577 |
|
|
2578 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
2579 |
|
dialog.hide(); |
2580 |
std::string filename = dialog.get_filename(); |
std::string filename = dialog.get_filename(); |
2581 |
if (!Glib::str_has_suffix(filename, ".gig")) { |
if (!Glib::str_has_suffix(filename, ".gig")) { |
2582 |
filename += ".gig"; |
filename += ".gig"; |
2705 |
|
|
2706 |
void MainWindow::on_action_file_properties() |
void MainWindow::on_action_file_properties() |
2707 |
{ |
{ |
2708 |
propDialog.show(); |
fileProps.show(); |
2709 |
propDialog.deiconify(); |
fileProps.deiconify(); |
2710 |
} |
} |
2711 |
|
|
2712 |
void MainWindow::on_action_warn_user_on_extensions() { |
void MainWindow::on_action_warn_user_on_extensions() { |
2730 |
dimreg_stereo.set_has_tooltip(b); |
dimreg_stereo.set_has_tooltip(b); |
2731 |
|
|
2732 |
// Not doing this here, we let onQueryTreeViewTooltip() handle this per cell |
// Not doing this here, we let onQueryTreeViewTooltip() handle this per cell |
2733 |
//m_TreeView.set_has_tooltip(b); |
//m_TreeViewInstruments.set_has_tooltip(b); |
2734 |
|
|
2735 |
m_TreeViewSamples.set_has_tooltip(b); |
m_TreeViewSamples.set_has_tooltip(b); |
2736 |
m_TreeViewScripts.set_has_tooltip(b); |
m_TreeViewScripts.set_has_tooltip(b); |
2768 |
"backup your Gigasampler/GigaStudio files before editing them with " |
"backup your Gigasampler/GigaStudio files before editing them with " |
2769 |
"this application.\n" |
"this application.\n" |
2770 |
"\n" |
"\n" |
2771 |
"Please report bugs to: http://bugs.linuxsampler.org" |
"Please report bugs to: https://bugs.linuxsampler.org" |
2772 |
); |
); |
2773 |
dialog.set_comments(sComment.c_str()); |
dialog.set_comments(sComment.c_str()); |
2774 |
dialog.set_website("http://www.linuxsampler.org"); |
dialog.set_website("https://www.linuxsampler.org"); |
2775 |
dialog.set_website_label("http://www.linuxsampler.org"); |
dialog.set_website_label("https://www.linuxsampler.org"); |
2776 |
dialog.set_position(Gtk::WIN_POS_CENTER); |
dialog.set_position(Gtk::WIN_POS_CENTER); |
2777 |
dialog.run(); |
dialog.run(); |
2778 |
} |
} |
2779 |
|
|
2780 |
PropDialog::PropDialog() |
FilePropDialog::FilePropDialog() |
2781 |
: eFileFormat(_("File Format")), |
: eFileFormat(_("File Format")), |
2782 |
eName(_("Name")), |
eName(_("Name")), |
2783 |
eCreationDate(_("Creation date")), |
eCreationDate(_("Creation date")), |
2811 |
set_title(_("File Properties")); |
set_title(_("File Properties")); |
2812 |
eName.set_width_chars(50); |
eName.set_width_chars(50); |
2813 |
|
|
2814 |
|
connect(eFileFormat, &FilePropDialog::set_FileFormat); |
2815 |
connect(eName, &DLS::Info::Name); |
connect(eName, &DLS::Info::Name); |
2816 |
connect(eCreationDate, &DLS::Info::CreationDate); |
connect(eCreationDate, &DLS::Info::CreationDate); |
2817 |
connect(eComments, &DLS::Info::Comments); |
connect(eComments, &DLS::Info::Comments); |
2872 |
quitButton.set_can_default(); |
quitButton.set_can_default(); |
2873 |
quitButton.grab_focus(); |
quitButton.grab_focus(); |
2874 |
quitButton.signal_clicked().connect( |
quitButton.signal_clicked().connect( |
2875 |
sigc::mem_fun(*this, &PropDialog::hide)); |
sigc::mem_fun(*this, &FilePropDialog::hide)); |
|
eFileFormat.signal_value_changed().connect( |
|
|
sigc::mem_fun(*this, &PropDialog::onFileFormatChanged)); |
|
2876 |
|
|
2877 |
quitButton.show(); |
quitButton.show(); |
2878 |
vbox.show(); |
vbox.show(); |
2881 |
#endif |
#endif |
2882 |
} |
} |
2883 |
|
|
2884 |
void PropDialog::set_file(gig::File* file) |
void FilePropDialog::set_file(gig::File* file) |
2885 |
{ |
{ |
2886 |
m_file = file; |
m_file = file; |
2887 |
|
update(file->pInfo); |
2888 |
|
|
2889 |
// update file format version combo box |
// update file format version combo box |
2890 |
const std::string sGiga = "Gigasampler/GigaStudio v"; |
const std::string sGiga = "Gigasampler/GigaStudio v"; |
2900 |
std::vector<const char*> texts; |
std::vector<const char*> texts; |
2901 |
for (int i = 0; i < txts.size(); ++i) texts.push_back(txts[i].c_str()); |
for (int i = 0; i < txts.size(); ++i) texts.push_back(txts[i].c_str()); |
2902 |
texts.push_back(NULL); values.push_back(0); |
texts.push_back(NULL); values.push_back(0); |
2903 |
|
|
2904 |
|
update_model++; |
2905 |
eFileFormat.set_choices(&texts[0], &values[0]); |
eFileFormat.set_choices(&texts[0], &values[0]); |
2906 |
eFileFormat.set_value(major); |
eFileFormat.set_value(major); |
2907 |
|
update_model--; |
2908 |
} |
} |
2909 |
|
|
2910 |
void PropDialog::onFileFormatChanged() { |
void FilePropDialog::set_FileFormat(int value) |
|
const int major = eFileFormat.get_value(); |
|
|
if (m_file) m_file->pVersion->major = major; |
|
|
} |
|
|
|
|
|
void PropDialog::set_info(DLS::Info* info) |
|
2911 |
{ |
{ |
2912 |
update(info); |
m_file->pVersion->major = value; |
2913 |
} |
} |
2914 |
|
|
2915 |
|
|
2951 |
eIsDrum(_("Is drum")), |
eIsDrum(_("Is drum")), |
2952 |
eMIDIBank(_("MIDI bank"), 0, 16383), |
eMIDIBank(_("MIDI bank"), 0, 16383), |
2953 |
eMIDIProgram(_("MIDI program")), |
eMIDIProgram(_("MIDI program")), |
2954 |
eAttenuation(_("Attenuation"), 0, 96, 0, 1), |
eAttenuation(_("Attenuation (dB)"), -96, +96, 0, 1), |
|
eGainPlus6(_("Gain +6dB"), eAttenuation, -6), |
|
2955 |
eEffectSend(_("Effect send"), 0, 65535), |
eEffectSend(_("Effect send"), 0, 65535), |
2956 |
eFineTune(_("Fine tune"), -8400, 8400), |
eFineTune(_("Fine tune"), -8400, 8400), |
2957 |
ePitchbendRange(_("Pitchbend range"), 0, 48), |
ePitchbendRange(_("Pitchbend range (halftones)"), 0, 48), |
2958 |
ePianoReleaseMode(_("Piano release mode")), |
ePianoReleaseMode(_("Piano release mode")), |
2959 |
eDimensionKeyRangeLow(_("Keyswitching range low")), |
eDimensionKeyRangeLow(_("Keyswitching range low")), |
2960 |
eDimensionKeyRangeHigh(_("Keyswitching range high")) |
eDimensionKeyRangeHigh(_("Keyswitching range high")), |
2961 |
|
table2(2,1), |
2962 |
|
eName2(_("Name")), |
2963 |
|
eCreationDate(_("Creation date")), |
2964 |
|
eComments(_("Comments")), |
2965 |
|
eProduct(_("Product")), |
2966 |
|
eCopyright(_("Copyright")), |
2967 |
|
eArtists(_("Artists")), |
2968 |
|
eGenre(_("Genre")), |
2969 |
|
eKeywords(_("Keywords")), |
2970 |
|
eEngineer(_("Engineer")), |
2971 |
|
eTechnician(_("Technician")), |
2972 |
|
eSoftware(_("Software")), |
2973 |
|
eMedium(_("Medium")), |
2974 |
|
eSource(_("Source")), |
2975 |
|
eSourceForm(_("Source form")), |
2976 |
|
eCommissioned(_("Commissioned")), |
2977 |
|
eSubject(_("Subject")) |
2978 |
{ |
{ |
2979 |
if (!Settings::singleton()->autoRestoreWindowDimension) { |
if (!Settings::singleton()->autoRestoreWindowDimension) { |
2980 |
//set_default_size(470, 390); |
//set_default_size(470, 390); |
2983 |
|
|
2984 |
set_title(_("Instrument Properties")); |
set_title(_("Instrument Properties")); |
2985 |
|
|
2986 |
|
tabs.append_page(vbox[1], _("Settings")); |
2987 |
|
tabs.append_page(vbox[2], _("Info")); |
2988 |
|
|
2989 |
eDimensionKeyRangeLow.set_tip( |
eDimensionKeyRangeLow.set_tip( |
2990 |
_("start of the keyboard area which should switch the " |
_("start of the keyboard area which should switch the " |
2991 |
"\"keyswitching\" dimension") |
"\"keyswitching\" dimension") |
3000 |
connect(eMIDIBank, &InstrumentProps::set_MIDIBank); |
connect(eMIDIBank, &InstrumentProps::set_MIDIBank); |
3001 |
connect(eMIDIProgram, &InstrumentProps::set_MIDIProgram); |
connect(eMIDIProgram, &InstrumentProps::set_MIDIProgram); |
3002 |
connect(eAttenuation, &gig::Instrument::Attenuation); |
connect(eAttenuation, &gig::Instrument::Attenuation); |
|
connect(eGainPlus6, &gig::Instrument::Attenuation); |
|
3003 |
connect(eEffectSend, &gig::Instrument::EffectSend); |
connect(eEffectSend, &gig::Instrument::EffectSend); |
3004 |
connect(eFineTune, &gig::Instrument::FineTune); |
connect(eFineTune, &gig::Instrument::FineTune); |
3005 |
connect(ePitchbendRange, &gig::Instrument::PitchbendRange); |
connect(ePitchbendRange, &gig::Instrument::PitchbendRange); |
3009 |
|
|
3010 |
eName.signal_value_changed().connect(sig_name_changed.make_slot()); |
eName.signal_value_changed().connect(sig_name_changed.make_slot()); |
3011 |
|
|
3012 |
|
connect(eName2, &InstrumentProps::set_Name); |
3013 |
|
connectLambda(eCreationDate, [this](gig::String s) { |
3014 |
|
m->pInfo->CreationDate = s; |
3015 |
|
}); |
3016 |
|
connectLambda(eComments, [this](gig::String s) { |
3017 |
|
m->pInfo->Comments = s; |
3018 |
|
}); |
3019 |
|
connectLambda(eProduct, [this](gig::String s) { |
3020 |
|
m->pInfo->Product = s; |
3021 |
|
}); |
3022 |
|
connectLambda(eCopyright, [this](gig::String s) { |
3023 |
|
m->pInfo->Copyright = s; |
3024 |
|
}); |
3025 |
|
connectLambda(eArtists, [this](gig::String s) { |
3026 |
|
m->pInfo->Artists = s; |
3027 |
|
}); |
3028 |
|
connectLambda(eGenre, [this](gig::String s) { |
3029 |
|
m->pInfo->Genre = s; |
3030 |
|
}); |
3031 |
|
connectLambda(eKeywords, [this](gig::String s) { |
3032 |
|
m->pInfo->Keywords = s; |
3033 |
|
}); |
3034 |
|
connectLambda(eEngineer, [this](gig::String s) { |
3035 |
|
m->pInfo->Engineer = s; |
3036 |
|
}); |
3037 |
|
connectLambda(eTechnician, [this](gig::String s) { |
3038 |
|
m->pInfo->Technician = s; |
3039 |
|
}); |
3040 |
|
connectLambda(eSoftware, [this](gig::String s) { |
3041 |
|
m->pInfo->Software = s; |
3042 |
|
}); |
3043 |
|
connectLambda(eMedium, [this](gig::String s) { |
3044 |
|
m->pInfo->Medium = s; |
3045 |
|
}); |
3046 |
|
connectLambda(eSource, [this](gig::String s) { |
3047 |
|
m->pInfo->Source = s; |
3048 |
|
}); |
3049 |
|
connectLambda(eSourceForm, [this](gig::String s) { |
3050 |
|
m->pInfo->SourceForm = s; |
3051 |
|
}); |
3052 |
|
connectLambda(eCommissioned, [this](gig::String s) { |
3053 |
|
m->pInfo->Commissioned = s; |
3054 |
|
}); |
3055 |
|
connectLambda(eSubject, [this](gig::String s) { |
3056 |
|
m->pInfo->Subject = s; |
3057 |
|
}); |
3058 |
|
|
3059 |
|
// tab 1 |
3060 |
#if USE_GTKMM_GRID |
#if USE_GTKMM_GRID |
3061 |
table.set_column_spacing(5); |
table.set_column_spacing(5); |
3062 |
#else |
#else |
3063 |
table.set_col_spacings(5); |
table.set_col_spacings(5); |
3064 |
#endif |
#endif |
|
|
|
3065 |
table.add(eName); |
table.add(eName); |
3066 |
table.add(eIsDrum); |
table.add(eIsDrum); |
3067 |
table.add(eMIDIBank); |
table.add(eMIDIBank); |
3068 |
table.add(eMIDIProgram); |
table.add(eMIDIProgram); |
3069 |
table.add(eAttenuation); |
table.add(eAttenuation); |
|
table.add(eGainPlus6); |
|
3070 |
table.add(eEffectSend); |
table.add(eEffectSend); |
3071 |
table.add(eFineTune); |
table.add(eFineTune); |
3072 |
table.add(ePitchbendRange); |
table.add(ePitchbendRange); |
3074 |
table.add(eDimensionKeyRangeLow); |
table.add(eDimensionKeyRangeLow); |
3075 |
table.add(eDimensionKeyRangeHigh); |
table.add(eDimensionKeyRangeHigh); |
3076 |
|
|
3077 |
add(vbox); |
// tab 2 |
3078 |
|
#if USE_GTKMM_GRID |
3079 |
|
table2.set_column_spacing(5); |
3080 |
|
#else |
3081 |
|
table2.set_col_spacings(5); |
3082 |
|
#endif |
3083 |
|
table2.add(eName2); |
3084 |
|
table2.add(eCreationDate); |
3085 |
|
table2.add(eComments); |
3086 |
|
table2.add(eProduct); |
3087 |
|
table2.add(eCopyright); |
3088 |
|
table2.add(eArtists); |
3089 |
|
table2.add(eGenre); |
3090 |
|
table2.add(eKeywords); |
3091 |
|
table2.add(eEngineer); |
3092 |
|
table2.add(eTechnician); |
3093 |
|
table2.add(eSoftware); |
3094 |
|
table2.add(eMedium); |
3095 |
|
table2.add(eSource); |
3096 |
|
table2.add(eSourceForm); |
3097 |
|
table2.add(eCommissioned); |
3098 |
|
table2.add(eSubject); |
3099 |
|
|
3100 |
|
add(vbox[0]); |
3101 |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24) |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24) |
3102 |
table.set_margin(5); |
table.set_margin(5); |
3103 |
#else |
#else |
3104 |
table.set_border_width(5); |
table.set_border_width(5); |
3105 |
#endif |
#endif |
3106 |
vbox.pack_start(table); |
vbox[1].pack_start(table); |
3107 |
|
vbox[2].pack_start(table2); |
3108 |
table.show(); |
table.show(); |
3109 |
vbox.pack_start(buttonBox, Gtk::PACK_SHRINK); |
table2.show(); |
3110 |
|
vbox[0].pack_start(tabs); |
3111 |
|
vbox[0].pack_start(buttonBox, Gtk::PACK_SHRINK); |
3112 |
buttonBox.set_layout(Gtk::BUTTONBOX_END); |
buttonBox.set_layout(Gtk::BUTTONBOX_END); |
3113 |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24) |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24) |
3114 |
buttonBox.set_margin(5); |
buttonBox.set_margin(5); |
3124 |
sigc::mem_fun(*this, &InstrumentProps::hide)); |
sigc::mem_fun(*this, &InstrumentProps::hide)); |
3125 |
|
|
3126 |
quitButton.show(); |
quitButton.show(); |
3127 |
vbox.show(); |
vbox[0].show(); |
3128 |
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
3129 |
show_all_children(); |
show_all_children(); |
3130 |
#endif |
#endif |
3135 |
update(instrument); |
update(instrument); |
3136 |
|
|
3137 |
update_model++; |
update_model++; |
3138 |
|
|
3139 |
|
// tab 1 |
3140 |
eName.set_value(instrument->pInfo->Name); |
eName.set_value(instrument->pInfo->Name); |
3141 |
eIsDrum.set_value(instrument->IsDrum); |
eIsDrum.set_value(instrument->IsDrum); |
3142 |
eMIDIBank.set_value(instrument->MIDIBank); |
eMIDIBank.set_value(instrument->MIDIBank); |
3143 |
eMIDIProgram.set_value(instrument->MIDIProgram); |
eMIDIProgram.set_value(instrument->MIDIProgram); |
3144 |
|
// tab 2 |
3145 |
|
eName2.set_value(instrument->pInfo->Name); |
3146 |
|
eCreationDate.set_value(instrument->pInfo->CreationDate); |
3147 |
|
eComments.set_value(instrument->pInfo->Comments); |
3148 |
|
eProduct.set_value(instrument->pInfo->Product); |
3149 |
|
eCopyright.set_value(instrument->pInfo->Copyright); |
3150 |
|
eArtists.set_value(instrument->pInfo->Artists); |
3151 |
|
eGenre.set_value(instrument->pInfo->Genre); |
3152 |
|
eKeywords.set_value(instrument->pInfo->Keywords); |
3153 |
|
eEngineer.set_value(instrument->pInfo->Engineer); |
3154 |
|
eTechnician.set_value(instrument->pInfo->Technician); |
3155 |
|
eSoftware.set_value(instrument->pInfo->Software); |
3156 |
|
eMedium.set_value(instrument->pInfo->Medium); |
3157 |
|
eSource.set_value(instrument->pInfo->Source); |
3158 |
|
eSourceForm.set_value(instrument->pInfo->SourceForm); |
3159 |
|
eCommissioned.set_value(instrument->pInfo->Commissioned); |
3160 |
|
eSubject.set_value(instrument->pInfo->Subject); |
3161 |
|
|
3162 |
|
update_model--; |
3163 |
|
} |
3164 |
|
|
3165 |
|
|
3166 |
|
SampleProps::SampleProps() : |
3167 |
|
#if HAS_GTKMM_STOCK |
3168 |
|
quitButton(Gtk::Stock::CLOSE), |
3169 |
|
#else |
3170 |
|
quitButton(_("_Close")), |
3171 |
|
#endif |
3172 |
|
table(2,1), |
3173 |
|
eName(_("Name")), |
3174 |
|
eUnityNote(_("Unity Note")), |
3175 |
|
eSampleGroup(_("Sample Group")), |
3176 |
|
eSampleFormatInfo(_("Sample Format")), |
3177 |
|
eSampleID("Sample ID"), |
3178 |
|
eChecksum("Wave Data CRC-32"), |
3179 |
|
eLoopsCount(_("Loops"), 0, 1), // we might support more than 1 loop in future |
3180 |
|
eLoopStart(_("Loop start position"), 0, 9999999), |
3181 |
|
eLoopLength(_("Loop size"), 0, 9999999), |
3182 |
|
eLoopType(_("Loop type")), |
3183 |
|
eLoopPlayCount(_("Playback count")), |
3184 |
|
table2(2,1), |
3185 |
|
eName2(_("Name")), |
3186 |
|
eCreationDate(_("Creation date")), |
3187 |
|
eComments(_("Comments")), |
3188 |
|
eProduct(_("Product")), |
3189 |
|
eCopyright(_("Copyright")), |
3190 |
|
eArtists(_("Artists")), |
3191 |
|
eGenre(_("Genre")), |
3192 |
|
eKeywords(_("Keywords")), |
3193 |
|
eEngineer(_("Engineer")), |
3194 |
|
eTechnician(_("Technician")), |
3195 |
|
eSoftware(_("Software")), |
3196 |
|
eMedium(_("Medium")), |
3197 |
|
eSource(_("Source")), |
3198 |
|
eSourceForm(_("Source form")), |
3199 |
|
eCommissioned(_("Commissioned")), |
3200 |
|
eSubject(_("Subject")) |
3201 |
|
{ |
3202 |
|
if (!Settings::singleton()->autoRestoreWindowDimension) { |
3203 |
|
//set_default_size(470, 390); |
3204 |
|
set_position(Gtk::WIN_POS_MOUSE); |
3205 |
|
} |
3206 |
|
|
3207 |
|
set_title(_("Sample Properties")); |
3208 |
|
|
3209 |
|
tabs.append_page(vbox[1], _("Settings")); |
3210 |
|
tabs.append_page(vbox[2], _("Info")); |
3211 |
|
|
3212 |
|
connect(eName, &SampleProps::set_Name); |
3213 |
|
connect(eUnityNote, &gig::Sample::MIDIUnityNote); |
3214 |
|
connect(eLoopsCount, &gig::Sample::Loops); |
3215 |
|
connectLambda(eLoopStart, [this](uint32_t start){ |
3216 |
|
m->LoopStart = start; |
3217 |
|
m->LoopEnd = start + m->LoopSize; |
3218 |
|
}); |
3219 |
|
connectLambda(eLoopLength, [this](uint32_t length){ |
3220 |
|
m->LoopSize = length; |
3221 |
|
m->LoopEnd = m->LoopStart + length; |
3222 |
|
}); |
3223 |
|
{ |
3224 |
|
const char* choices[] = { _("normal"), _("bidirectional"), _("backward"), 0 }; |
3225 |
|
static const gig::loop_type_t values[] = { |
3226 |
|
gig::loop_type_normal, |
3227 |
|
gig::loop_type_bidirectional, |
3228 |
|
gig::loop_type_backward |
3229 |
|
}; |
3230 |
|
eLoopType.set_choices(choices, values); |
3231 |
|
} |
3232 |
|
connect(eLoopType, &gig::Sample::LoopType); |
3233 |
|
connect(eLoopPlayCount, &gig::Sample::LoopPlayCount); |
3234 |
|
|
3235 |
|
eName.signal_value_changed().connect(sig_name_changed.make_slot()); |
3236 |
|
|
3237 |
|
connect(eName2, &SampleProps::set_Name); |
3238 |
|
connectLambda(eCreationDate, [this](gig::String s) { |
3239 |
|
m->pInfo->CreationDate = s; |
3240 |
|
}); |
3241 |
|
connectLambda(eComments, [this](gig::String s) { |
3242 |
|
m->pInfo->Comments = s; |
3243 |
|
}); |
3244 |
|
connectLambda(eProduct, [this](gig::String s) { |
3245 |
|
m->pInfo->Product = s; |
3246 |
|
}); |
3247 |
|
connectLambda(eCopyright, [this](gig::String s) { |
3248 |
|
m->pInfo->Copyright = s; |
3249 |
|
}); |
3250 |
|
connectLambda(eArtists, [this](gig::String s) { |
3251 |
|
m->pInfo->Artists = s; |
3252 |
|
}); |
3253 |
|
connectLambda(eGenre, [this](gig::String s) { |
3254 |
|
m->pInfo->Genre = s; |
3255 |
|
}); |
3256 |
|
connectLambda(eKeywords, [this](gig::String s) { |
3257 |
|
m->pInfo->Keywords = s; |
3258 |
|
}); |
3259 |
|
connectLambda(eEngineer, [this](gig::String s) { |
3260 |
|
m->pInfo->Engineer = s; |
3261 |
|
}); |
3262 |
|
connectLambda(eTechnician, [this](gig::String s) { |
3263 |
|
m->pInfo->Technician = s; |
3264 |
|
}); |
3265 |
|
connectLambda(eSoftware, [this](gig::String s) { |
3266 |
|
m->pInfo->Software = s; |
3267 |
|
}); |
3268 |
|
connectLambda(eMedium, [this](gig::String s) { |
3269 |
|
m->pInfo->Medium = s; |
3270 |
|
}); |
3271 |
|
connectLambda(eSource, [this](gig::String s) { |
3272 |
|
m->pInfo->Source = s; |
3273 |
|
}); |
3274 |
|
connectLambda(eSourceForm, [this](gig::String s) { |
3275 |
|
m->pInfo->SourceForm = s; |
3276 |
|
}); |
3277 |
|
connectLambda(eCommissioned, [this](gig::String s) { |
3278 |
|
m->pInfo->Commissioned = s; |
3279 |
|
}); |
3280 |
|
connectLambda(eSubject, [this](gig::String s) { |
3281 |
|
m->pInfo->Subject = s; |
3282 |
|
}); |
3283 |
|
|
3284 |
|
// tab 1 |
3285 |
|
#if USE_GTKMM_GRID |
3286 |
|
table.set_column_spacing(5); |
3287 |
|
#else |
3288 |
|
table.set_col_spacings(5); |
3289 |
|
#endif |
3290 |
|
table.add(eName); |
3291 |
|
table.add(eUnityNote); |
3292 |
|
table.add(eSampleGroup); |
3293 |
|
table.add(eSampleFormatInfo); |
3294 |
|
table.add(eSampleID); |
3295 |
|
table.add(eChecksum); |
3296 |
|
table.add(eLoopsCount); |
3297 |
|
table.add(eLoopStart); |
3298 |
|
table.add(eLoopLength); |
3299 |
|
table.add(eLoopType); |
3300 |
|
table.add(eLoopPlayCount); |
3301 |
|
|
3302 |
|
// tab 2 |
3303 |
|
#if USE_GTKMM_GRID |
3304 |
|
table2.set_column_spacing(5); |
3305 |
|
#else |
3306 |
|
table2.set_col_spacings(5); |
3307 |
|
#endif |
3308 |
|
table2.add(eName2); |
3309 |
|
table2.add(eCreationDate); |
3310 |
|
table2.add(eComments); |
3311 |
|
table2.add(eProduct); |
3312 |
|
table2.add(eCopyright); |
3313 |
|
table2.add(eArtists); |
3314 |
|
table2.add(eGenre); |
3315 |
|
table2.add(eKeywords); |
3316 |
|
table2.add(eEngineer); |
3317 |
|
table2.add(eTechnician); |
3318 |
|
table2.add(eSoftware); |
3319 |
|
table2.add(eMedium); |
3320 |
|
table2.add(eSource); |
3321 |
|
table2.add(eSourceForm); |
3322 |
|
table2.add(eCommissioned); |
3323 |
|
table2.add(eSubject); |
3324 |
|
|
3325 |
|
add(vbox[0]); |
3326 |
|
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24) |
3327 |
|
table.set_margin(5); |
3328 |
|
#else |
3329 |
|
table.set_border_width(5); |
3330 |
|
#endif |
3331 |
|
vbox[1].pack_start(table); |
3332 |
|
vbox[2].pack_start(table2); |
3333 |
|
table.show(); |
3334 |
|
table2.show(); |
3335 |
|
vbox[0].pack_start(tabs); |
3336 |
|
vbox[0].pack_start(buttonBox, Gtk::PACK_SHRINK); |
3337 |
|
buttonBox.set_layout(Gtk::BUTTONBOX_END); |
3338 |
|
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24) |
3339 |
|
buttonBox.set_margin(5); |
3340 |
|
#else |
3341 |
|
buttonBox.set_border_width(5); |
3342 |
|
#endif |
3343 |
|
buttonBox.show(); |
3344 |
|
buttonBox.pack_start(quitButton); |
3345 |
|
quitButton.set_can_default(); |
3346 |
|
quitButton.grab_focus(); |
3347 |
|
|
3348 |
|
quitButton.signal_clicked().connect( |
3349 |
|
sigc::mem_fun(*this, &SampleProps::hide)); |
3350 |
|
|
3351 |
|
quitButton.show(); |
3352 |
|
vbox[0].show(); |
3353 |
|
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
3354 |
|
show_all_children(); |
3355 |
|
#endif |
3356 |
|
} |
3357 |
|
|
3358 |
|
void SampleProps::set_sample(gig::Sample* sample) |
3359 |
|
{ |
3360 |
|
update(sample); |
3361 |
|
|
3362 |
|
update_model++; |
3363 |
|
|
3364 |
|
// tab 1 |
3365 |
|
eName.set_value(sample->pInfo->Name); |
3366 |
|
eUnityNote.set_value(sample->MIDIUnityNote); |
3367 |
|
// show sample group name |
3368 |
|
{ |
3369 |
|
Glib::ustring s = "---"; |
3370 |
|
if (sample && sample->GetGroup()) |
3371 |
|
s = sample->GetGroup()->Name; |
3372 |
|
eSampleGroup.text.set_text(s); |
3373 |
|
} |
3374 |
|
// assemble sample format info string |
3375 |
|
{ |
3376 |
|
Glib::ustring s; |
3377 |
|
if (sample) { |
3378 |
|
switch (sample->Channels) { |
3379 |
|
case 1: s = _("Mono"); break; |
3380 |
|
case 2: s = _("Stereo"); break; |
3381 |
|
default: |
3382 |
|
s = ToString(sample->Channels) + _(" audio channels"); |
3383 |
|
break; |
3384 |
|
} |
3385 |
|
s += " " + ToString(sample->BitDepth) + " Bits"; |
3386 |
|
s += " " + ToString(sample->SamplesPerSecond/1000) + "." |
3387 |
|
+ ToString((sample->SamplesPerSecond%1000)/100) + " kHz"; |
3388 |
|
} else { |
3389 |
|
s = _("No sample assigned to this dimension region."); |
3390 |
|
} |
3391 |
|
eSampleFormatInfo.text.set_text(s); |
3392 |
|
} |
3393 |
|
// generate sample's memory address pointer string |
3394 |
|
{ |
3395 |
|
Glib::ustring s; |
3396 |
|
if (sample) { |
3397 |
|
char buf[64] = {}; |
3398 |
|
snprintf(buf, sizeof(buf), "%p", sample); |
3399 |
|
s = buf; |
3400 |
|
} else { |
3401 |
|
s = "---"; |
3402 |
|
} |
3403 |
|
eSampleID.text.set_text(s); |
3404 |
|
} |
3405 |
|
// generate raw wave form data CRC-32 checksum string |
3406 |
|
{ |
3407 |
|
Glib::ustring s = "---"; |
3408 |
|
if (sample) { |
3409 |
|
char buf[64] = {}; |
3410 |
|
snprintf(buf, sizeof(buf), "%x", sample->GetWaveDataCRC32Checksum()); |
3411 |
|
s = buf; |
3412 |
|
} |
3413 |
|
eChecksum.text.set_text(s); |
3414 |
|
} |
3415 |
|
eLoopsCount.set_value(sample->Loops); |
3416 |
|
eLoopStart.set_value(sample->LoopStart); |
3417 |
|
eLoopLength.set_value(sample->LoopSize); |
3418 |
|
eLoopType.set_value(sample->LoopType); |
3419 |
|
eLoopPlayCount.set_value(sample->LoopPlayCount); |
3420 |
|
// tab 2 |
3421 |
|
eName2.set_value(sample->pInfo->Name); |
3422 |
|
eCreationDate.set_value(sample->pInfo->CreationDate); |
3423 |
|
eComments.set_value(sample->pInfo->Comments); |
3424 |
|
eProduct.set_value(sample->pInfo->Product); |
3425 |
|
eCopyright.set_value(sample->pInfo->Copyright); |
3426 |
|
eArtists.set_value(sample->pInfo->Artists); |
3427 |
|
eGenre.set_value(sample->pInfo->Genre); |
3428 |
|
eKeywords.set_value(sample->pInfo->Keywords); |
3429 |
|
eEngineer.set_value(sample->pInfo->Engineer); |
3430 |
|
eTechnician.set_value(sample->pInfo->Technician); |
3431 |
|
eSoftware.set_value(sample->pInfo->Software); |
3432 |
|
eMedium.set_value(sample->pInfo->Medium); |
3433 |
|
eSource.set_value(sample->pInfo->Source); |
3434 |
|
eSourceForm.set_value(sample->pInfo->SourceForm); |
3435 |
|
eCommissioned.set_value(sample->pInfo->Commissioned); |
3436 |
|
eSubject.set_value(sample->pInfo->Subject); |
3437 |
|
|
3438 |
|
update_model--; |
3439 |
|
} |
3440 |
|
|
3441 |
|
void SampleProps::set_Name(const gig::String& name) |
3442 |
|
{ |
3443 |
|
m->pInfo->Name = name; |
3444 |
|
} |
3445 |
|
|
3446 |
|
void SampleProps::update_name() |
3447 |
|
{ |
3448 |
|
update_model++; |
3449 |
|
eName.set_value(m->pInfo->Name); |
3450 |
update_model--; |
update_model--; |
3451 |
} |
} |
3452 |
|
|
3482 |
|
|
3483 |
bool MainWindow::onQueryTreeViewTooltip(int x, int y, bool keyboardTip, const Glib::RefPtr<Gtk::Tooltip>& tooltip) { |
bool MainWindow::onQueryTreeViewTooltip(int x, int y, bool keyboardTip, const Glib::RefPtr<Gtk::Tooltip>& tooltip) { |
3484 |
Gtk::TreeModel::iterator iter; |
Gtk::TreeModel::iterator iter; |
3485 |
if (!m_TreeView.get_tooltip_context_iter(x, y, keyboardTip, iter)) { |
if (!m_TreeViewInstruments.get_tooltip_context_iter(x, y, keyboardTip, iter)) { |
3486 |
return false; |
return false; |
3487 |
} |
} |
3488 |
Gtk::TreeModel::Path path(iter); |
Gtk::TreeModel::Path path(iter); |
3492 |
{ |
{ |
3493 |
Gtk::TreeModel::Path path; // unused |
Gtk::TreeModel::Path path; // unused |
3494 |
int cellX, cellY; // unused |
int cellX, cellY; // unused |
3495 |
m_TreeView.get_path_at_pos(x, y, path, pointedColumn, cellX, cellY); |
m_TreeViewInstruments.get_path_at_pos(x, y, path, pointedColumn, cellX, cellY); |
3496 |
} |
} |
3497 |
Gtk::TreeViewColumn* scriptsColumn = m_TreeView.get_column(2); |
Gtk::TreeViewColumn* scriptsColumn = m_TreeViewInstruments.get_column(2); |
3498 |
if (pointedColumn == scriptsColumn) { // mouse hovers scripts column ... |
if (pointedColumn == scriptsColumn) { // mouse hovers scripts column ... |
3499 |
// show the script(s) assigned to the hovered instrument as tooltip |
// show the script(s) assigned to the hovered instrument as tooltip |
3500 |
tooltip->set_markup( row[m_Columns.m_col_tooltip] ); |
tooltip->set_markup( row[m_InstrumentsModel.m_col_tooltip] ); |
3501 |
m_TreeView.set_tooltip_cell(tooltip, &path, scriptsColumn, NULL); |
m_TreeViewInstruments.set_tooltip_cell(tooltip, &path, scriptsColumn, NULL); |
3502 |
} else { |
} else { |
3503 |
// if beginners' tooltips is disabled then don't show the following one |
// if beginners' tooltips is disabled then don't show the following one |
3504 |
if (!Settings::singleton()->showTooltips) |
if (!Settings::singleton()->showTooltips) |
3508 |
"Right click here for actions on instruments & MIDI Rules. " |
"Right click here for actions on instruments & MIDI Rules. " |
3509 |
"Drag & drop to change the order of instruments." |
"Drag & drop to change the order of instruments." |
3510 |
)); |
)); |
3511 |
m_TreeView.set_tooltip_cell(tooltip, &path, pointedColumn, NULL); |
m_TreeViewInstruments.set_tooltip_cell(tooltip, &path, pointedColumn, NULL); |
3512 |
} |
} |
3513 |
return true; |
return true; |
3514 |
} |
} |
3542 |
file_has_name = filename; |
file_has_name = filename; |
3543 |
file_is_changed = false; |
file_is_changed = false; |
3544 |
|
|
3545 |
propDialog.set_file(gig); |
fileProps.set_file(gig); |
|
propDialog.set_info(gig->pInfo); |
|
3546 |
|
|
3547 |
instrument_name_connection.block(); |
instrument_name_connection.block(); |
3548 |
int index = 0; |
int index = 0; |
3551 |
Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); |
Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); |
3552 |
const int iScriptSlots = instrument->ScriptSlotCount(); |
const int iScriptSlots = instrument->ScriptSlotCount(); |
3553 |
|
|
3554 |
Gtk::TreeModel::iterator iter = m_refTreeModel->append(); |
Gtk::TreeModel::iterator iter = m_refInstrumentsTreeModel->append(); |
3555 |
Gtk::TreeModel::Row row = *iter; |
Gtk::TreeModel::Row row = *iter; |
3556 |
row[m_Columns.m_col_nr] = index; |
row[m_InstrumentsModel.m_col_nr] = index; |
3557 |
row[m_Columns.m_col_name] = name; |
row[m_InstrumentsModel.m_col_name] = name; |
3558 |
row[m_Columns.m_col_instr] = instrument; |
row[m_InstrumentsModel.m_col_instr] = instrument; |
3559 |
row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : ""; |
row[m_InstrumentsModel.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : ""; |
3560 |
row[m_Columns.m_col_tooltip] = scriptTooltipFor(instrument, index); |
row[m_InstrumentsModel.m_col_tooltip] = scriptTooltipFor(instrument, index); |
3561 |
|
|
3562 |
#if !USE_GTKMM_BUILDER |
#if !USE_GTKMM_BUILDER |
3563 |
add_instrument_to_menu(name); |
add_instrument_to_menu(name); |
3619 |
file = gig; |
file = gig; |
3620 |
|
|
3621 |
// select the first instrument |
// select the first instrument |
3622 |
m_TreeView.get_selection()->select(Gtk::TreePath("0")); |
m_TreeViewInstruments.get_selection()->select(Gtk::TreePath("0")); |
3623 |
|
|
3624 |
instr_props_set_instrument(); |
instr_props_set_instrument(); |
3625 |
gig::Instrument* instrument = get_instrument(); |
gig::Instrument* instrument = get_instrument(); |
3632 |
{ |
{ |
3633 |
instrumentProps.signal_name_changed().clear(); |
instrumentProps.signal_name_changed().clear(); |
3634 |
|
|
3635 |
std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows(); |
// get visual selection |
3636 |
|
std::vector<Gtk::TreeModel::Path> rows = m_TreeViewInstruments.get_selection()->get_selected_rows(); |
3637 |
if (rows.empty()) { |
if (rows.empty()) { |
3638 |
instrumentProps.hide(); |
instrumentProps.hide(); |
3639 |
return false; |
return false; |
3640 |
} |
} |
3641 |
|
|
3642 |
|
// convert index of visual selection (i.e. if filtered) to index of model |
3643 |
|
Gtk::TreeModel::Path path = m_refInstrumentsModelFilter->convert_path_to_child_path(rows[0]); |
3644 |
|
|
3645 |
//NOTE: was const_iterator before, which did not compile with GTKMM4 development branch, probably going to be fixed before final GTKMM4 release though. |
//NOTE: was const_iterator before, which did not compile with GTKMM4 development branch, probably going to be fixed before final GTKMM4 release though. |
3646 |
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]); |
Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(path); |
3647 |
if (it) { |
if (it) { |
3648 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
3649 |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
gig::Instrument* instrument = row[m_InstrumentsModel.m_col_instr]; |
3650 |
|
|
3651 |
instrumentProps.set_instrument(instrument); |
instrumentProps.set_instrument(instrument); |
3652 |
|
|
3675 |
void MainWindow::instr_name_changed_by_instr_props(Gtk::TreeModel::iterator& it) |
void MainWindow::instr_name_changed_by_instr_props(Gtk::TreeModel::iterator& it) |
3676 |
{ |
{ |
3677 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
3678 |
Glib::ustring name = row[m_Columns.m_col_name]; |
Glib::ustring name = row[m_InstrumentsModel.m_col_name]; |
3679 |
|
|
3680 |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
gig::Instrument* instrument = row[m_InstrumentsModel.m_col_instr]; |
3681 |
Glib::ustring gigname(gig_to_utf8(instrument->pInfo->Name)); |
Glib::ustring gigname(gig_to_utf8(instrument->pInfo->Name)); |
3682 |
if (gigname != name) { |
if (gigname != name) { |
3683 |
Gtk::TreeModel::Path path(*it); |
Gtk::TreeModel::Path path(*it); |
3684 |
const int index = path[0]; |
const int index = path[0]; |
3685 |
row[m_Columns.m_col_name] = gigname; |
row[m_InstrumentsModel.m_col_name] = gigname; |
3686 |
row[m_Columns.m_col_tooltip] = scriptTooltipFor(instrument, index); |
row[m_InstrumentsModel.m_col_tooltip] = scriptTooltipFor(instrument, index); |
3687 |
|
} |
3688 |
|
} |
3689 |
|
|
3690 |
|
bool MainWindow::sample_props_set_sample() |
3691 |
|
{ |
3692 |
|
sampleProps.signal_name_changed().clear(); |
3693 |
|
|
3694 |
|
std::vector<Gtk::TreeModel::Path> rows = m_TreeViewSamples.get_selection()->get_selected_rows(); |
3695 |
|
if (rows.empty()) { |
3696 |
|
sampleProps.hide(); |
3697 |
|
return false; |
3698 |
|
} |
3699 |
|
//NOTE: was const_iterator before, which did not compile with GTKMM4 development branch, probably going to be fixed before final GTKMM4 release though. |
3700 |
|
Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[0]); |
3701 |
|
if (it) { |
3702 |
|
Gtk::TreeModel::Row row = *it; |
3703 |
|
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
3704 |
|
|
3705 |
|
sampleProps.set_sample(sample); |
3706 |
|
|
3707 |
|
// make sure sample tree is updated when user changes the |
3708 |
|
// sample name in sample properties window |
3709 |
|
sampleProps.signal_name_changed().connect( |
3710 |
|
sigc::bind( |
3711 |
|
sigc::mem_fun(*this, |
3712 |
|
&MainWindow::sample_name_changed_by_sample_props |
3713 |
|
), it |
3714 |
|
) |
3715 |
|
); |
3716 |
|
} else { |
3717 |
|
sampleProps.hide(); |
3718 |
|
} |
3719 |
|
//NOTE: explicit boolean cast required for GTKMM4 development branch here |
3720 |
|
return it ? true : false; |
3721 |
|
} |
3722 |
|
|
3723 |
|
void MainWindow::show_sample_props() |
3724 |
|
{ |
3725 |
|
if (sample_props_set_sample()) { |
3726 |
|
sampleProps.show(); |
3727 |
|
sampleProps.deiconify(); |
3728 |
|
} |
3729 |
|
} |
3730 |
|
|
3731 |
|
void MainWindow::sample_name_changed_by_sample_props(Gtk::TreeModel::iterator& it) |
3732 |
|
{ |
3733 |
|
Gtk::TreeModel::Row row = *it; |
3734 |
|
Glib::ustring name = row[m_SamplesModel.m_col_name]; |
3735 |
|
|
3736 |
|
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
3737 |
|
Glib::ustring gigname(gig_to_utf8(sample->pInfo->Name)); |
3738 |
|
if (gigname != name) { |
3739 |
|
Gtk::TreeModel::Path path(*it); |
3740 |
|
row[m_SamplesModel.m_col_name] = gigname; |
3741 |
} |
} |
3742 |
} |
} |
3743 |
|
|
3753 |
|
|
3754 |
void MainWindow::show_script_slots() { |
void MainWindow::show_script_slots() { |
3755 |
if (!file) return; |
if (!file) return; |
3756 |
|
|
3757 |
// get selected instrument |
// get selected instrument |
3758 |
std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows(); |
gig::Instrument* instrument = get_instrument(); |
|
if (rows.empty()) return; |
|
|
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]); |
|
|
if (!it) return; |
|
|
Gtk::TreeModel::Row row = *it; |
|
|
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
|
3759 |
if (!instrument) return; |
if (!instrument) return; |
3760 |
|
|
3761 |
ScriptSlots* window = new ScriptSlots; |
ScriptSlots* window = new ScriptSlots; |
3771 |
if (!pInstrument) return; |
if (!pInstrument) return; |
3772 |
const int iScriptSlots = pInstrument->ScriptSlotCount(); |
const int iScriptSlots = pInstrument->ScriptSlotCount(); |
3773 |
|
|
3774 |
//NOTE: This is a big mess! Sometimes GTK requires m_TreeView.get_model(), here we need m_refTreeModelFilter->get_model(), otherwise accessing children below causes an error! |
//NOTE: This is a big mess! Sometimes GTK requires m_TreeViewInstruments.get_model(), here we need m_refInstrumentsModelFilter->get_model(), otherwise accessing children below causes an error! |
3775 |
//Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model(); |
//Glib::RefPtr<Gtk::TreeModel> model = m_TreeViewInstruments.get_model(); |
3776 |
Glib::RefPtr<Gtk::TreeModel> model = m_refTreeModelFilter->get_model(); |
Glib::RefPtr<Gtk::TreeModel> model = m_refInstrumentsModelFilter->get_model(); |
3777 |
|
|
3778 |
for (int i = 0; i < model->children().size(); ++i) { |
for (int i = 0; i < model->children().size(); ++i) { |
3779 |
Gtk::TreeModel::Row row = model->children()[i]; |
Gtk::TreeModel::Row row = model->children()[i]; |
3780 |
if (row[m_Columns.m_col_instr] != pInstrument) continue; |
if (row[m_InstrumentsModel.m_col_instr] != pInstrument) continue; |
3781 |
row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : ""; |
row[m_InstrumentsModel.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : ""; |
3782 |
row[m_Columns.m_col_tooltip] = scriptTooltipFor(pInstrument, i); |
row[m_InstrumentsModel.m_col_tooltip] = scriptTooltipFor(pInstrument, i); |
3783 |
break; |
break; |
3784 |
} |
} |
3785 |
|
|
3786 |
// causes the sampler to reload the instrument with the new script |
// causes the sampler to reload the instrument with the new script |
3787 |
on_sel_change(); |
on_sel_change(); |
3788 |
|
|
3789 |
|
// force script 'patch' variables editor ("Script" tab) to be refreshed |
3790 |
|
dimreg_edit.scriptVars.setInstrument(pInstrument, true/*force update*/); |
3791 |
} |
} |
3792 |
|
|
3793 |
void MainWindow::assignScript(gig::Script* pScript) { |
void MainWindow::assignScript(gig::Script* pScript) { |
3868 |
#endif |
#endif |
3869 |
} |
} |
3870 |
|
|
3871 |
|
void MainWindow::on_instr_double_click_opens_props() { |
3872 |
|
#if USE_GLIB_ACTION |
3873 |
|
bool active = false; |
3874 |
|
m_actionInstrDoubleClickOpensProps->get_state(active); |
3875 |
|
// for some reason toggle state does not change automatically |
3876 |
|
active = !active; |
3877 |
|
m_actionInstrDoubleClickOpensProps->change_state(active); |
3878 |
|
Settings::singleton()->instrumentDoubleClickOpensProps = active; |
3879 |
|
#else |
3880 |
|
Gtk::CheckMenuItem* item = |
3881 |
|
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/OpenInstrPropsByDoubleClick")); |
3882 |
|
if (!item) { |
3883 |
|
std::cerr << "/MenuBar/MenuView/OpenInstrPropsByDoubleClick == NULL\n"; |
3884 |
|
return; |
3885 |
|
} |
3886 |
|
Settings::singleton()->instrumentDoubleClickOpensProps = item->get_active(); |
3887 |
|
#endif |
3888 |
|
} |
3889 |
|
|
3890 |
void MainWindow::on_save_with_temporary_file() { |
void MainWindow::on_save_with_temporary_file() { |
3891 |
#if USE_GLIB_ACTION |
#if USE_GLIB_ACTION |
3892 |
bool active = false; |
bool active = false; |
3961 |
void MainWindow::on_button_release(GdkEventButton* button) { |
void MainWindow::on_button_release(GdkEventButton* button) { |
3962 |
#endif |
#endif |
3963 |
if (button->type == GDK_2BUTTON_PRESS) { |
if (button->type == GDK_2BUTTON_PRESS) { |
3964 |
show_instr_props(); |
if (Settings::singleton()->instrumentDoubleClickOpensProps) |
3965 |
|
show_instr_props(); |
3966 |
} else if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
} else if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
3967 |
// gig v2 files have no midi rules |
// gig v2 files have no midi rules |
3968 |
const bool bEnabled = !(file->pVersion && file->pVersion->major == 2); |
const bool bEnabled = !(file->pVersion && file->pVersion->major == 2); |
3994 |
find(children.begin(), children.end(), item); |
find(children.begin(), children.end(), item); |
3995 |
if (it != children.end()) { |
if (it != children.end()) { |
3996 |
int index = it - children.begin(); |
int index = it - children.begin(); |
3997 |
m_TreeView.get_selection()->select(Gtk::TreePath(ToString(index))); |
|
3998 |
|
// convert index of model to index of visual presentation (i.e. if filtered) |
3999 |
|
Gtk::TreeModel::Path path = m_refInstrumentsModelFilter->convert_child_path_to_path(Gtk::TreePath(ToString(index))); |
4000 |
|
|
4001 |
|
if (path) |
4002 |
|
m_TreeViewInstruments.get_selection()->select(path); |
4003 |
|
else |
4004 |
|
m_TreeViewInstruments.get_selection()->unselect_all(); |
4005 |
|
|
4006 |
m_RegionChooser.set_instrument(file->GetInstrument(index)); |
m_RegionChooser.set_instrument(file->GetInstrument(index)); |
4007 |
} |
} |
4009 |
} |
} |
4010 |
#endif |
#endif |
4011 |
|
|
4012 |
|
void MainWindow::on_action_move_instr() { |
4013 |
|
gig::Instrument* instr = get_instrument(); |
4014 |
|
if (!instr) return; |
4015 |
|
|
4016 |
|
int currentIndex = getIndexOf(instr); |
4017 |
|
|
4018 |
|
Gtk::Dialog dialog(_("Move Instrument"), true /*modal*/); |
4019 |
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
4020 |
|
Gtk::Adjustment adjustment( |
4021 |
|
currentIndex, |
4022 |
|
0 /*min*/, file->CountInstruments() - 1 /*max*/ |
4023 |
|
); |
4024 |
|
Gtk::SpinButton spinBox(adjustment); |
4025 |
|
#else |
4026 |
|
Gtk::SpinButton spinBox( |
4027 |
|
Gtk::Adjustment::create( |
4028 |
|
currentIndex, |
4029 |
|
0 /*min*/, file->CountInstruments() - 1 /*max*/ |
4030 |
|
) |
4031 |
|
); |
4032 |
|
#endif |
4033 |
|
#if USE_GTKMM_BOX |
4034 |
|
dialog.get_content_area()->pack_start(spinBox); |
4035 |
|
#else |
4036 |
|
dialog.get_vbox()->pack_start(spinBox); |
4037 |
|
#endif |
4038 |
|
#if HAS_GTKMM_STOCK |
4039 |
|
Gtk::Button* okButton = dialog.add_button(Gtk::Stock::OK, 0); |
4040 |
|
dialog.add_button(Gtk::Stock::CANCEL, 1); |
4041 |
|
#else |
4042 |
|
Gtk::Button* okButton = dialog.add_button(_("_OK"), 0); |
4043 |
|
dialog.add_button(_("_Cancel"), 1); |
4044 |
|
#endif |
4045 |
|
okButton->set_sensitive(false); |
4046 |
|
// show the dialog at a reasonable screen position |
4047 |
|
dialog.set_position(Gtk::WIN_POS_MOUSE); |
4048 |
|
// only enable the 'OK' button if entered new index is not instrument's |
4049 |
|
// current index already |
4050 |
|
spinBox.signal_value_changed().connect([&]{ |
4051 |
|
okButton->set_sensitive( spinBox.get_value_as_int() != currentIndex ); |
4052 |
|
}); |
4053 |
|
// usability acceleration: if user hits enter key on the text entry field |
4054 |
|
// then auto trigger the 'OK' button |
4055 |
|
spinBox.signal_activate().connect([&]{ |
4056 |
|
if (okButton->get_sensitive()) |
4057 |
|
okButton->clicked(); |
4058 |
|
}); |
4059 |
|
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
4060 |
|
dialog.show_all_children(); |
4061 |
|
#endif |
4062 |
|
if (!dialog.run()) { // 'OK' selected ... |
4063 |
|
int newIndex = spinBox.get_value_as_int(); |
4064 |
|
printf("MOVE TO %d\n", newIndex); |
4065 |
|
gig::Instrument* dst = file->GetInstrument(newIndex); |
4066 |
|
instr->MoveTo(dst); |
4067 |
|
__refreshEntireGUI(); |
4068 |
|
select_instrument(instr); |
4069 |
|
} |
4070 |
|
} |
4071 |
|
|
4072 |
void MainWindow::select_instrument(gig::Instrument* instrument) { |
void MainWindow::select_instrument(gig::Instrument* instrument) { |
4073 |
if (!instrument) return; |
if (!instrument) return; |
4074 |
|
|
4075 |
//NOTE: This is a big mess! Sometimes GTK requires m_refTreeModelFilter->get_model(), here we need m_TreeView.get_model(), otherwise treeview selection below causes an error! |
//NOTE: This is a big mess! Sometimes GTK requires m_refInstrumentsModelFilter->get_model(), here we need m_TreeViewInstruments.get_model(), otherwise treeview selection below causes an error! |
4076 |
Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model(); |
Glib::RefPtr<Gtk::TreeModel> model = m_TreeViewInstruments.get_model(); |
4077 |
//Glib::RefPtr<Gtk::TreeModel> model = m_refTreeModelFilter->get_model(); |
//Glib::RefPtr<Gtk::TreeModel> model = m_refInstrumentsModelFilter->get_model(); |
4078 |
|
|
4079 |
for (int i = 0; i < model->children().size(); ++i) { |
for (int i = 0; i < model->children().size(); ++i) { |
4080 |
Gtk::TreeModel::Row row = model->children()[i]; |
Gtk::TreeModel::Row row = model->children()[i]; |
4081 |
if (row[m_Columns.m_col_instr] == instrument) { |
if (row[m_InstrumentsModel.m_col_instr] == instrument) { |
4082 |
// select and show the respective instrument in the list view |
// select and show the respective instrument in the list view |
4083 |
show_intruments_tab(); |
show_intruments_tab(); |
4084 |
m_TreeView.get_selection()->unselect_all(); |
m_TreeViewInstruments.get_selection()->unselect_all(); |
4085 |
|
|
4086 |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24) |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24) |
4087 |
auto iterSel = model->children()[i].get_iter(); |
auto iterSel = model->children()[i].get_iter(); |
4088 |
m_TreeView.get_selection()->select(iterSel); |
m_TreeViewInstruments.get_selection()->select(iterSel); |
4089 |
#else |
#else |
4090 |
m_TreeView.get_selection()->select(model->children()[i]); |
m_TreeViewInstruments.get_selection()->select(model->children()[i]); |
4091 |
#endif |
#endif |
4092 |
std::vector<Gtk::TreeModel::Path> rows = |
std::vector<Gtk::TreeModel::Path> rows = |
4093 |
m_TreeView.get_selection()->get_selected_rows(); |
m_TreeViewInstruments.get_selection()->get_selected_rows(); |
4094 |
if (!rows.empty()) |
if (!rows.empty()) |
4095 |
m_TreeView.scroll_to_row(rows[0]); |
m_TreeViewInstruments.scroll_to_row(rows[0]); |
4096 |
on_sel_change(); // the regular instrument selection change callback |
on_sel_change(); // the regular instrument selection change callback |
4097 |
} |
} |
4098 |
} |
} |
4103 |
gig::Region* pRegion = (gig::Region*) dimRgn->GetParent(); |
gig::Region* pRegion = (gig::Region*) dimRgn->GetParent(); |
4104 |
gig::Instrument* pInstrument = (gig::Instrument*) pRegion->GetParent(); |
gig::Instrument* pInstrument = (gig::Instrument*) pRegion->GetParent(); |
4105 |
|
|
4106 |
//NOTE: This is a big mess! Sometimes GTK requires m_refTreeModelFilter->get_model(), here we need m_TreeView.get_model(), otherwise treeview selection below causes an error! |
//NOTE: This is a big mess! Sometimes GTK requires m_refInstrumentsModelFilter->get_model(), here we need m_TreeViewInstruments.get_model(), otherwise treeview selection below causes an error! |
4107 |
Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model(); |
Glib::RefPtr<Gtk::TreeModel> model = m_TreeViewInstruments.get_model(); |
4108 |
//Glib::RefPtr<Gtk::TreeModel> model = m_refTreeModelFilter->get_model(); |
//Glib::RefPtr<Gtk::TreeModel> model = m_refInstrumentsModelFilter->get_model(); |
4109 |
|
|
4110 |
for (int i = 0; i < model->children().size(); ++i) { |
for (int i = 0; i < model->children().size(); ++i) { |
4111 |
Gtk::TreeModel::Row row = model->children()[i]; |
Gtk::TreeModel::Row row = model->children()[i]; |
4112 |
if (row[m_Columns.m_col_instr] == pInstrument) { |
if (row[m_InstrumentsModel.m_col_instr] == pInstrument) { |
4113 |
// select and show the respective instrument in the list view |
// select and show the respective instrument in the list view |
4114 |
show_intruments_tab(); |
show_intruments_tab(); |
4115 |
m_TreeView.get_selection()->unselect_all(); |
m_TreeViewInstruments.get_selection()->unselect_all(); |
4116 |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24) |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24) |
4117 |
auto iterSel = model->children()[i].get_iter(); |
auto iterSel = model->children()[i].get_iter(); |
4118 |
m_TreeView.get_selection()->select(iterSel); |
m_TreeViewInstruments.get_selection()->select(iterSel); |
4119 |
#else |
#else |
4120 |
m_TreeView.get_selection()->select(model->children()[i]); |
m_TreeViewInstruments.get_selection()->select(model->children()[i]); |
4121 |
#endif |
#endif |
4122 |
std::vector<Gtk::TreeModel::Path> rows = |
std::vector<Gtk::TreeModel::Path> rows = |
4123 |
m_TreeView.get_selection()->get_selected_rows(); |
m_TreeViewInstruments.get_selection()->get_selected_rows(); |
4124 |
if (!rows.empty()) |
if (!rows.empty()) |
4125 |
m_TreeView.scroll_to_row(rows[0]); |
m_TreeViewInstruments.scroll_to_row(rows[0]); |
4126 |
on_sel_change(); // the regular instrument selection change callback |
on_sel_change(); // the regular instrument selection change callback |
4127 |
|
|
4128 |
// select respective region in the region selector |
// select respective region in the region selector |
4407 |
|
|
4408 |
// update instrument tree view |
// update instrument tree view |
4409 |
instrument_name_connection.block(); |
instrument_name_connection.block(); |
4410 |
Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append(); |
Gtk::TreeModel::iterator iterInstr = m_refInstrumentsTreeModel->append(); |
4411 |
Gtk::TreeModel::Row rowInstr = *iterInstr; |
Gtk::TreeModel::Row rowInstr = *iterInstr; |
4412 |
const int index = m_refTreeModel->children().size() - 1; |
const int index = m_refInstrumentsTreeModel->children().size() - 1; |
4413 |
rowInstr[m_Columns.m_col_nr] = index; |
const int iScriptSlots = instrument->ScriptSlotCount(); |
4414 |
rowInstr[m_Columns.m_col_name] = name; |
rowInstr[m_InstrumentsModel.m_col_nr] = index; |
4415 |
rowInstr[m_Columns.m_col_instr] = instrument; |
rowInstr[m_InstrumentsModel.m_col_name] = name; |
4416 |
rowInstr[m_Columns.m_col_scripts] = ""; |
rowInstr[m_InstrumentsModel.m_col_instr] = instrument; |
4417 |
rowInstr[m_Columns.m_col_tooltip] = scriptTooltipFor(instrument, index); |
rowInstr[m_InstrumentsModel.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : ""; |
4418 |
|
rowInstr[m_InstrumentsModel.m_col_tooltip] = scriptTooltipFor(instrument, index); |
4419 |
instrument_name_connection.unblock(); |
instrument_name_connection.unblock(); |
4420 |
|
|
4421 |
#if !USE_GTKMM_BUILDER |
#if !USE_GTKMM_BUILDER |
4441 |
|
|
4442 |
// retrieve the currently selected instrument |
// retrieve the currently selected instrument |
4443 |
// (being the original instrument to be duplicated) |
// (being the original instrument to be duplicated) |
4444 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewInstruments.get_selection(); |
4445 |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
4446 |
for (int r = 0; r < rows.size(); ++r) { |
for (int r = 0; r < rows.size(); ++r) { |
4447 |
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[r]); |
// convert index of visual selection (i.e. if filtered) to index of model |
4448 |
|
Gtk::TreeModel::Path path = m_refInstrumentsModelFilter->convert_path_to_child_path(rows[r]); |
4449 |
|
Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(path); |
4450 |
if (it) { |
if (it) { |
4451 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
4452 |
gig::Instrument* instrOrig = row[m_Columns.m_col_instr]; |
gig::Instrument* instrOrig = row[m_InstrumentsModel.m_col_instr]; |
4453 |
if (instrOrig) { |
if (instrOrig) { |
4454 |
// duplicate the orginal instrument |
// duplicate the orginal instrument |
4455 |
gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig); |
gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig); |
4476 |
return; |
return; |
4477 |
} |
} |
4478 |
|
|
4479 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewInstruments.get_selection(); |
4480 |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
std::vector<Gtk::TreeModel::Path> rowsVisual = sel->get_selected_rows(); |
4481 |
|
|
4482 |
|
// convert indeces of visual selection (i.e. if filtered) to indeces of model |
4483 |
|
std::vector<Gtk::TreeModel::Path> rows; |
4484 |
|
for (int rv = 0; rv < rowsVisual.size(); ++rv) { |
4485 |
|
Gtk::TreeModel::Path path = m_refInstrumentsModelFilter->convert_path_to_child_path(rowsVisual[rv]); |
4486 |
|
if (path) |
4487 |
|
rows.push_back(path); |
4488 |
|
} |
4489 |
|
|
4490 |
for (int r = rows.size() - 1; r >= 0; --r) { |
for (int r = rows.size() - 1; r >= 0; --r) { |
4491 |
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[r]); |
Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(rows[r]); |
4492 |
if (!it) continue; |
if (!it) continue; |
4493 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
4494 |
gig::Instrument* instr = row[m_Columns.m_col_instr]; |
gig::Instrument* instr = row[m_InstrumentsModel.m_col_instr]; |
4495 |
try { |
try { |
4496 |
Gtk::TreePath path(it); |
Gtk::TreePath path(it); |
4497 |
int index = path[0]; |
int index = path[0]; |
4505 |
#endif |
#endif |
4506 |
|
|
4507 |
// remove row from instruments tree view |
// remove row from instruments tree view |
4508 |
m_refTreeModel->erase(it); |
m_refInstrumentsTreeModel->erase(it); |
4509 |
// update "Nr" column of all instrument rows |
// update "Nr" column of all instrument rows |
4510 |
{ |
{ |
4511 |
int index = 0; |
int index = 0; |
4512 |
for (Gtk::TreeModel::iterator it = m_refTreeModel->children().begin(); |
for (Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->children().begin(); |
4513 |
it != m_refTreeModel->children().end(); ++it, ++index) |
it != m_refInstrumentsTreeModel->children().end(); ++it, ++index) |
4514 |
{ |
{ |
4515 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
4516 |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
gig::Instrument* instrument = row[m_InstrumentsModel.m_col_instr]; |
4517 |
row[m_Columns.m_col_nr] = index; |
row[m_InstrumentsModel.m_col_nr] = index; |
4518 |
row[m_Columns.m_col_tooltip] = scriptTooltipFor(instrument, index); |
row[m_InstrumentsModel.m_col_tooltip] = scriptTooltipFor(instrument, index); |
4519 |
} |
} |
4520 |
} |
} |
4521 |
|
|
4522 |
#if GTKMM_MAJOR_VERSION < 3 |
#if GTKMM_MAJOR_VERSION < 3 |
4523 |
// select another instrument (in gtk3 this is done |
// select another instrument (in gtk3 this is done |
4524 |
// automatically) |
// automatically) |
4525 |
if (!m_refTreeModel->children().empty()) { |
if (!m_refInstrumentsTreeModel->children().empty()) { |
4526 |
if (index == m_refTreeModel->children().size()) { |
if (index == m_refInstrumentsTreeModel->children().size()) { |
4527 |
index--; |
index--; |
4528 |
} |
} |
4529 |
m_TreeView.get_selection()->select( |
m_TreeViewInstruments.get_selection()->select( |
4530 |
Gtk::TreePath(ToString(index))); |
Gtk::TreePath(ToString(index))); |
4531 |
} |
} |
4532 |
#endif |
#endif |
4545 |
} |
} |
4546 |
|
|
4547 |
void MainWindow::on_action_sample_properties() { |
void MainWindow::on_action_sample_properties() { |
4548 |
//TODO: show a dialog where the selected sample's properties can be edited |
show_sample_props(); |
|
Gtk::MessageDialog msg( |
|
|
*this, _("Sorry, yet to be implemented!"), false, Gtk::MESSAGE_INFO |
|
|
); |
|
|
msg.run(); |
|
4549 |
} |
} |
4550 |
|
|
4551 |
void MainWindow::on_action_add_script_group() { |
void MainWindow::on_action_add_script_group() { |
4608 |
if (!it) return; |
if (!it) return; |
4609 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
4610 |
gig::Script* script = row[m_ScriptsModel.m_col_script]; |
gig::Script* script = row[m_ScriptsModel.m_col_script]; |
4611 |
if (!script) return; |
editScript(script); |
4612 |
|
} |
4613 |
|
|
4614 |
|
void MainWindow::editScript(gig::Script* script) { |
4615 |
|
if (!script) return; |
4616 |
ScriptEditor* editor = new ScriptEditor; |
ScriptEditor* editor = new ScriptEditor; |
4617 |
editor->signal_script_to_be_changed.connect( |
editor->signal_script_to_be_changed.connect( |
4618 |
signal_script_to_be_changed.make_slot() |
signal_script_to_be_changed.make_slot() |
4619 |
); |
); |
4620 |
editor->signal_script_changed.connect( |
editor->signal_script_changed.connect([this](gig::Script* script) { |
4621 |
signal_script_changed.make_slot() |
// signal to sampler (which will reload the script due to this) |
4622 |
); |
signal_script_changed.emit(script); |
4623 |
|
// force script 'patch' variables editor ("Script" tab) to be refreshed |
4624 |
|
gig::Instrument* instr = get_instrument(); |
4625 |
|
dimreg_edit.scriptVars.setInstrument(instr, true/*force update*/); |
4626 |
|
}); |
4627 |
editor->setScript(script); |
editor->setScript(script); |
4628 |
//editor->reparent(*this); |
//editor->reparent(*this); |
4629 |
editor->show(); |
editor->show(); |
4771 |
dialog.set_current_folder(current_sample_dir); |
dialog.set_current_folder(current_sample_dir); |
4772 |
} |
} |
4773 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
4774 |
|
dialog.hide(); |
4775 |
current_sample_dir = dialog.get_current_folder(); |
current_sample_dir = dialog.get_current_folder(); |
4776 |
Glib::ustring error_files; |
Glib::ustring error_files; |
4777 |
std::vector<std::string> filenames = dialog.get_filenames(); |
std::vector<std::string> filenames = dialog.get_filenames(); |
4952 |
} |
} |
4953 |
if (dialog.run() == Gtk::RESPONSE_OK) |
if (dialog.run() == Gtk::RESPONSE_OK) |
4954 |
{ |
{ |
4955 |
|
dialog.hide(); |
4956 |
current_sample_dir = dialog.get_current_folder(); |
current_sample_dir = dialog.get_current_folder(); |
4957 |
Glib::ustring error_files; |
Glib::ustring error_files; |
4958 |
std::string folder = dialog.get_filename(); |
std::string folder = dialog.get_filename(); |
5081 |
if (!file) return; |
if (!file) return; |
5082 |
|
|
5083 |
// collect all samples that are not referenced by any instrument |
// collect all samples that are not referenced by any instrument |
5084 |
std::list<gig::Sample*> lsamples; |
std::list<gig::Sample*> lsamples = unusedSamples(file); |
|
for (int iSample = 0; file->GetSample(iSample); ++iSample) { |
|
|
gig::Sample* sample = file->GetSample(iSample); |
|
|
bool isUsed = false; |
|
|
for (gig::Instrument* instrument = file->GetFirstInstrument(); instrument; |
|
|
instrument = file->GetNextInstrument()) |
|
|
{ |
|
|
for (gig::Region* rgn = instrument->GetFirstRegion(); rgn; |
|
|
rgn = instrument->GetNextRegion()) |
|
|
{ |
|
|
for (int i = 0; i < 256; ++i) { |
|
|
if (!rgn->pDimensionRegions[i]) continue; |
|
|
if (rgn->pDimensionRegions[i]->pSample != sample) continue; |
|
|
isUsed = true; |
|
|
goto endOfRefSearch; |
|
|
} |
|
|
} |
|
|
} |
|
|
endOfRefSearch: |
|
|
if (!isUsed) lsamples.push_back(sample); |
|
|
} |
|
|
|
|
5085 |
if (lsamples.empty()) return; |
if (lsamples.empty()) return; |
5086 |
|
|
5087 |
// notify everybody that we're going to remove these samples |
// notify everybody that we're going to remove these samples |
5157 |
// get selected source instrument |
// get selected source instrument |
5158 |
gig::Instrument* src = NULL; |
gig::Instrument* src = NULL; |
5159 |
{ |
{ |
5160 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewInstruments.get_selection(); |
5161 |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
5162 |
if (!rows.empty()) { |
if (!rows.empty()) { |
5163 |
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]); |
// convert index of visual selection (i.e. if filtered) to index of model |
5164 |
|
Gtk::TreeModel::Path path = m_refInstrumentsModelFilter->convert_path_to_child_path(rows[0]); |
5165 |
|
Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(path); |
5166 |
if (it) { |
if (it) { |
5167 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
5168 |
src = row[m_Columns.m_col_instr]; |
src = row[m_InstrumentsModel.m_col_instr]; |
5169 |
} |
} |
5170 |
} |
} |
5171 |
} |
} |
5187 |
gig::Instrument* dst = NULL; |
gig::Instrument* dst = NULL; |
5188 |
{ |
{ |
5189 |
Gtk::TreeModel::Path path; |
Gtk::TreeModel::Path path; |
5190 |
const bool found = m_TreeView.get_path_at_pos(x, y, path); |
const bool found = m_TreeViewInstruments.get_path_at_pos(x, y, path); |
5191 |
if (!found) return; |
if (!found) return; |
5192 |
|
|
5193 |
Gtk::TreeModel::iterator iter = m_refTreeModel->get_iter(path); |
// convert index of visual selection (i.e. if filtered) to index of model |
5194 |
|
path = m_refInstrumentsModelFilter->convert_path_to_child_path(path); |
5195 |
|
if (!path) return; |
5196 |
|
|
5197 |
|
Gtk::TreeModel::iterator iter = m_refInstrumentsTreeModel->get_iter(path); |
5198 |
if (!iter) return; |
if (!iter) return; |
5199 |
Gtk::TreeModel::Row row = *iter; |
Gtk::TreeModel::Row row = *iter; |
5200 |
dst = row[m_Columns.m_col_instr]; |
dst = row[m_InstrumentsModel.m_col_instr]; |
5201 |
} |
} |
5202 |
if (!dst) return; |
if (!dst) return; |
5203 |
|
|
5336 |
file_changed(); |
file_changed(); |
5337 |
} |
} |
5338 |
} |
} |
5339 |
|
// change name in the sample properties window |
5340 |
|
if (sampleProps.get_sample() == sample && sample) { |
5341 |
|
sampleProps.set_sample(sample); |
5342 |
|
} |
5343 |
} |
} |
5344 |
|
|
5345 |
void MainWindow::script_name_changed(const Gtk::TreeModel::Path& path, |
void MainWindow::script_name_changed(const Gtk::TreeModel::Path& path, |
5372 |
if (!iter) return; |
if (!iter) return; |
5373 |
Gtk::TreeModel::Row row = *iter; |
Gtk::TreeModel::Row row = *iter; |
5374 |
gig::Script* script = row[m_ScriptsModel.m_col_script]; |
gig::Script* script = row[m_ScriptsModel.m_col_script]; |
5375 |
if (!script) return; |
editScript(script); |
|
|
|
|
ScriptEditor* editor = new ScriptEditor; |
|
|
editor->signal_script_to_be_changed.connect( |
|
|
signal_script_to_be_changed.make_slot() |
|
|
); |
|
|
editor->signal_script_changed.connect( |
|
|
signal_script_changed.make_slot() |
|
|
); |
|
|
editor->setScript(script); |
|
|
//editor->reparent(*this); |
|
|
editor->show(); |
|
5376 |
} |
} |
5377 |
|
|
5378 |
void MainWindow::instrument_name_changed(const Gtk::TreeModel::Path& path, |
void MainWindow::instrument_name_changed(const Gtk::TreeModel::Path& path, |
5379 |
const Gtk::TreeModel::iterator& iter) { |
const Gtk::TreeModel::iterator& iter) { |
5380 |
if (!iter) return; |
if (!iter) return; |
5381 |
Gtk::TreeModel::Row row = *iter; |
Gtk::TreeModel::Row row = *iter; |
5382 |
Glib::ustring name = row[m_Columns.m_col_name]; |
Glib::ustring name = row[m_InstrumentsModel.m_col_name]; |
5383 |
|
|
5384 |
#if !USE_GTKMM_BUILDER |
#if !USE_GTKMM_BUILDER |
5385 |
// change name in instrument menu |
// change name in instrument menu |
5397 |
#endif |
#endif |
5398 |
|
|
5399 |
// change name in gig |
// change name in gig |
5400 |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
gig::Instrument* instrument = row[m_InstrumentsModel.m_col_instr]; |
5401 |
gig::String gigname(gig_from_utf8(name)); |
gig::String gigname(gig_from_utf8(name)); |
5402 |
if (instrument && instrument->pInfo->Name != gigname) { |
if (instrument && instrument->pInfo->Name != gigname) { |
5403 |
instrument->pInfo->Name = gigname; |
instrument->pInfo->Name = gigname; |
5425 |
#else |
#else |
5426 |
Gtk::TreeModel::Row row = *iter; |
Gtk::TreeModel::Row row = *iter; |
5427 |
#endif |
#endif |
5428 |
Glib::ustring name = row[m_Columns.m_col_name]; |
Glib::ustring name = row[m_InstrumentsModel.m_col_name]; |
5429 |
name = name.lowercase(); |
name = name.lowercase(); |
5430 |
|
|
5431 |
std::vector<Glib::ustring> tokens = Glib::Regex::split_simple(" ", pattern); |
std::vector<Glib::ustring> tokens = Glib::Regex::split_simple(" ", pattern); |
5443 |
// list view as pre-selection |
// list view as pre-selection |
5444 |
std::set<int> indeces; |
std::set<int> indeces; |
5445 |
{ |
{ |
5446 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewInstruments.get_selection(); |
5447 |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
5448 |
for (int r = 0; r < rows.size(); ++r) { |
for (int r = 0; r < rows.size(); ++r) { |
5449 |
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[r]); |
// convert index of visual selection (i.e. if filtered) to index of model |
5450 |
|
Gtk::TreeModel::Path path = m_refInstrumentsModelFilter->convert_path_to_child_path(rows[r]); |
5451 |
|
Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(path); |
5452 |
if (it) { |
if (it) { |
5453 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
5454 |
int index = row[m_Columns.m_col_nr]; |
int index = row[m_InstrumentsModel.m_col_nr]; |
5455 |
indeces.insert(index); |
indeces.insert(index); |
5456 |
} |
} |
5457 |
} |
} |
5661 |
#endif |
#endif |
5662 |
|
|
5663 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
5664 |
|
dialog.hide(); |
5665 |
|
#ifdef GLIB_THREADS |
5666 |
printf("on_action_merge_files self=%p\n", |
printf("on_action_merge_files self=%p\n", |
5667 |
static_cast<void*>(Glib::Threads::Thread::self())); |
static_cast<void*>(Glib::Threads::Thread::self())); |
5668 |
|
#else |
5669 |
|
std::cout << "on_action_merge_files self=" << |
5670 |
|
std::this_thread::get_id() << "\n"; |
5671 |
|
#endif |
5672 |
std::vector<std::string> filenames = dialog.get_filenames(); |
std::vector<std::string> filenames = dialog.get_filenames(); |
5673 |
|
|
5674 |
// merge the selected files to the currently open .gig file |
// merge the selected files to the currently open .gig file |