62 |
#include "gfx/builtinpix.h" |
#include "gfx/builtinpix.h" |
63 |
#include "MacroEditor.h" |
#include "MacroEditor.h" |
64 |
#include "MacrosSetup.h" |
#include "MacrosSetup.h" |
65 |
|
#if defined(__APPLE__) |
66 |
|
# include "MacHelper.h" |
67 |
|
#endif |
68 |
|
|
69 |
|
static const Gdk::ModifierType primaryModifierKey = |
70 |
|
#if defined(__APPLE__) |
71 |
|
Gdk::META_MASK; // Cmd key on Mac |
72 |
|
#else |
73 |
|
Gdk::CONTROL_MASK; // Ctrl key on all other OSs |
74 |
|
#endif |
75 |
|
|
76 |
MainWindow::MainWindow() : |
MainWindow::MainWindow() : |
77 |
m_DimRegionChooser(*this), |
m_DimRegionChooser(*this), |
88 |
loadBuiltInPix(); |
loadBuiltInPix(); |
89 |
|
|
90 |
// set_border_width(5); |
// set_border_width(5); |
91 |
// set_default_size(400, 200); |
|
92 |
|
if (!Settings::singleton()->autoRestoreWindowDimension) { |
93 |
|
set_default_size(800, 600); |
94 |
|
set_position(Gtk::WIN_POS_CENTER); |
95 |
|
} |
96 |
|
|
97 |
add(m_VBox); |
add(m_VBox); |
98 |
|
|
347 |
sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument) |
sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument) |
348 |
); |
); |
349 |
actionGroup->add( |
actionGroup->add( |
350 |
|
Gtk::Action::create("CombInstruments", _("_Combine Instruments ...")), |
351 |
|
Gtk::AccelKey(GDK_KEY_j, primaryModifierKey), |
352 |
|
sigc::mem_fun(*this, &MainWindow::on_action_combine_instruments) |
353 |
|
); |
354 |
|
actionGroup->add( |
355 |
Gtk::Action::create("RemoveInstrument", Gtk::Stock::REMOVE), |
Gtk::Action::create("RemoveInstrument", Gtk::Stock::REMOVE), |
356 |
sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument) |
sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument) |
357 |
); |
); |
510 |
" <menuitem action='ScriptSlots'/>" |
" <menuitem action='ScriptSlots'/>" |
511 |
" <menuitem action='AddInstrument'/>" |
" <menuitem action='AddInstrument'/>" |
512 |
" <menuitem action='DupInstrument'/>" |
" <menuitem action='DupInstrument'/>" |
513 |
|
" <menuitem action='CombInstruments'/>" |
514 |
" <separator/>" |
" <separator/>" |
515 |
" <menuitem action='RemoveInstrument'/>" |
" <menuitem action='RemoveInstrument'/>" |
516 |
" </menu>" |
" </menu>" |
547 |
" <menuitem action='ScriptSlots'/>" |
" <menuitem action='ScriptSlots'/>" |
548 |
" <menuitem action='AddInstrument'/>" |
" <menuitem action='AddInstrument'/>" |
549 |
" <menuitem action='DupInstrument'/>" |
" <menuitem action='DupInstrument'/>" |
550 |
|
" <menuitem action='CombInstruments'/>" |
551 |
" <separator/>" |
" <separator/>" |
552 |
" <menuitem action='RemoveInstrument'/>" |
" <menuitem action='RemoveInstrument'/>" |
553 |
" </popup>" |
" </popup>" |
675 |
// Add the TreeView's view columns: |
// Add the TreeView's view columns: |
676 |
m_TreeView.append_column(_("Nr"), m_Columns.m_col_nr); |
m_TreeView.append_column(_("Nr"), m_Columns.m_col_nr); |
677 |
m_TreeView.append_column_editable(_("Instrument"), m_Columns.m_col_name); |
m_TreeView.append_column_editable(_("Instrument"), m_Columns.m_col_name); |
678 |
|
m_TreeView.append_column(_("Scripts"), m_Columns.m_col_scripts); |
679 |
m_TreeView.set_headers_visible(true); |
m_TreeView.set_headers_visible(true); |
680 |
|
|
681 |
// establish drag&drop within the instrument tree view, allowing to reorder |
// establish drag&drop within the instrument tree view, allowing to reorder |
865 |
uiManager->get_widget("/MenuBar/MenuMacro") |
uiManager->get_widget("/MenuBar/MenuMacro") |
866 |
)->get_submenu(); |
)->get_submenu(); |
867 |
|
|
|
const Gdk::ModifierType primaryModifierKey = |
|
|
#if defined(__APPLE__) |
|
|
Gdk::META_MASK; // Cmd key on Mac |
|
|
#else |
|
|
Gdk::CONTROL_MASK; // Ctrl key on all other OSs |
|
|
#endif |
|
|
|
|
868 |
const Gdk::ModifierType noModifier = (Gdk::ModifierType)0; |
const Gdk::ModifierType noModifier = (Gdk::ModifierType)0; |
869 |
Gtk::AccelMap::add_entry("<Macros>/macro_0", GDK_KEY_F1, noModifier); |
Gtk::AccelMap::add_entry("<Macros>/macro_0", GDK_KEY_F1, noModifier); |
870 |
Gtk::AccelMap::add_entry("<Macros>/macro_1", GDK_KEY_F2, noModifier); |
Gtk::AccelMap::add_entry("<Macros>/macro_1", GDK_KEY_F2, noModifier); |
885 |
|
|
886 |
updateMacroMenu(); |
updateMacroMenu(); |
887 |
} |
} |
888 |
|
|
889 |
|
Glib::signal_idle().connect_once( |
890 |
|
sigc::mem_fun(*this, &MainWindow::bringToFront), |
891 |
|
200 |
892 |
|
); |
893 |
} |
} |
894 |
|
|
895 |
MainWindow::~MainWindow() |
MainWindow::~MainWindow() |
896 |
{ |
{ |
897 |
} |
} |
898 |
|
|
899 |
|
void MainWindow::bringToFront() { |
900 |
|
#if defined(__APPLE__) |
901 |
|
macRaiseAppWindow(); |
902 |
|
#endif |
903 |
|
raise(); |
904 |
|
present(); |
905 |
|
} |
906 |
|
|
907 |
void MainWindow::updateMacroMenu() { |
void MainWindow::updateMacroMenu() { |
908 |
Gtk::Menu* menuMacro = dynamic_cast<Gtk::MenuItem*>( |
Gtk::Menu* menuMacro = dynamic_cast<Gtk::MenuItem*>( |
909 |
uiManager->get_widget("/MenuBar/MenuMacro") |
uiManager->get_widget("/MenuBar/MenuMacro") |
1232 |
// save the file as separate temporary file first, |
// save the file as separate temporary file first, |
1233 |
// then move the saved file over the old file |
// then move the saved file over the old file |
1234 |
// (may result in performance speedup during save) |
// (may result in performance speedup during save) |
1235 |
String tmpname = filename + ".TMP"; |
gig::String tmpname = filename + ".TMP"; |
1236 |
gig->Save(tmpname, &progress); |
gig->Save(tmpname, &progress); |
1237 |
#if defined(WIN32) |
#if defined(WIN32) |
1238 |
if (!DeleteFile(filename.c_str())) { |
if (!DeleteFile(filename.c_str())) { |
1240 |
} |
} |
1241 |
#else // POSIX ... |
#else // POSIX ... |
1242 |
if (unlink(filename.c_str())) { |
if (unlink(filename.c_str())) { |
1243 |
throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file): " + String(strerror(errno))); |
throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file): " + gig::String(strerror(errno))); |
1244 |
} |
} |
1245 |
#endif |
#endif |
1246 |
if (rename(tmpname.c_str(), filename.c_str())) { |
if (rename(tmpname.c_str(), filename.c_str())) { |
1247 |
#if defined(WIN32) |
#if defined(WIN32) |
1248 |
throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file)."); |
throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file)."); |
1249 |
#else |
#else |
1250 |
throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file): " + String(strerror(errno))); |
throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file): " + gig::String(strerror(errno))); |
1251 |
#endif |
#endif |
1252 |
} |
} |
1253 |
} |
} |
1843 |
dialog.set_comments(sComment.c_str()); |
dialog.set_comments(sComment.c_str()); |
1844 |
dialog.set_website("http://www.linuxsampler.org"); |
dialog.set_website("http://www.linuxsampler.org"); |
1845 |
dialog.set_website_label("http://www.linuxsampler.org"); |
dialog.set_website_label("http://www.linuxsampler.org"); |
1846 |
|
dialog.set_position(Gtk::WIN_POS_CENTER); |
1847 |
dialog.run(); |
dialog.run(); |
1848 |
} |
} |
1849 |
|
|
1869 |
table(2, 1), |
table(2, 1), |
1870 |
m_file(NULL) |
m_file(NULL) |
1871 |
{ |
{ |
1872 |
|
if (!Settings::singleton()->autoRestoreWindowDimension) { |
1873 |
|
set_default_size(470, 390); |
1874 |
|
set_position(Gtk::WIN_POS_MOUSE); |
1875 |
|
} |
1876 |
|
|
1877 |
set_title(_("File Properties")); |
set_title(_("File Properties")); |
1878 |
eName.set_width_chars(50); |
eName.set_width_chars(50); |
1879 |
|
|
2008 |
eDimensionKeyRangeLow(_("Keyswitching range low")), |
eDimensionKeyRangeLow(_("Keyswitching range low")), |
2009 |
eDimensionKeyRangeHigh(_("Keyswitching range high")) |
eDimensionKeyRangeHigh(_("Keyswitching range high")) |
2010 |
{ |
{ |
2011 |
|
if (!Settings::singleton()->autoRestoreWindowDimension) { |
2012 |
|
//set_default_size(470, 390); |
2013 |
|
set_position(Gtk::WIN_POS_MOUSE); |
2014 |
|
} |
2015 |
|
|
2016 |
set_title(_("Instrument Properties")); |
set_title(_("Instrument Properties")); |
2017 |
|
|
2018 |
eDimensionKeyRangeLow.set_tip( |
eDimensionKeyRangeLow.set_tip( |
2137 |
for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ; |
for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ; |
2138 |
instrument = gig->GetNextInstrument(), ++index) { |
instrument = gig->GetNextInstrument(), ++index) { |
2139 |
Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); |
Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); |
2140 |
|
const int iScriptSlots = instrument->ScriptSlotCount(); |
2141 |
|
|
2142 |
Gtk::TreeModel::iterator iter = m_refTreeModel->append(); |
Gtk::TreeModel::iterator iter = m_refTreeModel->append(); |
2143 |
Gtk::TreeModel::Row row = *iter; |
Gtk::TreeModel::Row row = *iter; |
2144 |
row[m_Columns.m_col_nr] = index; |
row[m_Columns.m_col_nr] = index; |
2145 |
row[m_Columns.m_col_name] = name; |
row[m_Columns.m_col_name] = name; |
2146 |
row[m_Columns.m_col_instr] = instrument; |
row[m_Columns.m_col_instr] = instrument; |
2147 |
|
row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : ""; |
2148 |
|
|
2149 |
add_instrument_to_menu(name); |
add_instrument_to_menu(name); |
2150 |
} |
} |
2283 |
|
|
2284 |
ScriptSlots* window = new ScriptSlots; |
ScriptSlots* window = new ScriptSlots; |
2285 |
window->setInstrument(instrument); |
window->setInstrument(instrument); |
2286 |
|
window->signal_script_slots_changed().connect( |
2287 |
|
sigc::mem_fun(*this, &MainWindow::onScriptSlotsModified) |
2288 |
|
); |
2289 |
//window->reparent(*this); |
//window->reparent(*this); |
2290 |
window->show(); |
window->show(); |
2291 |
} |
} |
2292 |
|
|
2293 |
|
void MainWindow::onScriptSlotsModified(gig::Instrument* pInstrument) { |
2294 |
|
if (!pInstrument) return; |
2295 |
|
const int iScriptSlots = pInstrument->ScriptSlotCount(); |
2296 |
|
|
2297 |
|
Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model(); |
2298 |
|
for (int i = 0; i < model->children().size(); ++i) { |
2299 |
|
Gtk::TreeModel::Row row = model->children()[i]; |
2300 |
|
if (row[m_Columns.m_col_instr] != pInstrument) continue; |
2301 |
|
row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : ""; |
2302 |
|
break; |
2303 |
|
} |
2304 |
|
} |
2305 |
|
|
2306 |
void MainWindow::on_action_refresh_all() { |
void MainWindow::on_action_refresh_all() { |
2307 |
__refreshEntireGUI(); |
__refreshEntireGUI(); |
2308 |
} |
} |
2617 |
rowInstr[m_Columns.m_col_nr] = m_refTreeModel->children().size() - 1; |
rowInstr[m_Columns.m_col_nr] = m_refTreeModel->children().size() - 1; |
2618 |
rowInstr[m_Columns.m_col_name] = name; |
rowInstr[m_Columns.m_col_name] = name; |
2619 |
rowInstr[m_Columns.m_col_instr] = instrument; |
rowInstr[m_Columns.m_col_instr] = instrument; |
2620 |
|
rowInstr[m_Columns.m_col_scripts] = ""; |
2621 |
instrument_name_connection.unblock(); |
instrument_name_connection.unblock(); |
2622 |
|
|
2623 |
add_instrument_to_menu(name); |
add_instrument_to_menu(name); |
3595 |
|
|
3596 |
void MainWindow::on_action_combine_instruments() { |
void MainWindow::on_action_combine_instruments() { |
3597 |
CombineInstrumentsDialog* d = new CombineInstrumentsDialog(*this, file); |
CombineInstrumentsDialog* d = new CombineInstrumentsDialog(*this, file); |
3598 |
|
|
3599 |
|
// take over selection from instruments list view for the combine dialog's |
3600 |
|
// list view as pre-selection |
3601 |
|
std::set<int> indeces; |
3602 |
|
{ |
3603 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
3604 |
|
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
3605 |
|
for (int r = 0; r < rows.size(); ++r) { |
3606 |
|
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[r]); |
3607 |
|
if (it) { |
3608 |
|
Gtk::TreeModel::Row row = *it; |
3609 |
|
int index = row[m_Columns.m_col_nr]; |
3610 |
|
indeces.insert(index); |
3611 |
|
} |
3612 |
|
} |
3613 |
|
} |
3614 |
|
d->setSelectedInstruments(indeces); |
3615 |
|
|
3616 |
d->show_all(); |
d->show_all(); |
|
d->resize(500, 400); |
|
3617 |
d->run(); |
d->run(); |
3618 |
if (d->fileWasChanged()) { |
if (d->fileWasChanged()) { |
3619 |
// update GUI with new instrument just created |
// update GUI with new instrument just created |