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> |
42 |
|
#include <gtkmm/accelmap.h> |
43 |
#if GTKMM_MAJOR_VERSION < 3 |
#if GTKMM_MAJOR_VERSION < 3 |
44 |
#include "wrapLabel.hh" |
#include "wrapLabel.hh" |
45 |
#endif |
#endif |
61 |
#include "../../gfx/status_detached.xpm" |
#include "../../gfx/status_detached.xpm" |
62 |
#include "gfx/builtinpix.h" |
#include "gfx/builtinpix.h" |
63 |
#include "MacroEditor.h" |
#include "MacroEditor.h" |
64 |
|
#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 |
|
|
171 |
actionGroup = Gtk::ActionGroup::create(); |
actionGroup = Gtk::ActionGroup::create(); |
172 |
|
|
173 |
actionGroup->add(Gtk::Action::create("MenuFile", _("_File"))); |
actionGroup->add(Gtk::Action::create("MenuFile", _("_File"))); |
174 |
actionGroup->add(Gtk::Action::create("New", _("_New")), |
actionGroup->add(Gtk::Action::create("New", Gtk::Stock::NEW), |
|
Gtk::AccelKey("<control>n"), |
|
175 |
sigc::mem_fun( |
sigc::mem_fun( |
176 |
*this, &MainWindow::on_action_file_new)); |
*this, &MainWindow::on_action_file_new)); |
177 |
actionGroup->add(Gtk::Action::create("Open", _("_Open...")), |
Glib::RefPtr<Gtk::Action> action = |
178 |
Gtk::AccelKey("<control>o"), |
Gtk::Action::create("Open", Gtk::Stock::OPEN); |
179 |
|
action->property_label() = action->property_label() + "..."; |
180 |
|
actionGroup->add(action, |
181 |
sigc::mem_fun( |
sigc::mem_fun( |
182 |
*this, &MainWindow::on_action_file_open)); |
*this, &MainWindow::on_action_file_open)); |
183 |
actionGroup->add(Gtk::Action::create("Save", _("_Save")), |
actionGroup->add(Gtk::Action::create("Save", Gtk::Stock::SAVE), |
|
Gtk::AccelKey("<control>s"), |
|
184 |
sigc::mem_fun( |
sigc::mem_fun( |
185 |
*this, &MainWindow::on_action_file_save)); |
*this, &MainWindow::on_action_file_save)); |
186 |
actionGroup->add(Gtk::Action::create("SaveAs", _("Save _As...")), |
action = Gtk::Action::create("SaveAs", Gtk::Stock::SAVE_AS); |
187 |
|
action->property_label() = action->property_label() + "..."; |
188 |
|
actionGroup->add(action, |
189 |
Gtk::AccelKey("<shift><control>s"), |
Gtk::AccelKey("<shift><control>s"), |
190 |
sigc::mem_fun( |
sigc::mem_fun( |
191 |
*this, &MainWindow::on_action_file_save_as)); |
*this, &MainWindow::on_action_file_save_as)); |
192 |
actionGroup->add(Gtk::Action::create("Properties", |
actionGroup->add(Gtk::Action::create("Properties", |
193 |
_("_Properties")), |
Gtk::Stock::PROPERTIES), |
194 |
sigc::mem_fun( |
sigc::mem_fun( |
195 |
*this, &MainWindow::on_action_file_properties)); |
*this, &MainWindow::on_action_file_properties)); |
196 |
actionGroup->add(Gtk::Action::create("InstrProperties", |
actionGroup->add(Gtk::Action::create("InstrProperties", |
197 |
_("_Properties")), |
Gtk::Stock::PROPERTIES), |
198 |
sigc::mem_fun( |
sigc::mem_fun( |
199 |
*this, &MainWindow::show_instr_props)); |
*this, &MainWindow::show_instr_props)); |
200 |
actionGroup->add(Gtk::Action::create("MidiRules", |
actionGroup->add(Gtk::Action::create("MidiRules", |
205 |
_("_Script Slots...")), |
_("_Script Slots...")), |
206 |
sigc::mem_fun( |
sigc::mem_fun( |
207 |
*this, &MainWindow::show_script_slots)); |
*this, &MainWindow::show_script_slots)); |
208 |
actionGroup->add(Gtk::Action::create("Quit", _("_Quit")), |
actionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT), |
|
Gtk::AccelKey("<control>q"), |
|
209 |
sigc::mem_fun( |
sigc::mem_fun( |
210 |
*this, &MainWindow::on_action_quit)); |
*this, &MainWindow::on_action_quit)); |
211 |
actionGroup->add( |
actionGroup->add( |
302 |
actionGroup->add(toggle_action); |
actionGroup->add(toggle_action); |
303 |
|
|
304 |
|
|
305 |
|
actionGroup->add(Gtk::Action::create("MenuMacro", _("_Macro"))); |
306 |
|
|
307 |
|
|
308 |
actionGroup->add(Gtk::Action::create("MenuView", _("Vie_w"))); |
actionGroup->add(Gtk::Action::create("MenuView", _("Vie_w"))); |
309 |
toggle_action = |
toggle_action = |
310 |
Gtk::ToggleAction::create("Statusbar", _("_Statusbar")); |
Gtk::ToggleAction::create("Statusbar", _("_Statusbar")); |
332 |
sigc::mem_fun(*this, &MainWindow::on_action_refresh_all) |
sigc::mem_fun(*this, &MainWindow::on_action_refresh_all) |
333 |
); |
); |
334 |
|
|
335 |
actionGroup->add(Gtk::Action::create("MenuHelp", _("_Help"))); |
action = Gtk::Action::create("MenuHelp", Gtk::Stock::HELP); |
336 |
actionGroup->add(Gtk::Action::create("About", _("_About")), |
actionGroup->add(Gtk::Action::create("MenuHelp", |
337 |
|
action->property_label())); |
338 |
|
actionGroup->add(Gtk::Action::create("About", Gtk::Stock::ABOUT), |
339 |
sigc::mem_fun( |
sigc::mem_fun( |
340 |
*this, &MainWindow::on_action_help_about)); |
*this, &MainWindow::on_action_help_about)); |
341 |
actionGroup->add( |
actionGroup->add( |
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("RemoveInstrument", _("_Remove")), |
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), |
356 |
sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument) |
sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument) |
357 |
); |
); |
358 |
|
|
399 |
|
|
400 |
// sample right-click popup actions |
// sample right-click popup actions |
401 |
actionGroup->add( |
actionGroup->add( |
402 |
Gtk::Action::create("SampleProperties", _("_Properties")), |
Gtk::Action::create("SampleProperties", Gtk::Stock::PROPERTIES), |
403 |
sigc::mem_fun(*this, &MainWindow::on_action_sample_properties) |
sigc::mem_fun(*this, &MainWindow::on_action_sample_properties) |
404 |
); |
); |
405 |
actionGroup->add( |
actionGroup->add( |
411 |
sigc::mem_fun(*this, &MainWindow::on_action_add_sample) |
sigc::mem_fun(*this, &MainWindow::on_action_add_sample) |
412 |
); |
); |
413 |
actionGroup->add( |
actionGroup->add( |
414 |
Gtk::Action::create("RemoveSample", _("_Remove")), |
Gtk::Action::create("RemoveSample", Gtk::Stock::REMOVE), |
415 |
sigc::mem_fun(*this, &MainWindow::on_action_remove_sample) |
sigc::mem_fun(*this, &MainWindow::on_action_remove_sample) |
416 |
); |
); |
417 |
actionGroup->add( |
actionGroup->add( |
447 |
sigc::mem_fun(*this, &MainWindow::on_action_edit_script) |
sigc::mem_fun(*this, &MainWindow::on_action_edit_script) |
448 |
); |
); |
449 |
actionGroup->add( |
actionGroup->add( |
450 |
Gtk::Action::create("RemoveScript", _("_Remove")), |
Gtk::Action::create("RemoveScript", Gtk::Stock::REMOVE), |
451 |
sigc::mem_fun(*this, &MainWindow::on_action_remove_script) |
sigc::mem_fun(*this, &MainWindow::on_action_remove_script) |
452 |
); |
); |
453 |
|
|
488 |
" <menuitem action='CopySampleTune'/>" |
" <menuitem action='CopySampleTune'/>" |
489 |
" <menuitem action='CopySampleLoop'/>" |
" <menuitem action='CopySampleLoop'/>" |
490 |
" </menu>" |
" </menu>" |
491 |
|
" <menu action='MenuMacro'>" |
492 |
|
" </menu>" |
493 |
" <menu action='MenuSample'>" |
" <menu action='MenuSample'>" |
494 |
" <menuitem action='SampleProperties'/>" |
" <menuitem action='SampleProperties'/>" |
495 |
" <menuitem action='AddGroup'/>" |
" <menuitem action='AddGroup'/>" |
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 |
858 |
); |
); |
859 |
updateClipboardPasteAvailable(); |
updateClipboardPasteAvailable(); |
860 |
updateClipboardCopyAvailable(); |
updateClipboardCopyAvailable(); |
861 |
|
|
862 |
|
// setup macros and their keyboard accelerators |
863 |
|
{ |
864 |
|
Gtk::Menu* menuMacro = dynamic_cast<Gtk::MenuItem*>( |
865 |
|
uiManager->get_widget("/MenuBar/MenuMacro") |
866 |
|
)->get_submenu(); |
867 |
|
|
868 |
|
const Gdk::ModifierType noModifier = (Gdk::ModifierType)0; |
869 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_0", GDK_KEY_F1, noModifier); |
870 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_1", GDK_KEY_F2, noModifier); |
871 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_2", GDK_KEY_F3, noModifier); |
872 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_3", GDK_KEY_F4, noModifier); |
873 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_4", GDK_KEY_F5, noModifier); |
874 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_5", GDK_KEY_F6, noModifier); |
875 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_6", GDK_KEY_F7, noModifier); |
876 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_7", GDK_KEY_F8, noModifier); |
877 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_8", GDK_KEY_F9, noModifier); |
878 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_9", GDK_KEY_F10, noModifier); |
879 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_10", GDK_KEY_F11, noModifier); |
880 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_11", GDK_KEY_F12, noModifier); |
881 |
|
Gtk::AccelMap::add_entry("<Macros>/SetupMacros", 'm', primaryModifierKey); |
882 |
|
|
883 |
|
Glib::RefPtr<Gtk::AccelGroup> accelGroup = this->get_accel_group(); |
884 |
|
menuMacro->set_accel_group(accelGroup); |
885 |
|
|
886 |
|
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() { |
908 |
|
Gtk::Menu* menuMacro = dynamic_cast<Gtk::MenuItem*>( |
909 |
|
uiManager->get_widget("/MenuBar/MenuMacro") |
910 |
|
)->get_submenu(); |
911 |
|
|
912 |
|
// remove all entries from "Macro" menu |
913 |
|
{ |
914 |
|
const std::vector<Gtk::Widget*> children = menuMacro->get_children(); |
915 |
|
for (int i = 0; i < children.size(); ++i) { |
916 |
|
Gtk::Widget* child = children[i]; |
917 |
|
menuMacro->remove(*child); |
918 |
|
delete child; |
919 |
|
} |
920 |
|
} |
921 |
|
|
922 |
|
// (re)load all macros from config file |
923 |
|
try { |
924 |
|
Settings::singleton()->loadMacros(m_macros); |
925 |
|
} catch (Serialization::Exception e) { |
926 |
|
std::cerr << "Exception while loading macros: " << e.Message << std::endl; |
927 |
|
} catch (...) { |
928 |
|
std::cerr << "Unknown exception while loading macros!" << std::endl; |
929 |
|
} |
930 |
|
|
931 |
|
// add all configured macros as menu items to the "Macro" menu |
932 |
|
for (int iMacro = 0; iMacro < m_macros.size(); ++iMacro) { |
933 |
|
const Serialization::Archive& macro = m_macros[iMacro]; |
934 |
|
std::string name = |
935 |
|
macro.name().empty() ? |
936 |
|
(std::string(_("Unnamed Macro")) + " " + ToString(iMacro+1)) : macro.name(); |
937 |
|
Gtk::MenuItem* item = new Gtk::MenuItem(name); |
938 |
|
item->signal_activate().connect( |
939 |
|
sigc::bind( |
940 |
|
sigc::mem_fun(*this, &MainWindow::onMacroSelected), iMacro |
941 |
|
) |
942 |
|
); |
943 |
|
menuMacro->append(*item); |
944 |
|
item->set_accel_path("<Macros>/macro_" + ToString(iMacro)); |
945 |
|
Glib::ustring comment = macro.comment(); |
946 |
|
if (!comment.empty()) |
947 |
|
item->set_tooltip_text(comment); |
948 |
|
} |
949 |
|
// if there are no macros configured at all, then show a dummy entry instead |
950 |
|
if (m_macros.empty()) { |
951 |
|
Gtk::MenuItem* item = new Gtk::MenuItem(_("No Macros")); |
952 |
|
item->set_sensitive(false); |
953 |
|
menuMacro->append(*item); |
954 |
|
} |
955 |
|
|
956 |
|
// add separator line to menu |
957 |
|
menuMacro->append(*new Gtk::SeparatorMenuItem); |
958 |
|
|
959 |
|
{ |
960 |
|
Gtk::MenuItem* item = new Gtk::MenuItem(_("Setup Macros ...")); |
961 |
|
item->signal_activate().connect( |
962 |
|
sigc::mem_fun(*this, &MainWindow::setupMacros) |
963 |
|
); |
964 |
|
menuMacro->append(*item); |
965 |
|
item->set_accel_path("<Macros>/SetupMacros"); |
966 |
|
} |
967 |
|
|
968 |
|
menuMacro->show_all_children(); |
969 |
|
} |
970 |
|
|
971 |
|
void MainWindow::onMacroSelected(int iMacro) { |
972 |
|
printf("onMacroSelected(%d)\n", iMacro); |
973 |
|
if (iMacro < 0 || iMacro >= m_macros.size()) return; |
974 |
|
Glib::ustring errorText; |
975 |
|
try { |
976 |
|
applyMacro(m_macros[iMacro]); |
977 |
|
} catch (Serialization::Exception e) { |
978 |
|
errorText = e.Message; |
979 |
|
} catch (...) { |
980 |
|
errorText = _("Unknown exception while applying macro"); |
981 |
|
} |
982 |
|
if (!errorText.empty()) { |
983 |
|
Glib::ustring txt = _("Applying macro failed:\n") + errorText; |
984 |
|
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
985 |
|
msg.run(); |
986 |
|
} |
987 |
|
} |
988 |
|
|
989 |
|
void MainWindow::setupMacros() { |
990 |
|
MacrosSetup* setup = new MacrosSetup(); |
991 |
|
gig::DimensionRegion* pDimRgn = m_DimRegionChooser.get_main_dimregion(); |
992 |
|
setup->setMacros(m_macros, &m_serializationArchive, pDimRgn); |
993 |
|
setup->signal_macros_changed().connect( |
994 |
|
sigc::mem_fun(*this, &MainWindow::onMacrosSetupChanged) |
995 |
|
); |
996 |
|
setup->show(); |
997 |
|
} |
998 |
|
|
999 |
|
void MainWindow::onMacrosSetupChanged(const std::vector<Serialization::Archive>& macros) { |
1000 |
|
m_macros = macros; |
1001 |
|
Settings::singleton()->saveMacros(m_macros); |
1002 |
|
updateMacroMenu(); |
1003 |
|
} |
1004 |
|
|
1005 |
bool MainWindow::on_delete_event(GdkEventAny* event) |
bool MainWindow::on_delete_event(GdkEventAny* event) |
1006 |
{ |
{ |
1007 |
return !file_is_shared && file_is_changed && !close_confirmation_dialog(); |
return !file_is_shared && file_is_changed && !close_confirmation_dialog(); |
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 |
} |
} |
1375 |
g_free(msg); |
g_free(msg); |
1376 |
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.")); |
1377 |
dialog.add_button(_("Close _Without Saving"), Gtk::RESPONSE_NO); |
dialog.add_button(_("Close _Without Saving"), Gtk::RESPONSE_NO); |
1378 |
dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
1379 |
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); |
1380 |
dialog.set_default_response(Gtk::RESPONSE_YES); |
dialog.set_default_response(Gtk::RESPONSE_YES); |
1381 |
int response = dialog.run(); |
int response = dialog.run(); |
1382 |
dialog.hide(); |
dialog.hide(); |
1407 |
"used by the sampler until you tell the sampler explicitly to " |
"used by the sampler until you tell the sampler explicitly to " |
1408 |
"load it.")); |
"load it.")); |
1409 |
dialog.add_button(_("_Yes, Detach"), Gtk::RESPONSE_YES); |
dialog.add_button(_("_Yes, Detach"), Gtk::RESPONSE_YES); |
1410 |
dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
1411 |
dialog.set_default_response(Gtk::RESPONSE_CANCEL); |
dialog.set_default_response(Gtk::RESPONSE_CANCEL); |
1412 |
int response = dialog.run(); |
int response = dialog.run(); |
1413 |
dialog.hide(); |
dialog.hide(); |
1421 |
if (file_is_shared && !leaving_shared_mode_dialog()) return; |
if (file_is_shared && !leaving_shared_mode_dialog()) return; |
1422 |
|
|
1423 |
Gtk::FileChooserDialog dialog(*this, _("Open file")); |
Gtk::FileChooserDialog dialog(*this, _("Open file")); |
1424 |
dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
1425 |
dialog.add_button(_("_Open"), Gtk::RESPONSE_OK); |
dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); |
1426 |
dialog.set_default_response(Gtk::RESPONSE_OK); |
dialog.set_default_response(Gtk::RESPONSE_OK); |
1427 |
#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 |
1428 |
Gtk::FileFilter filter; |
Gtk::FileFilter filter; |
1617 |
|
|
1618 |
bool MainWindow::file_save_as() |
bool MainWindow::file_save_as() |
1619 |
{ |
{ |
1620 |
Gtk::FileChooserDialog dialog(*this, _("Save As"), Gtk::FILE_CHOOSER_ACTION_SAVE); |
Gtk::FileChooserDialog dialog(*this, _("Save as"), Gtk::FILE_CHOOSER_ACTION_SAVE); |
1621 |
dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
1622 |
dialog.add_button(_("_Save"), Gtk::RESPONSE_OK); |
dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK); |
1623 |
dialog.set_default_response(Gtk::RESPONSE_OK); |
dialog.set_default_response(Gtk::RESPONSE_OK); |
1624 |
dialog.set_do_overwrite_confirmation(); |
dialog.set_do_overwrite_confirmation(); |
1625 |
|
|
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 |
|
|
1865 |
eSourceForm(_("Source form")), |
eSourceForm(_("Source form")), |
1866 |
eCommissioned(_("Commissioned")), |
eCommissioned(_("Commissioned")), |
1867 |
eSubject(_("Subject")), |
eSubject(_("Subject")), |
1868 |
quitButton(_("_Close"), true), |
quitButton(Gtk::Stock::CLOSE), |
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 |
|
|
1993 |
} |
} |
1994 |
|
|
1995 |
InstrumentProps::InstrumentProps() : |
InstrumentProps::InstrumentProps() : |
1996 |
quitButton(_("_Close"), true), |
quitButton(Gtk::Stock::CLOSE), |
1997 |
table(2,1), |
table(2,1), |
1998 |
eName(_("Name")), |
eName(_("Name")), |
1999 |
eIsDrum(_("Is drum")), |
eIsDrum(_("Is drum")), |
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); |
2624 |
|
|
2625 |
m_TreeView.get_selection()->select(iterInstr); |
m_TreeView.get_selection()->select(iterInstr); |
2626 |
|
m_TreeView.scroll_to_row(Gtk::TreePath(iterInstr)); |
2627 |
|
|
2628 |
file_changed(); |
file_changed(); |
2629 |
} |
} |
2907 |
|
|
2908 |
// show 'browse for file' dialog |
// show 'browse for file' dialog |
2909 |
Gtk::FileChooserDialog dialog(*this, replace ? _("Replace Sample with") : _("Add Sample(s)")); |
Gtk::FileChooserDialog dialog(*this, replace ? _("Replace Sample with") : _("Add Sample(s)")); |
2910 |
dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
2911 |
dialog.add_button(_("_Open"), Gtk::RESPONSE_OK); |
dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); |
2912 |
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 |
2913 |
|
|
2914 |
// matches all file types supported by libsndfile |
// matches all file types supported by libsndfile |
3108 |
dialog.get_vbox()->pack_start(entryArea, Gtk::PACK_SHRINK); |
dialog.get_vbox()->pack_start(entryArea, Gtk::PACK_SHRINK); |
3109 |
description.show(); |
description.show(); |
3110 |
entryArea.show_all(); |
entryArea.show_all(); |
3111 |
dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
3112 |
dialog.add_button(_("Select"), Gtk::RESPONSE_OK); |
dialog.add_button(_("Select"), Gtk::RESPONSE_OK); |
3113 |
dialog.set_select_multiple(false); |
dialog.set_select_multiple(false); |
3114 |
if (current_sample_dir != "") { |
if (current_sample_dir != "") { |
3596 |
|
|
3597 |
void MainWindow::on_action_combine_instruments() { |
void MainWindow::on_action_combine_instruments() { |
3598 |
CombineInstrumentsDialog* d = new CombineInstrumentsDialog(*this, file); |
CombineInstrumentsDialog* d = new CombineInstrumentsDialog(*this, file); |
3599 |
|
|
3600 |
|
// take over selection from instruments list view for the combine dialog's |
3601 |
|
// list view as pre-selection |
3602 |
|
std::set<int> indeces; |
3603 |
|
{ |
3604 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
3605 |
|
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
3606 |
|
for (int r = 0; r < rows.size(); ++r) { |
3607 |
|
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[r]); |
3608 |
|
if (it) { |
3609 |
|
Gtk::TreeModel::Row row = *it; |
3610 |
|
int index = row[m_Columns.m_col_nr]; |
3611 |
|
indeces.insert(index); |
3612 |
|
} |
3613 |
|
} |
3614 |
|
} |
3615 |
|
d->setSelectedInstruments(indeces); |
3616 |
|
|
3617 |
d->show_all(); |
d->show_all(); |
|
d->resize(500, 400); |
|
3618 |
d->run(); |
d->run(); |
3619 |
if (d->fileWasChanged()) { |
if (d->fileWasChanged()) { |
3620 |
// update GUI with new instrument just created |
// update GUI with new instrument just created |
3749 |
} |
} |
3750 |
|
|
3751 |
Gtk::FileChooserDialog dialog(*this, _("Merge .gig files")); |
Gtk::FileChooserDialog dialog(*this, _("Merge .gig files")); |
3752 |
dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
3753 |
dialog.add_button(_("Merge"), Gtk::RESPONSE_OK); |
dialog.add_button(_("Merge"), Gtk::RESPONSE_OK); |
3754 |
dialog.set_default_response(Gtk::RESPONSE_CANCEL); |
dialog.set_default_response(Gtk::RESPONSE_CANCEL); |
3755 |
#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 |
3949 |
|
|
3950 |
void MainWindow::adjust_clipboard_content() { |
void MainWindow::adjust_clipboard_content() { |
3951 |
MacroEditor* editor = new MacroEditor(); |
MacroEditor* editor = new MacroEditor(); |
3952 |
editor->setMacro(&m_serializationArchive); |
editor->setMacro(&m_serializationArchive, true); |
3953 |
editor->show(); |
editor->show(); |
3954 |
} |
} |
3955 |
|
|
3990 |
updateClipboardCopyAvailable(); |
updateClipboardCopyAvailable(); |
3991 |
} |
} |
3992 |
|
|
3993 |
|
//NOTE: Might throw exception !!! |
3994 |
|
void MainWindow::applyMacro(Serialization::Archive& macro) { |
3995 |
|
gig::DimensionRegion* pDimRgn = m_DimRegionChooser.get_main_dimregion(); |
3996 |
|
if (!pDimRgn) return; |
3997 |
|
|
3998 |
|
for (std::set<gig::DimensionRegion*>::iterator itDimReg = dimreg_edit.dimregs.begin(); |
3999 |
|
itDimReg != dimreg_edit.dimregs.end(); ++itDimReg) |
4000 |
|
{ |
4001 |
|
gig::DimensionRegion* pDimRgn = *itDimReg; |
4002 |
|
DimRegionChangeGuard(this, pDimRgn); |
4003 |
|
macro.deserialize(pDimRgn); |
4004 |
|
} |
4005 |
|
//region_changed() |
4006 |
|
file_changed(); |
4007 |
|
dimreg_changed(); |
4008 |
|
} |
4009 |
|
|
4010 |
void MainWindow::on_clipboard_received(const Gtk::SelectionData& selection_data) { |
void MainWindow::on_clipboard_received(const Gtk::SelectionData& selection_data) { |
4011 |
const std::string target = selection_data.get_target(); |
const std::string target = selection_data.get_target(); |
4012 |
if (target == CLIPBOARD_DIMENSIONREGION_TARGET) { |
if (target == CLIPBOARD_DIMENSIONREGION_TARGET) { |
|
gig::DimensionRegion* pDimRgn = m_DimRegionChooser.get_main_dimregion(); |
|
|
if (!pDimRgn) return; |
|
|
|
|
4013 |
Glib::ustring errorText; |
Glib::ustring errorText; |
4014 |
try { |
try { |
4015 |
m_serializationArchive.decode( |
m_serializationArchive.decode( |
4016 |
selection_data.get_data(), selection_data.get_length() |
selection_data.get_data(), selection_data.get_length() |
4017 |
); |
); |
4018 |
|
applyMacro(m_serializationArchive); |
|
for (std::set<gig::DimensionRegion*>::iterator itDimReg = dimreg_edit.dimregs.begin(); |
|
|
itDimReg != dimreg_edit.dimregs.end(); ++itDimReg) |
|
|
{ |
|
|
gig::DimensionRegion* pDimRgn = *itDimReg; |
|
|
|
|
|
dimreg_to_be_changed_signal.emit(pDimRgn); |
|
|
|
|
|
m_serializationArchive.deserialize(pDimRgn); |
|
|
|
|
|
dimreg_changed_signal.emit(pDimRgn); |
|
|
} |
|
|
|
|
|
//region_changed() |
|
|
file_changed(); |
|
|
dimreg_changed(); |
|
|
|
|
4019 |
} catch (Serialization::Exception e) { |
} catch (Serialization::Exception e) { |
4020 |
errorText = e.Message; |
errorText = e.Message; |
4021 |
} catch (...) { |
} catch (...) { |
4022 |
errorText = _("Unknown exception during deserialization decoding"); |
errorText = _("Unknown exception while pasting DimensionRegion"); |
4023 |
} |
} |
4024 |
if (!errorText.empty()) { |
if (!errorText.empty()) { |
4025 |
Glib::ustring txt = _("Pasting DimensionRegion failed:\n") + errorText; |
Glib::ustring txt = _("Pasting DimensionRegion failed:\n") + errorText; |