/[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 3157 by schoenebeck, Mon May 8 17:30:10 2017 UTC revision 3180 by schoenebeck, Sun May 14 13:17:03 2017 UTC
# Line 35  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>
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>
# Line 156  MainWindow::MainWindow() : Line 157  MainWindow::MainWindow() :
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",
# Line 188  MainWindow::MainWindow() : Line 191  MainWindow::MainWindow() :
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(
# Line 316  MainWindow::MainWindow() : Line 318  MainWindow::MainWindow() :
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(
# Line 329  MainWindow::MainWindow() : Line 333  MainWindow::MainWindow() :
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    
# Line 376  MainWindow::MainWindow() : Line 380  MainWindow::MainWindow() :
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(
# Line 388  MainWindow::MainWindow() : Line 392  MainWindow::MainWindow() :
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(
# Line 424  MainWindow::MainWindow() : Line 428  MainWindow::MainWindow() :
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    
# Line 910  void MainWindow::updateMacroMenu() { Line 914  void MainWindow::updateMacroMenu() {
914          );          );
915          menuMacro->append(*item);          menuMacro->append(*item);
916          item->set_accel_path("<Macros>/macro_" + ToString(iMacro));          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      // if there are no macros configured at all, then show a dummy entry instead
922      if (m_macros.empty()) {      if (m_macros.empty()) {
# Line 953  void MainWindow::onMacroSelected(int iMa Line 960  void MainWindow::onMacroSelected(int iMa
960    
961  void MainWindow::setupMacros() {  void MainWindow::setupMacros() {
962      MacrosSetup* setup = new MacrosSetup();      MacrosSetup* setup = new MacrosSetup();
963      setup->setMacros(m_macros);      gig::DimensionRegion* pDimRgn = m_DimRegionChooser.get_main_dimregion();
964        setup->setMacros(m_macros, &m_serializationArchive, pDimRgn);
965      setup->signal_macros_changed().connect(      setup->signal_macros_changed().connect(
966          sigc::mem_fun(*this, &MainWindow::onMacrosSetupChanged)          sigc::mem_fun(*this, &MainWindow::onMacrosSetupChanged)
967      );      );
# Line 1196  void Saver::thread_function() Line 1204  void Saver::thread_function()
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())) {
# Line 1204  void Saver::thread_function() Line 1212  void Saver::thread_function()
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              }              }
# Line 1339  bool MainWindow::close_confirmation_dial Line 1347  bool MainWindow::close_confirmation_dial
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();
# Line 1371  bool MainWindow::leaving_shared_mode_dia Line 1379  bool MainWindow::leaving_shared_mode_dia
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();
# Line 1385  void MainWindow::on_action_file_open() Line 1393  void MainWindow::on_action_file_open()
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;
# Line 1581  void MainWindow::on_action_file_save_as( Line 1589  void MainWindow::on_action_file_save_as(
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    
# Line 1828  PropDialog::PropDialog() Line 1836  PropDialog::PropDialog()
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  {  {
# Line 1951  void InstrumentProps::set_MIDIProgram(ui Line 1959  void InstrumentProps::set_MIDIProgram(ui
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")),
# Line 2840  void MainWindow::add_or_replace_sample(b Line 2848  void MainWindow::add_or_replace_sample(b
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
# Line 3041  void MainWindow::on_action_replace_all_s Line 3049  void MainWindow::on_action_replace_all_s
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 != "") {
# Line 3665  void MainWindow::on_action_merge_files() Line 3673  void MainWindow::on_action_merge_files()
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
# Line 3865  void MainWindow::paste_copied_dimrgn() { Line 3873  void MainWindow::paste_copied_dimrgn() {
3873    
3874  void MainWindow::adjust_clipboard_content() {  void MainWindow::adjust_clipboard_content() {
3875      MacroEditor* editor = new MacroEditor();      MacroEditor* editor = new MacroEditor();
3876      editor->setMacro(&m_serializationArchive);      editor->setMacro(&m_serializationArchive, true);
3877      editor->show();      editor->show();
3878  }  }
3879    
# Line 3915  void MainWindow::applyMacro(Serializatio Line 3923  void MainWindow::applyMacro(Serializatio
3923           itDimReg != dimreg_edit.dimregs.end(); ++itDimReg)           itDimReg != dimreg_edit.dimregs.end(); ++itDimReg)
3924      {      {
3925          gig::DimensionRegion* pDimRgn = *itDimReg;          gig::DimensionRegion* pDimRgn = *itDimReg;
3926          dimreg_to_be_changed_signal.emit(pDimRgn);          DimRegionChangeGuard(this, pDimRgn);
3927          m_serializationArchive.deserialize(pDimRgn);          macro.deserialize(pDimRgn);
         dimreg_changed_signal.emit(pDimRgn);  
3928      }      }
3929      //region_changed()      //region_changed()
3930      file_changed();      file_changed();

Legend:
Removed from v.3157  
changed lines
  Added in v.3180

  ViewVC Help
Powered by ViewVC