/[svn]/gigedit/trunk/src/gigedit/mainwindow.cpp
ViewVC logotype

Diff of /gigedit/trunk/src/gigedit/mainwindow.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2772 by schoenebeck, Thu Jun 11 20:29:22 2015 UTC revision 2968 by schoenebeck, Mon Jul 18 11:25:13 2016 UTC
# Line 1  Line 1 
1  /*  /*
2   * Copyright (C) 2006-2015 Andreas Persson   * Copyright (C) 2006-2016 Andreas Persson
3   *   *
4   * This program is free software; you can redistribute it and/or   * This program is free software; you can redistribute it and/or
5   * modify it under the terms of the GNU General Public License as   * modify it under the terms of the GNU General Public License as
# Line 20  Line 20 
20  #include <iostream>  #include <iostream>
21  #include <cstring>  #include <cstring>
22    
23    #include <glibmmconfig.h>
24    // threads.h must be included first to be able to build with
25    // G_DISABLE_DEPRECATED
26    #if (GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION == 31 && GLIBMM_MICRO_VERSION >= 2) || \
27        (GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION > 31) || GLIBMM_MAJOR_VERSION > 2
28    #include <glibmm/threads.h>
29    #endif
30    
31  #include <glibmm/convert.h>  #include <glibmm/convert.h>
32  #include <glibmm/dispatcher.h>  #include <glibmm/dispatcher.h>
33  #include <glibmm/miscutils.h>  #include <glibmm/miscutils.h>
# Line 27  Line 35 
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>
 #include <gtkmm/stock.h>  
38  #include <gtkmm/targetentry.h>  #include <gtkmm/targetentry.h>
39  #include <gtkmm/main.h>  #include <gtkmm/main.h>
40  #include <gtkmm/toggleaction.h>  #include <gtkmm/toggleaction.h>
# Line 110  MainWindow::MainWindow() : Line 117  MainWindow::MainWindow() :
117      actionGroup = Gtk::ActionGroup::create();      actionGroup = Gtk::ActionGroup::create();
118    
119      actionGroup->add(Gtk::Action::create("MenuFile", _("_File")));      actionGroup->add(Gtk::Action::create("MenuFile", _("_File")));
120      actionGroup->add(Gtk::Action::create("New", Gtk::Stock::NEW),      actionGroup->add(Gtk::Action::create("New", _("_New")),
121                         Gtk::AccelKey("<control>n"),
122                       sigc::mem_fun(                       sigc::mem_fun(
123                           *this, &MainWindow::on_action_file_new));                           *this, &MainWindow::on_action_file_new));
124      Glib::RefPtr<Gtk::Action> action =      actionGroup->add(Gtk::Action::create("Open", _("_Open...")),
125          Gtk::Action::create("Open", Gtk::Stock::OPEN);                       Gtk::AccelKey("<control>o"),
     action->property_label() = action->property_label() + "...";  
     actionGroup->add(action,  
126                       sigc::mem_fun(                       sigc::mem_fun(
127                           *this, &MainWindow::on_action_file_open));                           *this, &MainWindow::on_action_file_open));
128      actionGroup->add(Gtk::Action::create("Save", Gtk::Stock::SAVE),      actionGroup->add(Gtk::Action::create("Save", _("_Save")),
129                         Gtk::AccelKey("<control>s"),
130                       sigc::mem_fun(                       sigc::mem_fun(
131                           *this, &MainWindow::on_action_file_save));                           *this, &MainWindow::on_action_file_save));
132      action = Gtk::Action::create("SaveAs", Gtk::Stock::SAVE_AS);      actionGroup->add(Gtk::Action::create("SaveAs", _("Save _As...")),
     action->property_label() = action->property_label() + "...";  
     actionGroup->add(action,  
133                       Gtk::AccelKey("<shift><control>s"),                       Gtk::AccelKey("<shift><control>s"),
134                       sigc::mem_fun(                       sigc::mem_fun(
135                           *this, &MainWindow::on_action_file_save_as));                           *this, &MainWindow::on_action_file_save_as));
136      actionGroup->add(Gtk::Action::create("Properties",      actionGroup->add(Gtk::Action::create("Properties",
137                                           Gtk::Stock::PROPERTIES),                                           _("_Properties")),
138                       sigc::mem_fun(                       sigc::mem_fun(
139                           *this, &MainWindow::on_action_file_properties));                           *this, &MainWindow::on_action_file_properties));
140      actionGroup->add(Gtk::Action::create("InstrProperties",      actionGroup->add(Gtk::Action::create("InstrProperties",
141                                           Gtk::Stock::PROPERTIES),                                           _("_Properties")),
142                       sigc::mem_fun(                       sigc::mem_fun(
143                           *this, &MainWindow::show_instr_props));                           *this, &MainWindow::show_instr_props));
144      actionGroup->add(Gtk::Action::create("MidiRules",      actionGroup->add(Gtk::Action::create("MidiRules",
# Line 144  MainWindow::MainWindow() : Line 149  MainWindow::MainWindow() :
149                                           _("_Script Slots...")),                                           _("_Script Slots...")),
150                       sigc::mem_fun(                       sigc::mem_fun(
151                           *this, &MainWindow::show_script_slots));                           *this, &MainWindow::show_script_slots));
152      actionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT),      actionGroup->add(Gtk::Action::create("Quit", _("_Quit")),
153                         Gtk::AccelKey("<control>q"),
154                       sigc::mem_fun(                       sigc::mem_fun(
155                           *this, &MainWindow::on_action_quit));                           *this, &MainWindow::on_action_quit));
156      actionGroup->add(      actionGroup->add(
# Line 186  MainWindow::MainWindow() : Line 192  MainWindow::MainWindow() :
192      actionGroup->add(toggle_action,      actionGroup->add(toggle_action,
193                       sigc::mem_fun(                       sigc::mem_fun(
194                           *this, &MainWindow::on_action_view_status_bar));                           *this, &MainWindow::on_action_view_status_bar));
195    
196        toggle_action =
197            Gtk::ToggleAction::create("AutoRestoreWinDim", _("_Auto Restore Window Dimension"));
198        toggle_action->set_active(Settings::singleton()->autoRestoreWindowDimension);
199        actionGroup->add(toggle_action,
200                         sigc::mem_fun(
201                             *this, &MainWindow::on_auto_restore_win_dim));
202    
203        toggle_action =
204            Gtk::ToggleAction::create("SaveWithTemporaryFile", _("Save with _temporary file"));
205        toggle_action->set_active(Settings::singleton()->saveWithTemporaryFile);
206        actionGroup->add(toggle_action,
207                         sigc::mem_fun(
208                             *this, &MainWindow::on_save_with_temporary_file));
209    
210      actionGroup->add(      actionGroup->add(
211          Gtk::Action::create("RefreshAll", _("_Refresh All")),          Gtk::Action::create("RefreshAll", _("_Refresh All")),
212          sigc::mem_fun(*this, &MainWindow::on_action_refresh_all)          sigc::mem_fun(*this, &MainWindow::on_action_refresh_all)
213      );                      );                
214    
215      action = Gtk::Action::create("MenuHelp", Gtk::Stock::HELP);      actionGroup->add(Gtk::Action::create("MenuHelp", _("_Help")));
216      actionGroup->add(Gtk::Action::create("MenuHelp",      actionGroup->add(Gtk::Action::create("About", _("_About")),
                                          action->property_label()));  
     actionGroup->add(Gtk::Action::create("About", Gtk::Stock::ABOUT),  
217                       sigc::mem_fun(                       sigc::mem_fun(
218                           *this, &MainWindow::on_action_help_about));                           *this, &MainWindow::on_action_help_about));
219      actionGroup->add(      actionGroup->add(
# Line 206  MainWindow::MainWindow() : Line 225  MainWindow::MainWindow() :
225          sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument)          sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument)
226      );      );
227      actionGroup->add(      actionGroup->add(
228          Gtk::Action::create("RemoveInstrument", Gtk::Stock::REMOVE),          Gtk::Action::create("RemoveInstrument", _("_Remove")),
229          sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument)          sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument)
230      );      );
231    
# Line 229  MainWindow::MainWindow() : Line 248  MainWindow::MainWindow() :
248          sigc::mem_fun(*this, &MainWindow::on_action_sync_sampler_instrument_selection)          sigc::mem_fun(*this, &MainWindow::on_action_sync_sampler_instrument_selection)
249      );      );
250    
251        toggle_action =
252            Gtk::ToggleAction::create("MoveRootNoteWithRegionMoved", _("Move root note with region moved"));
253        toggle_action->set_active(Settings::singleton()->moveRootNoteWithRegionMoved);
254        actionGroup->add(
255            toggle_action,
256            sigc::mem_fun(*this, &MainWindow::on_action_move_root_note_with_region_moved)
257        );
258    
259    
260      actionGroup->add(Gtk::Action::create("MenuTools", _("_Tools")));      actionGroup->add(Gtk::Action::create("MenuTools", _("_Tools")));
261    
# Line 245  MainWindow::MainWindow() : Line 272  MainWindow::MainWindow() :
272    
273      // sample right-click popup actions      // sample right-click popup actions
274      actionGroup->add(      actionGroup->add(
275          Gtk::Action::create("SampleProperties", Gtk::Stock::PROPERTIES),          Gtk::Action::create("SampleProperties", _("_Properties")),
276          sigc::mem_fun(*this, &MainWindow::on_action_sample_properties)          sigc::mem_fun(*this, &MainWindow::on_action_sample_properties)
277      );      );
278      actionGroup->add(      actionGroup->add(
# Line 257  MainWindow::MainWindow() : Line 284  MainWindow::MainWindow() :
284          sigc::mem_fun(*this, &MainWindow::on_action_add_sample)          sigc::mem_fun(*this, &MainWindow::on_action_add_sample)
285      );      );
286      actionGroup->add(      actionGroup->add(
287          Gtk::Action::create("RemoveSample", Gtk::Stock::REMOVE),          Gtk::Action::create("RemoveSample", _("_Remove")),
288          sigc::mem_fun(*this, &MainWindow::on_action_remove_sample)          sigc::mem_fun(*this, &MainWindow::on_action_remove_sample)
289      );      );
290      actionGroup->add(      actionGroup->add(
# Line 293  MainWindow::MainWindow() : Line 320  MainWindow::MainWindow() :
320          sigc::mem_fun(*this, &MainWindow::on_action_edit_script)          sigc::mem_fun(*this, &MainWindow::on_action_edit_script)
321      );      );
322      actionGroup->add(      actionGroup->add(
323          Gtk::Action::create("RemoveScript", Gtk::Stock::REMOVE),          Gtk::Action::create("RemoveScript", _("_Remove")),
324          sigc::mem_fun(*this, &MainWindow::on_action_remove_script)          sigc::mem_fun(*this, &MainWindow::on_action_remove_script)
325      );      );
326    
# Line 352  MainWindow::MainWindow() : Line 379  MainWindow::MainWindow() :
379          "    </menu>"          "    </menu>"
380          "    <menu action='MenuView'>"          "    <menu action='MenuView'>"
381          "      <menuitem action='Statusbar'/>"          "      <menuitem action='Statusbar'/>"
382            "      <menuitem action='AutoRestoreWinDim'/>"
383          "      <separator/>"          "      <separator/>"
384          "      <menuitem action='RefreshAll'/>"          "      <menuitem action='RefreshAll'/>"
385          "    </menu>"          "    </menu>"
# Line 362  MainWindow::MainWindow() : Line 390  MainWindow::MainWindow() :
390          "    <menu action='MenuSettings'>"          "    <menu action='MenuSettings'>"
391          "      <menuitem action='WarnUserOnExtensions'/>"          "      <menuitem action='WarnUserOnExtensions'/>"
392          "      <menuitem action='SyncSamplerInstrumentSelection'/>"          "      <menuitem action='SyncSamplerInstrumentSelection'/>"
393            "      <menuitem action='MoveRootNoteWithRegionMoved'/>"
394            "      <menuitem action='SaveWithTemporaryFile'/>"
395          "    </menu>"          "    </menu>"
396          "    <menu action='MenuHelp'>"          "    <menu action='MenuHelp'>"
397          "      <menuitem action='About'/>"          "      <menuitem action='About'/>"
# Line 430  MainWindow::MainWindow() : Line 460  MainWindow::MainWindow() :
460      }      }
461      {      {
462          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(
463                uiManager->get_widget("/MenuBar/MenuSettings/MoveRootNoteWithRegionMoved"));
464            item->set_tooltip_text(_("If checked, and when a region is moved by dragging it around on the virtual keyboard, the keybord position dependent pitch will move exactly with the amount of semi tones the region was moved around."));
465        }
466        {
467            Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(
468              uiManager->get_widget("/MenuBar/MenuSample/RemoveUnusedSamples"));              uiManager->get_widget("/MenuBar/MenuSample/RemoveUnusedSamples"));
469          item->set_tooltip_text(_("Removes all samples that are not referenced by any instrument (i.e. red ones)."));          item->set_tooltip_text(_("Removes all samples that are not referenced by any instrument (i.e. red ones)."));
470          // copy tooltip to popup menu          // copy tooltip to popup menu
# Line 444  MainWindow::MainWindow() : Line 479  MainWindow::MainWindow() :
479      }      }
480      {      {
481          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(
482                uiManager->get_widget("/MenuBar/MenuView/AutoRestoreWinDim"));
483            item->set_tooltip_text(_("If checked, size and position of all windows will be saved and automatically restored next time."));
484        }
485        {
486            Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(
487              uiManager->get_widget("/MenuBar/MenuTools/CombineInstruments"));              uiManager->get_widget("/MenuBar/MenuTools/CombineInstruments"));
488          item->set_tooltip_text(_("Create combi sounds out of individual sounds of this .gig file."));          item->set_tooltip_text(_("Create combi sounds out of individual sounds of this .gig file."));
489      }      }
# Line 591  MainWindow::MainWindow() : Line 631  MainWindow::MainWindow() :
631          sigc::hide(sigc::mem_fun(*this, &MainWindow::file_changed)));          sigc::hide(sigc::mem_fun(*this, &MainWindow::file_changed)));
632      m_RegionChooser.signal_instrument_changed().connect(      m_RegionChooser.signal_instrument_changed().connect(
633          sigc::mem_fun(*this, &MainWindow::file_changed));          sigc::mem_fun(*this, &MainWindow::file_changed));
634        m_RegionChooser.signal_instrument_changed().connect(
635            sigc::mem_fun(*this, &MainWindow::region_changed));
636      m_DimRegionChooser.signal_region_changed().connect(      m_DimRegionChooser.signal_region_changed().connect(
637          sigc::mem_fun(*this, &MainWindow::file_changed));          sigc::mem_fun(*this, &MainWindow::file_changed));
638      instrumentProps.signal_changed().connect(      instrumentProps.signal_changed().connect(
# Line 780  void Loader::progress_callback(float fra Line 822  void Loader::progress_callback(float fra
822    
823  void Loader::thread_function()  void Loader::thread_function()
824  {  {
825      printf("thread_function self=%x\n", Glib::Threads::Thread::self());      printf("thread_function self=%p\n",
826               static_cast<void*>(Glib::Threads::Thread::self()));
827      printf("Start %s\n", filename.c_str());      printf("Start %s\n", filename.c_str());
828      try {      try {
829          RIFF::File* riff = new RIFF::File(filename);          RIFF::File* riff = new RIFF::File(filename);
# Line 802  void Loader::thread_function() Line 845  void Loader::thread_function()
845  }  }
846    
847  Loader::Loader(const char* filename)  Loader::Loader(const char* filename)
848      : filename(filename), thread(0), progress(0.f)      : filename(filename), gig(0), thread(0), progress(0.f)
849  {  {
850  }  }
851    
# Line 813  void Loader::launch() Line 856  void Loader::launch()
856  #else  #else
857      thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Loader::thread_function));      thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Loader::thread_function));
858  #endif  #endif
859      printf("launch thread=%x\n", thread);      printf("launch thread=%p\n", static_cast<void*>(thread));
860  }  }
861    
862  float Loader::get_progress()  float Loader::get_progress()
# Line 858  void Saver::progress_callback(float frac Line 901  void Saver::progress_callback(float frac
901    
902  void Saver::thread_function()  void Saver::thread_function()
903  {  {
904      printf("thread_function self=%x\n", Glib::Threads::Thread::self());      printf("thread_function self=%p\n",
905               static_cast<void*>(Glib::Threads::Thread::self()));
906      printf("Start %s\n", filename.c_str());      printf("Start %s\n", filename.c_str());
907      try {      try {
908          gig::progress_t progress;          gig::progress_t progress;
# Line 867  void Saver::thread_function() Line 911  void Saver::thread_function()
911    
912          // if no filename was provided, that means "save", if filename was provided means "save as"          // if no filename was provided, that means "save", if filename was provided means "save as"
913          if (filename.empty()) {          if (filename.empty()) {
914              gig->Save(&progress);              if (!Settings::singleton()->saveWithTemporaryFile) {
915                    // save directly over the existing .gig file
916                    // (requires less disk space than solution below
917                    // but may be slower)
918                    gig->Save(&progress);
919                } else {
920                    // save the file as separate temporary file first,
921                    // then move the saved file over the old file
922                    // (may result in performance speedup during save)
923                    String tmpname = filename + ".TMP";
924                    gig->Save(tmpname, &progress);
925                    #if defined(WIN32)
926                    if (!DeleteFile(filename.c_str())) {
927                        throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file).");
928                    }
929                    #else // POSIX ...
930                    if (unlink(filename.c_str())) {
931                        throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file): " + String(strerror(errno)));
932                    }
933                    #endif
934                    if (rename(tmpname.c_str(), filename.c_str())) {
935                        #if defined(WIN32)
936                        throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file).");
937                        #else
938                        throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file): " + String(strerror(errno)));
939                        #endif
940                    }
941                }
942          } else {          } else {
943              gig->Save(filename, &progress);              gig->Save(filename, &progress);
944          }          }
# Line 895  void Saver::launch() Line 966  void Saver::launch()
966  #else  #else
967      thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Saver::thread_function));      thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Saver::thread_function));
968  #endif  #endif
969      printf("launch thread=%x\n", thread);      printf("launch thread=%p\n", static_cast<void*>(thread));
970  }  }
971    
972  float Saver::get_progress()  float Saver::get_progress()
# Line 992  bool MainWindow::close_confirmation_dial Line 1063  bool MainWindow::close_confirmation_dial
1063      g_free(msg);      g_free(msg);
1064      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."));
1065      dialog.add_button(_("Close _Without Saving"), Gtk::RESPONSE_NO);      dialog.add_button(_("Close _Without Saving"), Gtk::RESPONSE_NO);
1066      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
1067      dialog.add_button(file_has_name ? Gtk::Stock::SAVE : Gtk::Stock::SAVE_AS, Gtk::RESPONSE_YES);      dialog.add_button(file_has_name ? _("_Save") : _("Save _As"), Gtk::RESPONSE_YES);
1068      dialog.set_default_response(Gtk::RESPONSE_YES);      dialog.set_default_response(Gtk::RESPONSE_YES);
1069      int response = dialog.run();      int response = dialog.run();
1070      dialog.hide();      dialog.hide();
# Line 1024  bool MainWindow::leaving_shared_mode_dia Line 1095  bool MainWindow::leaving_shared_mode_dia
1095            "used by the sampler until you tell the sampler explicitly to "            "used by the sampler until you tell the sampler explicitly to "
1096            "load it."));            "load it."));
1097      dialog.add_button(_("_Yes, Detach"), Gtk::RESPONSE_YES);      dialog.add_button(_("_Yes, Detach"), Gtk::RESPONSE_YES);
1098      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
1099      dialog.set_default_response(Gtk::RESPONSE_CANCEL);      dialog.set_default_response(Gtk::RESPONSE_CANCEL);
1100      int response = dialog.run();      int response = dialog.run();
1101      dialog.hide();      dialog.hide();
# Line 1038  void MainWindow::on_action_file_open() Line 1109  void MainWindow::on_action_file_open()
1109      if (file_is_shared && !leaving_shared_mode_dialog()) return;      if (file_is_shared && !leaving_shared_mode_dialog()) return;
1110    
1111      Gtk::FileChooserDialog dialog(*this, _("Open file"));      Gtk::FileChooserDialog dialog(*this, _("Open file"));
1112      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
1113      dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);      dialog.add_button(_("_Open"), Gtk::RESPONSE_OK);
1114      dialog.set_default_response(Gtk::RESPONSE_OK);      dialog.set_default_response(Gtk::RESPONSE_OK);
1115  #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
1116      Gtk::FileFilter filter;      Gtk::FileFilter filter;
# Line 1055  void MainWindow::on_action_file_open() Line 1126  void MainWindow::on_action_file_open()
1126      if (dialog.run() == Gtk::RESPONSE_OK) {      if (dialog.run() == Gtk::RESPONSE_OK) {
1127          std::string filename = dialog.get_filename();          std::string filename = dialog.get_filename();
1128          printf("filename=%s\n", filename.c_str());          printf("filename=%s\n", filename.c_str());
1129          printf("on_action_file_open self=%x\n", Glib::Threads::Thread::self());          printf("on_action_file_open self=%p\n",
1130                   static_cast<void*>(Glib::Threads::Thread::self()));
1131          load_file(filename.c_str());          load_file(filename.c_str());
1132          current_gig_dir = Glib::path_get_dirname(filename);          current_gig_dir = Glib::path_get_dirname(filename);
1133      }      }
# Line 1125  void MainWindow::on_loader_progress() Line 1197  void MainWindow::on_loader_progress()
1197  void MainWindow::on_loader_finished()  void MainWindow::on_loader_finished()
1198  {  {
1199      printf("Loader finished!\n");      printf("Loader finished!\n");
1200      printf("on_loader_finished self=%x\n", Glib::Threads::Thread::self());      printf("on_loader_finished self=%p\n",
1201               static_cast<void*>(Glib::Threads::Thread::self()));
1202      load_gig(loader->gig, loader->filename.c_str());      load_gig(loader->gig, loader->filename.c_str());
1203      progress_dialog->hide();      progress_dialog->hide();
1204  }  }
# Line 1232  void MainWindow::on_action_file_save_as( Line 1305  void MainWindow::on_action_file_save_as(
1305    
1306  bool MainWindow::file_save_as()  bool MainWindow::file_save_as()
1307  {  {
1308      Gtk::FileChooserDialog dialog(*this, _("Save as"), Gtk::FILE_CHOOSER_ACTION_SAVE);      Gtk::FileChooserDialog dialog(*this, _("Save As"), Gtk::FILE_CHOOSER_ACTION_SAVE);
1309      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
1310      dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK);      dialog.add_button(_("_Save"), Gtk::RESPONSE_OK);
1311      dialog.set_default_response(Gtk::RESPONSE_OK);      dialog.set_default_response(Gtk::RESPONSE_OK);
1312      dialog.set_do_overwrite_confirmation();      dialog.set_do_overwrite_confirmation();
1313    
# Line 1265  bool MainWindow::file_save_as() Line 1338  bool MainWindow::file_save_as()
1338      // show warning in the dialog      // show warning in the dialog
1339      Gtk::HBox descriptionArea;      Gtk::HBox descriptionArea;
1340      descriptionArea.set_spacing(15);      descriptionArea.set_spacing(15);
1341      Gtk::Image warningIcon(Gtk::Stock::DIALOG_WARNING, Gtk::IconSize(Gtk::ICON_SIZE_DIALOG));      Gtk::Image warningIcon;
1342        warningIcon.set_from_icon_name("dialog-warning",
1343                                       Gtk::IconSize(Gtk::ICON_SIZE_DIALOG));
1344      descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK);      descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK);
1345  #if GTKMM_MAJOR_VERSION < 3  #if GTKMM_MAJOR_VERSION < 3
1346      view::WrapLabel description;      view::WrapLabel description;
# Line 1317  bool MainWindow::file_save_as() Line 1392  bool MainWindow::file_save_as()
1392  void MainWindow::__import_queued_samples() {  void MainWindow::__import_queued_samples() {
1393      std::cout << "Starting sample import\n" << std::flush;      std::cout << "Starting sample import\n" << std::flush;
1394      Glib::ustring error_files;      Glib::ustring error_files;
1395      printf("Samples to import: %d\n", m_SampleImportQueue.size());      printf("Samples to import: %d\n", int(m_SampleImportQueue.size()));
1396      for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin();      for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin();
1397           iter != m_SampleImportQueue.end(); ) {           iter != m_SampleImportQueue.end(); ) {
1398          printf("Importing sample %s\n",(*iter).sample_path.c_str());          printf("Importing sample %s\n",(*iter).sample_path.c_str());
# Line 1423  void MainWindow::on_action_sync_sampler_ Line 1498  void MainWindow::on_action_sync_sampler_
1498          !Settings::singleton()->syncSamplerInstrumentSelection;          !Settings::singleton()->syncSamplerInstrumentSelection;
1499  }  }
1500    
1501    void MainWindow::on_action_move_root_note_with_region_moved() {
1502        Settings::singleton()->moveRootNoteWithRegionMoved =
1503            !Settings::singleton()->moveRootNoteWithRegionMoved;
1504    }
1505    
1506  void MainWindow::on_action_help_about()  void MainWindow::on_action_help_about()
1507  {  {
1508      Gtk::AboutDialog dialog;      Gtk::AboutDialog dialog;
# Line 1432  void MainWindow::on_action_help_about() Line 1512  void MainWindow::on_action_help_about()
1512      dialog.set_name("Gigedit");      dialog.set_name("Gigedit");
1513  #endif  #endif
1514      dialog.set_version(VERSION);      dialog.set_version(VERSION);
1515      dialog.set_copyright("Copyright (C) 2006-2015 Andreas Persson");      dialog.set_copyright("Copyright (C) 2006-2016 Andreas Persson");
1516      const std::string sComment =      const std::string sComment =
1517          _("Built " __DATE__ "\nUsing ") +          _("Built " __DATE__ "\nUsing ") +
1518          ::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" +          ::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" +
# Line 1469  PropDialog::PropDialog() Line 1549  PropDialog::PropDialog()
1549        eSourceForm(_("Source form")),        eSourceForm(_("Source form")),
1550        eCommissioned(_("Commissioned")),        eCommissioned(_("Commissioned")),
1551        eSubject(_("Subject")),        eSubject(_("Subject")),
1552        quitButton(Gtk::Stock::CLOSE),        quitButton(_("_Close"), true),
1553        table(2, 1),        table(2, 1),
1554        m_file(NULL)        m_file(NULL)
1555  {  {
# Line 1592  void InstrumentProps::set_MIDIProgram(ui Line 1672  void InstrumentProps::set_MIDIProgram(ui
1672  }  }
1673    
1674  InstrumentProps::InstrumentProps() :  InstrumentProps::InstrumentProps() :
1675      quitButton(Gtk::Stock::CLOSE),      quitButton(_("_Close"), true),
1676      table(2,1),      table(2,1),
1677      eName(_("Name")),      eName(_("Name")),
1678      eIsDrum(_("Is drum")),      eIsDrum(_("Is drum")),
# Line 1887  void MainWindow::on_action_view_status_b Line 1967  void MainWindow::on_action_view_status_b
1967      else                    m_StatusBar.hide();      else                    m_StatusBar.hide();
1968  }  }
1969    
1970    void MainWindow::on_auto_restore_win_dim() {
1971        Gtk::CheckMenuItem* item =
1972            dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/AutoRestoreWinDim"));
1973        if (!item) {
1974            std::cerr << "/MenuBar/MenuView/AutoRestoreWinDim == NULL\n";
1975            return;
1976        }
1977        Settings::singleton()->autoRestoreWindowDimension = item->get_active();
1978    }
1979    
1980    void MainWindow::on_save_with_temporary_file() {
1981        Gtk::CheckMenuItem* item =
1982            dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuSettings/SaveWithTemporaryFile"));
1983        if (!item) {
1984            std::cerr << "/MenuBar/MenuSettings/SaveWithTemporaryFile == NULL\n";
1985            return;
1986        }
1987        Settings::singleton()->saveWithTemporaryFile = item->get_active();
1988    }
1989    
1990  bool MainWindow::is_copy_samples_unity_note_enabled() const {  bool MainWindow::is_copy_samples_unity_note_enabled() const {
1991      Gtk::CheckMenuItem* item =      Gtk::CheckMenuItem* item =
1992          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleUnity"));          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleUnity"));
# Line 2309  void MainWindow::on_action_edit_script() Line 2409  void MainWindow::on_action_edit_script()
2409      if (!script) return;      if (!script) return;
2410    
2411      ScriptEditor* editor = new ScriptEditor;      ScriptEditor* editor = new ScriptEditor;
2412        editor->signal_script_to_be_changed.connect(
2413            signal_script_to_be_changed.make_slot()
2414        );
2415        editor->signal_script_changed.connect(
2416            signal_script_changed.make_slot()
2417        );
2418      editor->setScript(script);      editor->setScript(script);
2419      //editor->reparent(*this);      //editor->reparent(*this);
2420      editor->show();      editor->show();
# Line 2405  void MainWindow::add_or_replace_sample(b Line 2511  void MainWindow::add_or_replace_sample(b
2511    
2512      // show 'browse for file' dialog      // show 'browse for file' dialog
2513      Gtk::FileChooserDialog dialog(*this, replace ? _("Replace Sample with") : _("Add Sample(s)"));      Gtk::FileChooserDialog dialog(*this, replace ? _("Replace Sample with") : _("Add Sample(s)"));
2514      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
2515      dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);      dialog.add_button(_("_Open"), Gtk::RESPONSE_OK);
2516      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
2517    
2518      // matches all file types supported by libsndfile      // matches all file types supported by libsndfile
# Line 2606  void MainWindow::on_action_replace_all_s Line 2712  void MainWindow::on_action_replace_all_s
2712      dialog.get_vbox()->pack_start(entryArea, Gtk::PACK_SHRINK);      dialog.get_vbox()->pack_start(entryArea, Gtk::PACK_SHRINK);
2713      description.show();      description.show();
2714      entryArea.show_all();      entryArea.show_all();
2715      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
2716      dialog.add_button(_("Select"), Gtk::RESPONSE_OK);      dialog.add_button(_("Select"), Gtk::RESPONSE_OK);
2717      dialog.set_select_multiple(false);      dialog.set_select_multiple(false);
2718      if (current_sample_dir != "") {      if (current_sample_dir != "") {
# Line 2630  void MainWindow::on_action_replace_all_s Line 2736  void MainWindow::on_action_replace_all_s
2736              try              try
2737              {              {
2738                  if (!hFile) throw std::string(_("could not open file"));                  if (!hFile) throw std::string(_("could not open file"));
                 int bitdepth;  
2739                  switch (info.format & 0xff) {                  switch (info.format & 0xff) {
2740                      case SF_FORMAT_PCM_S8:                      case SF_FORMAT_PCM_S8:
2741                      case SF_FORMAT_PCM_16:                      case SF_FORMAT_PCM_16:
2742                      case SF_FORMAT_PCM_U8:                      case SF_FORMAT_PCM_U8:
                         bitdepth = 16;  
                         break;  
2743                      case SF_FORMAT_PCM_24:                      case SF_FORMAT_PCM_24:
2744                      case SF_FORMAT_PCM_32:                      case SF_FORMAT_PCM_32:
2745                      case SF_FORMAT_FLOAT:                      case SF_FORMAT_FLOAT:
2746                      case SF_FORMAT_DOUBLE:                      case SF_FORMAT_DOUBLE:
                         bitdepth = 24;  
2747                          break;                          break;
2748                      default:                      default:
2749                          sf_close(hFile);                          sf_close(hFile);
# Line 3055  void MainWindow::script_double_clicked(c Line 3157  void MainWindow::script_double_clicked(c
3157      if (!script) return;      if (!script) return;
3158    
3159      ScriptEditor* editor = new ScriptEditor;      ScriptEditor* editor = new ScriptEditor;
3160        editor->signal_script_to_be_changed.connect(
3161            signal_script_to_be_changed.make_slot()
3162        );
3163        editor->signal_script_changed.connect(
3164            signal_script_changed.make_slot()
3165        );
3166      editor->setScript(script);      editor->setScript(script);
3167      //editor->reparent(*this);      //editor->reparent(*this);
3168      editor->show();      editor->show();
# Line 3230  void MainWindow::on_action_merge_files() Line 3338  void MainWindow::on_action_merge_files()
3338      }      }
3339    
3340      Gtk::FileChooserDialog dialog(*this, _("Merge .gig files"));      Gtk::FileChooserDialog dialog(*this, _("Merge .gig files"));
3341      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
3342      dialog.add_button(_("Merge"), Gtk::RESPONSE_OK);      dialog.add_button(_("Merge"), Gtk::RESPONSE_OK);
3343      dialog.set_default_response(Gtk::RESPONSE_CANCEL);      dialog.set_default_response(Gtk::RESPONSE_CANCEL);
3344  #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
# Line 3249  void MainWindow::on_action_merge_files() Line 3357  void MainWindow::on_action_merge_files()
3357      // show warning in the file picker dialog      // show warning in the file picker dialog
3358      Gtk::HBox descriptionArea;      Gtk::HBox descriptionArea;
3359      descriptionArea.set_spacing(15);      descriptionArea.set_spacing(15);
3360      Gtk::Image warningIcon(Gtk::Stock::DIALOG_WARNING, Gtk::IconSize(Gtk::ICON_SIZE_DIALOG));      Gtk::Image warningIcon;
3361        warningIcon.set_from_icon_name("dialog-warning",
3362                                       Gtk::IconSize(Gtk::ICON_SIZE_DIALOG));
3363      descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK);      descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK);
3364  #if GTKMM_MAJOR_VERSION < 3  #if GTKMM_MAJOR_VERSION < 3
3365      view::WrapLabel description;      view::WrapLabel description;
# Line 3272  void MainWindow::on_action_merge_files() Line 3382  void MainWindow::on_action_merge_files()
3382      descriptionArea.show_all();      descriptionArea.show_all();
3383    
3384      if (dialog.run() == Gtk::RESPONSE_OK) {      if (dialog.run() == Gtk::RESPONSE_OK) {
3385          printf("on_action_merge_files self=%x\n", Glib::Threads::Thread::self());          printf("on_action_merge_files self=%p\n",
3386                   static_cast<void*>(Glib::Threads::Thread::self()));
3387          std::vector<std::string> filenames = dialog.get_filenames();          std::vector<std::string> filenames = dialog.get_filenames();
3388    
3389          // merge the selected files to the currently open .gig file          // merge the selected files to the currently open .gig file

Legend:
Removed from v.2772  
changed lines
  Added in v.2968

  ViewVC Help
Powered by ViewVC