35 |
#include <gtkmm/aboutdialog.h> |
#include <gtkmm/aboutdialog.h> |
36 |
#include <gtkmm/filechooserdialog.h> |
#include <gtkmm/filechooserdialog.h> |
37 |
#include <gtkmm/messagedialog.h> |
#include <gtkmm/messagedialog.h> |
38 |
|
#include <gtkmm/stock.h> |
39 |
#include <gtkmm/targetentry.h> |
#include <gtkmm/targetentry.h> |
40 |
#include <gtkmm/main.h> |
#include <gtkmm/main.h> |
41 |
#include <gtkmm/toggleaction.h> |
#include <gtkmm/toggleaction.h> |
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), |
87 |
{ |
{ |
88 |
loadBuiltInPix(); |
loadBuiltInPix(); |
89 |
|
|
90 |
|
this->file = NULL; |
91 |
|
|
92 |
// set_border_width(5); |
// set_border_width(5); |
93 |
// set_default_size(400, 200); |
|
94 |
|
if (!Settings::singleton()->autoRestoreWindowDimension) { |
95 |
|
set_default_size(800, 600); |
96 |
|
set_position(Gtk::WIN_POS_CENTER); |
97 |
|
} |
98 |
|
|
99 |
add(m_VBox); |
add(m_VBox); |
100 |
|
|
173 |
actionGroup = Gtk::ActionGroup::create(); |
actionGroup = Gtk::ActionGroup::create(); |
174 |
|
|
175 |
actionGroup->add(Gtk::Action::create("MenuFile", _("_File"))); |
actionGroup->add(Gtk::Action::create("MenuFile", _("_File"))); |
176 |
actionGroup->add(Gtk::Action::create("New", _("_New")), |
actionGroup->add(Gtk::Action::create("New", Gtk::Stock::NEW), |
|
Gtk::AccelKey("<control>n"), |
|
177 |
sigc::mem_fun( |
sigc::mem_fun( |
178 |
*this, &MainWindow::on_action_file_new)); |
*this, &MainWindow::on_action_file_new)); |
179 |
actionGroup->add(Gtk::Action::create("Open", _("_Open...")), |
Glib::RefPtr<Gtk::Action> action = |
180 |
Gtk::AccelKey("<control>o"), |
Gtk::Action::create("Open", Gtk::Stock::OPEN); |
181 |
|
action->property_label() = action->property_label() + "..."; |
182 |
|
actionGroup->add(action, |
183 |
sigc::mem_fun( |
sigc::mem_fun( |
184 |
*this, &MainWindow::on_action_file_open)); |
*this, &MainWindow::on_action_file_open)); |
185 |
actionGroup->add(Gtk::Action::create("Save", _("_Save")), |
actionGroup->add(Gtk::Action::create("Save", Gtk::Stock::SAVE), |
|
Gtk::AccelKey("<control>s"), |
|
186 |
sigc::mem_fun( |
sigc::mem_fun( |
187 |
*this, &MainWindow::on_action_file_save)); |
*this, &MainWindow::on_action_file_save)); |
188 |
actionGroup->add(Gtk::Action::create("SaveAs", _("Save _As...")), |
action = Gtk::Action::create("SaveAs", Gtk::Stock::SAVE_AS); |
189 |
|
action->property_label() = action->property_label() + "..."; |
190 |
|
actionGroup->add(action, |
191 |
Gtk::AccelKey("<shift><control>s"), |
Gtk::AccelKey("<shift><control>s"), |
192 |
sigc::mem_fun( |
sigc::mem_fun( |
193 |
*this, &MainWindow::on_action_file_save_as)); |
*this, &MainWindow::on_action_file_save_as)); |
194 |
actionGroup->add(Gtk::Action::create("Properties", |
actionGroup->add(Gtk::Action::create("Properties", |
195 |
_("_Properties")), |
Gtk::Stock::PROPERTIES), |
196 |
sigc::mem_fun( |
sigc::mem_fun( |
197 |
*this, &MainWindow::on_action_file_properties)); |
*this, &MainWindow::on_action_file_properties)); |
198 |
actionGroup->add(Gtk::Action::create("InstrProperties", |
actionGroup->add(Gtk::Action::create("InstrProperties", |
199 |
_("_Properties")), |
Gtk::Stock::PROPERTIES), |
200 |
sigc::mem_fun( |
sigc::mem_fun( |
201 |
*this, &MainWindow::show_instr_props)); |
*this, &MainWindow::show_instr_props)); |
202 |
actionGroup->add(Gtk::Action::create("MidiRules", |
actionGroup->add(Gtk::Action::create("MidiRules", |
207 |
_("_Script Slots...")), |
_("_Script Slots...")), |
208 |
sigc::mem_fun( |
sigc::mem_fun( |
209 |
*this, &MainWindow::show_script_slots)); |
*this, &MainWindow::show_script_slots)); |
210 |
actionGroup->add(Gtk::Action::create("Quit", _("_Quit")), |
actionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT), |
|
Gtk::AccelKey("<control>q"), |
|
211 |
sigc::mem_fun( |
sigc::mem_fun( |
212 |
*this, &MainWindow::on_action_quit)); |
*this, &MainWindow::on_action_quit)); |
213 |
actionGroup->add( |
actionGroup->add( |
223 |
sigc::mem_fun(*this, &MainWindow::show_scripts_tab) |
sigc::mem_fun(*this, &MainWindow::show_scripts_tab) |
224 |
); |
); |
225 |
actionGroup->add(Gtk::Action::create("AllInstruments", _("_Select"))); |
actionGroup->add(Gtk::Action::create("AllInstruments", _("_Select"))); |
226 |
|
actionGroup->add(Gtk::Action::create("AssignScripts", _("Assign Script"))); |
227 |
|
|
228 |
actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit"))); |
actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit"))); |
229 |
|
|
249 |
Gtk::AccelKey(GDK_KEY_x, Gdk::MOD1_MASK), |
Gtk::AccelKey(GDK_KEY_x, Gdk::MOD1_MASK), |
250 |
sigc::mem_fun(*this, &MainWindow::adjust_clipboard_content)); |
sigc::mem_fun(*this, &MainWindow::adjust_clipboard_content)); |
251 |
|
|
252 |
|
actionGroup->add(Gtk::Action::create("SelectPrevInstr", |
253 |
|
_("Select Previous Instrument")), |
254 |
|
Gtk::AccelKey(GDK_KEY_Up, primaryModifierKey), |
255 |
|
sigc::mem_fun(*this, &MainWindow::select_prev_instrument)); |
256 |
|
|
257 |
|
actionGroup->add(Gtk::Action::create("SelectNextInstr", |
258 |
|
_("Select Next Instrument")), |
259 |
|
Gtk::AccelKey(GDK_KEY_Down, primaryModifierKey), |
260 |
|
sigc::mem_fun(*this, &MainWindow::select_next_instrument)); |
261 |
|
|
262 |
actionGroup->add(Gtk::Action::create("SelectPrevRegion", |
actionGroup->add(Gtk::Action::create("SelectPrevRegion", |
263 |
_("Select Previous Region")), |
_("Select Previous Region")), |
264 |
Gtk::AccelKey(GDK_KEY_Left, primaryModifierKey), |
Gtk::AccelKey(GDK_KEY_Left, primaryModifierKey), |
345 |
sigc::mem_fun(*this, &MainWindow::on_action_refresh_all) |
sigc::mem_fun(*this, &MainWindow::on_action_refresh_all) |
346 |
); |
); |
347 |
|
|
348 |
actionGroup->add(Gtk::Action::create("MenuHelp", _("_Help"))); |
action = Gtk::Action::create("MenuHelp", Gtk::Stock::HELP); |
349 |
actionGroup->add(Gtk::Action::create("About", _("_About")), |
actionGroup->add(Gtk::Action::create("MenuHelp", |
350 |
|
action->property_label())); |
351 |
|
actionGroup->add(Gtk::Action::create("About", Gtk::Stock::ABOUT), |
352 |
sigc::mem_fun( |
sigc::mem_fun( |
353 |
*this, &MainWindow::on_action_help_about)); |
*this, &MainWindow::on_action_help_about)); |
354 |
actionGroup->add( |
actionGroup->add( |
360 |
sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument) |
sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument) |
361 |
); |
); |
362 |
actionGroup->add( |
actionGroup->add( |
363 |
Gtk::Action::create("RemoveInstrument", _("_Remove")), |
Gtk::Action::create("CombInstruments", _("_Combine Instruments ...")), |
364 |
|
Gtk::AccelKey(GDK_KEY_j, primaryModifierKey), |
365 |
|
sigc::mem_fun(*this, &MainWindow::on_action_combine_instruments) |
366 |
|
); |
367 |
|
actionGroup->add( |
368 |
|
Gtk::Action::create("RemoveInstrument", Gtk::Stock::REMOVE), |
369 |
sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument) |
sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument) |
370 |
); |
); |
371 |
|
|
412 |
|
|
413 |
// sample right-click popup actions |
// sample right-click popup actions |
414 |
actionGroup->add( |
actionGroup->add( |
415 |
Gtk::Action::create("SampleProperties", _("_Properties")), |
Gtk::Action::create("SampleProperties", Gtk::Stock::PROPERTIES), |
416 |
sigc::mem_fun(*this, &MainWindow::on_action_sample_properties) |
sigc::mem_fun(*this, &MainWindow::on_action_sample_properties) |
417 |
); |
); |
418 |
actionGroup->add( |
actionGroup->add( |
424 |
sigc::mem_fun(*this, &MainWindow::on_action_add_sample) |
sigc::mem_fun(*this, &MainWindow::on_action_add_sample) |
425 |
); |
); |
426 |
actionGroup->add( |
actionGroup->add( |
427 |
Gtk::Action::create("RemoveSample", _("_Remove")), |
Gtk::Action::create("RemoveSample", Gtk::Stock::REMOVE), |
428 |
sigc::mem_fun(*this, &MainWindow::on_action_remove_sample) |
sigc::mem_fun(*this, &MainWindow::on_action_remove_sample) |
429 |
); |
); |
430 |
actionGroup->add( |
actionGroup->add( |
460 |
sigc::mem_fun(*this, &MainWindow::on_action_edit_script) |
sigc::mem_fun(*this, &MainWindow::on_action_edit_script) |
461 |
); |
); |
462 |
actionGroup->add( |
actionGroup->add( |
463 |
Gtk::Action::create("RemoveScript", _("_Remove")), |
Gtk::Action::create("RemoveScript", Gtk::Stock::REMOVE), |
464 |
sigc::mem_fun(*this, &MainWindow::on_action_remove_script) |
sigc::mem_fun(*this, &MainWindow::on_action_remove_script) |
465 |
); |
); |
466 |
|
|
487 |
" <menuitem action='AdjustClipboard'/>" |
" <menuitem action='AdjustClipboard'/>" |
488 |
" <menuitem action='PasteDimRgn'/>" |
" <menuitem action='PasteDimRgn'/>" |
489 |
" <separator/>" |
" <separator/>" |
490 |
|
" <menuitem action='SelectPrevInstr'/>" |
491 |
|
" <menuitem action='SelectNextInstr'/>" |
492 |
|
" <separator/>" |
493 |
" <menuitem action='SelectPrevRegion'/>" |
" <menuitem action='SelectPrevRegion'/>" |
494 |
" <menuitem action='SelectNextRegion'/>" |
" <menuitem action='SelectNextRegion'/>" |
495 |
" <separator/>" |
" <separator/>" |
524 |
" <menuitem action='InstrProperties'/>" |
" <menuitem action='InstrProperties'/>" |
525 |
" <menuitem action='MidiRules'/>" |
" <menuitem action='MidiRules'/>" |
526 |
" <menuitem action='ScriptSlots'/>" |
" <menuitem action='ScriptSlots'/>" |
527 |
|
" <menu action='AssignScripts'/>" |
528 |
" <menuitem action='AddInstrument'/>" |
" <menuitem action='AddInstrument'/>" |
529 |
" <menuitem action='DupInstrument'/>" |
" <menuitem action='DupInstrument'/>" |
530 |
|
" <menuitem action='CombInstruments'/>" |
531 |
" <separator/>" |
" <separator/>" |
532 |
" <menuitem action='RemoveInstrument'/>" |
" <menuitem action='RemoveInstrument'/>" |
533 |
" </menu>" |
" </menu>" |
564 |
" <menuitem action='ScriptSlots'/>" |
" <menuitem action='ScriptSlots'/>" |
565 |
" <menuitem action='AddInstrument'/>" |
" <menuitem action='AddInstrument'/>" |
566 |
" <menuitem action='DupInstrument'/>" |
" <menuitem action='DupInstrument'/>" |
567 |
|
" <menuitem action='CombInstruments'/>" |
568 |
" <separator/>" |
" <separator/>" |
569 |
" <menuitem action='RemoveInstrument'/>" |
" <menuitem action='RemoveInstrument'/>" |
570 |
" </popup>" |
" </popup>" |
659 |
instrument_menu = static_cast<Gtk::MenuItem*>( |
instrument_menu = static_cast<Gtk::MenuItem*>( |
660 |
uiManager->get_widget("/MenuBar/MenuInstrument/AllInstruments"))->get_submenu(); |
uiManager->get_widget("/MenuBar/MenuInstrument/AllInstruments"))->get_submenu(); |
661 |
|
|
662 |
|
assign_scripts_menu = static_cast<Gtk::MenuItem*>( |
663 |
|
uiManager->get_widget("/MenuBar/MenuInstrument/AssignScripts"))->get_submenu(); |
664 |
|
|
665 |
Gtk::Widget* menuBar = uiManager->get_widget("/MenuBar"); |
Gtk::Widget* menuBar = uiManager->get_widget("/MenuBar"); |
666 |
m_VBox.pack_start(*menuBar, Gtk::PACK_SHRINK); |
m_VBox.pack_start(*menuBar, Gtk::PACK_SHRINK); |
667 |
m_VBox.pack_start(m_HPaned); |
m_VBox.pack_start(m_HPaned); |
695 |
// Add the TreeView's view columns: |
// Add the TreeView's view columns: |
696 |
m_TreeView.append_column(_("Nr"), m_Columns.m_col_nr); |
m_TreeView.append_column(_("Nr"), m_Columns.m_col_nr); |
697 |
m_TreeView.append_column_editable(_("Instrument"), m_Columns.m_col_name); |
m_TreeView.append_column_editable(_("Instrument"), m_Columns.m_col_name); |
698 |
|
m_TreeView.append_column(_("Scripts"), m_Columns.m_col_scripts); |
699 |
m_TreeView.set_headers_visible(true); |
m_TreeView.set_headers_visible(true); |
700 |
|
|
701 |
// establish drag&drop within the instrument tree view, allowing to reorder |
// establish drag&drop within the instrument tree view, allowing to reorder |
885 |
uiManager->get_widget("/MenuBar/MenuMacro") |
uiManager->get_widget("/MenuBar/MenuMacro") |
886 |
)->get_submenu(); |
)->get_submenu(); |
887 |
|
|
|
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 |
|
|
|
|
888 |
const Gdk::ModifierType noModifier = (Gdk::ModifierType)0; |
const Gdk::ModifierType noModifier = (Gdk::ModifierType)0; |
889 |
Gtk::AccelMap::add_entry("<Macros>/macro_0", GDK_KEY_F1, noModifier); |
Gtk::AccelMap::add_entry("<Macros>/macro_0", GDK_KEY_F1, noModifier); |
890 |
Gtk::AccelMap::add_entry("<Macros>/macro_1", GDK_KEY_F2, noModifier); |
Gtk::AccelMap::add_entry("<Macros>/macro_1", GDK_KEY_F2, noModifier); |
905 |
|
|
906 |
updateMacroMenu(); |
updateMacroMenu(); |
907 |
} |
} |
908 |
|
|
909 |
|
// setup "Assign Scripts" keyboard accelerators |
910 |
|
{ |
911 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_0", GDK_KEY_F1, Gdk::SHIFT_MASK); |
912 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_1", GDK_KEY_F2, Gdk::SHIFT_MASK); |
913 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_2", GDK_KEY_F3, Gdk::SHIFT_MASK); |
914 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_3", GDK_KEY_F4, Gdk::SHIFT_MASK); |
915 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_4", GDK_KEY_F5, Gdk::SHIFT_MASK); |
916 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_5", GDK_KEY_F6, Gdk::SHIFT_MASK); |
917 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_6", GDK_KEY_F7, Gdk::SHIFT_MASK); |
918 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_7", GDK_KEY_F8, Gdk::SHIFT_MASK); |
919 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_8", GDK_KEY_F9, Gdk::SHIFT_MASK); |
920 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_9", GDK_KEY_F10, Gdk::SHIFT_MASK); |
921 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_10", GDK_KEY_F11, Gdk::SHIFT_MASK); |
922 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_11", GDK_KEY_F12, Gdk::SHIFT_MASK); |
923 |
|
|
924 |
|
Glib::RefPtr<Gtk::AccelGroup> accelGroup = this->get_accel_group(); |
925 |
|
assign_scripts_menu->set_accel_group(accelGroup); |
926 |
|
} |
927 |
|
|
928 |
|
Glib::signal_idle().connect_once( |
929 |
|
sigc::mem_fun(*this, &MainWindow::bringToFront), |
930 |
|
200 |
931 |
|
); |
932 |
} |
} |
933 |
|
|
934 |
MainWindow::~MainWindow() |
MainWindow::~MainWindow() |
935 |
{ |
{ |
936 |
} |
} |
937 |
|
|
938 |
|
void MainWindow::bringToFront() { |
939 |
|
#if defined(__APPLE__) |
940 |
|
macRaiseAppWindow(); |
941 |
|
#endif |
942 |
|
raise(); |
943 |
|
present(); |
944 |
|
} |
945 |
|
|
946 |
void MainWindow::updateMacroMenu() { |
void MainWindow::updateMacroMenu() { |
947 |
Gtk::Menu* menuMacro = dynamic_cast<Gtk::MenuItem*>( |
Gtk::Menu* menuMacro = dynamic_cast<Gtk::MenuItem*>( |
948 |
uiManager->get_widget("/MenuBar/MenuMacro") |
uiManager->get_widget("/MenuBar/MenuMacro") |
981 |
); |
); |
982 |
menuMacro->append(*item); |
menuMacro->append(*item); |
983 |
item->set_accel_path("<Macros>/macro_" + ToString(iMacro)); |
item->set_accel_path("<Macros>/macro_" + ToString(iMacro)); |
984 |
|
Glib::ustring comment = macro.comment(); |
985 |
|
if (!comment.empty()) |
986 |
|
item->set_tooltip_text(comment); |
987 |
} |
} |
988 |
// if there are no macros configured at all, then show a dummy entry instead |
// if there are no macros configured at all, then show a dummy entry instead |
989 |
if (m_macros.empty()) { |
if (m_macros.empty()) { |
1027 |
|
|
1028 |
void MainWindow::setupMacros() { |
void MainWindow::setupMacros() { |
1029 |
MacrosSetup* setup = new MacrosSetup(); |
MacrosSetup* setup = new MacrosSetup(); |
1030 |
setup->setMacros(m_macros); |
gig::DimensionRegion* pDimRgn = m_DimRegionChooser.get_main_dimregion(); |
1031 |
|
setup->setMacros(m_macros, &m_serializationArchive, pDimRgn); |
1032 |
setup->signal_macros_changed().connect( |
setup->signal_macros_changed().connect( |
1033 |
sigc::mem_fun(*this, &MainWindow::onMacrosSetupChanged) |
sigc::mem_fun(*this, &MainWindow::onMacrosSetupChanged) |
1034 |
); |
); |
1141 |
} |
} |
1142 |
} |
} |
1143 |
|
|
1144 |
|
updateScriptListOfMenu(); |
1145 |
|
|
1146 |
m_RegionChooser.set_instrument(get_instrument()); |
m_RegionChooser.set_instrument(get_instrument()); |
1147 |
|
|
1148 |
if (Settings::singleton()->syncSamplerInstrumentSelection) { |
if (Settings::singleton()->syncSamplerInstrumentSelection) { |
1273 |
// save the file as separate temporary file first, |
// save the file as separate temporary file first, |
1274 |
// then move the saved file over the old file |
// then move the saved file over the old file |
1275 |
// (may result in performance speedup during save) |
// (may result in performance speedup during save) |
1276 |
String tmpname = filename + ".TMP"; |
gig::String tmpname = filename + ".TMP"; |
1277 |
gig->Save(tmpname, &progress); |
gig->Save(tmpname, &progress); |
1278 |
#if defined(WIN32) |
#if defined(WIN32) |
1279 |
if (!DeleteFile(filename.c_str())) { |
if (!DeleteFile(filename.c_str())) { |
1281 |
} |
} |
1282 |
#else // POSIX ... |
#else // POSIX ... |
1283 |
if (unlink(filename.c_str())) { |
if (unlink(filename.c_str())) { |
1284 |
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))); |
1285 |
} |
} |
1286 |
#endif |
#endif |
1287 |
if (rename(tmpname.c_str(), filename.c_str())) { |
if (rename(tmpname.c_str(), filename.c_str())) { |
1288 |
#if defined(WIN32) |
#if defined(WIN32) |
1289 |
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)."); |
1290 |
#else |
#else |
1291 |
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))); |
1292 |
#endif |
#endif |
1293 |
} |
} |
1294 |
} |
} |
1416 |
g_free(msg); |
g_free(msg); |
1417 |
dialog.set_secondary_text(_("If you close without saving, your changes will be lost.")); |
dialog.set_secondary_text(_("If you close without saving, your changes will be lost.")); |
1418 |
dialog.add_button(_("Close _Without Saving"), Gtk::RESPONSE_NO); |
dialog.add_button(_("Close _Without Saving"), Gtk::RESPONSE_NO); |
1419 |
dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
1420 |
dialog.add_button(file_has_name ? _("_Save") : _("Save _As"), Gtk::RESPONSE_YES); |
dialog.add_button(file_has_name ? Gtk::Stock::SAVE : Gtk::Stock::SAVE_AS, Gtk::RESPONSE_YES); |
1421 |
dialog.set_default_response(Gtk::RESPONSE_YES); |
dialog.set_default_response(Gtk::RESPONSE_YES); |
1422 |
int response = dialog.run(); |
int response = dialog.run(); |
1423 |
dialog.hide(); |
dialog.hide(); |
1448 |
"used by the sampler until you tell the sampler explicitly to " |
"used by the sampler until you tell the sampler explicitly to " |
1449 |
"load it.")); |
"load it.")); |
1450 |
dialog.add_button(_("_Yes, Detach"), Gtk::RESPONSE_YES); |
dialog.add_button(_("_Yes, Detach"), Gtk::RESPONSE_YES); |
1451 |
dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
1452 |
dialog.set_default_response(Gtk::RESPONSE_CANCEL); |
dialog.set_default_response(Gtk::RESPONSE_CANCEL); |
1453 |
int response = dialog.run(); |
int response = dialog.run(); |
1454 |
dialog.hide(); |
dialog.hide(); |
1462 |
if (file_is_shared && !leaving_shared_mode_dialog()) return; |
if (file_is_shared && !leaving_shared_mode_dialog()) return; |
1463 |
|
|
1464 |
Gtk::FileChooserDialog dialog(*this, _("Open file")); |
Gtk::FileChooserDialog dialog(*this, _("Open file")); |
1465 |
dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
1466 |
dialog.add_button(_("_Open"), Gtk::RESPONSE_OK); |
dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); |
1467 |
dialog.set_default_response(Gtk::RESPONSE_OK); |
dialog.set_default_response(Gtk::RESPONSE_OK); |
1468 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
1469 |
Gtk::FileFilter filter; |
Gtk::FileFilter filter; |
1658 |
|
|
1659 |
bool MainWindow::file_save_as() |
bool MainWindow::file_save_as() |
1660 |
{ |
{ |
1661 |
Gtk::FileChooserDialog dialog(*this, _("Save As"), Gtk::FILE_CHOOSER_ACTION_SAVE); |
Gtk::FileChooserDialog dialog(*this, _("Save as"), Gtk::FILE_CHOOSER_ACTION_SAVE); |
1662 |
dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
1663 |
dialog.add_button(_("_Save"), Gtk::RESPONSE_OK); |
dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK); |
1664 |
dialog.set_default_response(Gtk::RESPONSE_OK); |
dialog.set_default_response(Gtk::RESPONSE_OK); |
1665 |
dialog.set_do_overwrite_confirmation(); |
dialog.set_do_overwrite_confirmation(); |
1666 |
|
|
1884 |
dialog.set_comments(sComment.c_str()); |
dialog.set_comments(sComment.c_str()); |
1885 |
dialog.set_website("http://www.linuxsampler.org"); |
dialog.set_website("http://www.linuxsampler.org"); |
1886 |
dialog.set_website_label("http://www.linuxsampler.org"); |
dialog.set_website_label("http://www.linuxsampler.org"); |
1887 |
|
dialog.set_position(Gtk::WIN_POS_CENTER); |
1888 |
dialog.run(); |
dialog.run(); |
1889 |
} |
} |
1890 |
|
|
1906 |
eSourceForm(_("Source form")), |
eSourceForm(_("Source form")), |
1907 |
eCommissioned(_("Commissioned")), |
eCommissioned(_("Commissioned")), |
1908 |
eSubject(_("Subject")), |
eSubject(_("Subject")), |
1909 |
quitButton(_("_Close"), true), |
quitButton(Gtk::Stock::CLOSE), |
1910 |
table(2, 1), |
table(2, 1), |
1911 |
m_file(NULL) |
m_file(NULL) |
1912 |
{ |
{ |
1913 |
|
if (!Settings::singleton()->autoRestoreWindowDimension) { |
1914 |
|
set_default_size(470, 390); |
1915 |
|
set_position(Gtk::WIN_POS_MOUSE); |
1916 |
|
} |
1917 |
|
|
1918 |
set_title(_("File Properties")); |
set_title(_("File Properties")); |
1919 |
eName.set_width_chars(50); |
eName.set_width_chars(50); |
1920 |
|
|
2034 |
} |
} |
2035 |
|
|
2036 |
InstrumentProps::InstrumentProps() : |
InstrumentProps::InstrumentProps() : |
2037 |
quitButton(_("_Close"), true), |
quitButton(Gtk::Stock::CLOSE), |
2038 |
table(2,1), |
table(2,1), |
2039 |
eName(_("Name")), |
eName(_("Name")), |
2040 |
eIsDrum(_("Is drum")), |
eIsDrum(_("Is drum")), |
2049 |
eDimensionKeyRangeLow(_("Keyswitching range low")), |
eDimensionKeyRangeLow(_("Keyswitching range low")), |
2050 |
eDimensionKeyRangeHigh(_("Keyswitching range high")) |
eDimensionKeyRangeHigh(_("Keyswitching range high")) |
2051 |
{ |
{ |
2052 |
|
if (!Settings::singleton()->autoRestoreWindowDimension) { |
2053 |
|
//set_default_size(470, 390); |
2054 |
|
set_position(Gtk::WIN_POS_MOUSE); |
2055 |
|
} |
2056 |
|
|
2057 |
set_title(_("Instrument Properties")); |
set_title(_("Instrument Properties")); |
2058 |
|
|
2059 |
eDimensionKeyRangeLow.set_tip( |
eDimensionKeyRangeLow.set_tip( |
2178 |
for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ; |
for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ; |
2179 |
instrument = gig->GetNextInstrument(), ++index) { |
instrument = gig->GetNextInstrument(), ++index) { |
2180 |
Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); |
Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); |
2181 |
|
const int iScriptSlots = instrument->ScriptSlotCount(); |
2182 |
|
|
2183 |
Gtk::TreeModel::iterator iter = m_refTreeModel->append(); |
Gtk::TreeModel::iterator iter = m_refTreeModel->append(); |
2184 |
Gtk::TreeModel::Row row = *iter; |
Gtk::TreeModel::Row row = *iter; |
2185 |
row[m_Columns.m_col_nr] = index; |
row[m_Columns.m_col_nr] = index; |
2186 |
row[m_Columns.m_col_name] = name; |
row[m_Columns.m_col_name] = name; |
2187 |
row[m_Columns.m_col_instr] = instrument; |
row[m_Columns.m_col_instr] = instrument; |
2188 |
|
row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : ""; |
2189 |
|
|
2190 |
add_instrument_to_menu(name); |
add_instrument_to_menu(name); |
2191 |
} |
} |
2324 |
|
|
2325 |
ScriptSlots* window = new ScriptSlots; |
ScriptSlots* window = new ScriptSlots; |
2326 |
window->setInstrument(instrument); |
window->setInstrument(instrument); |
2327 |
|
window->signal_script_slots_changed().connect( |
2328 |
|
sigc::mem_fun(*this, &MainWindow::onScriptSlotsModified) |
2329 |
|
); |
2330 |
//window->reparent(*this); |
//window->reparent(*this); |
2331 |
window->show(); |
window->show(); |
2332 |
} |
} |
2333 |
|
|
2334 |
|
void MainWindow::onScriptSlotsModified(gig::Instrument* pInstrument) { |
2335 |
|
if (!pInstrument) return; |
2336 |
|
const int iScriptSlots = pInstrument->ScriptSlotCount(); |
2337 |
|
|
2338 |
|
Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model(); |
2339 |
|
for (int i = 0; i < model->children().size(); ++i) { |
2340 |
|
Gtk::TreeModel::Row row = model->children()[i]; |
2341 |
|
if (row[m_Columns.m_col_instr] != pInstrument) continue; |
2342 |
|
row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : ""; |
2343 |
|
break; |
2344 |
|
} |
2345 |
|
|
2346 |
|
// causes the sampler to reload the instrument with the new script |
2347 |
|
on_sel_change(); |
2348 |
|
} |
2349 |
|
|
2350 |
|
void MainWindow::assignScript(gig::Script* pScript) { |
2351 |
|
if (!pScript) { |
2352 |
|
printf("assignScript() : !script\n"); |
2353 |
|
return; |
2354 |
|
} |
2355 |
|
printf("assignScript('%s')\n", pScript->Name.c_str()); |
2356 |
|
|
2357 |
|
gig::Instrument* pInstrument = get_instrument(); |
2358 |
|
if (!pInstrument) { |
2359 |
|
printf("!instrument\n"); |
2360 |
|
return; |
2361 |
|
} |
2362 |
|
|
2363 |
|
pInstrument->AddScriptSlot(pScript); |
2364 |
|
|
2365 |
|
onScriptSlotsModified(pInstrument); |
2366 |
|
} |
2367 |
|
|
2368 |
void MainWindow::on_action_refresh_all() { |
void MainWindow::on_action_refresh_all() { |
2369 |
__refreshEntireGUI(); |
__refreshEntireGUI(); |
2370 |
} |
} |
2637 |
} |
} |
2638 |
} |
} |
2639 |
|
|
2640 |
|
void MainWindow::updateScriptListOfMenu() { |
2641 |
|
// remove all entries from "Assign Script" menu |
2642 |
|
{ |
2643 |
|
const std::vector<Gtk::Widget*> children = assign_scripts_menu->get_children(); |
2644 |
|
for (int i = 0; i < children.size(); ++i) { |
2645 |
|
Gtk::Widget* child = children[i]; |
2646 |
|
assign_scripts_menu->remove(*child); |
2647 |
|
delete child; |
2648 |
|
} |
2649 |
|
} |
2650 |
|
|
2651 |
|
int iTotalScripts = 0; |
2652 |
|
|
2653 |
|
if (!file) goto noScripts; |
2654 |
|
|
2655 |
|
// add all configured macros as menu items to the "Macro" menu |
2656 |
|
for (int iGroup = 0; file->GetScriptGroup(iGroup); ++iGroup) { |
2657 |
|
gig::ScriptGroup* pGroup = file->GetScriptGroup(iGroup); |
2658 |
|
for (int iScript = 0; pGroup->GetScript(iScript); ++iScript, ++iTotalScripts) { |
2659 |
|
gig::Script* pScript = pGroup->GetScript(iScript); |
2660 |
|
std::string name = pScript->Name; |
2661 |
|
|
2662 |
|
Gtk::MenuItem* item = new Gtk::MenuItem(name); |
2663 |
|
item->signal_activate().connect( |
2664 |
|
sigc::bind( |
2665 |
|
sigc::mem_fun(*this, &MainWindow::assignScript), pScript |
2666 |
|
) |
2667 |
|
); |
2668 |
|
assign_scripts_menu->append(*item); |
2669 |
|
item->set_accel_path("<Scripts>/script_" + ToString(iTotalScripts)); |
2670 |
|
//item->set_tooltip_text(comment); |
2671 |
|
} |
2672 |
|
} |
2673 |
|
|
2674 |
|
noScripts: |
2675 |
|
|
2676 |
|
// if there are no macros configured at all, then show a dummy entry instead |
2677 |
|
if (!iTotalScripts) { |
2678 |
|
Gtk::MenuItem* item = new Gtk::MenuItem(_("No Scripts")); |
2679 |
|
item->set_sensitive(false); |
2680 |
|
assign_scripts_menu->append(*item); |
2681 |
|
} |
2682 |
|
|
2683 |
|
assign_scripts_menu->show_all_children(); |
2684 |
|
} |
2685 |
|
|
2686 |
Gtk::RadioMenuItem* MainWindow::add_instrument_to_menu( |
Gtk::RadioMenuItem* MainWindow::add_instrument_to_menu( |
2687 |
const Glib::ustring& name, int position) { |
const Glib::ustring& name, int position) { |
2688 |
|
|
2725 |
rowInstr[m_Columns.m_col_nr] = m_refTreeModel->children().size() - 1; |
rowInstr[m_Columns.m_col_nr] = m_refTreeModel->children().size() - 1; |
2726 |
rowInstr[m_Columns.m_col_name] = name; |
rowInstr[m_Columns.m_col_name] = name; |
2727 |
rowInstr[m_Columns.m_col_instr] = instrument; |
rowInstr[m_Columns.m_col_instr] = instrument; |
2728 |
|
rowInstr[m_Columns.m_col_scripts] = ""; |
2729 |
instrument_name_connection.unblock(); |
instrument_name_connection.unblock(); |
2730 |
|
|
2731 |
add_instrument_to_menu(name); |
add_instrument_to_menu(name); |
2732 |
|
select_instrument(instrument); |
|
m_TreeView.get_selection()->select(iterInstr); |
|
|
|
|
2733 |
file_changed(); |
file_changed(); |
2734 |
} |
} |
2735 |
|
|
3012 |
|
|
3013 |
// show 'browse for file' dialog |
// show 'browse for file' dialog |
3014 |
Gtk::FileChooserDialog dialog(*this, replace ? _("Replace Sample with") : _("Add Sample(s)")); |
Gtk::FileChooserDialog dialog(*this, replace ? _("Replace Sample with") : _("Add Sample(s)")); |
3015 |
dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
3016 |
dialog.add_button(_("_Open"), Gtk::RESPONSE_OK); |
dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); |
3017 |
dialog.set_select_multiple(!replace); // allow multi audio file selection only when adding new samples, does not make sense when replacing a specific sample |
dialog.set_select_multiple(!replace); // allow multi audio file selection only when adding new samples, does not make sense when replacing a specific sample |
3018 |
|
|
3019 |
// matches all file types supported by libsndfile |
// matches all file types supported by libsndfile |
3213 |
dialog.get_vbox()->pack_start(entryArea, Gtk::PACK_SHRINK); |
dialog.get_vbox()->pack_start(entryArea, Gtk::PACK_SHRINK); |
3214 |
description.show(); |
description.show(); |
3215 |
entryArea.show_all(); |
entryArea.show_all(); |
3216 |
dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
3217 |
dialog.add_button(_("Select"), Gtk::RESPONSE_OK); |
dialog.add_button(_("Select"), Gtk::RESPONSE_OK); |
3218 |
dialog.set_select_multiple(false); |
dialog.set_select_multiple(false); |
3219 |
if (current_sample_dir != "") { |
if (current_sample_dir != "") { |
3701 |
|
|
3702 |
void MainWindow::on_action_combine_instruments() { |
void MainWindow::on_action_combine_instruments() { |
3703 |
CombineInstrumentsDialog* d = new CombineInstrumentsDialog(*this, file); |
CombineInstrumentsDialog* d = new CombineInstrumentsDialog(*this, file); |
3704 |
|
|
3705 |
|
// take over selection from instruments list view for the combine dialog's |
3706 |
|
// list view as pre-selection |
3707 |
|
std::set<int> indeces; |
3708 |
|
{ |
3709 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
3710 |
|
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
3711 |
|
for (int r = 0; r < rows.size(); ++r) { |
3712 |
|
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[r]); |
3713 |
|
if (it) { |
3714 |
|
Gtk::TreeModel::Row row = *it; |
3715 |
|
int index = row[m_Columns.m_col_nr]; |
3716 |
|
indeces.insert(index); |
3717 |
|
} |
3718 |
|
} |
3719 |
|
} |
3720 |
|
d->setSelectedInstruments(indeces); |
3721 |
|
|
3722 |
d->show_all(); |
d->show_all(); |
|
d->resize(500, 400); |
|
3723 |
d->run(); |
d->run(); |
3724 |
if (d->fileWasChanged()) { |
if (d->fileWasChanged()) { |
3725 |
// update GUI with new instrument just created |
// update GUI with new instrument just created |
3854 |
} |
} |
3855 |
|
|
3856 |
Gtk::FileChooserDialog dialog(*this, _("Merge .gig files")); |
Gtk::FileChooserDialog dialog(*this, _("Merge .gig files")); |
3857 |
dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
3858 |
dialog.add_button(_("Merge"), Gtk::RESPONSE_OK); |
dialog.add_button(_("Merge"), Gtk::RESPONSE_OK); |
3859 |
dialog.set_default_response(Gtk::RESPONSE_CANCEL); |
dialog.set_default_response(Gtk::RESPONSE_CANCEL); |
3860 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
3981 |
m_TreeViewNotebook.set_current_page(2); |
m_TreeViewNotebook.set_current_page(2); |
3982 |
} |
} |
3983 |
|
|
3984 |
|
void MainWindow::select_instrument_by_dir(int dir) { |
3985 |
|
if (!file) return; |
3986 |
|
gig::Instrument* pInstrument = get_instrument(); |
3987 |
|
if (!pInstrument) { |
3988 |
|
select_instrument( file->GetInstrument(0) ); |
3989 |
|
return; |
3990 |
|
} |
3991 |
|
for (int i = 0; file->GetInstrument(i); ++i) { |
3992 |
|
if (file->GetInstrument(i) == pInstrument) { |
3993 |
|
select_instrument( file->GetInstrument(i + dir) ); |
3994 |
|
return; |
3995 |
|
} |
3996 |
|
} |
3997 |
|
} |
3998 |
|
|
3999 |
|
void MainWindow::select_prev_instrument() { |
4000 |
|
select_instrument_by_dir(-1); |
4001 |
|
} |
4002 |
|
|
4003 |
|
void MainWindow::select_next_instrument() { |
4004 |
|
select_instrument_by_dir(1); |
4005 |
|
} |
4006 |
|
|
4007 |
void MainWindow::select_prev_region() { |
void MainWindow::select_prev_region() { |
4008 |
m_RegionChooser.select_prev_region(); |
m_RegionChooser.select_prev_region(); |
4009 |
} |
} |
4077 |
|
|
4078 |
void MainWindow::adjust_clipboard_content() { |
void MainWindow::adjust_clipboard_content() { |
4079 |
MacroEditor* editor = new MacroEditor(); |
MacroEditor* editor = new MacroEditor(); |
4080 |
editor->setMacro(&m_serializationArchive); |
editor->setMacro(&m_serializationArchive, true); |
4081 |
editor->show(); |
editor->show(); |
4082 |
} |
} |
4083 |
|
|
4127 |
itDimReg != dimreg_edit.dimregs.end(); ++itDimReg) |
itDimReg != dimreg_edit.dimregs.end(); ++itDimReg) |
4128 |
{ |
{ |
4129 |
gig::DimensionRegion* pDimRgn = *itDimReg; |
gig::DimensionRegion* pDimRgn = *itDimReg; |
4130 |
dimreg_to_be_changed_signal.emit(pDimRgn); |
DimRegionChangeGuard(this, pDimRgn); |
4131 |
m_serializationArchive.deserialize(pDimRgn); |
macro.deserialize(pDimRgn); |
|
dimreg_changed_signal.emit(pDimRgn); |
|
4132 |
} |
} |
4133 |
//region_changed() |
//region_changed() |
4134 |
file_changed(); |
file_changed(); |