/[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 2773 by schoenebeck, Fri Jun 12 17:57:52 2015 UTC revision 2918 by schoenebeck, Wed May 18 10:10:25 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      actionGroup->add(      actionGroup->add(
204          Gtk::Action::create("RefreshAll", _("_Refresh All")),          Gtk::Action::create("RefreshAll", _("_Refresh All")),
205          sigc::mem_fun(*this, &MainWindow::on_action_refresh_all)          sigc::mem_fun(*this, &MainWindow::on_action_refresh_all)
206      );                      );                
207    
208      action = Gtk::Action::create("MenuHelp", Gtk::Stock::HELP);      actionGroup->add(Gtk::Action::create("MenuHelp", _("_Help")));
209      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),  
210                       sigc::mem_fun(                       sigc::mem_fun(
211                           *this, &MainWindow::on_action_help_about));                           *this, &MainWindow::on_action_help_about));
212      actionGroup->add(      actionGroup->add(
# Line 206  MainWindow::MainWindow() : Line 218  MainWindow::MainWindow() :
218          sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument)          sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument)
219      );      );
220      actionGroup->add(      actionGroup->add(
221          Gtk::Action::create("RemoveInstrument", Gtk::Stock::REMOVE),          Gtk::Action::create("RemoveInstrument", _("_Remove")),
222          sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument)          sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument)
223      );      );
224    
# Line 253  MainWindow::MainWindow() : Line 265  MainWindow::MainWindow() :
265    
266      // sample right-click popup actions      // sample right-click popup actions
267      actionGroup->add(      actionGroup->add(
268          Gtk::Action::create("SampleProperties", Gtk::Stock::PROPERTIES),          Gtk::Action::create("SampleProperties", _("_Properties")),
269          sigc::mem_fun(*this, &MainWindow::on_action_sample_properties)          sigc::mem_fun(*this, &MainWindow::on_action_sample_properties)
270      );      );
271      actionGroup->add(      actionGroup->add(
# Line 265  MainWindow::MainWindow() : Line 277  MainWindow::MainWindow() :
277          sigc::mem_fun(*this, &MainWindow::on_action_add_sample)          sigc::mem_fun(*this, &MainWindow::on_action_add_sample)
278      );      );
279      actionGroup->add(      actionGroup->add(
280          Gtk::Action::create("RemoveSample", Gtk::Stock::REMOVE),          Gtk::Action::create("RemoveSample", _("_Remove")),
281          sigc::mem_fun(*this, &MainWindow::on_action_remove_sample)          sigc::mem_fun(*this, &MainWindow::on_action_remove_sample)
282      );      );
283      actionGroup->add(      actionGroup->add(
# Line 301  MainWindow::MainWindow() : Line 313  MainWindow::MainWindow() :
313          sigc::mem_fun(*this, &MainWindow::on_action_edit_script)          sigc::mem_fun(*this, &MainWindow::on_action_edit_script)
314      );      );
315      actionGroup->add(      actionGroup->add(
316          Gtk::Action::create("RemoveScript", Gtk::Stock::REMOVE),          Gtk::Action::create("RemoveScript", _("_Remove")),
317          sigc::mem_fun(*this, &MainWindow::on_action_remove_script)          sigc::mem_fun(*this, &MainWindow::on_action_remove_script)
318      );      );
319    
# Line 360  MainWindow::MainWindow() : Line 372  MainWindow::MainWindow() :
372          "    </menu>"          "    </menu>"
373          "    <menu action='MenuView'>"          "    <menu action='MenuView'>"
374          "      <menuitem action='Statusbar'/>"          "      <menuitem action='Statusbar'/>"
375            "      <menuitem action='AutoRestoreWinDim'/>"
376          "      <separator/>"          "      <separator/>"
377          "      <menuitem action='RefreshAll'/>"          "      <menuitem action='RefreshAll'/>"
378          "    </menu>"          "    </menu>"
# Line 458  MainWindow::MainWindow() : Line 471  MainWindow::MainWindow() :
471      }      }
472      {      {
473          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(
474                uiManager->get_widget("/MenuBar/MenuView/AutoRestoreWinDim"));
475            item->set_tooltip_text(_("If checked, size and position of all windows will be saved and automatically restored next time."));
476        }
477        {
478            Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(
479              uiManager->get_widget("/MenuBar/MenuTools/CombineInstruments"));              uiManager->get_widget("/MenuBar/MenuTools/CombineInstruments"));
480          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."));
481      }      }
# Line 796  void Loader::progress_callback(float fra Line 814  void Loader::progress_callback(float fra
814    
815  void Loader::thread_function()  void Loader::thread_function()
816  {  {
817      printf("thread_function self=%x\n", Glib::Threads::Thread::self());      printf("thread_function self=%p\n",
818               static_cast<void*>(Glib::Threads::Thread::self()));
819      printf("Start %s\n", filename.c_str());      printf("Start %s\n", filename.c_str());
820      try {      try {
821          RIFF::File* riff = new RIFF::File(filename);          RIFF::File* riff = new RIFF::File(filename);
# Line 818  void Loader::thread_function() Line 837  void Loader::thread_function()
837  }  }
838    
839  Loader::Loader(const char* filename)  Loader::Loader(const char* filename)
840      : filename(filename), thread(0), progress(0.f)      : filename(filename), gig(0), thread(0), progress(0.f)
841  {  {
842  }  }
843    
# Line 829  void Loader::launch() Line 848  void Loader::launch()
848  #else  #else
849      thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Loader::thread_function));      thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Loader::thread_function));
850  #endif  #endif
851      printf("launch thread=%x\n", thread);      printf("launch thread=%p\n", static_cast<void*>(thread));
852  }  }
853    
854  float Loader::get_progress()  float Loader::get_progress()
# Line 874  void Saver::progress_callback(float frac Line 893  void Saver::progress_callback(float frac
893    
894  void Saver::thread_function()  void Saver::thread_function()
895  {  {
896      printf("thread_function self=%x\n", Glib::Threads::Thread::self());      printf("thread_function self=%p\n",
897               static_cast<void*>(Glib::Threads::Thread::self()));
898      printf("Start %s\n", filename.c_str());      printf("Start %s\n", filename.c_str());
899      try {      try {
900          gig::progress_t progress;          gig::progress_t progress;
# Line 911  void Saver::launch() Line 931  void Saver::launch()
931  #else  #else
932      thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Saver::thread_function));      thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Saver::thread_function));
933  #endif  #endif
934      printf("launch thread=%x\n", thread);      printf("launch thread=%p\n", static_cast<void*>(thread));
935  }  }
936    
937  float Saver::get_progress()  float Saver::get_progress()
# Line 1008  bool MainWindow::close_confirmation_dial Line 1028  bool MainWindow::close_confirmation_dial
1028      g_free(msg);      g_free(msg);
1029      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."));
1030      dialog.add_button(_("Close _Without Saving"), Gtk::RESPONSE_NO);      dialog.add_button(_("Close _Without Saving"), Gtk::RESPONSE_NO);
1031      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
1032      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);
1033      dialog.set_default_response(Gtk::RESPONSE_YES);      dialog.set_default_response(Gtk::RESPONSE_YES);
1034      int response = dialog.run();      int response = dialog.run();
1035      dialog.hide();      dialog.hide();
# Line 1040  bool MainWindow::leaving_shared_mode_dia Line 1060  bool MainWindow::leaving_shared_mode_dia
1060            "used by the sampler until you tell the sampler explicitly to "            "used by the sampler until you tell the sampler explicitly to "
1061            "load it."));            "load it."));
1062      dialog.add_button(_("_Yes, Detach"), Gtk::RESPONSE_YES);      dialog.add_button(_("_Yes, Detach"), Gtk::RESPONSE_YES);
1063      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
1064      dialog.set_default_response(Gtk::RESPONSE_CANCEL);      dialog.set_default_response(Gtk::RESPONSE_CANCEL);
1065      int response = dialog.run();      int response = dialog.run();
1066      dialog.hide();      dialog.hide();
# Line 1054  void MainWindow::on_action_file_open() Line 1074  void MainWindow::on_action_file_open()
1074      if (file_is_shared && !leaving_shared_mode_dialog()) return;      if (file_is_shared && !leaving_shared_mode_dialog()) return;
1075    
1076      Gtk::FileChooserDialog dialog(*this, _("Open file"));      Gtk::FileChooserDialog dialog(*this, _("Open file"));
1077      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
1078      dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);      dialog.add_button(_("_Open"), Gtk::RESPONSE_OK);
1079      dialog.set_default_response(Gtk::RESPONSE_OK);      dialog.set_default_response(Gtk::RESPONSE_OK);
1080  #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
1081      Gtk::FileFilter filter;      Gtk::FileFilter filter;
# Line 1071  void MainWindow::on_action_file_open() Line 1091  void MainWindow::on_action_file_open()
1091      if (dialog.run() == Gtk::RESPONSE_OK) {      if (dialog.run() == Gtk::RESPONSE_OK) {
1092          std::string filename = dialog.get_filename();          std::string filename = dialog.get_filename();
1093          printf("filename=%s\n", filename.c_str());          printf("filename=%s\n", filename.c_str());
1094          printf("on_action_file_open self=%x\n", Glib::Threads::Thread::self());          printf("on_action_file_open self=%p\n",
1095                   static_cast<void*>(Glib::Threads::Thread::self()));
1096          load_file(filename.c_str());          load_file(filename.c_str());
1097          current_gig_dir = Glib::path_get_dirname(filename);          current_gig_dir = Glib::path_get_dirname(filename);
1098      }      }
# Line 1141  void MainWindow::on_loader_progress() Line 1162  void MainWindow::on_loader_progress()
1162  void MainWindow::on_loader_finished()  void MainWindow::on_loader_finished()
1163  {  {
1164      printf("Loader finished!\n");      printf("Loader finished!\n");
1165      printf("on_loader_finished self=%x\n", Glib::Threads::Thread::self());      printf("on_loader_finished self=%p\n",
1166               static_cast<void*>(Glib::Threads::Thread::self()));
1167      load_gig(loader->gig, loader->filename.c_str());      load_gig(loader->gig, loader->filename.c_str());
1168      progress_dialog->hide();      progress_dialog->hide();
1169  }  }
# Line 1248  void MainWindow::on_action_file_save_as( Line 1270  void MainWindow::on_action_file_save_as(
1270    
1271  bool MainWindow::file_save_as()  bool MainWindow::file_save_as()
1272  {  {
1273      Gtk::FileChooserDialog dialog(*this, _("Save as"), Gtk::FILE_CHOOSER_ACTION_SAVE);      Gtk::FileChooserDialog dialog(*this, _("Save As"), Gtk::FILE_CHOOSER_ACTION_SAVE);
1274      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
1275      dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK);      dialog.add_button(_("_Save"), Gtk::RESPONSE_OK);
1276      dialog.set_default_response(Gtk::RESPONSE_OK);      dialog.set_default_response(Gtk::RESPONSE_OK);
1277      dialog.set_do_overwrite_confirmation();      dialog.set_do_overwrite_confirmation();
1278    
# Line 1281  bool MainWindow::file_save_as() Line 1303  bool MainWindow::file_save_as()
1303      // show warning in the dialog      // show warning in the dialog
1304      Gtk::HBox descriptionArea;      Gtk::HBox descriptionArea;
1305      descriptionArea.set_spacing(15);      descriptionArea.set_spacing(15);
1306      Gtk::Image warningIcon(Gtk::Stock::DIALOG_WARNING, Gtk::IconSize(Gtk::ICON_SIZE_DIALOG));      Gtk::Image warningIcon;
1307        warningIcon.set_from_icon_name("dialog-warning",
1308                                       Gtk::IconSize(Gtk::ICON_SIZE_DIALOG));
1309      descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK);      descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK);
1310  #if GTKMM_MAJOR_VERSION < 3  #if GTKMM_MAJOR_VERSION < 3
1311      view::WrapLabel description;      view::WrapLabel description;
# Line 1333  bool MainWindow::file_save_as() Line 1357  bool MainWindow::file_save_as()
1357  void MainWindow::__import_queued_samples() {  void MainWindow::__import_queued_samples() {
1358      std::cout << "Starting sample import\n" << std::flush;      std::cout << "Starting sample import\n" << std::flush;
1359      Glib::ustring error_files;      Glib::ustring error_files;
1360      printf("Samples to import: %d\n", m_SampleImportQueue.size());      printf("Samples to import: %d\n", int(m_SampleImportQueue.size()));
1361      for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin();      for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin();
1362           iter != m_SampleImportQueue.end(); ) {           iter != m_SampleImportQueue.end(); ) {
1363          printf("Importing sample %s\n",(*iter).sample_path.c_str());          printf("Importing sample %s\n",(*iter).sample_path.c_str());
# Line 1453  void MainWindow::on_action_help_about() Line 1477  void MainWindow::on_action_help_about()
1477      dialog.set_name("Gigedit");      dialog.set_name("Gigedit");
1478  #endif  #endif
1479      dialog.set_version(VERSION);      dialog.set_version(VERSION);
1480      dialog.set_copyright("Copyright (C) 2006-2015 Andreas Persson");      dialog.set_copyright("Copyright (C) 2006-2016 Andreas Persson");
1481      const std::string sComment =      const std::string sComment =
1482          _("Built " __DATE__ "\nUsing ") +          _("Built " __DATE__ "\nUsing ") +
1483          ::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" +          ::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" +
# Line 1490  PropDialog::PropDialog() Line 1514  PropDialog::PropDialog()
1514        eSourceForm(_("Source form")),        eSourceForm(_("Source form")),
1515        eCommissioned(_("Commissioned")),        eCommissioned(_("Commissioned")),
1516        eSubject(_("Subject")),        eSubject(_("Subject")),
1517        quitButton(Gtk::Stock::CLOSE),        quitButton(_("_Close"), true),
1518        table(2, 1),        table(2, 1),
1519        m_file(NULL)        m_file(NULL)
1520  {  {
# Line 1613  void InstrumentProps::set_MIDIProgram(ui Line 1637  void InstrumentProps::set_MIDIProgram(ui
1637  }  }
1638    
1639  InstrumentProps::InstrumentProps() :  InstrumentProps::InstrumentProps() :
1640      quitButton(Gtk::Stock::CLOSE),      quitButton(_("_Close"), true),
1641      table(2,1),      table(2,1),
1642      eName(_("Name")),      eName(_("Name")),
1643      eIsDrum(_("Is drum")),      eIsDrum(_("Is drum")),
# Line 1908  void MainWindow::on_action_view_status_b Line 1932  void MainWindow::on_action_view_status_b
1932      else                    m_StatusBar.hide();      else                    m_StatusBar.hide();
1933  }  }
1934    
1935    void MainWindow::on_auto_restore_win_dim() {
1936        Gtk::CheckMenuItem* item =
1937            dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/AutoRestoreWinDim"));
1938        if (!item) {
1939            std::cerr << "/MenuBar/MenuView/AutoRestoreWinDim == NULL\n";
1940            return;
1941        }
1942        Settings::singleton()->autoRestoreWindowDimension = item->get_active();
1943    }
1944    
1945  bool MainWindow::is_copy_samples_unity_note_enabled() const {  bool MainWindow::is_copy_samples_unity_note_enabled() const {
1946      Gtk::CheckMenuItem* item =      Gtk::CheckMenuItem* item =
1947          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleUnity"));          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleUnity"));
# Line 2330  void MainWindow::on_action_edit_script() Line 2364  void MainWindow::on_action_edit_script()
2364      if (!script) return;      if (!script) return;
2365    
2366      ScriptEditor* editor = new ScriptEditor;      ScriptEditor* editor = new ScriptEditor;
2367        editor->signal_script_to_be_changed.connect(
2368            signal_script_to_be_changed.make_slot()
2369        );
2370        editor->signal_script_changed.connect(
2371            signal_script_changed.make_slot()
2372        );
2373      editor->setScript(script);      editor->setScript(script);
2374      //editor->reparent(*this);      //editor->reparent(*this);
2375      editor->show();      editor->show();
# Line 2426  void MainWindow::add_or_replace_sample(b Line 2466  void MainWindow::add_or_replace_sample(b
2466    
2467      // show 'browse for file' dialog      // show 'browse for file' dialog
2468      Gtk::FileChooserDialog dialog(*this, replace ? _("Replace Sample with") : _("Add Sample(s)"));      Gtk::FileChooserDialog dialog(*this, replace ? _("Replace Sample with") : _("Add Sample(s)"));
2469      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
2470      dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);      dialog.add_button(_("_Open"), Gtk::RESPONSE_OK);
2471      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
2472    
2473      // matches all file types supported by libsndfile      // matches all file types supported by libsndfile
# Line 2627  void MainWindow::on_action_replace_all_s Line 2667  void MainWindow::on_action_replace_all_s
2667      dialog.get_vbox()->pack_start(entryArea, Gtk::PACK_SHRINK);      dialog.get_vbox()->pack_start(entryArea, Gtk::PACK_SHRINK);
2668      description.show();      description.show();
2669      entryArea.show_all();      entryArea.show_all();
2670      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
2671      dialog.add_button(_("Select"), Gtk::RESPONSE_OK);      dialog.add_button(_("Select"), Gtk::RESPONSE_OK);
2672      dialog.set_select_multiple(false);      dialog.set_select_multiple(false);
2673      if (current_sample_dir != "") {      if (current_sample_dir != "") {
# Line 2651  void MainWindow::on_action_replace_all_s Line 2691  void MainWindow::on_action_replace_all_s
2691              try              try
2692              {              {
2693                  if (!hFile) throw std::string(_("could not open file"));                  if (!hFile) throw std::string(_("could not open file"));
                 int bitdepth;  
2694                  switch (info.format & 0xff) {                  switch (info.format & 0xff) {
2695                      case SF_FORMAT_PCM_S8:                      case SF_FORMAT_PCM_S8:
2696                      case SF_FORMAT_PCM_16:                      case SF_FORMAT_PCM_16:
2697                      case SF_FORMAT_PCM_U8:                      case SF_FORMAT_PCM_U8:
                         bitdepth = 16;  
                         break;  
2698                      case SF_FORMAT_PCM_24:                      case SF_FORMAT_PCM_24:
2699                      case SF_FORMAT_PCM_32:                      case SF_FORMAT_PCM_32:
2700                      case SF_FORMAT_FLOAT:                      case SF_FORMAT_FLOAT:
2701                      case SF_FORMAT_DOUBLE:                      case SF_FORMAT_DOUBLE:
                         bitdepth = 24;  
2702                          break;                          break;
2703                      default:                      default:
2704                          sf_close(hFile);                          sf_close(hFile);
# Line 3076  void MainWindow::script_double_clicked(c Line 3112  void MainWindow::script_double_clicked(c
3112      if (!script) return;      if (!script) return;
3113    
3114      ScriptEditor* editor = new ScriptEditor;      ScriptEditor* editor = new ScriptEditor;
3115        editor->signal_script_to_be_changed.connect(
3116            signal_script_to_be_changed.make_slot()
3117        );
3118        editor->signal_script_changed.connect(
3119            signal_script_changed.make_slot()
3120        );
3121      editor->setScript(script);      editor->setScript(script);
3122      //editor->reparent(*this);      //editor->reparent(*this);
3123      editor->show();      editor->show();
# Line 3251  void MainWindow::on_action_merge_files() Line 3293  void MainWindow::on_action_merge_files()
3293      }      }
3294    
3295      Gtk::FileChooserDialog dialog(*this, _("Merge .gig files"));      Gtk::FileChooserDialog dialog(*this, _("Merge .gig files"));
3296      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
3297      dialog.add_button(_("Merge"), Gtk::RESPONSE_OK);      dialog.add_button(_("Merge"), Gtk::RESPONSE_OK);
3298      dialog.set_default_response(Gtk::RESPONSE_CANCEL);      dialog.set_default_response(Gtk::RESPONSE_CANCEL);
3299  #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 3270  void MainWindow::on_action_merge_files() Line 3312  void MainWindow::on_action_merge_files()
3312      // show warning in the file picker dialog      // show warning in the file picker dialog
3313      Gtk::HBox descriptionArea;      Gtk::HBox descriptionArea;
3314      descriptionArea.set_spacing(15);      descriptionArea.set_spacing(15);
3315      Gtk::Image warningIcon(Gtk::Stock::DIALOG_WARNING, Gtk::IconSize(Gtk::ICON_SIZE_DIALOG));      Gtk::Image warningIcon;
3316        warningIcon.set_from_icon_name("dialog-warning",
3317                                       Gtk::IconSize(Gtk::ICON_SIZE_DIALOG));
3318      descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK);      descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK);
3319  #if GTKMM_MAJOR_VERSION < 3  #if GTKMM_MAJOR_VERSION < 3
3320      view::WrapLabel description;      view::WrapLabel description;
# Line 3293  void MainWindow::on_action_merge_files() Line 3337  void MainWindow::on_action_merge_files()
3337      descriptionArea.show_all();      descriptionArea.show_all();
3338    
3339      if (dialog.run() == Gtk::RESPONSE_OK) {      if (dialog.run() == Gtk::RESPONSE_OK) {
3340          printf("on_action_merge_files self=%x\n", Glib::Threads::Thread::self());          printf("on_action_merge_files self=%p\n",
3341                   static_cast<void*>(Glib::Threads::Thread::self()));
3342          std::vector<std::string> filenames = dialog.get_filenames();          std::vector<std::string> filenames = dialog.get_filenames();
3343    
3344          // merge the selected files to the currently open .gig file          // merge the selected files to the currently open .gig file

Legend:
Removed from v.2773  
changed lines
  Added in v.2918

  ViewVC Help
Powered by ViewVC