1 |
/* |
/* |
2 |
* Copyright (C) 2006-2017 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_tooltip_text(_("Right click here for actions on instruments & MIDI Rules. Drag & drop to change the order of instruments.")); |
m_TreeViewInstruments.set_has_tooltip(true); |
1395 |
instrument_name_connection = m_refTreeModel->signal_row_changed().connect( |
m_TreeViewInstruments.signal_query_tooltip().connect( |
1396 |
|
sigc::mem_fun(*this, &MainWindow::onQueryTreeViewTooltip) |
1397 |
|
); |
1398 |
|
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; |
1674 |
Gtk::AccelMap::add_entry("<Macros>/macro_9", GDK_KEY_F10, noModifier); |
Gtk::AccelMap::add_entry("<Macros>/macro_9", GDK_KEY_F10, noModifier); |
1675 |
Gtk::AccelMap::add_entry("<Macros>/macro_10", GDK_KEY_F11, noModifier); |
Gtk::AccelMap::add_entry("<Macros>/macro_10", GDK_KEY_F11, noModifier); |
1676 |
Gtk::AccelMap::add_entry("<Macros>/macro_11", GDK_KEY_F12, noModifier); |
Gtk::AccelMap::add_entry("<Macros>/macro_11", GDK_KEY_F12, noModifier); |
1677 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_12", GDK_KEY_F13, noModifier); |
1678 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_13", GDK_KEY_F14, noModifier); |
1679 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_14", GDK_KEY_F15, noModifier); |
1680 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_15", GDK_KEY_F16, noModifier); |
1681 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_16", GDK_KEY_F17, noModifier); |
1682 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_17", GDK_KEY_F18, noModifier); |
1683 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_18", GDK_KEY_F19, noModifier); |
1684 |
Gtk::AccelMap::add_entry("<Macros>/SetupMacros", 'm', primaryModifierKey); |
Gtk::AccelMap::add_entry("<Macros>/SetupMacros", 'm', primaryModifierKey); |
1685 |
|
|
1686 |
Glib::RefPtr<Gtk::AccelGroup> accelGroup = this->get_accel_group(); |
Glib::RefPtr<Gtk::AccelGroup> accelGroup = this->get_accel_group(); |
1703 |
Gtk::AccelMap::add_entry("<Scripts>/script_9", GDK_KEY_F10, Gdk::SHIFT_MASK); |
Gtk::AccelMap::add_entry("<Scripts>/script_9", GDK_KEY_F10, Gdk::SHIFT_MASK); |
1704 |
Gtk::AccelMap::add_entry("<Scripts>/script_10", GDK_KEY_F11, Gdk::SHIFT_MASK); |
Gtk::AccelMap::add_entry("<Scripts>/script_10", GDK_KEY_F11, Gdk::SHIFT_MASK); |
1705 |
Gtk::AccelMap::add_entry("<Scripts>/script_11", GDK_KEY_F12, Gdk::SHIFT_MASK); |
Gtk::AccelMap::add_entry("<Scripts>/script_11", GDK_KEY_F12, Gdk::SHIFT_MASK); |
1706 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_12", GDK_KEY_F13, Gdk::SHIFT_MASK); |
1707 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_13", GDK_KEY_F14, Gdk::SHIFT_MASK); |
1708 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_14", GDK_KEY_F15, Gdk::SHIFT_MASK); |
1709 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_15", GDK_KEY_F16, Gdk::SHIFT_MASK); |
1710 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_16", GDK_KEY_F17, Gdk::SHIFT_MASK); |
1711 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_17", GDK_KEY_F18, Gdk::SHIFT_MASK); |
1712 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_18", GDK_KEY_F19, Gdk::SHIFT_MASK); |
1713 |
|
Gtk::AccelMap::add_entry("<Scripts>/DropAllScriptSlots", GDK_KEY_BackSpace, Gdk::SHIFT_MASK); |
1714 |
|
|
1715 |
Glib::RefPtr<Gtk::AccelGroup> accelGroup = this->get_accel_group(); |
Glib::RefPtr<Gtk::AccelGroup> accelGroup = this->get_accel_group(); |
1716 |
assign_scripts_menu->set_accel_group(accelGroup); |
assign_scripts_menu->set_accel_group(accelGroup); |
1865 |
gig::Instrument* MainWindow::get_instrument() |
gig::Instrument* MainWindow::get_instrument() |
1866 |
{ |
{ |
1867 |
gig::Instrument* instrument = 0; |
gig::Instrument* instrument = 0; |
1868 |
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(); |
1869 |
if (rows.empty()) return NULL; |
if (rows.empty()) return NULL; |
1870 |
//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. |
1871 |
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]); |
Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(rows[0]); |
1872 |
if (it) { |
if (it) { |
1873 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
1874 |
instrument = row[m_Columns.m_col_instr]; |
instrument = row[m_InstrumentsModel.m_col_instr]; |
1875 |
} |
} |
1876 |
return instrument; |
return instrument; |
1877 |
} |
} |
1936 |
{ |
{ |
1937 |
#if !USE_GTKMM_BUILDER |
#if !USE_GTKMM_BUILDER |
1938 |
// select item in instrument menu |
// select item in instrument menu |
1939 |
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(); |
1940 |
if (!rows.empty()) { |
if (!rows.empty()) { |
1941 |
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]); |
Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(rows[0]); |
1942 |
if (it) { |
if (it) { |
1943 |
Gtk::TreePath path(it); |
Gtk::TreePath path(it); |
1944 |
int index = path[0]; |
int index = path[0]; |
1951 |
|
|
1952 |
updateScriptListOfMenu(); |
updateScriptListOfMenu(); |
1953 |
|
|
1954 |
m_RegionChooser.set_instrument(get_instrument()); |
gig::Instrument* instr = get_instrument(); |
1955 |
|
|
1956 |
|
m_RegionChooser.set_instrument(instr); |
1957 |
|
dimreg_edit.scriptVars.setInstrument(instr, true/*force update*/); |
1958 |
|
|
1959 |
if (Settings::singleton()->syncSamplerInstrumentSelection) { |
if (Settings::singleton()->syncSamplerInstrumentSelection) { |
1960 |
switch_sampler_instrument_signal.emit(get_instrument()); |
switch_sampler_instrument_signal.emit(get_instrument()); |
1961 |
} |
} |
1962 |
} |
} |
1963 |
|
|
1964 |
|
|
1965 |
|
LoaderSaverBase::LoaderSaverBase(const Glib::ustring filename, gig::File* gig) : |
1966 |
|
filename(filename), gig(gig), |
1967 |
|
#ifdef GLIB_THREADS |
1968 |
|
thread(0), |
1969 |
|
#endif |
1970 |
|
progress(0.f) |
1971 |
|
{ |
1972 |
|
} |
1973 |
|
|
1974 |
void loader_progress_callback(gig::progress_t* progress) |
void loader_progress_callback(gig::progress_t* progress) |
1975 |
{ |
{ |
1976 |
Loader* loader = static_cast<Loader*>(progress->custom); |
LoaderSaverBase* loader = static_cast<LoaderSaverBase*>(progress->custom); |
1977 |
loader->progress_callback(progress->factor); |
loader->progress_callback(progress->factor); |
1978 |
} |
} |
1979 |
|
|
1980 |
void Loader::progress_callback(float fraction) |
void LoaderSaverBase::progress_callback(float fraction) |
1981 |
{ |
{ |
1982 |
{ |
{ |
1983 |
|
#ifdef GLIB_THREADS |
1984 |
Glib::Threads::Mutex::Lock lock(progressMutex); |
Glib::Threads::Mutex::Lock lock(progressMutex); |
1985 |
|
#else |
1986 |
|
std::lock_guard<std::mutex> lock(progressMutex); |
1987 |
|
#endif |
1988 |
progress = fraction; |
progress = fraction; |
1989 |
} |
} |
1990 |
progress_dispatcher(); |
progress_dispatcher(); |
1994 |
// make sure stack is 16-byte aligned for SSE instructions |
// make sure stack is 16-byte aligned for SSE instructions |
1995 |
__attribute__((force_align_arg_pointer)) |
__attribute__((force_align_arg_pointer)) |
1996 |
#endif |
#endif |
1997 |
void Loader::thread_function() |
void LoaderSaverBase::thread_function() |
1998 |
{ |
{ |
1999 |
|
#ifdef GLIB_THREADS |
2000 |
printf("thread_function self=%p\n", |
printf("thread_function self=%p\n", |
2001 |
static_cast<void*>(Glib::Threads::Thread::self())); |
static_cast<void*>(Glib::Threads::Thread::self())); |
2002 |
|
#else |
2003 |
|
std::cout << "thread_function self=" << std::this_thread::get_id() << "\n"; |
2004 |
|
#endif |
2005 |
printf("Start %s\n", filename.c_str()); |
printf("Start %s\n", filename.c_str()); |
2006 |
try { |
try { |
|
RIFF::File* riff = new RIFF::File(filename); |
|
|
gig = new gig::File(riff); |
|
2007 |
gig::progress_t progress; |
gig::progress_t progress; |
2008 |
progress.callback = loader_progress_callback; |
progress.callback = loader_progress_callback; |
2009 |
progress.custom = this; |
progress.custom = this; |
2010 |
|
|
2011 |
gig->GetInstrument(0, &progress); |
thread_function_sub(progress); |
2012 |
printf("End\n"); |
printf("End\n"); |
2013 |
finished_dispatcher(); |
finished_dispatcher(); |
2014 |
} catch (RIFF::Exception e) { |
} catch (RIFF::Exception e) { |
2020 |
} |
} |
2021 |
} |
} |
2022 |
|
|
2023 |
Loader::Loader(const char* filename) |
void LoaderSaverBase::launch() |
|
: filename(filename), gig(0), thread(0), progress(0.f) |
|
|
{ |
|
|
} |
|
|
|
|
|
void Loader::launch() |
|
2024 |
{ |
{ |
2025 |
|
#ifdef GLIB_THREADS |
2026 |
#ifdef OLD_THREADS |
#ifdef OLD_THREADS |
2027 |
thread = Glib::Thread::create(sigc::mem_fun(*this, &Loader::thread_function), true); |
thread = Glib::Thread::create(sigc::mem_fun(*this, &LoaderSaverBase::thread_function), true); |
2028 |
#else |
#else |
2029 |
thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Loader::thread_function)); |
thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &LoaderSaverBase::thread_function)); |
2030 |
#endif |
#endif |
2031 |
printf("launch thread=%p\n", static_cast<void*>(thread)); |
printf("launch thread=%p\n", static_cast<void*>(thread)); |
2032 |
|
#else |
2033 |
|
thread = std::thread([this](){ thread_function(); }); |
2034 |
|
std::cout << "launch thread=" << thread.get_id() << "\n"; |
2035 |
|
#endif |
2036 |
} |
} |
2037 |
|
|
2038 |
float Loader::get_progress() |
float LoaderSaverBase::get_progress() |
2039 |
{ |
{ |
2040 |
float res; |
#ifdef GLIB_THREADS |
2041 |
{ |
Glib::Threads::Mutex::Lock lock(progressMutex); |
2042 |
Glib::Threads::Mutex::Lock lock(progressMutex); |
#else |
2043 |
res = progress; |
std::lock_guard<std::mutex> lock(progressMutex); |
2044 |
} |
#endif |
2045 |
return res; |
return progress; |
2046 |
} |
} |
2047 |
|
|
2048 |
Glib::Dispatcher& Loader::signal_progress() |
Glib::Dispatcher& LoaderSaverBase::signal_progress() |
2049 |
{ |
{ |
2050 |
return progress_dispatcher; |
return progress_dispatcher; |
2051 |
} |
} |
2052 |
|
|
2053 |
Glib::Dispatcher& Loader::signal_finished() |
Glib::Dispatcher& LoaderSaverBase::signal_finished() |
2054 |
{ |
{ |
2055 |
return finished_dispatcher; |
return finished_dispatcher; |
2056 |
} |
} |
2057 |
|
|
2058 |
Glib::Dispatcher& Loader::signal_error() |
Glib::Dispatcher& LoaderSaverBase::signal_error() |
2059 |
{ |
{ |
2060 |
return error_dispatcher; |
return error_dispatcher; |
2061 |
} |
} |
2062 |
|
|
2063 |
void saver_progress_callback(gig::progress_t* progress) |
void LoaderSaverBase::join() { |
2064 |
{ |
#ifdef GLIB_THREADS |
2065 |
Saver* saver = static_cast<Saver*>(progress->custom); |
thread->join(); |
2066 |
saver->progress_callback(progress->factor); |
#else |
2067 |
|
thread.join(); |
2068 |
|
#endif |
2069 |
} |
} |
2070 |
|
|
2071 |
void Saver::progress_callback(float fraction) |
|
2072 |
|
Loader::Loader(const char* filename) : |
2073 |
|
LoaderSaverBase(filename, 0) |
2074 |
{ |
{ |
|
{ |
|
|
Glib::Threads::Mutex::Lock lock(progressMutex); |
|
|
progress = fraction; |
|
|
} |
|
|
progress_dispatcher.emit(); |
|
2075 |
} |
} |
2076 |
|
|
2077 |
#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() |
|
2078 |
{ |
{ |
2079 |
printf("thread_function self=%p\n", |
RIFF::File* riff = new RIFF::File(filename); |
2080 |
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; |
|
2081 |
|
|
2082 |
// if no filename was provided, that means "save", if filename was provided means "save as" |
gig->GetInstrument(0, &progress); |
|
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); |
|
|
} |
|
|
|
|
|
printf("End\n"); |
|
|
finished_dispatcher.emit(); |
|
|
} catch (RIFF::Exception e) { |
|
|
error_message = e.Message; |
|
|
error_dispatcher.emit(); |
|
|
} catch (...) { |
|
|
error_message = _("Unknown exception occurred"); |
|
|
error_dispatcher.emit(); |
|
|
} |
|
2083 |
} |
} |
2084 |
|
|
2085 |
Saver::Saver(gig::File* file, Glib::ustring filename) |
|
2086 |
: gig(file), filename(filename), thread(0), progress(0.f) |
Saver::Saver(gig::File* file, Glib::ustring filename) : |
2087 |
|
LoaderSaverBase(filename, file) |
2088 |
{ |
{ |
2089 |
} |
} |
2090 |
|
|
2091 |
void Saver::launch() |
void Saver::thread_function_sub(gig::progress_t& progress) |
2092 |
{ |
{ |
2093 |
#ifdef OLD_THREADS |
// if no filename was provided, that means "save", if filename was provided means "save as" |
2094 |
thread = Glib::Thread::create(sigc::mem_fun(*this, &Saver::thread_function), true); |
if (filename.empty()) { |
2095 |
|
if (!Settings::singleton()->saveWithTemporaryFile) { |
2096 |
|
// save directly over the existing .gig file |
2097 |
|
// (requires less disk space than solution below |
2098 |
|
// but may be slower) |
2099 |
|
gig->Save(&progress); |
2100 |
|
} else { |
2101 |
|
// save the file as separate temporary file first, |
2102 |
|
// then move the saved file over the old file |
2103 |
|
// (may result in performance speedup during save) |
2104 |
|
gig::String tmpname = filename + ".TMP"; |
2105 |
|
gig->Save(tmpname, &progress); |
2106 |
|
#if defined(WIN32) |
2107 |
|
if (!DeleteFile(filename.c_str())) { |
2108 |
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file)."); |
2109 |
|
} |
2110 |
|
#else // POSIX ... |
2111 |
|
if (unlink(filename.c_str())) { |
2112 |
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file): " + gig::String(strerror(errno))); |
2113 |
|
} |
2114 |
|
#endif |
2115 |
|
if (rename(tmpname.c_str(), filename.c_str())) { |
2116 |
|
#if defined(WIN32) |
2117 |
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file)."); |
2118 |
#else |
#else |
2119 |
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))); |
2120 |
#endif |
#endif |
2121 |
printf("launch thread=%p\n", static_cast<void*>(thread)); |
} |
2122 |
} |
} |
2123 |
|
} else { |
2124 |
float Saver::get_progress() |
gig->Save(filename, &progress); |
|
{ |
|
|
float res; |
|
|
{ |
|
|
Glib::Threads::Mutex::Lock lock(progressMutex); |
|
|
res = progress; |
|
2125 |
} |
} |
|
return res; |
|
|
} |
|
|
|
|
|
Glib::Dispatcher& Saver::signal_progress() |
|
|
{ |
|
|
return progress_dispatcher; |
|
|
} |
|
|
|
|
|
Glib::Dispatcher& Saver::signal_finished() |
|
|
{ |
|
|
return finished_dispatcher; |
|
2126 |
} |
} |
2127 |
|
|
|
Glib::Dispatcher& Saver::signal_error() |
|
|
{ |
|
|
return error_dispatcher; |
|
|
} |
|
2128 |
|
|
2129 |
ProgressDialog::ProgressDialog(const Glib::ustring& title, Gtk::Window& parent) |
ProgressDialog::ProgressDialog(const Glib::ustring& title, Gtk::Window& parent) |
2130 |
: Gtk::Dialog(title, parent, true) |
: Gtk::Dialog(title, parent, true) |
2146 |
// forget all samples that ought to be imported |
// forget all samples that ought to be imported |
2147 |
m_SampleImportQueue.clear(); |
m_SampleImportQueue.clear(); |
2148 |
// clear the samples and instruments tree views |
// clear the samples and instruments tree views |
2149 |
m_refTreeModel->clear(); |
m_refInstrumentsTreeModel->clear(); |
2150 |
m_refSamplesTreeModel->clear(); |
m_refSamplesTreeModel->clear(); |
2151 |
m_refScriptsTreeModel->clear(); |
m_refScriptsTreeModel->clear(); |
2152 |
#if !USE_GTKMM_BUILDER |
#if !USE_GTKMM_BUILDER |
2163 |
|
|
2164 |
void MainWindow::__refreshEntireGUI() { |
void MainWindow::__refreshEntireGUI() { |
2165 |
// clear the samples and instruments tree views |
// clear the samples and instruments tree views |
2166 |
m_refTreeModel->clear(); |
m_refInstrumentsTreeModel->clear(); |
2167 |
m_refSamplesTreeModel->clear(); |
m_refSamplesTreeModel->clear(); |
2168 |
m_refScriptsTreeModel->clear(); |
m_refScriptsTreeModel->clear(); |
2169 |
#if !USE_GTKMM_BUILDER |
#if !USE_GTKMM_BUILDER |
2280 |
dialog.set_current_folder(current_gig_dir); |
dialog.set_current_folder(current_gig_dir); |
2281 |
} |
} |
2282 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
2283 |
|
dialog.hide(); |
2284 |
std::string filename = dialog.get_filename(); |
std::string filename = dialog.get_filename(); |
2285 |
printf("filename=%s\n", filename.c_str()); |
printf("filename=%s\n", filename.c_str()); |
2286 |
|
#ifdef GLIB_THREADS |
2287 |
printf("on_action_file_open self=%p\n", |
printf("on_action_file_open self=%p\n", |
2288 |
static_cast<void*>(Glib::Threads::Thread::self())); |
static_cast<void*>(Glib::Threads::Thread::self())); |
2289 |
|
#else |
2290 |
|
std::cout << "on_action_file_open self=" << |
2291 |
|
std::this_thread::get_id() << "\n"; |
2292 |
|
#endif |
2293 |
load_file(filename.c_str()); |
load_file(filename.c_str()); |
2294 |
current_gig_dir = Glib::path_get_dirname(filename); |
current_gig_dir = Glib::path_get_dirname(filename); |
2295 |
} |
} |
2336 |
{ |
{ |
2337 |
if (instrument == instr) { |
if (instrument == instr) { |
2338 |
// select item in "instruments" tree view |
// select item in "instruments" tree view |
2339 |
m_TreeView.get_selection()->select(Gtk::TreePath(ToString(i))); |
m_TreeViewInstruments.get_selection()->select(Gtk::TreePath(ToString(i))); |
2340 |
// make sure the selected item in the "instruments" tree view is |
// make sure the selected item in the "instruments" tree view is |
2341 |
// visible (scroll to it) |
// visible (scroll to it) |
2342 |
m_TreeView.scroll_to_row(Gtk::TreePath(ToString(i))); |
m_TreeViewInstruments.scroll_to_row(Gtk::TreePath(ToString(i))); |
2343 |
#if !USE_GTKMM_BUILDER |
#if !USE_GTKMM_BUILDER |
2344 |
// select item in instrument menu |
// select item in instrument menu |
2345 |
{ |
{ |
2362 |
|
|
2363 |
void MainWindow::on_loader_finished() |
void MainWindow::on_loader_finished() |
2364 |
{ |
{ |
2365 |
|
loader->join(); |
2366 |
printf("Loader finished!\n"); |
printf("Loader finished!\n"); |
2367 |
|
#ifdef GLIB_THREADS |
2368 |
printf("on_loader_finished self=%p\n", |
printf("on_loader_finished self=%p\n", |
2369 |
static_cast<void*>(Glib::Threads::Thread::self())); |
static_cast<void*>(Glib::Threads::Thread::self())); |
2370 |
|
#else |
2371 |
|
std::cout << "on_loader_finished self=" << |
2372 |
|
std::this_thread::get_id() << "\n"; |
2373 |
|
#endif |
2374 |
load_gig(loader->gig, loader->filename.c_str()); |
load_gig(loader->gig, loader->filename.c_str()); |
2375 |
progress_dialog->hide(); |
progress_dialog->hide(); |
2376 |
} |
} |
2377 |
|
|
2378 |
void MainWindow::on_loader_error() |
void MainWindow::on_loader_error() |
2379 |
{ |
{ |
2380 |
|
loader->join(); |
2381 |
Glib::ustring txt = _("Could not load file: ") + loader->error_message; |
Glib::ustring txt = _("Could not load file: ") + loader->error_message; |
2382 |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
2383 |
msg.run(); |
msg.run(); |
2448 |
|
|
2449 |
void MainWindow::on_saver_error() |
void MainWindow::on_saver_error() |
2450 |
{ |
{ |
2451 |
|
saver->join(); |
2452 |
file_structure_changed_signal.emit(this->file); |
file_structure_changed_signal.emit(this->file); |
2453 |
Glib::ustring txt = _("Could not save file: ") + saver->error_message; |
Glib::ustring txt = _("Could not save file: ") + saver->error_message; |
2454 |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
2457 |
|
|
2458 |
void MainWindow::on_saver_finished() |
void MainWindow::on_saver_finished() |
2459 |
{ |
{ |
2460 |
|
saver->join(); |
2461 |
this->file = saver->gig; |
this->file = saver->gig; |
2462 |
this->filename = saver->filename; |
this->filename = saver->filename; |
2463 |
current_gig_dir = Glib::path_get_dirname(filename); |
current_gig_dir = Glib::path_get_dirname(filename); |
2549 |
#endif |
#endif |
2550 |
|
|
2551 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
2552 |
|
dialog.hide(); |
2553 |
std::string filename = dialog.get_filename(); |
std::string filename = dialog.get_filename(); |
2554 |
if (!Glib::str_has_suffix(filename, ".gig")) { |
if (!Glib::str_has_suffix(filename, ".gig")) { |
2555 |
filename += ".gig"; |
filename += ".gig"; |
2678 |
|
|
2679 |
void MainWindow::on_action_file_properties() |
void MainWindow::on_action_file_properties() |
2680 |
{ |
{ |
2681 |
propDialog.show(); |
fileProps.show(); |
2682 |
propDialog.deiconify(); |
fileProps.deiconify(); |
2683 |
} |
} |
2684 |
|
|
2685 |
void MainWindow::on_action_warn_user_on_extensions() { |
void MainWindow::on_action_warn_user_on_extensions() { |
2701 |
dimreg_all_regions.set_has_tooltip(b); |
dimreg_all_regions.set_has_tooltip(b); |
2702 |
dimreg_all_dimregs.set_has_tooltip(b); |
dimreg_all_dimregs.set_has_tooltip(b); |
2703 |
dimreg_stereo.set_has_tooltip(b); |
dimreg_stereo.set_has_tooltip(b); |
2704 |
m_TreeView.set_has_tooltip(b); |
|
2705 |
|
// Not doing this here, we let onQueryTreeViewTooltip() handle this per cell |
2706 |
|
//m_TreeViewInstruments.set_has_tooltip(b); |
2707 |
|
|
2708 |
m_TreeViewSamples.set_has_tooltip(b); |
m_TreeViewSamples.set_has_tooltip(b); |
2709 |
m_TreeViewScripts.set_has_tooltip(b); |
m_TreeViewScripts.set_has_tooltip(b); |
2710 |
|
|
2730 |
dialog.set_name("Gigedit"); |
dialog.set_name("Gigedit"); |
2731 |
#endif |
#endif |
2732 |
dialog.set_version(VERSION); |
dialog.set_version(VERSION); |
2733 |
dialog.set_copyright("Copyright (C) 2006-2017 Andreas Persson"); |
dialog.set_copyright("Copyright (C) 2006-2019 Andreas Persson"); |
2734 |
const std::string sComment = |
const std::string sComment = |
2735 |
_("Built " __DATE__ "\nUsing ") + |
_("Built " __DATE__ "\nUsing ") + |
2736 |
::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" + |
::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" + |
2741 |
"backup your Gigasampler/GigaStudio files before editing them with " |
"backup your Gigasampler/GigaStudio files before editing them with " |
2742 |
"this application.\n" |
"this application.\n" |
2743 |
"\n" |
"\n" |
2744 |
"Please report bugs to: http://bugs.linuxsampler.org" |
"Please report bugs to: https://bugs.linuxsampler.org" |
2745 |
); |
); |
2746 |
dialog.set_comments(sComment.c_str()); |
dialog.set_comments(sComment.c_str()); |
2747 |
dialog.set_website("http://www.linuxsampler.org"); |
dialog.set_website("https://www.linuxsampler.org"); |
2748 |
dialog.set_website_label("http://www.linuxsampler.org"); |
dialog.set_website_label("https://www.linuxsampler.org"); |
2749 |
dialog.set_position(Gtk::WIN_POS_CENTER); |
dialog.set_position(Gtk::WIN_POS_CENTER); |
2750 |
dialog.run(); |
dialog.run(); |
2751 |
} |
} |
2752 |
|
|
2753 |
PropDialog::PropDialog() |
FilePropDialog::FilePropDialog() |
2754 |
: eFileFormat(_("File Format")), |
: eFileFormat(_("File Format")), |
2755 |
eName(_("Name")), |
eName(_("Name")), |
2756 |
eCreationDate(_("Creation date")), |
eCreationDate(_("Creation date")), |
2784 |
set_title(_("File Properties")); |
set_title(_("File Properties")); |
2785 |
eName.set_width_chars(50); |
eName.set_width_chars(50); |
2786 |
|
|
2787 |
|
connect(eFileFormat, &FilePropDialog::set_FileFormat); |
2788 |
connect(eName, &DLS::Info::Name); |
connect(eName, &DLS::Info::Name); |
2789 |
connect(eCreationDate, &DLS::Info::CreationDate); |
connect(eCreationDate, &DLS::Info::CreationDate); |
2790 |
connect(eComments, &DLS::Info::Comments); |
connect(eComments, &DLS::Info::Comments); |
2827 |
#endif |
#endif |
2828 |
|
|
2829 |
add(vbox); |
add(vbox); |
2830 |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22) |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24) |
2831 |
table.set_margin(5); |
table.set_margin(5); |
2832 |
#else |
#else |
2833 |
table.set_border_width(5); |
table.set_border_width(5); |
2835 |
vbox.add(table); |
vbox.add(table); |
2836 |
vbox.pack_start(buttonBox, Gtk::PACK_SHRINK); |
vbox.pack_start(buttonBox, Gtk::PACK_SHRINK); |
2837 |
buttonBox.set_layout(Gtk::BUTTONBOX_END); |
buttonBox.set_layout(Gtk::BUTTONBOX_END); |
2838 |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22) |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24) |
2839 |
buttonBox.set_margin(5); |
buttonBox.set_margin(5); |
2840 |
#else |
#else |
2841 |
buttonBox.set_border_width(5); |
buttonBox.set_border_width(5); |
2845 |
quitButton.set_can_default(); |
quitButton.set_can_default(); |
2846 |
quitButton.grab_focus(); |
quitButton.grab_focus(); |
2847 |
quitButton.signal_clicked().connect( |
quitButton.signal_clicked().connect( |
2848 |
sigc::mem_fun(*this, &PropDialog::hide)); |
sigc::mem_fun(*this, &FilePropDialog::hide)); |
|
eFileFormat.signal_value_changed().connect( |
|
|
sigc::mem_fun(*this, &PropDialog::onFileFormatChanged)); |
|
2849 |
|
|
2850 |
quitButton.show(); |
quitButton.show(); |
2851 |
vbox.show(); |
vbox.show(); |
2854 |
#endif |
#endif |
2855 |
} |
} |
2856 |
|
|
2857 |
void PropDialog::set_file(gig::File* file) |
void FilePropDialog::set_file(gig::File* file) |
2858 |
{ |
{ |
2859 |
m_file = file; |
m_file = file; |
2860 |
|
update(file->pInfo); |
2861 |
|
|
2862 |
// update file format version combo box |
// update file format version combo box |
2863 |
const std::string sGiga = "Gigasampler/GigaStudio v"; |
const std::string sGiga = "Gigasampler/GigaStudio v"; |
2865 |
std::vector<std::string> txts; |
std::vector<std::string> txts; |
2866 |
std::vector<int> values; |
std::vector<int> values; |
2867 |
txts.push_back(sGiga + "2"); values.push_back(2); |
txts.push_back(sGiga + "2"); values.push_back(2); |
2868 |
txts.push_back(sGiga + "3/v4"); values.push_back(3); |
txts.push_back(sGiga + "3"); values.push_back(3); |
2869 |
if (major != 2 && major != 3) { |
txts.push_back(sGiga + "4"); values.push_back(4); |
2870 |
|
if (major < 2 || major > 4) { |
2871 |
txts.push_back(sGiga + ToString(major)); values.push_back(major); |
txts.push_back(sGiga + ToString(major)); values.push_back(major); |
2872 |
} |
} |
2873 |
std::vector<const char*> texts; |
std::vector<const char*> texts; |
2874 |
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()); |
2875 |
texts.push_back(NULL); values.push_back(0); |
texts.push_back(NULL); values.push_back(0); |
2876 |
|
|
2877 |
|
update_model++; |
2878 |
eFileFormat.set_choices(&texts[0], &values[0]); |
eFileFormat.set_choices(&texts[0], &values[0]); |
2879 |
eFileFormat.set_value(major); |
eFileFormat.set_value(major); |
2880 |
|
update_model--; |
2881 |
} |
} |
2882 |
|
|
2883 |
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) |
|
2884 |
{ |
{ |
2885 |
update(info); |
m_file->pVersion->major = value; |
2886 |
} |
} |
2887 |
|
|
2888 |
|
|
2924 |
eIsDrum(_("Is drum")), |
eIsDrum(_("Is drum")), |
2925 |
eMIDIBank(_("MIDI bank"), 0, 16383), |
eMIDIBank(_("MIDI bank"), 0, 16383), |
2926 |
eMIDIProgram(_("MIDI program")), |
eMIDIProgram(_("MIDI program")), |
2927 |
eAttenuation(_("Attenuation"), 0, 96, 0, 1), |
eAttenuation(_("Attenuation (dB)"), -96, +96, 0, 1), |
|
eGainPlus6(_("Gain +6dB"), eAttenuation, -6), |
|
2928 |
eEffectSend(_("Effect send"), 0, 65535), |
eEffectSend(_("Effect send"), 0, 65535), |
2929 |
eFineTune(_("Fine tune"), -8400, 8400), |
eFineTune(_("Fine tune"), -8400, 8400), |
2930 |
ePitchbendRange(_("Pitchbend range"), 0, 48), |
ePitchbendRange(_("Pitchbend range (halftones)"), 0, 48), |
2931 |
ePianoReleaseMode(_("Piano release mode")), |
ePianoReleaseMode(_("Piano release mode")), |
2932 |
eDimensionKeyRangeLow(_("Keyswitching range low")), |
eDimensionKeyRangeLow(_("Keyswitching range low")), |
2933 |
eDimensionKeyRangeHigh(_("Keyswitching range high")) |
eDimensionKeyRangeHigh(_("Keyswitching range high")), |
2934 |
|
table2(2,1), |
2935 |
|
eName2(_("Name")), |
2936 |
|
eCreationDate(_("Creation date")), |
2937 |
|
eComments(_("Comments")), |
2938 |
|
eProduct(_("Product")), |
2939 |
|
eCopyright(_("Copyright")), |
2940 |
|
eArtists(_("Artists")), |
2941 |
|
eGenre(_("Genre")), |
2942 |
|
eKeywords(_("Keywords")), |
2943 |
|
eEngineer(_("Engineer")), |
2944 |
|
eTechnician(_("Technician")), |
2945 |
|
eSoftware(_("Software")), |
2946 |
|
eMedium(_("Medium")), |
2947 |
|
eSource(_("Source")), |
2948 |
|
eSourceForm(_("Source form")), |
2949 |
|
eCommissioned(_("Commissioned")), |
2950 |
|
eSubject(_("Subject")) |
2951 |
{ |
{ |
2952 |
if (!Settings::singleton()->autoRestoreWindowDimension) { |
if (!Settings::singleton()->autoRestoreWindowDimension) { |
2953 |
//set_default_size(470, 390); |
//set_default_size(470, 390); |
2956 |
|
|
2957 |
set_title(_("Instrument Properties")); |
set_title(_("Instrument Properties")); |
2958 |
|
|
2959 |
|
tabs.append_page(vbox[1], _("Settings")); |
2960 |
|
tabs.append_page(vbox[2], _("Info")); |
2961 |
|
|
2962 |
eDimensionKeyRangeLow.set_tip( |
eDimensionKeyRangeLow.set_tip( |
2963 |
_("start of the keyboard area which should switch the " |
_("start of the keyboard area which should switch the " |
2964 |
"\"keyswitching\" dimension") |
"\"keyswitching\" dimension") |
2973 |
connect(eMIDIBank, &InstrumentProps::set_MIDIBank); |
connect(eMIDIBank, &InstrumentProps::set_MIDIBank); |
2974 |
connect(eMIDIProgram, &InstrumentProps::set_MIDIProgram); |
connect(eMIDIProgram, &InstrumentProps::set_MIDIProgram); |
2975 |
connect(eAttenuation, &gig::Instrument::Attenuation); |
connect(eAttenuation, &gig::Instrument::Attenuation); |
|
connect(eGainPlus6, &gig::Instrument::Attenuation); |
|
2976 |
connect(eEffectSend, &gig::Instrument::EffectSend); |
connect(eEffectSend, &gig::Instrument::EffectSend); |
2977 |
connect(eFineTune, &gig::Instrument::FineTune); |
connect(eFineTune, &gig::Instrument::FineTune); |
2978 |
connect(ePitchbendRange, &gig::Instrument::PitchbendRange); |
connect(ePitchbendRange, &gig::Instrument::PitchbendRange); |
2982 |
|
|
2983 |
eName.signal_value_changed().connect(sig_name_changed.make_slot()); |
eName.signal_value_changed().connect(sig_name_changed.make_slot()); |
2984 |
|
|
2985 |
|
connect(eName2, &InstrumentProps::set_Name); |
2986 |
|
connectLambda(eCreationDate, [this](gig::String s) { |
2987 |
|
m->pInfo->CreationDate = s; |
2988 |
|
}); |
2989 |
|
connectLambda(eComments, [this](gig::String s) { |
2990 |
|
m->pInfo->Comments = s; |
2991 |
|
}); |
2992 |
|
connectLambda(eProduct, [this](gig::String s) { |
2993 |
|
m->pInfo->Product = s; |
2994 |
|
}); |
2995 |
|
connectLambda(eCopyright, [this](gig::String s) { |
2996 |
|
m->pInfo->Copyright = s; |
2997 |
|
}); |
2998 |
|
connectLambda(eArtists, [this](gig::String s) { |
2999 |
|
m->pInfo->Artists = s; |
3000 |
|
}); |
3001 |
|
connectLambda(eGenre, [this](gig::String s) { |
3002 |
|
m->pInfo->Genre = s; |
3003 |
|
}); |
3004 |
|
connectLambda(eKeywords, [this](gig::String s) { |
3005 |
|
m->pInfo->Keywords = s; |
3006 |
|
}); |
3007 |
|
connectLambda(eEngineer, [this](gig::String s) { |
3008 |
|
m->pInfo->Engineer = s; |
3009 |
|
}); |
3010 |
|
connectLambda(eTechnician, [this](gig::String s) { |
3011 |
|
m->pInfo->Technician = s; |
3012 |
|
}); |
3013 |
|
connectLambda(eSoftware, [this](gig::String s) { |
3014 |
|
m->pInfo->Software = s; |
3015 |
|
}); |
3016 |
|
connectLambda(eMedium, [this](gig::String s) { |
3017 |
|
m->pInfo->Medium = s; |
3018 |
|
}); |
3019 |
|
connectLambda(eSource, [this](gig::String s) { |
3020 |
|
m->pInfo->Source = s; |
3021 |
|
}); |
3022 |
|
connectLambda(eSourceForm, [this](gig::String s) { |
3023 |
|
m->pInfo->SourceForm = s; |
3024 |
|
}); |
3025 |
|
connectLambda(eCommissioned, [this](gig::String s) { |
3026 |
|
m->pInfo->Commissioned = s; |
3027 |
|
}); |
3028 |
|
connectLambda(eSubject, [this](gig::String s) { |
3029 |
|
m->pInfo->Subject = s; |
3030 |
|
}); |
3031 |
|
|
3032 |
|
// tab 1 |
3033 |
#if USE_GTKMM_GRID |
#if USE_GTKMM_GRID |
3034 |
table.set_column_spacing(5); |
table.set_column_spacing(5); |
3035 |
#else |
#else |
3036 |
table.set_col_spacings(5); |
table.set_col_spacings(5); |
3037 |
#endif |
#endif |
|
|
|
3038 |
table.add(eName); |
table.add(eName); |
3039 |
table.add(eIsDrum); |
table.add(eIsDrum); |
3040 |
table.add(eMIDIBank); |
table.add(eMIDIBank); |
3041 |
table.add(eMIDIProgram); |
table.add(eMIDIProgram); |
3042 |
table.add(eAttenuation); |
table.add(eAttenuation); |
|
table.add(eGainPlus6); |
|
3043 |
table.add(eEffectSend); |
table.add(eEffectSend); |
3044 |
table.add(eFineTune); |
table.add(eFineTune); |
3045 |
table.add(ePitchbendRange); |
table.add(ePitchbendRange); |
3047 |
table.add(eDimensionKeyRangeLow); |
table.add(eDimensionKeyRangeLow); |
3048 |
table.add(eDimensionKeyRangeHigh); |
table.add(eDimensionKeyRangeHigh); |
3049 |
|
|
3050 |
add(vbox); |
// tab 2 |
3051 |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22) |
#if USE_GTKMM_GRID |
3052 |
|
table2.set_column_spacing(5); |
3053 |
|
#else |
3054 |
|
table2.set_col_spacings(5); |
3055 |
|
#endif |
3056 |
|
table2.add(eName2); |
3057 |
|
table2.add(eCreationDate); |
3058 |
|
table2.add(eComments); |
3059 |
|
table2.add(eProduct); |
3060 |
|
table2.add(eCopyright); |
3061 |
|
table2.add(eArtists); |
3062 |
|
table2.add(eGenre); |
3063 |
|
table2.add(eKeywords); |
3064 |
|
table2.add(eEngineer); |
3065 |
|
table2.add(eTechnician); |
3066 |
|
table2.add(eSoftware); |
3067 |
|
table2.add(eMedium); |
3068 |
|
table2.add(eSource); |
3069 |
|
table2.add(eSourceForm); |
3070 |
|
table2.add(eCommissioned); |
3071 |
|
table2.add(eSubject); |
3072 |
|
|
3073 |
|
add(vbox[0]); |
3074 |
|
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24) |
3075 |
table.set_margin(5); |
table.set_margin(5); |
3076 |
#else |
#else |
3077 |
table.set_border_width(5); |
table.set_border_width(5); |
3078 |
#endif |
#endif |
3079 |
vbox.pack_start(table); |
vbox[1].pack_start(table); |
3080 |
|
vbox[2].pack_start(table2); |
3081 |
table.show(); |
table.show(); |
3082 |
vbox.pack_start(buttonBox, Gtk::PACK_SHRINK); |
table2.show(); |
3083 |
|
vbox[0].pack_start(tabs); |
3084 |
|
vbox[0].pack_start(buttonBox, Gtk::PACK_SHRINK); |
3085 |
buttonBox.set_layout(Gtk::BUTTONBOX_END); |
buttonBox.set_layout(Gtk::BUTTONBOX_END); |
3086 |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22) |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24) |
3087 |
buttonBox.set_margin(5); |
buttonBox.set_margin(5); |
3088 |
#else |
#else |
3089 |
buttonBox.set_border_width(5); |
buttonBox.set_border_width(5); |
3097 |
sigc::mem_fun(*this, &InstrumentProps::hide)); |
sigc::mem_fun(*this, &InstrumentProps::hide)); |
3098 |
|
|
3099 |
quitButton.show(); |
quitButton.show(); |
3100 |
vbox.show(); |
vbox[0].show(); |
3101 |
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
3102 |
show_all_children(); |
show_all_children(); |
3103 |
#endif |
#endif |
3108 |
update(instrument); |
update(instrument); |
3109 |
|
|
3110 |
update_model++; |
update_model++; |
3111 |
|
|
3112 |
|
// tab 1 |
3113 |
eName.set_value(instrument->pInfo->Name); |
eName.set_value(instrument->pInfo->Name); |
3114 |
eIsDrum.set_value(instrument->IsDrum); |
eIsDrum.set_value(instrument->IsDrum); |
3115 |
eMIDIBank.set_value(instrument->MIDIBank); |
eMIDIBank.set_value(instrument->MIDIBank); |
3116 |
eMIDIProgram.set_value(instrument->MIDIProgram); |
eMIDIProgram.set_value(instrument->MIDIProgram); |
3117 |
|
// tab 2 |
3118 |
|
eName2.set_value(instrument->pInfo->Name); |
3119 |
|
eCreationDate.set_value(instrument->pInfo->CreationDate); |
3120 |
|
eComments.set_value(instrument->pInfo->Comments); |
3121 |
|
eProduct.set_value(instrument->pInfo->Product); |
3122 |
|
eCopyright.set_value(instrument->pInfo->Copyright); |
3123 |
|
eArtists.set_value(instrument->pInfo->Artists); |
3124 |
|
eGenre.set_value(instrument->pInfo->Genre); |
3125 |
|
eKeywords.set_value(instrument->pInfo->Keywords); |
3126 |
|
eEngineer.set_value(instrument->pInfo->Engineer); |
3127 |
|
eTechnician.set_value(instrument->pInfo->Technician); |
3128 |
|
eSoftware.set_value(instrument->pInfo->Software); |
3129 |
|
eMedium.set_value(instrument->pInfo->Medium); |
3130 |
|
eSource.set_value(instrument->pInfo->Source); |
3131 |
|
eSourceForm.set_value(instrument->pInfo->SourceForm); |
3132 |
|
eCommissioned.set_value(instrument->pInfo->Commissioned); |
3133 |
|
eSubject.set_value(instrument->pInfo->Subject); |
3134 |
|
|
3135 |
|
update_model--; |
3136 |
|
} |
3137 |
|
|
3138 |
|
|
3139 |
|
SampleProps::SampleProps() : |
3140 |
|
#if HAS_GTKMM_STOCK |
3141 |
|
quitButton(Gtk::Stock::CLOSE), |
3142 |
|
#else |
3143 |
|
quitButton(_("_Close")), |
3144 |
|
#endif |
3145 |
|
table(2,1), |
3146 |
|
eName(_("Name")), |
3147 |
|
eUnityNote(_("Unity Note")), |
3148 |
|
eSampleGroup(_("Sample Group")), |
3149 |
|
eSampleFormatInfo(_("Sample Format")), |
3150 |
|
eSampleID("Sample ID"), |
3151 |
|
eChecksum("Wave Data CRC-32"), |
3152 |
|
eLoopsCount(_("Loops"), 0, 1), // we might support more than 1 loop in future |
3153 |
|
eLoopStart(_("Loop start position"), 0, 9999999), |
3154 |
|
eLoopLength(_("Loop size"), 0, 9999999), |
3155 |
|
eLoopType(_("Loop type")), |
3156 |
|
eLoopPlayCount(_("Playback count")), |
3157 |
|
table2(2,1), |
3158 |
|
eName2(_("Name")), |
3159 |
|
eCreationDate(_("Creation date")), |
3160 |
|
eComments(_("Comments")), |
3161 |
|
eProduct(_("Product")), |
3162 |
|
eCopyright(_("Copyright")), |
3163 |
|
eArtists(_("Artists")), |
3164 |
|
eGenre(_("Genre")), |
3165 |
|
eKeywords(_("Keywords")), |
3166 |
|
eEngineer(_("Engineer")), |
3167 |
|
eTechnician(_("Technician")), |
3168 |
|
eSoftware(_("Software")), |
3169 |
|
eMedium(_("Medium")), |
3170 |
|
eSource(_("Source")), |
3171 |
|
eSourceForm(_("Source form")), |
3172 |
|
eCommissioned(_("Commissioned")), |
3173 |
|
eSubject(_("Subject")) |
3174 |
|
{ |
3175 |
|
if (!Settings::singleton()->autoRestoreWindowDimension) { |
3176 |
|
//set_default_size(470, 390); |
3177 |
|
set_position(Gtk::WIN_POS_MOUSE); |
3178 |
|
} |
3179 |
|
|
3180 |
|
set_title(_("Sample Properties")); |
3181 |
|
|
3182 |
|
tabs.append_page(vbox[1], _("Settings")); |
3183 |
|
tabs.append_page(vbox[2], _("Info")); |
3184 |
|
|
3185 |
|
connect(eName, &SampleProps::set_Name); |
3186 |
|
connect(eUnityNote, &gig::Sample::MIDIUnityNote); |
3187 |
|
connect(eLoopsCount, &gig::Sample::Loops); |
3188 |
|
connectLambda(eLoopStart, [this](uint32_t start){ |
3189 |
|
m->LoopStart = start; |
3190 |
|
m->LoopEnd = start + m->LoopSize; |
3191 |
|
}); |
3192 |
|
connectLambda(eLoopLength, [this](uint32_t length){ |
3193 |
|
m->LoopSize = length; |
3194 |
|
m->LoopEnd = m->LoopStart + length; |
3195 |
|
}); |
3196 |
|
{ |
3197 |
|
const char* choices[] = { _("normal"), _("bidirectional"), _("backward"), 0 }; |
3198 |
|
static const gig::loop_type_t values[] = { |
3199 |
|
gig::loop_type_normal, |
3200 |
|
gig::loop_type_bidirectional, |
3201 |
|
gig::loop_type_backward |
3202 |
|
}; |
3203 |
|
eLoopType.set_choices(choices, values); |
3204 |
|
} |
3205 |
|
connect(eLoopType, &gig::Sample::LoopType); |
3206 |
|
connect(eLoopPlayCount, &gig::Sample::LoopPlayCount); |
3207 |
|
|
3208 |
|
eName.signal_value_changed().connect(sig_name_changed.make_slot()); |
3209 |
|
|
3210 |
|
connect(eName2, &SampleProps::set_Name); |
3211 |
|
connectLambda(eCreationDate, [this](gig::String s) { |
3212 |
|
m->pInfo->CreationDate = s; |
3213 |
|
}); |
3214 |
|
connectLambda(eComments, [this](gig::String s) { |
3215 |
|
m->pInfo->Comments = s; |
3216 |
|
}); |
3217 |
|
connectLambda(eProduct, [this](gig::String s) { |
3218 |
|
m->pInfo->Product = s; |
3219 |
|
}); |
3220 |
|
connectLambda(eCopyright, [this](gig::String s) { |
3221 |
|
m->pInfo->Copyright = s; |
3222 |
|
}); |
3223 |
|
connectLambda(eArtists, [this](gig::String s) { |
3224 |
|
m->pInfo->Artists = s; |
3225 |
|
}); |
3226 |
|
connectLambda(eGenre, [this](gig::String s) { |
3227 |
|
m->pInfo->Genre = s; |
3228 |
|
}); |
3229 |
|
connectLambda(eKeywords, [this](gig::String s) { |
3230 |
|
m->pInfo->Keywords = s; |
3231 |
|
}); |
3232 |
|
connectLambda(eEngineer, [this](gig::String s) { |
3233 |
|
m->pInfo->Engineer = s; |
3234 |
|
}); |
3235 |
|
connectLambda(eTechnician, [this](gig::String s) { |
3236 |
|
m->pInfo->Technician = s; |
3237 |
|
}); |
3238 |
|
connectLambda(eSoftware, [this](gig::String s) { |
3239 |
|
m->pInfo->Software = s; |
3240 |
|
}); |
3241 |
|
connectLambda(eMedium, [this](gig::String s) { |
3242 |
|
m->pInfo->Medium = s; |
3243 |
|
}); |
3244 |
|
connectLambda(eSource, [this](gig::String s) { |
3245 |
|
m->pInfo->Source = s; |
3246 |
|
}); |
3247 |
|
connectLambda(eSourceForm, [this](gig::String s) { |
3248 |
|
m->pInfo->SourceForm = s; |
3249 |
|
}); |
3250 |
|
connectLambda(eCommissioned, [this](gig::String s) { |
3251 |
|
m->pInfo->Commissioned = s; |
3252 |
|
}); |
3253 |
|
connectLambda(eSubject, [this](gig::String s) { |
3254 |
|
m->pInfo->Subject = s; |
3255 |
|
}); |
3256 |
|
|
3257 |
|
// tab 1 |
3258 |
|
#if USE_GTKMM_GRID |
3259 |
|
table.set_column_spacing(5); |
3260 |
|
#else |
3261 |
|
table.set_col_spacings(5); |
3262 |
|
#endif |
3263 |
|
table.add(eName); |
3264 |
|
table.add(eUnityNote); |
3265 |
|
table.add(eSampleGroup); |
3266 |
|
table.add(eSampleFormatInfo); |
3267 |
|
table.add(eSampleID); |
3268 |
|
table.add(eChecksum); |
3269 |
|
table.add(eLoopsCount); |
3270 |
|
table.add(eLoopStart); |
3271 |
|
table.add(eLoopLength); |
3272 |
|
table.add(eLoopType); |
3273 |
|
table.add(eLoopPlayCount); |
3274 |
|
|
3275 |
|
// tab 2 |
3276 |
|
#if USE_GTKMM_GRID |
3277 |
|
table2.set_column_spacing(5); |
3278 |
|
#else |
3279 |
|
table2.set_col_spacings(5); |
3280 |
|
#endif |
3281 |
|
table2.add(eName2); |
3282 |
|
table2.add(eCreationDate); |
3283 |
|
table2.add(eComments); |
3284 |
|
table2.add(eProduct); |
3285 |
|
table2.add(eCopyright); |
3286 |
|
table2.add(eArtists); |
3287 |
|
table2.add(eGenre); |
3288 |
|
table2.add(eKeywords); |
3289 |
|
table2.add(eEngineer); |
3290 |
|
table2.add(eTechnician); |
3291 |
|
table2.add(eSoftware); |
3292 |
|
table2.add(eMedium); |
3293 |
|
table2.add(eSource); |
3294 |
|
table2.add(eSourceForm); |
3295 |
|
table2.add(eCommissioned); |
3296 |
|
table2.add(eSubject); |
3297 |
|
|
3298 |
|
add(vbox[0]); |
3299 |
|
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24) |
3300 |
|
table.set_margin(5); |
3301 |
|
#else |
3302 |
|
table.set_border_width(5); |
3303 |
|
#endif |
3304 |
|
vbox[1].pack_start(table); |
3305 |
|
vbox[2].pack_start(table2); |
3306 |
|
table.show(); |
3307 |
|
table2.show(); |
3308 |
|
vbox[0].pack_start(tabs); |
3309 |
|
vbox[0].pack_start(buttonBox, Gtk::PACK_SHRINK); |
3310 |
|
buttonBox.set_layout(Gtk::BUTTONBOX_END); |
3311 |
|
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24) |
3312 |
|
buttonBox.set_margin(5); |
3313 |
|
#else |
3314 |
|
buttonBox.set_border_width(5); |
3315 |
|
#endif |
3316 |
|
buttonBox.show(); |
3317 |
|
buttonBox.pack_start(quitButton); |
3318 |
|
quitButton.set_can_default(); |
3319 |
|
quitButton.grab_focus(); |
3320 |
|
|
3321 |
|
quitButton.signal_clicked().connect( |
3322 |
|
sigc::mem_fun(*this, &SampleProps::hide)); |
3323 |
|
|
3324 |
|
quitButton.show(); |
3325 |
|
vbox[0].show(); |
3326 |
|
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
3327 |
|
show_all_children(); |
3328 |
|
#endif |
3329 |
|
} |
3330 |
|
|
3331 |
|
void SampleProps::set_sample(gig::Sample* sample) |
3332 |
|
{ |
3333 |
|
update(sample); |
3334 |
|
|
3335 |
|
update_model++; |
3336 |
|
|
3337 |
|
// tab 1 |
3338 |
|
eName.set_value(sample->pInfo->Name); |
3339 |
|
eUnityNote.set_value(sample->MIDIUnityNote); |
3340 |
|
// show sample group name |
3341 |
|
{ |
3342 |
|
Glib::ustring s = "---"; |
3343 |
|
if (sample && sample->GetGroup()) |
3344 |
|
s = sample->GetGroup()->Name; |
3345 |
|
eSampleGroup.text.set_text(s); |
3346 |
|
} |
3347 |
|
// assemble sample format info string |
3348 |
|
{ |
3349 |
|
Glib::ustring s; |
3350 |
|
if (sample) { |
3351 |
|
switch (sample->Channels) { |
3352 |
|
case 1: s = _("Mono"); break; |
3353 |
|
case 2: s = _("Stereo"); break; |
3354 |
|
default: |
3355 |
|
s = ToString(sample->Channels) + _(" audio channels"); |
3356 |
|
break; |
3357 |
|
} |
3358 |
|
s += " " + ToString(sample->BitDepth) + " Bits"; |
3359 |
|
s += " " + ToString(sample->SamplesPerSecond/1000) + "." |
3360 |
|
+ ToString((sample->SamplesPerSecond%1000)/100) + " kHz"; |
3361 |
|
} else { |
3362 |
|
s = _("No sample assigned to this dimension region."); |
3363 |
|
} |
3364 |
|
eSampleFormatInfo.text.set_text(s); |
3365 |
|
} |
3366 |
|
// generate sample's memory address pointer string |
3367 |
|
{ |
3368 |
|
Glib::ustring s; |
3369 |
|
if (sample) { |
3370 |
|
char buf[64] = {}; |
3371 |
|
snprintf(buf, sizeof(buf), "%p", sample); |
3372 |
|
s = buf; |
3373 |
|
} else { |
3374 |
|
s = "---"; |
3375 |
|
} |
3376 |
|
eSampleID.text.set_text(s); |
3377 |
|
} |
3378 |
|
// generate raw wave form data CRC-32 checksum string |
3379 |
|
{ |
3380 |
|
Glib::ustring s = "---"; |
3381 |
|
if (sample) { |
3382 |
|
char buf[64] = {}; |
3383 |
|
snprintf(buf, sizeof(buf), "%x", sample->GetWaveDataCRC32Checksum()); |
3384 |
|
s = buf; |
3385 |
|
} |
3386 |
|
eChecksum.text.set_text(s); |
3387 |
|
} |
3388 |
|
eLoopsCount.set_value(sample->Loops); |
3389 |
|
eLoopStart.set_value(sample->LoopStart); |
3390 |
|
eLoopLength.set_value(sample->LoopSize); |
3391 |
|
eLoopType.set_value(sample->LoopType); |
3392 |
|
eLoopPlayCount.set_value(sample->LoopPlayCount); |
3393 |
|
// tab 2 |
3394 |
|
eName2.set_value(sample->pInfo->Name); |
3395 |
|
eCreationDate.set_value(sample->pInfo->CreationDate); |
3396 |
|
eComments.set_value(sample->pInfo->Comments); |
3397 |
|
eProduct.set_value(sample->pInfo->Product); |
3398 |
|
eCopyright.set_value(sample->pInfo->Copyright); |
3399 |
|
eArtists.set_value(sample->pInfo->Artists); |
3400 |
|
eGenre.set_value(sample->pInfo->Genre); |
3401 |
|
eKeywords.set_value(sample->pInfo->Keywords); |
3402 |
|
eEngineer.set_value(sample->pInfo->Engineer); |
3403 |
|
eTechnician.set_value(sample->pInfo->Technician); |
3404 |
|
eSoftware.set_value(sample->pInfo->Software); |
3405 |
|
eMedium.set_value(sample->pInfo->Medium); |
3406 |
|
eSource.set_value(sample->pInfo->Source); |
3407 |
|
eSourceForm.set_value(sample->pInfo->SourceForm); |
3408 |
|
eCommissioned.set_value(sample->pInfo->Commissioned); |
3409 |
|
eSubject.set_value(sample->pInfo->Subject); |
3410 |
|
|
3411 |
|
update_model--; |
3412 |
|
} |
3413 |
|
|
3414 |
|
void SampleProps::set_Name(const gig::String& name) |
3415 |
|
{ |
3416 |
|
m->pInfo->Name = name; |
3417 |
|
} |
3418 |
|
|
3419 |
|
void SampleProps::update_name() |
3420 |
|
{ |
3421 |
|
update_model++; |
3422 |
|
eName.set_value(m->pInfo->Name); |
3423 |
update_model--; |
update_model--; |
3424 |
} |
} |
3425 |
|
|
3453 |
} |
} |
3454 |
} |
} |
3455 |
|
|
3456 |
|
bool MainWindow::onQueryTreeViewTooltip(int x, int y, bool keyboardTip, const Glib::RefPtr<Gtk::Tooltip>& tooltip) { |
3457 |
|
Gtk::TreeModel::iterator iter; |
3458 |
|
if (!m_TreeViewInstruments.get_tooltip_context_iter(x, y, keyboardTip, iter)) { |
3459 |
|
return false; |
3460 |
|
} |
3461 |
|
Gtk::TreeModel::Path path(iter); |
3462 |
|
Gtk::TreeModel::Row row = *iter; |
3463 |
|
Gtk::TreeViewColumn* pointedColumn = NULL; |
3464 |
|
// resolve the precise table column the mouse points to |
3465 |
|
{ |
3466 |
|
Gtk::TreeModel::Path path; // unused |
3467 |
|
int cellX, cellY; // unused |
3468 |
|
m_TreeViewInstruments.get_path_at_pos(x, y, path, pointedColumn, cellX, cellY); |
3469 |
|
} |
3470 |
|
Gtk::TreeViewColumn* scriptsColumn = m_TreeViewInstruments.get_column(2); |
3471 |
|
if (pointedColumn == scriptsColumn) { // mouse hovers scripts column ... |
3472 |
|
// show the script(s) assigned to the hovered instrument as tooltip |
3473 |
|
tooltip->set_markup( row[m_InstrumentsModel.m_col_tooltip] ); |
3474 |
|
m_TreeViewInstruments.set_tooltip_cell(tooltip, &path, scriptsColumn, NULL); |
3475 |
|
} else { |
3476 |
|
// if beginners' tooltips is disabled then don't show the following one |
3477 |
|
if (!Settings::singleton()->showTooltips) |
3478 |
|
return false; |
3479 |
|
// yeah, a beginners tooltip |
3480 |
|
tooltip->set_text(_( |
3481 |
|
"Right click here for actions on instruments & MIDI Rules. " |
3482 |
|
"Drag & drop to change the order of instruments." |
3483 |
|
)); |
3484 |
|
m_TreeViewInstruments.set_tooltip_cell(tooltip, &path, pointedColumn, NULL); |
3485 |
|
} |
3486 |
|
return true; |
3487 |
|
} |
3488 |
|
|
3489 |
|
static Glib::ustring scriptTooltipFor(gig::Instrument* instrument, int index) { |
3490 |
|
Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); |
3491 |
|
const int iScriptSlots = instrument->ScriptSlotCount(); |
3492 |
|
Glib::ustring tooltip = "<u>(" + ToString(index) + ") “" + name + "”</u>\n\n"; |
3493 |
|
if (!iScriptSlots) |
3494 |
|
tooltip += "<span foreground='red'><i>No script assigned</i></span>"; |
3495 |
|
else { |
3496 |
|
for (int i = 0; i < iScriptSlots; ++i) { |
3497 |
|
tooltip += "• " + ToString(i+1) + ". Script: “<span foreground='#46DEFF'><b>" + |
3498 |
|
instrument->GetScriptOfSlot(i)->Name + "</b></span>”"; |
3499 |
|
if (i + 1 < iScriptSlots) tooltip += "\n\n"; |
3500 |
|
} |
3501 |
|
} |
3502 |
|
return tooltip; |
3503 |
|
} |
3504 |
|
|
3505 |
void MainWindow::load_gig(gig::File* gig, const char* filename, bool isSharedInstrument) |
void MainWindow::load_gig(gig::File* gig, const char* filename, bool isSharedInstrument) |
3506 |
{ |
{ |
3507 |
file = 0; |
file = 0; |
3515 |
file_has_name = filename; |
file_has_name = filename; |
3516 |
file_is_changed = false; |
file_is_changed = false; |
3517 |
|
|
3518 |
propDialog.set_file(gig); |
fileProps.set_file(gig); |
|
propDialog.set_info(gig->pInfo); |
|
3519 |
|
|
3520 |
instrument_name_connection.block(); |
instrument_name_connection.block(); |
3521 |
int index = 0; |
int index = 0; |
3524 |
Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); |
Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); |
3525 |
const int iScriptSlots = instrument->ScriptSlotCount(); |
const int iScriptSlots = instrument->ScriptSlotCount(); |
3526 |
|
|
3527 |
Gtk::TreeModel::iterator iter = m_refTreeModel->append(); |
Gtk::TreeModel::iterator iter = m_refInstrumentsTreeModel->append(); |
3528 |
Gtk::TreeModel::Row row = *iter; |
Gtk::TreeModel::Row row = *iter; |
3529 |
row[m_Columns.m_col_nr] = index; |
row[m_InstrumentsModel.m_col_nr] = index; |
3530 |
row[m_Columns.m_col_name] = name; |
row[m_InstrumentsModel.m_col_name] = name; |
3531 |
row[m_Columns.m_col_instr] = instrument; |
row[m_InstrumentsModel.m_col_instr] = instrument; |
3532 |
row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : ""; |
row[m_InstrumentsModel.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : ""; |
3533 |
|
row[m_InstrumentsModel.m_col_tooltip] = scriptTooltipFor(instrument, index); |
3534 |
|
|
3535 |
#if !USE_GTKMM_BUILDER |
#if !USE_GTKMM_BUILDER |
3536 |
add_instrument_to_menu(name); |
add_instrument_to_menu(name); |
3592 |
file = gig; |
file = gig; |
3593 |
|
|
3594 |
// select the first instrument |
// select the first instrument |
3595 |
m_TreeView.get_selection()->select(Gtk::TreePath("0")); |
m_TreeViewInstruments.get_selection()->select(Gtk::TreePath("0")); |
3596 |
|
|
3597 |
instr_props_set_instrument(); |
instr_props_set_instrument(); |
3598 |
gig::Instrument* instrument = get_instrument(); |
gig::Instrument* instrument = get_instrument(); |
3605 |
{ |
{ |
3606 |
instrumentProps.signal_name_changed().clear(); |
instrumentProps.signal_name_changed().clear(); |
3607 |
|
|
3608 |
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(); |
3609 |
if (rows.empty()) { |
if (rows.empty()) { |
3610 |
instrumentProps.hide(); |
instrumentProps.hide(); |
3611 |
return false; |
return false; |
3612 |
} |
} |
3613 |
//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. |
3614 |
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]); |
Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(rows[0]); |
3615 |
if (it) { |
if (it) { |
3616 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
3617 |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
gig::Instrument* instrument = row[m_InstrumentsModel.m_col_instr]; |
3618 |
|
|
3619 |
instrumentProps.set_instrument(instrument); |
instrumentProps.set_instrument(instrument); |
3620 |
|
|
3643 |
void MainWindow::instr_name_changed_by_instr_props(Gtk::TreeModel::iterator& it) |
void MainWindow::instr_name_changed_by_instr_props(Gtk::TreeModel::iterator& it) |
3644 |
{ |
{ |
3645 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
3646 |
Glib::ustring name = row[m_Columns.m_col_name]; |
Glib::ustring name = row[m_InstrumentsModel.m_col_name]; |
3647 |
|
|
3648 |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
gig::Instrument* instrument = row[m_InstrumentsModel.m_col_instr]; |
3649 |
Glib::ustring gigname(gig_to_utf8(instrument->pInfo->Name)); |
Glib::ustring gigname(gig_to_utf8(instrument->pInfo->Name)); |
3650 |
if (gigname != name) { |
if (gigname != name) { |
3651 |
row[m_Columns.m_col_name] = gigname; |
Gtk::TreeModel::Path path(*it); |
3652 |
|
const int index = path[0]; |
3653 |
|
row[m_InstrumentsModel.m_col_name] = gigname; |
3654 |
|
row[m_InstrumentsModel.m_col_tooltip] = scriptTooltipFor(instrument, index); |
3655 |
|
} |
3656 |
|
} |
3657 |
|
|
3658 |
|
bool MainWindow::sample_props_set_sample() |
3659 |
|
{ |
3660 |
|
sampleProps.signal_name_changed().clear(); |
3661 |
|
|
3662 |
|
std::vector<Gtk::TreeModel::Path> rows = m_TreeViewSamples.get_selection()->get_selected_rows(); |
3663 |
|
if (rows.empty()) { |
3664 |
|
sampleProps.hide(); |
3665 |
|
return false; |
3666 |
|
} |
3667 |
|
//NOTE: was const_iterator before, which did not compile with GTKMM4 development branch, probably going to be fixed before final GTKMM4 release though. |
3668 |
|
Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[0]); |
3669 |
|
if (it) { |
3670 |
|
Gtk::TreeModel::Row row = *it; |
3671 |
|
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
3672 |
|
|
3673 |
|
sampleProps.set_sample(sample); |
3674 |
|
|
3675 |
|
// make sure sample tree is updated when user changes the |
3676 |
|
// sample name in sample properties window |
3677 |
|
sampleProps.signal_name_changed().connect( |
3678 |
|
sigc::bind( |
3679 |
|
sigc::mem_fun(*this, |
3680 |
|
&MainWindow::sample_name_changed_by_sample_props |
3681 |
|
), it |
3682 |
|
) |
3683 |
|
); |
3684 |
|
} else { |
3685 |
|
sampleProps.hide(); |
3686 |
|
} |
3687 |
|
//NOTE: explicit boolean cast required for GTKMM4 development branch here |
3688 |
|
return it ? true : false; |
3689 |
|
} |
3690 |
|
|
3691 |
|
void MainWindow::show_sample_props() |
3692 |
|
{ |
3693 |
|
if (sample_props_set_sample()) { |
3694 |
|
sampleProps.show(); |
3695 |
|
sampleProps.deiconify(); |
3696 |
|
} |
3697 |
|
} |
3698 |
|
|
3699 |
|
void MainWindow::sample_name_changed_by_sample_props(Gtk::TreeModel::iterator& it) |
3700 |
|
{ |
3701 |
|
Gtk::TreeModel::Row row = *it; |
3702 |
|
Glib::ustring name = row[m_SamplesModel.m_col_name]; |
3703 |
|
|
3704 |
|
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
3705 |
|
Glib::ustring gigname(gig_to_utf8(sample->pInfo->Name)); |
3706 |
|
if (gigname != name) { |
3707 |
|
Gtk::TreeModel::Path path(*it); |
3708 |
|
row[m_SamplesModel.m_col_name] = gigname; |
3709 |
} |
} |
3710 |
} |
} |
3711 |
|
|
3722 |
void MainWindow::show_script_slots() { |
void MainWindow::show_script_slots() { |
3723 |
if (!file) return; |
if (!file) return; |
3724 |
// get selected instrument |
// get selected instrument |
3725 |
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(); |
3726 |
if (rows.empty()) return; |
if (rows.empty()) return; |
3727 |
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]); |
Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(rows[0]); |
3728 |
if (!it) return; |
if (!it) return; |
3729 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
3730 |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
gig::Instrument* instrument = row[m_InstrumentsModel.m_col_instr]; |
3731 |
if (!instrument) return; |
if (!instrument) return; |
3732 |
|
|
3733 |
ScriptSlots* window = new ScriptSlots; |
ScriptSlots* window = new ScriptSlots; |
3743 |
if (!pInstrument) return; |
if (!pInstrument) return; |
3744 |
const int iScriptSlots = pInstrument->ScriptSlotCount(); |
const int iScriptSlots = pInstrument->ScriptSlotCount(); |
3745 |
|
|
3746 |
//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! |
3747 |
//Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model(); |
//Glib::RefPtr<Gtk::TreeModel> model = m_TreeViewInstruments.get_model(); |
3748 |
Glib::RefPtr<Gtk::TreeModel> model = m_refTreeModelFilter->get_model(); |
Glib::RefPtr<Gtk::TreeModel> model = m_refInstrumentsModelFilter->get_model(); |
3749 |
|
|
3750 |
for (int i = 0; i < model->children().size(); ++i) { |
for (int i = 0; i < model->children().size(); ++i) { |
3751 |
Gtk::TreeModel::Row row = model->children()[i]; |
Gtk::TreeModel::Row row = model->children()[i]; |
3752 |
if (row[m_Columns.m_col_instr] != pInstrument) continue; |
if (row[m_InstrumentsModel.m_col_instr] != pInstrument) continue; |
3753 |
row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : ""; |
row[m_InstrumentsModel.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : ""; |
3754 |
|
row[m_InstrumentsModel.m_col_tooltip] = scriptTooltipFor(pInstrument, i); |
3755 |
break; |
break; |
3756 |
} |
} |
3757 |
|
|
3758 |
// causes the sampler to reload the instrument with the new script |
// causes the sampler to reload the instrument with the new script |
3759 |
on_sel_change(); |
on_sel_change(); |
3760 |
|
|
3761 |
|
// force script 'patch' variables editor ("Script" tab) to be refreshed |
3762 |
|
dimreg_edit.scriptVars.setInstrument(pInstrument, true/*force update*/); |
3763 |
} |
} |
3764 |
|
|
3765 |
void MainWindow::assignScript(gig::Script* pScript) { |
void MainWindow::assignScript(gig::Script* pScript) { |
3780 |
onScriptSlotsModified(pInstrument); |
onScriptSlotsModified(pInstrument); |
3781 |
} |
} |
3782 |
|
|
3783 |
|
void MainWindow::dropAllScriptSlots() { |
3784 |
|
gig::Instrument* pInstrument = get_instrument(); |
3785 |
|
if (!pInstrument) { |
3786 |
|
printf("!instrument\n"); |
3787 |
|
return; |
3788 |
|
} |
3789 |
|
|
3790 |
|
const int iScriptSlots = pInstrument->ScriptSlotCount(); |
3791 |
|
for (int i = iScriptSlots - 1; i >= 0; --i) |
3792 |
|
pInstrument->RemoveScriptSlot(i); |
3793 |
|
|
3794 |
|
onScriptSlotsModified(pInstrument); |
3795 |
|
} |
3796 |
|
|
3797 |
void MainWindow::on_action_refresh_all() { |
void MainWindow::on_action_refresh_all() { |
3798 |
__refreshEntireGUI(); |
__refreshEntireGUI(); |
3799 |
} |
} |
3840 |
#endif |
#endif |
3841 |
} |
} |
3842 |
|
|
3843 |
|
void MainWindow::on_instr_double_click_opens_props() { |
3844 |
|
#if USE_GLIB_ACTION |
3845 |
|
bool active = false; |
3846 |
|
m_actionInstrDoubleClickOpensProps->get_state(active); |
3847 |
|
// for some reason toggle state does not change automatically |
3848 |
|
active = !active; |
3849 |
|
m_actionInstrDoubleClickOpensProps->change_state(active); |
3850 |
|
Settings::singleton()->instrumentDoubleClickOpensProps = active; |
3851 |
|
#else |
3852 |
|
Gtk::CheckMenuItem* item = |
3853 |
|
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/OpenInstrPropsByDoubleClick")); |
3854 |
|
if (!item) { |
3855 |
|
std::cerr << "/MenuBar/MenuView/OpenInstrPropsByDoubleClick == NULL\n"; |
3856 |
|
return; |
3857 |
|
} |
3858 |
|
Settings::singleton()->instrumentDoubleClickOpensProps = item->get_active(); |
3859 |
|
#endif |
3860 |
|
} |
3861 |
|
|
3862 |
void MainWindow::on_save_with_temporary_file() { |
void MainWindow::on_save_with_temporary_file() { |
3863 |
#if USE_GLIB_ACTION |
#if USE_GLIB_ACTION |
3864 |
bool active = false; |
bool active = false; |
3933 |
void MainWindow::on_button_release(GdkEventButton* button) { |
void MainWindow::on_button_release(GdkEventButton* button) { |
3934 |
#endif |
#endif |
3935 |
if (button->type == GDK_2BUTTON_PRESS) { |
if (button->type == GDK_2BUTTON_PRESS) { |
3936 |
show_instr_props(); |
if (Settings::singleton()->instrumentDoubleClickOpensProps) |
3937 |
|
show_instr_props(); |
3938 |
} else if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
} else if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
3939 |
// gig v2 files have no midi rules |
// gig v2 files have no midi rules |
3940 |
const bool bEnabled = !(file->pVersion && file->pVersion->major == 2); |
const bool bEnabled = !(file->pVersion && file->pVersion->major == 2); |
3966 |
find(children.begin(), children.end(), item); |
find(children.begin(), children.end(), item); |
3967 |
if (it != children.end()) { |
if (it != children.end()) { |
3968 |
int index = it - children.begin(); |
int index = it - children.begin(); |
3969 |
m_TreeView.get_selection()->select(Gtk::TreePath(ToString(index))); |
m_TreeViewInstruments.get_selection()->select(Gtk::TreePath(ToString(index))); |
3970 |
|
|
3971 |
m_RegionChooser.set_instrument(file->GetInstrument(index)); |
m_RegionChooser.set_instrument(file->GetInstrument(index)); |
3972 |
} |
} |
3974 |
} |
} |
3975 |
#endif |
#endif |
3976 |
|
|
3977 |
|
void MainWindow::on_action_move_instr() { |
3978 |
|
gig::Instrument* instr = get_instrument(); |
3979 |
|
if (!instr) return; |
3980 |
|
|
3981 |
|
int currentIndex = getIndexOf(instr); |
3982 |
|
|
3983 |
|
Gtk::Dialog dialog(_("Move Instrument"), true /*modal*/); |
3984 |
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
3985 |
|
Gtk::Adjustment adjustment( |
3986 |
|
currentIndex, |
3987 |
|
0 /*min*/, file->CountInstruments() - 1 /*max*/ |
3988 |
|
); |
3989 |
|
Gtk::SpinButton spinBox(adjustment); |
3990 |
|
#else |
3991 |
|
Gtk::SpinButton spinBox( |
3992 |
|
Gtk::Adjustment::create( |
3993 |
|
currentIndex, |
3994 |
|
0 /*min*/, file->CountInstruments() - 1 /*max*/ |
3995 |
|
) |
3996 |
|
); |
3997 |
|
#endif |
3998 |
|
#if USE_GTKMM_BOX |
3999 |
|
dialog.get_content_area()->pack_start(spinBox); |
4000 |
|
#else |
4001 |
|
dialog.get_vbox()->pack_start(spinBox); |
4002 |
|
#endif |
4003 |
|
#if HAS_GTKMM_STOCK |
4004 |
|
Gtk::Button* okButton = dialog.add_button(Gtk::Stock::OK, 0); |
4005 |
|
dialog.add_button(Gtk::Stock::CANCEL, 1); |
4006 |
|
#else |
4007 |
|
Gtk::Button* okButton = dialog.add_button(_("_OK"), 0); |
4008 |
|
dialog.add_button(_("_Cancel"), 1); |
4009 |
|
#endif |
4010 |
|
okButton->set_sensitive(false); |
4011 |
|
// show the dialog at a reasonable screen position |
4012 |
|
dialog.set_position(Gtk::WIN_POS_MOUSE); |
4013 |
|
// only enable the 'OK' button if entered new index is not instrument's |
4014 |
|
// current index already |
4015 |
|
spinBox.signal_value_changed().connect([&]{ |
4016 |
|
okButton->set_sensitive( spinBox.get_value_as_int() != currentIndex ); |
4017 |
|
}); |
4018 |
|
// usability acceleration: if user hits enter key on the text entry field |
4019 |
|
// then auto trigger the 'OK' button |
4020 |
|
spinBox.signal_activate().connect([&]{ |
4021 |
|
if (okButton->get_sensitive()) |
4022 |
|
okButton->clicked(); |
4023 |
|
}); |
4024 |
|
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
4025 |
|
dialog.show_all_children(); |
4026 |
|
#endif |
4027 |
|
if (!dialog.run()) { // 'OK' selected ... |
4028 |
|
int newIndex = spinBox.get_value_as_int(); |
4029 |
|
printf("MOVE TO %d\n", newIndex); |
4030 |
|
gig::Instrument* dst = file->GetInstrument(newIndex); |
4031 |
|
instr->MoveTo(dst); |
4032 |
|
__refreshEntireGUI(); |
4033 |
|
select_instrument(instr); |
4034 |
|
} |
4035 |
|
} |
4036 |
|
|
4037 |
void MainWindow::select_instrument(gig::Instrument* instrument) { |
void MainWindow::select_instrument(gig::Instrument* instrument) { |
4038 |
if (!instrument) return; |
if (!instrument) return; |
4039 |
|
|
4040 |
//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! |
4041 |
Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model(); |
Glib::RefPtr<Gtk::TreeModel> model = m_TreeViewInstruments.get_model(); |
4042 |
//Glib::RefPtr<Gtk::TreeModel> model = m_refTreeModelFilter->get_model(); |
//Glib::RefPtr<Gtk::TreeModel> model = m_refInstrumentsModelFilter->get_model(); |
4043 |
|
|
4044 |
for (int i = 0; i < model->children().size(); ++i) { |
for (int i = 0; i < model->children().size(); ++i) { |
4045 |
Gtk::TreeModel::Row row = model->children()[i]; |
Gtk::TreeModel::Row row = model->children()[i]; |
4046 |
if (row[m_Columns.m_col_instr] == instrument) { |
if (row[m_InstrumentsModel.m_col_instr] == instrument) { |
4047 |
// select and show the respective instrument in the list view |
// select and show the respective instrument in the list view |
4048 |
show_intruments_tab(); |
show_intruments_tab(); |
4049 |
m_TreeView.get_selection()->unselect_all(); |
m_TreeViewInstruments.get_selection()->unselect_all(); |
4050 |
|
|
4051 |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22) |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24) |
4052 |
auto iterSel = model->children()[i].get_iter(); |
auto iterSel = model->children()[i].get_iter(); |
4053 |
m_TreeView.get_selection()->select(iterSel); |
m_TreeViewInstruments.get_selection()->select(iterSel); |
4054 |
#else |
#else |
4055 |
m_TreeView.get_selection()->select(model->children()[i]); |
m_TreeViewInstruments.get_selection()->select(model->children()[i]); |
4056 |
#endif |
#endif |
4057 |
std::vector<Gtk::TreeModel::Path> rows = |
std::vector<Gtk::TreeModel::Path> rows = |
4058 |
m_TreeView.get_selection()->get_selected_rows(); |
m_TreeViewInstruments.get_selection()->get_selected_rows(); |
4059 |
if (!rows.empty()) |
if (!rows.empty()) |
4060 |
m_TreeView.scroll_to_row(rows[0]); |
m_TreeViewInstruments.scroll_to_row(rows[0]); |
4061 |
on_sel_change(); // the regular instrument selection change callback |
on_sel_change(); // the regular instrument selection change callback |
4062 |
} |
} |
4063 |
} |
} |
4068 |
gig::Region* pRegion = (gig::Region*) dimRgn->GetParent(); |
gig::Region* pRegion = (gig::Region*) dimRgn->GetParent(); |
4069 |
gig::Instrument* pInstrument = (gig::Instrument*) pRegion->GetParent(); |
gig::Instrument* pInstrument = (gig::Instrument*) pRegion->GetParent(); |
4070 |
|
|
4071 |
//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! |
4072 |
Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model(); |
Glib::RefPtr<Gtk::TreeModel> model = m_TreeViewInstruments.get_model(); |
4073 |
//Glib::RefPtr<Gtk::TreeModel> model = m_refTreeModelFilter->get_model(); |
//Glib::RefPtr<Gtk::TreeModel> model = m_refInstrumentsModelFilter->get_model(); |
4074 |
|
|
4075 |
for (int i = 0; i < model->children().size(); ++i) { |
for (int i = 0; i < model->children().size(); ++i) { |
4076 |
Gtk::TreeModel::Row row = model->children()[i]; |
Gtk::TreeModel::Row row = model->children()[i]; |
4077 |
if (row[m_Columns.m_col_instr] == pInstrument) { |
if (row[m_InstrumentsModel.m_col_instr] == pInstrument) { |
4078 |
// select and show the respective instrument in the list view |
// select and show the respective instrument in the list view |
4079 |
show_intruments_tab(); |
show_intruments_tab(); |
4080 |
m_TreeView.get_selection()->unselect_all(); |
m_TreeViewInstruments.get_selection()->unselect_all(); |
4081 |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22) |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24) |
4082 |
auto iterSel = model->children()[i].get_iter(); |
auto iterSel = model->children()[i].get_iter(); |
4083 |
m_TreeView.get_selection()->select(iterSel); |
m_TreeViewInstruments.get_selection()->select(iterSel); |
4084 |
#else |
#else |
4085 |
m_TreeView.get_selection()->select(model->children()[i]); |
m_TreeViewInstruments.get_selection()->select(model->children()[i]); |
4086 |
#endif |
#endif |
4087 |
std::vector<Gtk::TreeModel::Path> rows = |
std::vector<Gtk::TreeModel::Path> rows = |
4088 |
m_TreeView.get_selection()->get_selected_rows(); |
m_TreeViewInstruments.get_selection()->get_selected_rows(); |
4089 |
if (!rows.empty()) |
if (!rows.empty()) |
4090 |
m_TreeView.scroll_to_row(rows[0]); |
m_TreeViewInstruments.scroll_to_row(rows[0]); |
4091 |
on_sel_change(); // the regular instrument selection change callback |
on_sel_change(); // the regular instrument selection change callback |
4092 |
|
|
4093 |
// select respective region in the region selector |
// select respective region in the region selector |
4114 |
if (rowSample[m_SamplesModel.m_col_sample] == sample) { |
if (rowSample[m_SamplesModel.m_col_sample] == sample) { |
4115 |
show_samples_tab(); |
show_samples_tab(); |
4116 |
m_TreeViewSamples.get_selection()->unselect_all(); |
m_TreeViewSamples.get_selection()->unselect_all(); |
4117 |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22) |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24) |
4118 |
auto iterSel = rowGroup.children()[s].get_iter(); |
auto iterSel = rowGroup.children()[s].get_iter(); |
4119 |
m_TreeViewSamples.get_selection()->select(iterSel); |
m_TreeViewSamples.get_selection()->select(iterSel); |
4120 |
#else |
#else |
4314 |
assign_scripts_menu->append(*item); |
assign_scripts_menu->append(*item); |
4315 |
} |
} |
4316 |
|
|
4317 |
|
// add separator line to menu |
4318 |
|
assign_scripts_menu->append(*new Gtk::SeparatorMenuItem); |
4319 |
|
|
4320 |
|
{ |
4321 |
|
Gtk::MenuItem* item = new Gtk::MenuItem(_("Unassign All Scripts")); |
4322 |
|
item->signal_activate().connect( |
4323 |
|
sigc::mem_fun(*this, &MainWindow::dropAllScriptSlots) |
4324 |
|
); |
4325 |
|
assign_scripts_menu->append(*item); |
4326 |
|
item->set_accel_path("<Scripts>/DropAllScriptSlots"); |
4327 |
|
} |
4328 |
|
|
4329 |
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
4330 |
assign_scripts_menu->show_all_children(); |
assign_scripts_menu->show_all_children(); |
4331 |
#endif |
#endif |
4372 |
|
|
4373 |
// update instrument tree view |
// update instrument tree view |
4374 |
instrument_name_connection.block(); |
instrument_name_connection.block(); |
4375 |
Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append(); |
Gtk::TreeModel::iterator iterInstr = m_refInstrumentsTreeModel->append(); |
4376 |
Gtk::TreeModel::Row rowInstr = *iterInstr; |
Gtk::TreeModel::Row rowInstr = *iterInstr; |
4377 |
rowInstr[m_Columns.m_col_nr] = m_refTreeModel->children().size() - 1; |
const int index = m_refInstrumentsTreeModel->children().size() - 1; |
4378 |
rowInstr[m_Columns.m_col_name] = name; |
const int iScriptSlots = instrument->ScriptSlotCount(); |
4379 |
rowInstr[m_Columns.m_col_instr] = instrument; |
rowInstr[m_InstrumentsModel.m_col_nr] = index; |
4380 |
rowInstr[m_Columns.m_col_scripts] = ""; |
rowInstr[m_InstrumentsModel.m_col_name] = name; |
4381 |
|
rowInstr[m_InstrumentsModel.m_col_instr] = instrument; |
4382 |
|
rowInstr[m_InstrumentsModel.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : ""; |
4383 |
|
rowInstr[m_InstrumentsModel.m_col_tooltip] = scriptTooltipFor(instrument, index); |
4384 |
instrument_name_connection.unblock(); |
instrument_name_connection.unblock(); |
4385 |
|
|
4386 |
#if !USE_GTKMM_BUILDER |
#if !USE_GTKMM_BUILDER |
4406 |
|
|
4407 |
// retrieve the currently selected instrument |
// retrieve the currently selected instrument |
4408 |
// (being the original instrument to be duplicated) |
// (being the original instrument to be duplicated) |
4409 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewInstruments.get_selection(); |
4410 |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
4411 |
for (int r = 0; r < rows.size(); ++r) { |
for (int r = 0; r < rows.size(); ++r) { |
4412 |
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[r]); |
Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(rows[r]); |
4413 |
if (it) { |
if (it) { |
4414 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
4415 |
gig::Instrument* instrOrig = row[m_Columns.m_col_instr]; |
gig::Instrument* instrOrig = row[m_InstrumentsModel.m_col_instr]; |
4416 |
if (instrOrig) { |
if (instrOrig) { |
4417 |
// duplicate the orginal instrument |
// duplicate the orginal instrument |
4418 |
gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig); |
gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig); |
4439 |
return; |
return; |
4440 |
} |
} |
4441 |
|
|
4442 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewInstruments.get_selection(); |
4443 |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
4444 |
for (int r = rows.size() - 1; r >= 0; --r) { |
for (int r = rows.size() - 1; r >= 0; --r) { |
4445 |
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[r]); |
Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(rows[r]); |
4446 |
if (!it) continue; |
if (!it) continue; |
4447 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
4448 |
gig::Instrument* instr = row[m_Columns.m_col_instr]; |
gig::Instrument* instr = row[m_InstrumentsModel.m_col_instr]; |
4449 |
try { |
try { |
4450 |
Gtk::TreePath path(it); |
Gtk::TreePath path(it); |
4451 |
int index = path[0]; |
int index = path[0]; |
4459 |
#endif |
#endif |
4460 |
|
|
4461 |
// remove row from instruments tree view |
// remove row from instruments tree view |
4462 |
m_refTreeModel->erase(it); |
m_refInstrumentsTreeModel->erase(it); |
4463 |
// update "Nr" column of all instrument rows |
// update "Nr" column of all instrument rows |
4464 |
{ |
{ |
4465 |
int index = 0; |
int index = 0; |
4466 |
for (Gtk::TreeModel::iterator it = m_refTreeModel->children().begin(); |
for (Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->children().begin(); |
4467 |
it != m_refTreeModel->children().end(); ++it, ++index) |
it != m_refInstrumentsTreeModel->children().end(); ++it, ++index) |
4468 |
{ |
{ |
4469 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
4470 |
row[m_Columns.m_col_nr] = index; |
gig::Instrument* instrument = row[m_InstrumentsModel.m_col_instr]; |
4471 |
|
row[m_InstrumentsModel.m_col_nr] = index; |
4472 |
|
row[m_InstrumentsModel.m_col_tooltip] = scriptTooltipFor(instrument, index); |
4473 |
} |
} |
4474 |
} |
} |
4475 |
|
|
4476 |
#if GTKMM_MAJOR_VERSION < 3 |
#if GTKMM_MAJOR_VERSION < 3 |
4477 |
// select another instrument (in gtk3 this is done |
// select another instrument (in gtk3 this is done |
4478 |
// automatically) |
// automatically) |
4479 |
if (!m_refTreeModel->children().empty()) { |
if (!m_refInstrumentsTreeModel->children().empty()) { |
4480 |
if (index == m_refTreeModel->children().size()) { |
if (index == m_refInstrumentsTreeModel->children().size()) { |
4481 |
index--; |
index--; |
4482 |
} |
} |
4483 |
m_TreeView.get_selection()->select( |
m_TreeViewInstruments.get_selection()->select( |
4484 |
Gtk::TreePath(ToString(index))); |
Gtk::TreePath(ToString(index))); |
4485 |
} |
} |
4486 |
#endif |
#endif |
4499 |
} |
} |
4500 |
|
|
4501 |
void MainWindow::on_action_sample_properties() { |
void MainWindow::on_action_sample_properties() { |
4502 |
//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(); |
|
4503 |
} |
} |
4504 |
|
|
4505 |
void MainWindow::on_action_add_script_group() { |
void MainWindow::on_action_add_script_group() { |
4562 |
if (!it) return; |
if (!it) return; |
4563 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
4564 |
gig::Script* script = row[m_ScriptsModel.m_col_script]; |
gig::Script* script = row[m_ScriptsModel.m_col_script]; |
4565 |
if (!script) return; |
editScript(script); |
4566 |
|
} |
4567 |
|
|
4568 |
|
void MainWindow::editScript(gig::Script* script) { |
4569 |
|
if (!script) return; |
4570 |
ScriptEditor* editor = new ScriptEditor; |
ScriptEditor* editor = new ScriptEditor; |
4571 |
editor->signal_script_to_be_changed.connect( |
editor->signal_script_to_be_changed.connect( |
4572 |
signal_script_to_be_changed.make_slot() |
signal_script_to_be_changed.make_slot() |
4573 |
); |
); |
4574 |
editor->signal_script_changed.connect( |
editor->signal_script_changed.connect([this](gig::Script* script) { |
4575 |
signal_script_changed.make_slot() |
// signal to sampler (which will reload the script due to this) |
4576 |
); |
signal_script_changed.emit(script); |
4577 |
|
// force script 'patch' variables editor ("Script" tab) to be refreshed |
4578 |
|
gig::Instrument* instr = get_instrument(); |
4579 |
|
dimreg_edit.scriptVars.setInstrument(instr, true/*force update*/); |
4580 |
|
}); |
4581 |
editor->setScript(script); |
editor->setScript(script); |
4582 |
//editor->reparent(*this); |
//editor->reparent(*this); |
4583 |
editor->show(); |
editor->show(); |
4725 |
dialog.set_current_folder(current_sample_dir); |
dialog.set_current_folder(current_sample_dir); |
4726 |
} |
} |
4727 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
4728 |
|
dialog.hide(); |
4729 |
current_sample_dir = dialog.get_current_folder(); |
current_sample_dir = dialog.get_current_folder(); |
4730 |
Glib::ustring error_files; |
Glib::ustring error_files; |
4731 |
std::vector<std::string> filenames = dialog.get_filenames(); |
std::vector<std::string> filenames = dialog.get_filenames(); |
4906 |
} |
} |
4907 |
if (dialog.run() == Gtk::RESPONSE_OK) |
if (dialog.run() == Gtk::RESPONSE_OK) |
4908 |
{ |
{ |
4909 |
|
dialog.hide(); |
4910 |
current_sample_dir = dialog.get_current_folder(); |
current_sample_dir = dialog.get_current_folder(); |
4911 |
Glib::ustring error_files; |
Glib::ustring error_files; |
4912 |
std::string folder = dialog.get_filename(); |
std::string folder = dialog.get_filename(); |
5132 |
// get selected source instrument |
// get selected source instrument |
5133 |
gig::Instrument* src = NULL; |
gig::Instrument* src = NULL; |
5134 |
{ |
{ |
5135 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewInstruments.get_selection(); |
5136 |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
5137 |
if (!rows.empty()) { |
if (!rows.empty()) { |
5138 |
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]); |
Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(rows[0]); |
5139 |
if (it) { |
if (it) { |
5140 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
5141 |
src = row[m_Columns.m_col_instr]; |
src = row[m_InstrumentsModel.m_col_instr]; |
5142 |
} |
} |
5143 |
} |
} |
5144 |
} |
} |
5160 |
gig::Instrument* dst = NULL; |
gig::Instrument* dst = NULL; |
5161 |
{ |
{ |
5162 |
Gtk::TreeModel::Path path; |
Gtk::TreeModel::Path path; |
5163 |
const bool found = m_TreeView.get_path_at_pos(x, y, path); |
const bool found = m_TreeViewInstruments.get_path_at_pos(x, y, path); |
5164 |
if (!found) return; |
if (!found) return; |
5165 |
|
|
5166 |
Gtk::TreeModel::iterator iter = m_refTreeModel->get_iter(path); |
Gtk::TreeModel::iterator iter = m_refInstrumentsTreeModel->get_iter(path); |
5167 |
if (!iter) return; |
if (!iter) return; |
5168 |
Gtk::TreeModel::Row row = *iter; |
Gtk::TreeModel::Row row = *iter; |
5169 |
dst = row[m_Columns.m_col_instr]; |
dst = row[m_InstrumentsModel.m_col_instr]; |
5170 |
} |
} |
5171 |
if (!dst) return; |
if (!dst) return; |
5172 |
|
|
5305 |
file_changed(); |
file_changed(); |
5306 |
} |
} |
5307 |
} |
} |
5308 |
|
// change name in the sample properties window |
5309 |
|
if (sampleProps.get_sample() == sample && sample) { |
5310 |
|
sampleProps.set_sample(sample); |
5311 |
|
} |
5312 |
} |
} |
5313 |
|
|
5314 |
void MainWindow::script_name_changed(const Gtk::TreeModel::Path& path, |
void MainWindow::script_name_changed(const Gtk::TreeModel::Path& path, |
5341 |
if (!iter) return; |
if (!iter) return; |
5342 |
Gtk::TreeModel::Row row = *iter; |
Gtk::TreeModel::Row row = *iter; |
5343 |
gig::Script* script = row[m_ScriptsModel.m_col_script]; |
gig::Script* script = row[m_ScriptsModel.m_col_script]; |
5344 |
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(); |
|
5345 |
} |
} |
5346 |
|
|
5347 |
void MainWindow::instrument_name_changed(const Gtk::TreeModel::Path& path, |
void MainWindow::instrument_name_changed(const Gtk::TreeModel::Path& path, |
5348 |
const Gtk::TreeModel::iterator& iter) { |
const Gtk::TreeModel::iterator& iter) { |
5349 |
if (!iter) return; |
if (!iter) return; |
5350 |
Gtk::TreeModel::Row row = *iter; |
Gtk::TreeModel::Row row = *iter; |
5351 |
Glib::ustring name = row[m_Columns.m_col_name]; |
Glib::ustring name = row[m_InstrumentsModel.m_col_name]; |
5352 |
|
|
5353 |
#if !USE_GTKMM_BUILDER |
#if !USE_GTKMM_BUILDER |
5354 |
// change name in instrument menu |
// change name in instrument menu |
5366 |
#endif |
#endif |
5367 |
|
|
5368 |
// change name in gig |
// change name in gig |
5369 |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
gig::Instrument* instrument = row[m_InstrumentsModel.m_col_instr]; |
5370 |
gig::String gigname(gig_from_utf8(name)); |
gig::String gigname(gig_from_utf8(name)); |
5371 |
if (instrument && instrument->pInfo->Name != gigname) { |
if (instrument && instrument->pInfo->Name != gigname) { |
5372 |
instrument->pInfo->Name = gigname; |
instrument->pInfo->Name = gigname; |
5388 |
trim(pattern); |
trim(pattern); |
5389 |
if (pattern.empty()) return true; |
if (pattern.empty()) return true; |
5390 |
|
|
5391 |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22) |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24) |
5392 |
//HACK: on GTKMM4 development branch const_iterator cannot be easily converted to iterator, probably going to be fixed before final GTKMM4 release though. |
//HACK: on GTKMM4 development branch const_iterator cannot be easily converted to iterator, probably going to be fixed before final GTKMM4 release though. |
5393 |
Gtk::TreeModel::Row row = **(Gtk::TreeModel::iterator*)(&iter); |
Gtk::TreeModel::Row row = **(Gtk::TreeModel::iterator*)(&iter); |
5394 |
#else |
#else |
5395 |
Gtk::TreeModel::Row row = *iter; |
Gtk::TreeModel::Row row = *iter; |
5396 |
#endif |
#endif |
5397 |
Glib::ustring name = row[m_Columns.m_col_name]; |
Glib::ustring name = row[m_InstrumentsModel.m_col_name]; |
5398 |
name = name.lowercase(); |
name = name.lowercase(); |
5399 |
|
|
5400 |
std::vector<Glib::ustring> tokens = Glib::Regex::split_simple(" ", pattern); |
std::vector<Glib::ustring> tokens = Glib::Regex::split_simple(" ", pattern); |
5412 |
// list view as pre-selection |
// list view as pre-selection |
5413 |
std::set<int> indeces; |
std::set<int> indeces; |
5414 |
{ |
{ |
5415 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewInstruments.get_selection(); |
5416 |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
5417 |
for (int r = 0; r < rows.size(); ++r) { |
for (int r = 0; r < rows.size(); ++r) { |
5418 |
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[r]); |
Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(rows[r]); |
5419 |
if (it) { |
if (it) { |
5420 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
5421 |
int index = row[m_Columns.m_col_nr]; |
int index = row[m_InstrumentsModel.m_col_nr]; |
5422 |
indeces.insert(index); |
indeces.insert(index); |
5423 |
} |
} |
5424 |
} |
} |
5628 |
#endif |
#endif |
5629 |
|
|
5630 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
5631 |
|
dialog.hide(); |
5632 |
|
#ifdef GLIB_THREADS |
5633 |
printf("on_action_merge_files self=%p\n", |
printf("on_action_merge_files self=%p\n", |
5634 |
static_cast<void*>(Glib::Threads::Thread::self())); |
static_cast<void*>(Glib::Threads::Thread::self())); |
5635 |
|
#else |
5636 |
|
std::cout << "on_action_merge_files self=" << |
5637 |
|
std::this_thread::get_id() << "\n"; |
5638 |
|
#endif |
5639 |
std::vector<std::string> filenames = dialog.get_filenames(); |
std::vector<std::string> filenames = dialog.get_filenames(); |
5640 |
|
|
5641 |
// merge the selected files to the currently open .gig file |
// merge the selected files to the currently open .gig file |