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 |
60 |
#include "../../gfx/status_attached.xpm" |
#include "../../gfx/status_attached.xpm" |
61 |
#include "../../gfx/status_detached.xpm" |
#include "../../gfx/status_detached.xpm" |
62 |
#include "gfx/builtinpix.h" |
#include "gfx/builtinpix.h" |
63 |
|
#include "MacroEditor.h" |
64 |
|
#include "MacrosSetup.h" |
65 |
|
|
66 |
MainWindow::MainWindow() : |
MainWindow::MainWindow() : |
67 |
m_DimRegionChooser(*this), |
m_DimRegionChooser(*this), |
157 |
actionGroup = Gtk::ActionGroup::create(); |
actionGroup = Gtk::ActionGroup::create(); |
158 |
|
|
159 |
actionGroup->add(Gtk::Action::create("MenuFile", _("_File"))); |
actionGroup->add(Gtk::Action::create("MenuFile", _("_File"))); |
160 |
actionGroup->add(Gtk::Action::create("New", _("_New")), |
actionGroup->add(Gtk::Action::create("New", Gtk::Stock::NEW), |
|
Gtk::AccelKey("<control>n"), |
|
161 |
sigc::mem_fun( |
sigc::mem_fun( |
162 |
*this, &MainWindow::on_action_file_new)); |
*this, &MainWindow::on_action_file_new)); |
163 |
actionGroup->add(Gtk::Action::create("Open", _("_Open...")), |
Glib::RefPtr<Gtk::Action> action = |
164 |
Gtk::AccelKey("<control>o"), |
Gtk::Action::create("Open", Gtk::Stock::OPEN); |
165 |
|
action->property_label() = action->property_label() + "..."; |
166 |
|
actionGroup->add(action, |
167 |
sigc::mem_fun( |
sigc::mem_fun( |
168 |
*this, &MainWindow::on_action_file_open)); |
*this, &MainWindow::on_action_file_open)); |
169 |
actionGroup->add(Gtk::Action::create("Save", _("_Save")), |
actionGroup->add(Gtk::Action::create("Save", Gtk::Stock::SAVE), |
|
Gtk::AccelKey("<control>s"), |
|
170 |
sigc::mem_fun( |
sigc::mem_fun( |
171 |
*this, &MainWindow::on_action_file_save)); |
*this, &MainWindow::on_action_file_save)); |
172 |
actionGroup->add(Gtk::Action::create("SaveAs", _("Save _As...")), |
action = Gtk::Action::create("SaveAs", Gtk::Stock::SAVE_AS); |
173 |
|
action->property_label() = action->property_label() + "..."; |
174 |
|
actionGroup->add(action, |
175 |
Gtk::AccelKey("<shift><control>s"), |
Gtk::AccelKey("<shift><control>s"), |
176 |
sigc::mem_fun( |
sigc::mem_fun( |
177 |
*this, &MainWindow::on_action_file_save_as)); |
*this, &MainWindow::on_action_file_save_as)); |
178 |
actionGroup->add(Gtk::Action::create("Properties", |
actionGroup->add(Gtk::Action::create("Properties", |
179 |
_("_Properties")), |
Gtk::Stock::PROPERTIES), |
180 |
sigc::mem_fun( |
sigc::mem_fun( |
181 |
*this, &MainWindow::on_action_file_properties)); |
*this, &MainWindow::on_action_file_properties)); |
182 |
actionGroup->add(Gtk::Action::create("InstrProperties", |
actionGroup->add(Gtk::Action::create("InstrProperties", |
183 |
_("_Properties")), |
Gtk::Stock::PROPERTIES), |
184 |
sigc::mem_fun( |
sigc::mem_fun( |
185 |
*this, &MainWindow::show_instr_props)); |
*this, &MainWindow::show_instr_props)); |
186 |
actionGroup->add(Gtk::Action::create("MidiRules", |
actionGroup->add(Gtk::Action::create("MidiRules", |
191 |
_("_Script Slots...")), |
_("_Script Slots...")), |
192 |
sigc::mem_fun( |
sigc::mem_fun( |
193 |
*this, &MainWindow::show_script_slots)); |
*this, &MainWindow::show_script_slots)); |
194 |
actionGroup->add(Gtk::Action::create("Quit", _("_Quit")), |
actionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT), |
|
Gtk::AccelKey("<control>q"), |
|
195 |
sigc::mem_fun( |
sigc::mem_fun( |
196 |
*this, &MainWindow::on_action_quit)); |
*this, &MainWindow::on_action_quit)); |
197 |
actionGroup->add( |
actionGroup->add( |
227 |
Gtk::AccelKey(GDK_KEY_v, Gdk::MOD1_MASK), |
Gtk::AccelKey(GDK_KEY_v, Gdk::MOD1_MASK), |
228 |
sigc::mem_fun(*this, &MainWindow::paste_copied_dimrgn)); |
sigc::mem_fun(*this, &MainWindow::paste_copied_dimrgn)); |
229 |
|
|
230 |
|
actionGroup->add(Gtk::Action::create("AdjustClipboard", |
231 |
|
_("Adjust Clipboard Content")), |
232 |
|
Gtk::AccelKey(GDK_KEY_x, Gdk::MOD1_MASK), |
233 |
|
sigc::mem_fun(*this, &MainWindow::adjust_clipboard_content)); |
234 |
|
|
235 |
actionGroup->add(Gtk::Action::create("SelectPrevRegion", |
actionGroup->add(Gtk::Action::create("SelectPrevRegion", |
236 |
_("Select Previous Region")), |
_("Select Previous Region")), |
237 |
Gtk::AccelKey(GDK_KEY_Left, primaryModifierKey), |
Gtk::AccelKey(GDK_KEY_Left, primaryModifierKey), |
288 |
actionGroup->add(toggle_action); |
actionGroup->add(toggle_action); |
289 |
|
|
290 |
|
|
291 |
|
actionGroup->add(Gtk::Action::create("MenuMacro", _("_Macro"))); |
292 |
|
|
293 |
|
|
294 |
actionGroup->add(Gtk::Action::create("MenuView", _("Vie_w"))); |
actionGroup->add(Gtk::Action::create("MenuView", _("Vie_w"))); |
295 |
toggle_action = |
toggle_action = |
296 |
Gtk::ToggleAction::create("Statusbar", _("_Statusbar")); |
Gtk::ToggleAction::create("Statusbar", _("_Statusbar")); |
318 |
sigc::mem_fun(*this, &MainWindow::on_action_refresh_all) |
sigc::mem_fun(*this, &MainWindow::on_action_refresh_all) |
319 |
); |
); |
320 |
|
|
321 |
actionGroup->add(Gtk::Action::create("MenuHelp", _("_Help"))); |
action = Gtk::Action::create("MenuHelp", Gtk::Stock::HELP); |
322 |
actionGroup->add(Gtk::Action::create("About", _("_About")), |
actionGroup->add(Gtk::Action::create("MenuHelp", |
323 |
|
action->property_label())); |
324 |
|
actionGroup->add(Gtk::Action::create("About", Gtk::Stock::ABOUT), |
325 |
sigc::mem_fun( |
sigc::mem_fun( |
326 |
*this, &MainWindow::on_action_help_about)); |
*this, &MainWindow::on_action_help_about)); |
327 |
actionGroup->add( |
actionGroup->add( |
333 |
sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument) |
sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument) |
334 |
); |
); |
335 |
actionGroup->add( |
actionGroup->add( |
336 |
Gtk::Action::create("RemoveInstrument", _("_Remove")), |
Gtk::Action::create("RemoveInstrument", Gtk::Stock::REMOVE), |
337 |
sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument) |
sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument) |
338 |
); |
); |
339 |
|
|
380 |
|
|
381 |
// sample right-click popup actions |
// sample right-click popup actions |
382 |
actionGroup->add( |
actionGroup->add( |
383 |
Gtk::Action::create("SampleProperties", _("_Properties")), |
Gtk::Action::create("SampleProperties", Gtk::Stock::PROPERTIES), |
384 |
sigc::mem_fun(*this, &MainWindow::on_action_sample_properties) |
sigc::mem_fun(*this, &MainWindow::on_action_sample_properties) |
385 |
); |
); |
386 |
actionGroup->add( |
actionGroup->add( |
392 |
sigc::mem_fun(*this, &MainWindow::on_action_add_sample) |
sigc::mem_fun(*this, &MainWindow::on_action_add_sample) |
393 |
); |
); |
394 |
actionGroup->add( |
actionGroup->add( |
395 |
Gtk::Action::create("RemoveSample", _("_Remove")), |
Gtk::Action::create("RemoveSample", Gtk::Stock::REMOVE), |
396 |
sigc::mem_fun(*this, &MainWindow::on_action_remove_sample) |
sigc::mem_fun(*this, &MainWindow::on_action_remove_sample) |
397 |
); |
); |
398 |
actionGroup->add( |
actionGroup->add( |
428 |
sigc::mem_fun(*this, &MainWindow::on_action_edit_script) |
sigc::mem_fun(*this, &MainWindow::on_action_edit_script) |
429 |
); |
); |
430 |
actionGroup->add( |
actionGroup->add( |
431 |
Gtk::Action::create("RemoveScript", _("_Remove")), |
Gtk::Action::create("RemoveScript", Gtk::Stock::REMOVE), |
432 |
sigc::mem_fun(*this, &MainWindow::on_action_remove_script) |
sigc::mem_fun(*this, &MainWindow::on_action_remove_script) |
433 |
); |
); |
434 |
|
|
452 |
" </menu>" |
" </menu>" |
453 |
" <menu action='MenuEdit'>" |
" <menu action='MenuEdit'>" |
454 |
" <menuitem action='CopyDimRgn'/>" |
" <menuitem action='CopyDimRgn'/>" |
455 |
|
" <menuitem action='AdjustClipboard'/>" |
456 |
" <menuitem action='PasteDimRgn'/>" |
" <menuitem action='PasteDimRgn'/>" |
457 |
" <separator/>" |
" <separator/>" |
458 |
" <menuitem action='SelectPrevRegion'/>" |
" <menuitem action='SelectPrevRegion'/>" |
469 |
" <menuitem action='CopySampleTune'/>" |
" <menuitem action='CopySampleTune'/>" |
470 |
" <menuitem action='CopySampleLoop'/>" |
" <menuitem action='CopySampleLoop'/>" |
471 |
" </menu>" |
" </menu>" |
472 |
|
" <menu action='MenuMacro'>" |
473 |
|
" </menu>" |
474 |
" <menu action='MenuSample'>" |
" <menu action='MenuSample'>" |
475 |
" <menuitem action='SampleProperties'/>" |
" <menuitem action='SampleProperties'/>" |
476 |
" <menuitem action='AddGroup'/>" |
" <menuitem action='AddGroup'/>" |
836 |
); |
); |
837 |
updateClipboardPasteAvailable(); |
updateClipboardPasteAvailable(); |
838 |
updateClipboardCopyAvailable(); |
updateClipboardCopyAvailable(); |
839 |
|
|
840 |
|
// setup macros and their keyboard accelerators |
841 |
|
{ |
842 |
|
Gtk::Menu* menuMacro = dynamic_cast<Gtk::MenuItem*>( |
843 |
|
uiManager->get_widget("/MenuBar/MenuMacro") |
844 |
|
)->get_submenu(); |
845 |
|
|
846 |
|
const Gdk::ModifierType primaryModifierKey = |
847 |
|
#if defined(__APPLE__) |
848 |
|
Gdk::META_MASK; // Cmd key on Mac |
849 |
|
#else |
850 |
|
Gdk::CONTROL_MASK; // Ctrl key on all other OSs |
851 |
|
#endif |
852 |
|
|
853 |
|
const Gdk::ModifierType noModifier = (Gdk::ModifierType)0; |
854 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_0", GDK_KEY_F1, noModifier); |
855 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_1", GDK_KEY_F2, noModifier); |
856 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_2", GDK_KEY_F3, noModifier); |
857 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_3", GDK_KEY_F4, noModifier); |
858 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_4", GDK_KEY_F5, noModifier); |
859 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_5", GDK_KEY_F6, noModifier); |
860 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_6", GDK_KEY_F7, noModifier); |
861 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_7", GDK_KEY_F8, noModifier); |
862 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_8", GDK_KEY_F9, noModifier); |
863 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_9", GDK_KEY_F10, noModifier); |
864 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_10", GDK_KEY_F11, noModifier); |
865 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_11", GDK_KEY_F12, noModifier); |
866 |
|
Gtk::AccelMap::add_entry("<Macros>/SetupMacros", 'm', primaryModifierKey); |
867 |
|
|
868 |
|
Glib::RefPtr<Gtk::AccelGroup> accelGroup = this->get_accel_group(); |
869 |
|
menuMacro->set_accel_group(accelGroup); |
870 |
|
|
871 |
|
updateMacroMenu(); |
872 |
|
} |
873 |
} |
} |
874 |
|
|
875 |
MainWindow::~MainWindow() |
MainWindow::~MainWindow() |
876 |
{ |
{ |
877 |
} |
} |
878 |
|
|
879 |
|
void MainWindow::updateMacroMenu() { |
880 |
|
Gtk::Menu* menuMacro = dynamic_cast<Gtk::MenuItem*>( |
881 |
|
uiManager->get_widget("/MenuBar/MenuMacro") |
882 |
|
)->get_submenu(); |
883 |
|
|
884 |
|
// remove all entries from "Macro" menu |
885 |
|
{ |
886 |
|
const std::vector<Gtk::Widget*> children = menuMacro->get_children(); |
887 |
|
for (int i = 0; i < children.size(); ++i) { |
888 |
|
Gtk::Widget* child = children[i]; |
889 |
|
menuMacro->remove(*child); |
890 |
|
delete child; |
891 |
|
} |
892 |
|
} |
893 |
|
|
894 |
|
// (re)load all macros from config file |
895 |
|
try { |
896 |
|
Settings::singleton()->loadMacros(m_macros); |
897 |
|
} catch (Serialization::Exception e) { |
898 |
|
std::cerr << "Exception while loading macros: " << e.Message << std::endl; |
899 |
|
} catch (...) { |
900 |
|
std::cerr << "Unknown exception while loading macros!" << std::endl; |
901 |
|
} |
902 |
|
|
903 |
|
// add all configured macros as menu items to the "Macro" menu |
904 |
|
for (int iMacro = 0; iMacro < m_macros.size(); ++iMacro) { |
905 |
|
const Serialization::Archive& macro = m_macros[iMacro]; |
906 |
|
std::string name = |
907 |
|
macro.name().empty() ? |
908 |
|
(std::string(_("Unnamed Macro")) + " " + ToString(iMacro+1)) : macro.name(); |
909 |
|
Gtk::MenuItem* item = new Gtk::MenuItem(name); |
910 |
|
item->signal_activate().connect( |
911 |
|
sigc::bind( |
912 |
|
sigc::mem_fun(*this, &MainWindow::onMacroSelected), iMacro |
913 |
|
) |
914 |
|
); |
915 |
|
menuMacro->append(*item); |
916 |
|
item->set_accel_path("<Macros>/macro_" + ToString(iMacro)); |
917 |
|
Glib::ustring comment = macro.comment(); |
918 |
|
if (!comment.empty()) |
919 |
|
item->set_tooltip_text(comment); |
920 |
|
} |
921 |
|
// if there are no macros configured at all, then show a dummy entry instead |
922 |
|
if (m_macros.empty()) { |
923 |
|
Gtk::MenuItem* item = new Gtk::MenuItem(_("No Macros")); |
924 |
|
item->set_sensitive(false); |
925 |
|
menuMacro->append(*item); |
926 |
|
} |
927 |
|
|
928 |
|
// add separator line to menu |
929 |
|
menuMacro->append(*new Gtk::SeparatorMenuItem); |
930 |
|
|
931 |
|
{ |
932 |
|
Gtk::MenuItem* item = new Gtk::MenuItem(_("Setup Macros ...")); |
933 |
|
item->signal_activate().connect( |
934 |
|
sigc::mem_fun(*this, &MainWindow::setupMacros) |
935 |
|
); |
936 |
|
menuMacro->append(*item); |
937 |
|
item->set_accel_path("<Macros>/SetupMacros"); |
938 |
|
} |
939 |
|
|
940 |
|
menuMacro->show_all_children(); |
941 |
|
} |
942 |
|
|
943 |
|
void MainWindow::onMacroSelected(int iMacro) { |
944 |
|
printf("onMacroSelected(%d)\n", iMacro); |
945 |
|
if (iMacro < 0 || iMacro >= m_macros.size()) return; |
946 |
|
Glib::ustring errorText; |
947 |
|
try { |
948 |
|
applyMacro(m_macros[iMacro]); |
949 |
|
} catch (Serialization::Exception e) { |
950 |
|
errorText = e.Message; |
951 |
|
} catch (...) { |
952 |
|
errorText = _("Unknown exception while applying macro"); |
953 |
|
} |
954 |
|
if (!errorText.empty()) { |
955 |
|
Glib::ustring txt = _("Applying macro failed:\n") + errorText; |
956 |
|
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
957 |
|
msg.run(); |
958 |
|
} |
959 |
|
} |
960 |
|
|
961 |
|
void MainWindow::setupMacros() { |
962 |
|
MacrosSetup* setup = new MacrosSetup(); |
963 |
|
gig::DimensionRegion* pDimRgn = m_DimRegionChooser.get_main_dimregion(); |
964 |
|
setup->setMacros(m_macros, &m_serializationArchive, pDimRgn); |
965 |
|
setup->signal_macros_changed().connect( |
966 |
|
sigc::mem_fun(*this, &MainWindow::onMacrosSetupChanged) |
967 |
|
); |
968 |
|
setup->show(); |
969 |
|
} |
970 |
|
|
971 |
|
void MainWindow::onMacrosSetupChanged(const std::vector<Serialization::Archive>& macros) { |
972 |
|
m_macros = macros; |
973 |
|
Settings::singleton()->saveMacros(m_macros); |
974 |
|
updateMacroMenu(); |
975 |
|
} |
976 |
|
|
977 |
bool MainWindow::on_delete_event(GdkEventAny* event) |
bool MainWindow::on_delete_event(GdkEventAny* event) |
978 |
{ |
{ |
979 |
return !file_is_shared && file_is_changed && !close_confirmation_dialog(); |
return !file_is_shared && file_is_changed && !close_confirmation_dialog(); |
1039 |
} |
} |
1040 |
} |
} |
1041 |
|
|
1042 |
|
m_RegionChooser.setModifyAllRegions(all_regions); |
1043 |
m_DimRegionChooser.setModifyAllRegions(all_regions); |
m_DimRegionChooser.setModifyAllRegions(all_regions); |
1044 |
m_DimRegionChooser.setModifyAllDimensionRegions(all_dimregs); |
m_DimRegionChooser.setModifyAllDimensionRegions(all_dimregs); |
1045 |
m_DimRegionChooser.setModifyBothChannels(stereo); |
m_DimRegionChooser.setModifyBothChannels(stereo); |
1204 |
// save the file as separate temporary file first, |
// save the file as separate temporary file first, |
1205 |
// then move the saved file over the old file |
// then move the saved file over the old file |
1206 |
// (may result in performance speedup during save) |
// (may result in performance speedup during save) |
1207 |
String tmpname = filename + ".TMP"; |
gig::String tmpname = filename + ".TMP"; |
1208 |
gig->Save(tmpname, &progress); |
gig->Save(tmpname, &progress); |
1209 |
#if defined(WIN32) |
#if defined(WIN32) |
1210 |
if (!DeleteFile(filename.c_str())) { |
if (!DeleteFile(filename.c_str())) { |
1212 |
} |
} |
1213 |
#else // POSIX ... |
#else // POSIX ... |
1214 |
if (unlink(filename.c_str())) { |
if (unlink(filename.c_str())) { |
1215 |
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))); |
1216 |
} |
} |
1217 |
#endif |
#endif |
1218 |
if (rename(tmpname.c_str(), filename.c_str())) { |
if (rename(tmpname.c_str(), filename.c_str())) { |
1219 |
#if defined(WIN32) |
#if defined(WIN32) |
1220 |
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)."); |
1221 |
#else |
#else |
1222 |
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))); |
1223 |
#endif |
#endif |
1224 |
} |
} |
1225 |
} |
} |
1347 |
g_free(msg); |
g_free(msg); |
1348 |
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.")); |
1349 |
dialog.add_button(_("Close _Without Saving"), Gtk::RESPONSE_NO); |
dialog.add_button(_("Close _Without Saving"), Gtk::RESPONSE_NO); |
1350 |
dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
1351 |
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); |
1352 |
dialog.set_default_response(Gtk::RESPONSE_YES); |
dialog.set_default_response(Gtk::RESPONSE_YES); |
1353 |
int response = dialog.run(); |
int response = dialog.run(); |
1354 |
dialog.hide(); |
dialog.hide(); |
1379 |
"used by the sampler until you tell the sampler explicitly to " |
"used by the sampler until you tell the sampler explicitly to " |
1380 |
"load it.")); |
"load it.")); |
1381 |
dialog.add_button(_("_Yes, Detach"), Gtk::RESPONSE_YES); |
dialog.add_button(_("_Yes, Detach"), Gtk::RESPONSE_YES); |
1382 |
dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
1383 |
dialog.set_default_response(Gtk::RESPONSE_CANCEL); |
dialog.set_default_response(Gtk::RESPONSE_CANCEL); |
1384 |
int response = dialog.run(); |
int response = dialog.run(); |
1385 |
dialog.hide(); |
dialog.hide(); |
1393 |
if (file_is_shared && !leaving_shared_mode_dialog()) return; |
if (file_is_shared && !leaving_shared_mode_dialog()) return; |
1394 |
|
|
1395 |
Gtk::FileChooserDialog dialog(*this, _("Open file")); |
Gtk::FileChooserDialog dialog(*this, _("Open file")); |
1396 |
dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
1397 |
dialog.add_button(_("_Open"), Gtk::RESPONSE_OK); |
dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); |
1398 |
dialog.set_default_response(Gtk::RESPONSE_OK); |
dialog.set_default_response(Gtk::RESPONSE_OK); |
1399 |
#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 |
1400 |
Gtk::FileFilter filter; |
Gtk::FileFilter filter; |
1589 |
|
|
1590 |
bool MainWindow::file_save_as() |
bool MainWindow::file_save_as() |
1591 |
{ |
{ |
1592 |
Gtk::FileChooserDialog dialog(*this, _("Save As"), Gtk::FILE_CHOOSER_ACTION_SAVE); |
Gtk::FileChooserDialog dialog(*this, _("Save as"), Gtk::FILE_CHOOSER_ACTION_SAVE); |
1593 |
dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
1594 |
dialog.add_button(_("_Save"), Gtk::RESPONSE_OK); |
dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK); |
1595 |
dialog.set_default_response(Gtk::RESPONSE_OK); |
dialog.set_default_response(Gtk::RESPONSE_OK); |
1596 |
dialog.set_do_overwrite_confirmation(); |
dialog.set_do_overwrite_confirmation(); |
1597 |
|
|
1836 |
eSourceForm(_("Source form")), |
eSourceForm(_("Source form")), |
1837 |
eCommissioned(_("Commissioned")), |
eCommissioned(_("Commissioned")), |
1838 |
eSubject(_("Subject")), |
eSubject(_("Subject")), |
1839 |
quitButton(_("_Close"), true), |
quitButton(Gtk::Stock::CLOSE), |
1840 |
table(2, 1), |
table(2, 1), |
1841 |
m_file(NULL) |
m_file(NULL) |
1842 |
{ |
{ |
1959 |
} |
} |
1960 |
|
|
1961 |
InstrumentProps::InstrumentProps() : |
InstrumentProps::InstrumentProps() : |
1962 |
quitButton(_("_Close"), true), |
quitButton(Gtk::Stock::CLOSE), |
1963 |
table(2,1), |
table(2,1), |
1964 |
eName(_("Name")), |
eName(_("Name")), |
1965 |
eIsDrum(_("Is drum")), |
eIsDrum(_("Is drum")), |
2848 |
|
|
2849 |
// show 'browse for file' dialog |
// show 'browse for file' dialog |
2850 |
Gtk::FileChooserDialog dialog(*this, replace ? _("Replace Sample with") : _("Add Sample(s)")); |
Gtk::FileChooserDialog dialog(*this, replace ? _("Replace Sample with") : _("Add Sample(s)")); |
2851 |
dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
2852 |
dialog.add_button(_("_Open"), Gtk::RESPONSE_OK); |
dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); |
2853 |
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 |
2854 |
|
|
2855 |
// matches all file types supported by libsndfile |
// matches all file types supported by libsndfile |
3049 |
dialog.get_vbox()->pack_start(entryArea, Gtk::PACK_SHRINK); |
dialog.get_vbox()->pack_start(entryArea, Gtk::PACK_SHRINK); |
3050 |
description.show(); |
description.show(); |
3051 |
entryArea.show_all(); |
entryArea.show_all(); |
3052 |
dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
3053 |
dialog.add_button(_("Select"), Gtk::RESPONSE_OK); |
dialog.add_button(_("Select"), Gtk::RESPONSE_OK); |
3054 |
dialog.set_select_multiple(false); |
dialog.set_select_multiple(false); |
3055 |
if (current_sample_dir != "") { |
if (current_sample_dir != "") { |
3673 |
} |
} |
3674 |
|
|
3675 |
Gtk::FileChooserDialog dialog(*this, _("Merge .gig files")); |
Gtk::FileChooserDialog dialog(*this, _("Merge .gig files")); |
3676 |
dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
3677 |
dialog.add_button(_("Merge"), Gtk::RESPONSE_OK); |
dialog.add_button(_("Merge"), Gtk::RESPONSE_OK); |
3678 |
dialog.set_default_response(Gtk::RESPONSE_CANCEL); |
dialog.set_default_response(Gtk::RESPONSE_CANCEL); |
3679 |
#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 |
3871 |
updateClipboardPasteAvailable(); |
updateClipboardPasteAvailable(); |
3872 |
} |
} |
3873 |
|
|
3874 |
|
void MainWindow::adjust_clipboard_content() { |
3875 |
|
MacroEditor* editor = new MacroEditor(); |
3876 |
|
editor->setMacro(&m_serializationArchive, true); |
3877 |
|
editor->show(); |
3878 |
|
} |
3879 |
|
|
3880 |
void MainWindow::updateClipboardPasteAvailable() { |
void MainWindow::updateClipboardPasteAvailable() { |
3881 |
Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get(); |
Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get(); |
3882 |
clipboard->request_targets( |
clipboard->request_targets( |
3914 |
updateClipboardCopyAvailable(); |
updateClipboardCopyAvailable(); |
3915 |
} |
} |
3916 |
|
|
3917 |
|
//NOTE: Might throw exception !!! |
3918 |
|
void MainWindow::applyMacro(Serialization::Archive& macro) { |
3919 |
|
gig::DimensionRegion* pDimRgn = m_DimRegionChooser.get_main_dimregion(); |
3920 |
|
if (!pDimRgn) return; |
3921 |
|
|
3922 |
|
for (std::set<gig::DimensionRegion*>::iterator itDimReg = dimreg_edit.dimregs.begin(); |
3923 |
|
itDimReg != dimreg_edit.dimregs.end(); ++itDimReg) |
3924 |
|
{ |
3925 |
|
gig::DimensionRegion* pDimRgn = *itDimReg; |
3926 |
|
DimRegionChangeGuard(this, pDimRgn); |
3927 |
|
macro.deserialize(pDimRgn); |
3928 |
|
} |
3929 |
|
//region_changed() |
3930 |
|
file_changed(); |
3931 |
|
dimreg_changed(); |
3932 |
|
} |
3933 |
|
|
3934 |
void MainWindow::on_clipboard_received(const Gtk::SelectionData& selection_data) { |
void MainWindow::on_clipboard_received(const Gtk::SelectionData& selection_data) { |
3935 |
const std::string target = selection_data.get_target(); |
const std::string target = selection_data.get_target(); |
3936 |
if (target == CLIPBOARD_DIMENSIONREGION_TARGET) { |
if (target == CLIPBOARD_DIMENSIONREGION_TARGET) { |
|
gig::DimensionRegion* pDimRgn = m_DimRegionChooser.get_main_dimregion(); |
|
|
if (!pDimRgn) return; |
|
|
|
|
3937 |
Glib::ustring errorText; |
Glib::ustring errorText; |
3938 |
try { |
try { |
3939 |
m_serializationArchive.decode( |
m_serializationArchive.decode( |
3940 |
selection_data.get_data(), selection_data.get_length() |
selection_data.get_data(), selection_data.get_length() |
3941 |
); |
); |
3942 |
|
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(); |
|
|
|
|
3943 |
} catch (Serialization::Exception e) { |
} catch (Serialization::Exception e) { |
3944 |
errorText = e.Message; |
errorText = e.Message; |
3945 |
} catch (...) { |
} catch (...) { |
3946 |
errorText = _("Unknown exception during deserialization decoding"); |
errorText = _("Unknown exception while pasting DimensionRegion"); |
3947 |
} |
} |
3948 |
if (!errorText.empty()) { |
if (!errorText.empty()) { |
3949 |
Glib::ustring txt = _("Pasting DimensionRegion failed:\n") + errorText; |
Glib::ustring txt = _("Pasting DimensionRegion failed:\n") + errorText; |
3961 |
static_cast<Gtk::MenuItem*>( |
static_cast<Gtk::MenuItem*>( |
3962 |
uiManager->get_widget("/MenuBar/MenuEdit/PasteDimRgn") |
uiManager->get_widget("/MenuBar/MenuEdit/PasteDimRgn") |
3963 |
)->set_sensitive(bDimensionRegionPasteIsPossible); |
)->set_sensitive(bDimensionRegionPasteIsPossible); |
3964 |
|
|
3965 |
|
static_cast<Gtk::MenuItem*>( |
3966 |
|
uiManager->get_widget("/MenuBar/MenuEdit/AdjustClipboard") |
3967 |
|
)->set_sensitive(bDimensionRegionPasteIsPossible); |
3968 |
} |
} |
3969 |
|
|
3970 |
sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() { |
sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() { |