/[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 1714 by persson, Thu Mar 6 20:50:04 2008 UTC revision 2423 by persson, Sun Feb 24 15:19:39 2013 UTC
# Line 1  Line 1 
1  /*  /*
2   * Copyright (C) 2006 - 2008 Andreas Persson   * Copyright (C) 2006-2013 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 <glibmm/convert.h>
24    #include <glibmm/dispatcher.h>
25    #include <glibmm/miscutils.h>
26    #include <glibmm/stringutils.h>
27    #include <gtkmm/aboutdialog.h>
28  #include <gtkmm/filechooserdialog.h>  #include <gtkmm/filechooserdialog.h>
29  #include <gtkmm/messagedialog.h>  #include <gtkmm/messagedialog.h>
30  #include <gtkmm/stock.h>  #include <gtkmm/stock.h>
31  #include <gtkmm/targetentry.h>  #include <gtkmm/targetentry.h>
32  #include <gtkmm/main.h>  #include <gtkmm/main.h>
33    #include <gtkmm/radiomenuitem.h>
34  #include <gtkmm/toggleaction.h>  #include <gtkmm/toggleaction.h>
35    #if GTKMM_MAJOR_VERSION < 3
36  #include "global.h"  #include "wrapLabel.hh"
   
 #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION >= 6) || GTKMM_MAJOR_VERSION > 2  
 #define ABOUT_DIALOG  
 #include <gtkmm/aboutdialog.h>  
37  #endif  #endif
38    
39  #if (GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION < 6) || GLIBMM_MAJOR_VERSION < 2  #include "global.h"
40  namespace Glib {  #include "compat.h"
 Glib::ustring filename_display_basename(const std::string& filename)  
 {  
     gchar* gstr = g_path_get_basename(filename.c_str());  
     Glib::ustring str(gstr);  
     g_free(gstr);  
     return Glib::filename_to_utf8(str);  
 }  
 }  
 #endif  
41    
42  #include <stdio.h>  #include <stdio.h>
43  #include <sndfile.h>  #include <sndfile.h>
# Line 60  template<class T> inline std::string ToS Line 53  template<class T> inline std::string ToS
53      return ss.str();      return ss.str();
54  }  }
55    
 Table::Table(int x, int y) : Gtk::Table(x, y), rowno(0) {  }  
   
 void Table::add(BoolEntry& boolentry)  
 {  
     attach(boolentry.widget, 0, 2, rowno, rowno + 1,  
            Gtk::FILL, Gtk::SHRINK);  
     rowno++;  
 }  
   
 void Table::add(BoolEntryPlus6& boolentry)  
 {  
     attach(boolentry.widget, 0, 2, rowno, rowno + 1,  
            Gtk::FILL, Gtk::SHRINK);  
     rowno++;  
 }  
   
 void Table::add(LabelWidget& prop)  
 {  
     attach(prop.label, 1, 2, rowno, rowno + 1,  
            Gtk::FILL, Gtk::SHRINK);  
     attach(prop.widget, 2, 3, rowno, rowno + 1,  
            Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);  
     rowno++;  
 }  
56    
57  MainWindow::MainWindow() :  MainWindow::MainWindow() :
58      dimreg_label(_("Changes apply to:")),      dimreg_label(_("Changes apply to:")),
# Line 129  MainWindow::MainWindow() : Line 98  MainWindow::MainWindow() :
98      m_HPaned.add2(dimreg_vbox);      m_HPaned.add2(dimreg_vbox);
99    
100    
101      m_TreeViewNotebook.append_page(m_ScrolledWindowSamples, "Samples");      m_TreeViewNotebook.append_page(m_ScrolledWindowSamples, _("Samples"));
102      m_TreeViewNotebook.append_page(m_ScrolledWindow, "Instruments");      m_TreeViewNotebook.append_page(m_ScrolledWindow, _("Instruments"));
103    
104    
105      actionGroup = Gtk::ActionGroup::create();      actionGroup = Gtk::ActionGroup::create();
# Line 178  MainWindow::MainWindow() : Line 147  MainWindow::MainWindow() :
147      action = Gtk::Action::create("MenuHelp", Gtk::Stock::HELP);      action = Gtk::Action::create("MenuHelp", Gtk::Stock::HELP);
148      actionGroup->add(Gtk::Action::create("MenuHelp",      actionGroup->add(Gtk::Action::create("MenuHelp",
149                                           action->property_label()));                                           action->property_label()));
 #ifdef ABOUT_DIALOG  
150      actionGroup->add(Gtk::Action::create("About", Gtk::Stock::ABOUT),      actionGroup->add(Gtk::Action::create("About", Gtk::Stock::ABOUT),
151                       sigc::mem_fun(                       sigc::mem_fun(
152                           *this, &MainWindow::on_action_help_about));                           *this, &MainWindow::on_action_help_about));
 #endif  
153      actionGroup->add(      actionGroup->add(
154          Gtk::Action::create("AddInstrument", _("Add _Instrument")),          Gtk::Action::create("AddInstrument", _("Add _Instrument")),
155          sigc::mem_fun(*this, &MainWindow::on_action_add_instrument)          sigc::mem_fun(*this, &MainWindow::on_action_add_instrument)
156      );      );
157      actionGroup->add(      actionGroup->add(
158            Gtk::Action::create("DupInstrument", _("_Duplicate Instrument")),
159            sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument)
160        );
161        actionGroup->add(
162          Gtk::Action::create("RemoveInstrument", Gtk::Stock::REMOVE),          Gtk::Action::create("RemoveInstrument", Gtk::Stock::REMOVE),
163          sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument)          sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument)
164      );      );
# Line 202  MainWindow::MainWindow() : Line 173  MainWindow::MainWindow() :
173          sigc::mem_fun(*this, &MainWindow::on_action_add_group)          sigc::mem_fun(*this, &MainWindow::on_action_add_group)
174      );      );
175      actionGroup->add(      actionGroup->add(
176          Gtk::Action::create("AddSample", _("Add _Sample(s)")),          Gtk::Action::create("AddSample", _("Add _Sample(s)...")),
177          sigc::mem_fun(*this, &MainWindow::on_action_add_sample)          sigc::mem_fun(*this, &MainWindow::on_action_add_sample)
178      );      );
179      actionGroup->add(      actionGroup->add(
# Line 210  MainWindow::MainWindow() : Line 181  MainWindow::MainWindow() :
181          sigc::mem_fun(*this, &MainWindow::on_action_remove_sample)          sigc::mem_fun(*this, &MainWindow::on_action_remove_sample)
182      );      );
183      actionGroup->add(      actionGroup->add(
184          Gtk::Action::create("ReplaceAllSamplesInAllGroups", _("Replace All Samples In All Groups")),          Gtk::Action::create("ReplaceAllSamplesInAllGroups",
185                                _("Replace All Samples in All Groups...")),
186          sigc::mem_fun(*this, &MainWindow::on_action_replace_all_samples_in_all_groups)          sigc::mem_fun(*this, &MainWindow::on_action_replace_all_samples_in_all_groups)
187      );      );
188    
# Line 237  MainWindow::MainWindow() : Line 209  MainWindow::MainWindow() :
209          "    <menu action='MenuView'>"          "    <menu action='MenuView'>"
210          "      <menuitem action='Statusbar'/>"          "      <menuitem action='Statusbar'/>"
211          "    </menu>"          "    </menu>"
 #ifdef ABOUT_DIALOG  
212          "    <menu action='MenuHelp'>"          "    <menu action='MenuHelp'>"
213          "      <menuitem action='About'/>"          "      <menuitem action='About'/>"
214          "    </menu>"          "    </menu>"
 #endif  
215          "  </menubar>"          "  </menubar>"
216          "  <popup name='PopupMenu'>"          "  <popup name='PopupMenu'>"
217          "    <menuitem action='InstrProperties'/>"          "    <menuitem action='InstrProperties'/>"
218          "    <menuitem action='AddInstrument'/>"          "    <menuitem action='AddInstrument'/>"
219            "    <menuitem action='DupInstrument'/>"
220          "    <separator/>"          "    <separator/>"
221          "    <menuitem action='RemoveInstrument'/>"          "    <menuitem action='RemoveInstrument'/>"
222          "  </popup>"          "  </popup>"
# Line 270  MainWindow::MainWindow() : Line 241  MainWindow::MainWindow() :
241      m_VBox.pack_start(m_DimRegionChooser, Gtk::PACK_SHRINK);      m_VBox.pack_start(m_DimRegionChooser, Gtk::PACK_SHRINK);
242      m_VBox.pack_start(m_StatusBar, Gtk::PACK_SHRINK);      m_VBox.pack_start(m_StatusBar, Gtk::PACK_SHRINK);
243    
244        set_file_is_shared(false);
245    
246      // Status Bar:      // Status Bar:
247      m_StatusBar.pack_start(m_AttachedStateLabel, Gtk::PACK_SHRINK);      m_StatusBar.pack_start(m_AttachedStateLabel, Gtk::PACK_SHRINK);
248      m_StatusBar.pack_start(m_AttachedStateImage, Gtk::PACK_SHRINK);      m_StatusBar.pack_start(m_AttachedStateImage, Gtk::PACK_SHRINK);
# Line 306  MainWindow::MainWindow() : Line 279  MainWindow::MainWindow() :
279      );      );
280    
281      // establish drag&drop between samples tree view and dimension region 'Sample' text entry      // establish drag&drop between samples tree view and dimension region 'Sample' text entry
282      std::list<Gtk::TargetEntry> drag_target_gig_sample;      std::vector<Gtk::TargetEntry> drag_target_gig_sample;
283      drag_target_gig_sample.push_back( Gtk::TargetEntry("gig::Sample") );      drag_target_gig_sample.push_back(Gtk::TargetEntry("gig::Sample"));
284      m_TreeViewSamples.drag_source_set(drag_target_gig_sample);      m_TreeViewSamples.drag_source_set(drag_target_gig_sample);
285      m_TreeViewSamples.signal_drag_begin().connect(      m_TreeViewSamples.signal_drag_begin().connect(
286          sigc::mem_fun(*this, &MainWindow::on_sample_treeview_drag_begin)          sigc::mem_fun(*this, &MainWindow::on_sample_treeview_drag_begin)
# Line 325  MainWindow::MainWindow() : Line 298  MainWindow::MainWindow() :
298          sigc::mem_fun(*this, &MainWindow::file_changed));          sigc::mem_fun(*this, &MainWindow::file_changed));
299      m_DimRegionChooser.signal_region_changed().connect(      m_DimRegionChooser.signal_region_changed().connect(
300          sigc::mem_fun(*this, &MainWindow::file_changed));          sigc::mem_fun(*this, &MainWindow::file_changed));
301      instrumentProps.signal_instrument_changed().connect(      instrumentProps.signal_changed().connect(
302          sigc::mem_fun(*this, &MainWindow::file_changed));          sigc::mem_fun(*this, &MainWindow::file_changed));
303      propDialog.signal_info_changed().connect(      propDialog.signal_changed().connect(
304          sigc::mem_fun(*this, &MainWindow::file_changed));          sigc::mem_fun(*this, &MainWindow::file_changed));
305    
306      dimreg_edit.signal_dimreg_to_be_changed().connect(      dimreg_edit.signal_dimreg_to_be_changed().connect(
# Line 372  MainWindow::MainWindow() : Line 345  MainWindow::MainWindow() :
345    
346      file = 0;      file = 0;
347      file_is_changed = false;      file_is_changed = false;
     set_file_is_shared(false);  
348    
349      show_all_children();      show_all_children();
350    
# Line 476  void loader_progress_callback(gig::progr Line 448  void loader_progress_callback(gig::progr
448  void Loader::progress_callback(float fraction)  void Loader::progress_callback(float fraction)
449  {  {
450      {      {
451          Glib::Mutex::Lock lock(progressMutex);          Glib::Threads::Mutex::Lock lock(progressMutex);
452          progress = fraction;          progress = fraction;
453      }      }
454      progress_dispatcher();      progress_dispatcher();
# Line 484  void Loader::progress_callback(float fra Line 456  void Loader::progress_callback(float fra
456    
457  void Loader::thread_function()  void Loader::thread_function()
458  {  {
459      printf("thread_function self=%x\n", Glib::Thread::self());      printf("thread_function self=%x\n", Glib::Threads::Thread::self());
460      printf("Start %s\n", filename);      printf("Start %s\n", filename);
461      RIFF::File* riff = new RIFF::File(filename);      RIFF::File* riff = new RIFF::File(filename);
462      gig = new gig::File(riff);      gig = new gig::File(riff);
# Line 498  void Loader::thread_function() Line 470  void Loader::thread_function()
470  }  }
471    
472  Loader::Loader(const char* filename)  Loader::Loader(const char* filename)
473      : thread(0), filename(filename)      : filename(filename), thread(0)
474  {  {
475  }  }
476    
477  void Loader::launch()  void Loader::launch()
478  {  {
479    #ifdef OLD_THREADS
480      thread = Glib::Thread::create(sigc::mem_fun(*this, &Loader::thread_function), true);      thread = Glib::Thread::create(sigc::mem_fun(*this, &Loader::thread_function), true);
481    #else
482        thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Loader::thread_function));
483    #endif
484      printf("launch thread=%x\n", thread);      printf("launch thread=%x\n", thread);
485  }  }
486    
# Line 512  float Loader::get_progress() Line 488  float Loader::get_progress()
488  {  {
489      float res;      float res;
490      {      {
491          Glib::Mutex::Lock lock(progressMutex);          Glib::Threads::Mutex::Lock lock(progressMutex);
492          res = progress;          res = progress;
493      }      }
494      return res;      return res;
# Line 542  void MainWindow::__clear() { Line 518  void MainWindow::__clear() {
518      Gtk::MenuItem* instrument_menu =      Gtk::MenuItem* instrument_menu =
519          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuInstrument"));          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuInstrument"));
520      instrument_menu->hide();      instrument_menu->hide();
521      for (int i = 0; i < instrument_menu->get_submenu()->items().size(); i++) {      Gtk::Menu* menu = instrument_menu->get_submenu();
522          delete &instrument_menu->get_submenu()->items()[i];      while (menu->get_children().size()) {
523            Gtk::Widget* child = *menu->get_children().begin();
524            menu->remove(*child);
525            delete child;
526      }      }
     instrument_menu->get_submenu()->items().clear();  
527      // forget all samples that ought to be imported      // forget all samples that ought to be imported
528      m_SampleImportQueue.clear();      m_SampleImportQueue.clear();
529      // clear the samples and instruments tree views      // clear the samples and instruments tree views
# Line 569  void MainWindow::on_action_file_new() Line 547  void MainWindow::on_action_file_new()
547      gig::File* pFile = new gig::File;      gig::File* pFile = new gig::File;
548      // already add one new instrument by default      // already add one new instrument by default
549      gig::Instrument* pInstrument = pFile->AddInstrument();      gig::Instrument* pInstrument = pFile->AddInstrument();
550      pInstrument->pInfo->Name = "Unnamed Instrument";      pInstrument->pInfo->Name = _("Unnamed Instrument");
551      // update GUI with that new gig::File      // update GUI with that new gig::File
552      load_gig(pFile, 0 /*no file name yet*/);      load_gig(pFile, 0 /*no file name yet*/);
553  }  }
# Line 580  bool MainWindow::close_confirmation_dial Line 558  bool MainWindow::close_confirmation_dial
558                                   Glib::filename_display_basename(filename).c_str());                                   Glib::filename_display_basename(filename).c_str());
559      Gtk::MessageDialog dialog(*this, msg, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE);      Gtk::MessageDialog dialog(*this, msg, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE);
560      g_free(msg);      g_free(msg);
 #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION >= 6) || GTKMM_MAJOR_VERSION > 2  
561      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."));
 #endif  
562      dialog.add_button(_("Close _Without Saving"), Gtk::RESPONSE_NO);      dialog.add_button(_("Close _Without Saving"), Gtk::RESPONSE_NO);
563      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
564      dialog.add_button(file_has_name ? Gtk::Stock::SAVE : Gtk::Stock::SAVE_AS, Gtk::RESPONSE_YES);      dialog.add_button(file_has_name ? Gtk::Stock::SAVE : Gtk::Stock::SAVE_AS, Gtk::RESPONSE_YES);
# Line 596  bool MainWindow::close_confirmation_dial Line 572  bool MainWindow::close_confirmation_dial
572  bool MainWindow::leaving_shared_mode_dialog() {  bool MainWindow::leaving_shared_mode_dialog() {
573      Glib::ustring msg = _("Detach from sampler and proceed working stand-alone?");      Glib::ustring msg = _("Detach from sampler and proceed working stand-alone?");
574      Gtk::MessageDialog dialog(*this, msg, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE);      Gtk::MessageDialog dialog(*this, msg, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE);
 #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION >= 6) || GTKMM_MAJOR_VERSION > 2  
575      dialog.set_secondary_text(      dialog.set_secondary_text(
576          _("If you proceed to work on another instrument file, it won't be "          _("If you proceed to work on another instrument file, it won't be "
577            "used by the sampler until you tell the sampler explicitly to "            "used by the sampler until you tell the sampler explicitly to "
578            "load it.")            "load it."));
    );  
 #endif  
579      dialog.add_button(_("_Yes, Detach"), Gtk::RESPONSE_YES);      dialog.add_button(_("_Yes, Detach"), Gtk::RESPONSE_YES);
580      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
581      dialog.set_default_response(Gtk::RESPONSE_CANCEL);      dialog.set_default_response(Gtk::RESPONSE_CANCEL);
# Line 621  void MainWindow::on_action_file_open() Line 594  void MainWindow::on_action_file_open()
594      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
595      dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);      dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
596      dialog.set_default_response(Gtk::RESPONSE_OK);      dialog.set_default_response(Gtk::RESPONSE_OK);
597    #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
598      Gtk::FileFilter filter;      Gtk::FileFilter filter;
599      filter.add_pattern("*.gig");      filter.add_pattern("*.gig");
600    #else
601        Glib::RefPtr<Gtk::FileFilter> filter = Gtk::FileFilter::create();
602        filter->add_pattern("*.gig");
603    #endif
604      dialog.set_filter(filter);      dialog.set_filter(filter);
605      if (current_dir != "") {      if (current_gig_dir != "") {
606          dialog.set_current_folder(current_dir);          dialog.set_current_folder(current_gig_dir);
607      }      }
608      if (dialog.run() == Gtk::RESPONSE_OK) {      if (dialog.run() == Gtk::RESPONSE_OK) {
609          std::string filename = dialog.get_filename();          std::string filename = dialog.get_filename();
610          printf("filename=%s\n", filename.c_str());          printf("filename=%s\n", filename.c_str());
611          printf("on_action_file_open self=%x\n", Glib::Thread::self());          printf("on_action_file_open self=%x\n", Glib::Threads::Thread::self());
612          load_file(filename.c_str());          load_file(filename.c_str());
613          current_dir = Glib::path_get_dirname(filename);          current_gig_dir = Glib::path_get_dirname(filename);
614      }      }
615  }  }
616    
617  void MainWindow::load_file(const char* name)  void MainWindow::load_file(const char* name)
618  {  {
619      __clear();      __clear();
620      load_dialog = new LoadDialog("Loading...", *this);      load_dialog = new LoadDialog(_("Loading..."), *this);
621      load_dialog->show_all();      load_dialog->show_all();
622      loader = new Loader(strdup(name));      loader = new Loader(strdup(name));
623      loader->signal_progress().connect(      loader->signal_progress().connect(
# Line 672  void MainWindow::on_loader_progress() Line 650  void MainWindow::on_loader_progress()
650  void MainWindow::on_loader_finished()  void MainWindow::on_loader_finished()
651  {  {
652      printf("Loader finished!\n");      printf("Loader finished!\n");
653      printf("on_loader_finished self=%x\n", Glib::Thread::self());      printf("on_loader_finished self=%x\n", Glib::Threads::Thread::self());
654      load_gig(loader->gig, loader->filename);      load_gig(loader->gig, loader->filename);
655      load_dialog->hide();      load_dialog->hide();
656  }  }
# Line 744  bool MainWindow::file_save_as() Line 722  bool MainWindow::file_save_as()
722      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
723      dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK);      dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK);
724      dialog.set_default_response(Gtk::RESPONSE_OK);      dialog.set_default_response(Gtk::RESPONSE_OK);
   
 #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION >= 8) || GTKMM_MAJOR_VERSION > 2  
725      dialog.set_do_overwrite_confirmation();      dialog.set_do_overwrite_confirmation();
726      // TODO: an overwrite dialog for gtkmm < 2.8  
727  #endif  #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
728      Gtk::FileFilter filter;      Gtk::FileFilter filter;
729      filter.add_pattern("*.gig");      filter.add_pattern("*.gig");
730    #else
731        Glib::RefPtr<Gtk::FileFilter> filter = Gtk::FileFilter::create();
732        filter->add_pattern("*.gig");
733    #endif
734      dialog.set_filter(filter);      dialog.set_filter(filter);
735    
736      // set initial dir and filename of the Save As dialog      // set initial dir and filename of the Save As dialog
# Line 758  bool MainWindow::file_save_as() Line 738  bool MainWindow::file_save_as()
738      {      {
739          std::string basename = Glib::path_get_basename(filename);          std::string basename = Glib::path_get_basename(filename);
740          std::string dir = Glib::path_get_dirname(filename);          std::string dir = Glib::path_get_dirname(filename);
741          basename = std::string("copy_of_") + basename;          basename = std::string(_("copy_of_")) + basename;
742          Glib::ustring copyFileName = Glib::build_filename(dir, basename);          Glib::ustring copyFileName = Glib::build_filename(dir, basename);
743          if (Glib::path_is_absolute(filename)) {          if (Glib::path_is_absolute(filename)) {
744              dialog.set_filename(copyFileName);              dialog.set_filename(copyFileName);
745          } else {          } else {
746              if (current_dir != "") dialog.set_current_folder(current_dir);              if (current_gig_dir != "") dialog.set_current_folder(current_gig_dir);
747          }          }
748          dialog.set_current_name(Glib::filename_display_basename(copyFileName));          dialog.set_current_name(Glib::filename_display_basename(copyFileName));
749      }      }
# Line 773  bool MainWindow::file_save_as() Line 753  bool MainWindow::file_save_as()
753      descriptionArea.set_spacing(15);      descriptionArea.set_spacing(15);
754      Gtk::Image warningIcon(Gtk::Stock::DIALOG_WARNING, Gtk::IconSize(Gtk::ICON_SIZE_DIALOG));      Gtk::Image warningIcon(Gtk::Stock::DIALOG_WARNING, Gtk::IconSize(Gtk::ICON_SIZE_DIALOG));
755      descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK);      descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK);
756      warningIcon.show();  #if GTKMM_MAJOR_VERSION < 3
757        view::WrapLabel description;
758    #else
759      Gtk::Label description;      Gtk::Label description;
760        description.set_line_wrap();
761    #endif
762      description.set_markup(      description.set_markup(
763          _("\n<b>CAUTION:</b> You <b>MUST</b> use the "          _("\n<b>CAUTION:</b> You <b>MUST</b> use the "
764            "<span style=\"italic\">\"Save\"</span> dialog instead of "            "<span style=\"italic\">\"Save\"</span> dialog instead of "
# Line 783  bool MainWindow::file_save_as() Line 767  bool MainWindow::file_save_as()
767            "<span style=\"italic\">\"Save As...\"</span> for writing to the "            "<span style=\"italic\">\"Save As...\"</span> for writing to the "
768            "same .gig file will end up in corrupted sample wave data!\n")            "same .gig file will end up in corrupted sample wave data!\n")
769      );      );
770      description.set_line_wrap(true);      descriptionArea.pack_start(description);
     descriptionArea.pack_start(description, Gtk::PACK_SHRINK);  
     description.show();  
771      dialog.get_vbox()->pack_start(descriptionArea, Gtk::PACK_SHRINK);      dialog.get_vbox()->pack_start(descriptionArea, Gtk::PACK_SHRINK);
772      descriptionArea.show();      descriptionArea.show_all();
773    
774      if (dialog.run() == Gtk::RESPONSE_OK) {      if (dialog.run() == Gtk::RESPONSE_OK) {
775          file_structure_to_be_changed_signal.emit(this->file);          file_structure_to_be_changed_signal.emit(this->file);
# Line 799  bool MainWindow::file_save_as() Line 781  bool MainWindow::file_save_as()
781              printf("filename=%s\n", filename.c_str());              printf("filename=%s\n", filename.c_str());
782              file->Save(filename);              file->Save(filename);
783              this->filename = filename;              this->filename = filename;
784              current_dir = Glib::path_get_dirname(filename);              current_gig_dir = Glib::path_get_dirname(filename);
785              set_title(Glib::filename_display_basename(filename));              set_title(Glib::filename_display_basename(filename));
786              file_has_name = true;              file_has_name = true;
787              file_is_changed = false;              file_is_changed = false;
# Line 828  void MainWindow::__import_queued_samples Line 810  void MainWindow::__import_queued_samples
810          SF_INFO info;          SF_INFO info;
811          info.format = 0;          info.format = 0;
812          SNDFILE* hFile = sf_open((*iter).sample_path.c_str(), SFM_READ, &info);          SNDFILE* hFile = sf_open((*iter).sample_path.c_str(), SFM_READ, &info);
813            sf_command(hFile, SFC_SET_SCALE_FLOAT_INT_READ, 0, SF_TRUE);
814          try {          try {
815              if (!hFile) throw std::string("could not open file");              if (!hFile) throw std::string(_("could not open file"));
816              // determine sample's bit depth              // determine sample's bit depth
817              int bitdepth;              int bitdepth;
818              switch (info.format & 0xff) {              switch (info.format & 0xff) {
# Line 846  void MainWindow::__import_queued_samples Line 829  void MainWindow::__import_queued_samples
829                      break;                      break;
830                  default:                  default:
831                      sf_close(hFile); // close sound file                      sf_close(hFile); // close sound file
832                      throw std::string("format not supported"); // unsupported subformat (yet?)                      throw std::string(_("format not supported")); // unsupported subformat (yet?)
833              }              }
834    
835              const int bufsize = 10000;              const int bufsize = 10000;
# Line 888  void MainWindow::__import_queued_samples Line 871  void MainWindow::__import_queued_samples
871              }              }
872              // cleanup              // cleanup
873              sf_close(hFile);              sf_close(hFile);
874                // let the sampler re-cache the sample if needed
875                sample_changed_signal.emit(iter->gig_sample);
876              // on success we remove the sample from the import queue,              // on success we remove the sample from the import queue,
877              // otherwise keep it, maybe it works the next time ?              // otherwise keep it, maybe it works the next time ?
878              std::list<SampleImportItem>::iterator cur = iter;              std::list<SampleImportItem>::iterator cur = iter;
# Line 916  void MainWindow::on_action_file_properti Line 901  void MainWindow::on_action_file_properti
901    
902  void MainWindow::on_action_help_about()  void MainWindow::on_action_help_about()
903  {  {
 #ifdef ABOUT_DIALOG  
904      Gtk::AboutDialog dialog;      Gtk::AboutDialog dialog;
905    #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION >= 12) || GTKMM_MAJOR_VERSION > 2
906        dialog.set_program_name("Gigedit");
907    #else
908        dialog.set_name("Gigedit");
909    #endif
910      dialog.set_version(VERSION);      dialog.set_version(VERSION);
911      dialog.set_copyright("Copyright (C) 2006,2007 Andreas Persson");      dialog.set_copyright("Copyright (C) 2006-2013 Andreas Persson");
912      dialog.set_comments(      dialog.set_comments(_(
913          "Released under the GNU General Public License.\n"          "Released under the GNU General Public License.\n"
914          "\n"          "\n"
915          "Please notice that this is still a very young instrument editor. "          "Please notice that this is still a very young instrument editor. "
916          "So better backup your Gigasampler files before editing them with "          "So better backup your Gigasampler files before editing them with "
917          "this application.\n"          "this application.\n"
918          "\n"          "\n"
919          "Please report bugs to: http://bugs.linuxsampler.org"          "Please report bugs to: http://bugs.linuxsampler.org")
920      );      );
921      dialog.set_website("http://www.linuxsampler.org");      dialog.set_website("http://www.linuxsampler.org");
922      dialog.set_website_label("http://www.linuxsampler.org");      dialog.set_website_label("http://www.linuxsampler.org");
923      dialog.run();      dialog.run();
 #endif  
924  }  }
925    
926  PropDialog::PropDialog()  PropDialog::PropDialog()
927      : table(2,1),      : eName(_("Name")),
928        eName("Name"),        eCreationDate(_("Creation date")),
929        eCreationDate("Creation date"),        eComments(_("Comments")),
930        eComments("Comments"),        eProduct(_("Product")),
931        eProduct("Product"),        eCopyright(_("Copyright")),
932        eCopyright("Copyright"),        eArtists(_("Artists")),
933        eArtists("Artists"),        eGenre(_("Genre")),
934        eGenre("Genre"),        eKeywords(_("Keywords")),
935        eKeywords("Keywords"),        eEngineer(_("Engineer")),
936        eEngineer("Engineer"),        eTechnician(_("Technician")),
937        eTechnician("Technician"),        eSoftware(_("Software")),
938        eSoftware("Software"),        eMedium(_("Medium")),
939        eMedium("Medium"),        eSource(_("Source")),
940        eSource("Source"),        eSourceForm(_("Source form")),
941        eSourceForm("Source form"),        eCommissioned(_("Commissioned")),
942        eCommissioned("Commissioned"),        eSubject(_("Subject")),
       eSubject("Subject"),  
943        quitButton(Gtk::Stock::CLOSE),        quitButton(Gtk::Stock::CLOSE),
944        update_model(0)        table(2, 1)
945  {  {
946      set_title("File Properties");      set_title(_("File Properties"));
947      eName.set_width_chars(50);      eName.set_width_chars(50);
948    
949      connect(eName, &DLS::Info::Name);      connect(eName, &DLS::Info::Name);
# Line 1002  PropDialog::PropDialog() Line 989  PropDialog::PropDialog()
989      buttonBox.set_border_width(5);      buttonBox.set_border_width(5);
990      buttonBox.show();      buttonBox.show();
991      buttonBox.pack_start(quitButton);      buttonBox.pack_start(quitButton);
992      quitButton.set_flags(Gtk::CAN_DEFAULT);      quitButton.set_can_default();
993      quitButton.grab_focus();      quitButton.grab_focus();
994      quitButton.signal_clicked().connect(      quitButton.signal_clicked().connect(
995          sigc::mem_fun(*this, &PropDialog::hide));          sigc::mem_fun(*this, &PropDialog::hide));
# Line 1014  PropDialog::PropDialog() Line 1001  PropDialog::PropDialog()
1001    
1002  void PropDialog::set_info(DLS::Info* info)  void PropDialog::set_info(DLS::Info* info)
1003  {  {
1004      this->info = info;      update(info);
     update_model++;  
     eName.set_value(info->Name);  
     eCreationDate.set_value(info->CreationDate);  
     eComments.set_value(info->Comments);  
     eProduct.set_value(info->Product);  
     eCopyright.set_value(info->Copyright);  
     eArtists.set_value(info->Artists);  
     eGenre.set_value(info->Genre);  
     eKeywords.set_value(info->Keywords);  
     eEngineer.set_value(info->Engineer);  
     eTechnician.set_value(info->Technician);  
     eSoftware.set_value(info->Software);  
     eMedium.set_value(info->Medium);  
     eSource.set_value(info->Source);  
     eSourceForm.set_value(info->SourceForm);  
     eCommissioned.set_value(info->Commissioned);  
     eSubject.set_value(info->Subject);  
     update_model--;  
1005  }  }
1006    
 sigc::signal<void>& PropDialog::signal_info_changed()  
 {  
     return info_changed;  
 }  
1007    
1008  void InstrumentProps::set_IsDrum(bool value)  void InstrumentProps::set_IsDrum(bool value)
1009  {  {
1010      instrument->IsDrum = value;      m->IsDrum = value;
1011  }  }
1012    
1013  void InstrumentProps::set_MIDIBank(uint16_t value)  void InstrumentProps::set_MIDIBank(uint16_t value)
1014  {  {
1015      instrument->MIDIBank = value;      m->MIDIBank = value;
1016  }  }
1017    
1018  void InstrumentProps::set_MIDIProgram(uint32_t value)  void InstrumentProps::set_MIDIProgram(uint32_t value)
1019  {  {
1020      instrument->MIDIProgram = value;      m->MIDIProgram = value;
 }  
   
 void InstrumentProps::set_DimensionKeyRange_low(uint8_t value)  
 {  
     instrument->DimensionKeyRange.low = value;  
     if (value > instrument->DimensionKeyRange.high) {  
         eDimensionKeyRangeHigh.set_value(value);  
     }  
 }  
   
 void InstrumentProps::set_DimensionKeyRange_high(uint8_t value)  
 {  
     instrument->DimensionKeyRange.high = value;  
     if (value < instrument->DimensionKeyRange.low) {  
         eDimensionKeyRangeLow.set_value(value);  
     }  
1021  }  }
1022    
1023  InstrumentProps::InstrumentProps()  InstrumentProps::InstrumentProps() :
1024      : table(2,1),      quitButton(Gtk::Stock::CLOSE),
1025        quitButton(Gtk::Stock::CLOSE),      table(2,1),
1026        eName("Name"),      eName(_("Name")),
1027        eIsDrum("Is drum"),      eIsDrum(_("Is drum")),
1028        eMIDIBank("MIDI bank", 0, 16383),      eMIDIBank(_("MIDI bank"), 0, 16383),
1029        eMIDIProgram("MIDI program"),      eMIDIProgram(_("MIDI program")),
1030        eAttenuation("Attenuation", 0, 96, 0, 1),      eAttenuation(_("Attenuation"), 0, 96, 0, 1),
1031        eGainPlus6("Gain +6dB", eAttenuation, -6),      eGainPlus6(_("Gain +6dB"), eAttenuation, -6),
1032        eEffectSend("Effect send", 0, 65535),      eEffectSend(_("Effect send"), 0, 65535),
1033        eFineTune("Fine tune", -8400, 8400),      eFineTune(_("Fine tune"), -8400, 8400),
1034        ePitchbendRange("Pitchbend range", 0, 12),      ePitchbendRange(_("Pitchbend range"), 0, 12),
1035        ePianoReleaseMode("Piano release mode"),      ePianoReleaseMode(_("Piano release mode")),
1036        eDimensionKeyRangeLow("Keyswitching range low"),      eDimensionKeyRangeLow(_("Keyswitching range low")),
1037        eDimensionKeyRangeHigh("Keyswitching range high"),      eDimensionKeyRangeHigh(_("Keyswitching range high"))
       update_model(0)  
1038  {  {
1039      set_title("Instrument Properties");      set_title(_("Instrument Properties"));
1040    
1041      eDimensionKeyRangeLow.set_tip(      eDimensionKeyRangeLow.set_tip(
1042          _("start of the keyboard area which should switch the "          _("start of the keyboard area which should switch the "
# Line 1108  InstrumentProps::InstrumentProps() Line 1056  InstrumentProps::InstrumentProps()
1056      connect(eFineTune, &gig::Instrument::FineTune);      connect(eFineTune, &gig::Instrument::FineTune);
1057      connect(ePitchbendRange, &gig::Instrument::PitchbendRange);      connect(ePitchbendRange, &gig::Instrument::PitchbendRange);
1058      connect(ePianoReleaseMode, &gig::Instrument::PianoReleaseMode);      connect(ePianoReleaseMode, &gig::Instrument::PianoReleaseMode);
1059      connect(eDimensionKeyRangeLow,      connect(eDimensionKeyRangeLow, eDimensionKeyRangeHigh,
1060              &InstrumentProps::set_DimensionKeyRange_low);              &gig::Instrument::DimensionKeyRange);
     connect(eDimensionKeyRangeHigh,  
             &InstrumentProps::set_DimensionKeyRange_high);  
1061    
1062      table.set_col_spacings(5);      table.set_col_spacings(5);
1063    
# Line 1137  InstrumentProps::InstrumentProps() Line 1083  InstrumentProps::InstrumentProps()
1083      buttonBox.set_border_width(5);      buttonBox.set_border_width(5);
1084      buttonBox.show();      buttonBox.show();
1085      buttonBox.pack_start(quitButton);      buttonBox.pack_start(quitButton);
1086      quitButton.set_flags(Gtk::CAN_DEFAULT);      quitButton.set_can_default();
1087      quitButton.grab_focus();      quitButton.grab_focus();
1088    
1089      quitButton.signal_clicked().connect(      quitButton.signal_clicked().connect(
# Line 1150  InstrumentProps::InstrumentProps() Line 1096  InstrumentProps::InstrumentProps()
1096    
1097  void InstrumentProps::set_instrument(gig::Instrument* instrument)  void InstrumentProps::set_instrument(gig::Instrument* instrument)
1098  {  {
1099      this->instrument = instrument;      update(instrument);
1100    
1101      update_model++;      update_model++;
     eName.set_value(instrument->pInfo->Name);  
1102      eIsDrum.set_value(instrument->IsDrum);      eIsDrum.set_value(instrument->IsDrum);
1103      eMIDIBank.set_value(instrument->MIDIBank);      eMIDIBank.set_value(instrument->MIDIBank);
1104      eMIDIProgram.set_value(instrument->MIDIProgram);      eMIDIProgram.set_value(instrument->MIDIProgram);
     eAttenuation.set_value(instrument->Attenuation);  
     eGainPlus6.set_value(instrument->Attenuation);  
     eEffectSend.set_value(instrument->EffectSend);  
     eFineTune.set_value(instrument->FineTune);  
     ePitchbendRange.set_value(instrument->PitchbendRange);  
     ePianoReleaseMode.set_value(instrument->PianoReleaseMode);  
     eDimensionKeyRangeLow.set_value(instrument->DimensionKeyRange.low);  
     eDimensionKeyRangeHigh.set_value(instrument->DimensionKeyRange.high);  
1105      update_model--;      update_model--;
1106  }  }
1107    
 sigc::signal<void>& InstrumentProps::signal_instrument_changed()  
 {  
     return instrument_changed;  
 }  
1108    
1109  void MainWindow::file_changed()  void MainWindow::file_changed()
1110  {  {
# Line 1243  void MainWindow::load_gig(gig::File* gig Line 1176  void MainWindow::load_gig(gig::File* gig
1176      // select the first instrument      // select the first instrument
1177      Glib::RefPtr<Gtk::TreeSelection> tree_sel_ref = m_TreeView.get_selection();      Glib::RefPtr<Gtk::TreeSelection> tree_sel_ref = m_TreeView.get_selection();
1178      tree_sel_ref->select(Gtk::TreePath("0"));      tree_sel_ref->select(Gtk::TreePath("0"));
1179    
1180        gig::Instrument* instrument = get_instrument();
1181        if (instrument) {
1182            instrumentProps.set_instrument(instrument);
1183        }
1184  }  }
1185    
1186  void MainWindow::show_instr_props()  void MainWindow::show_instr_props()
# Line 1313  void MainWindow::on_action_add_instrumen Line 1251  void MainWindow::on_action_add_instrumen
1251      gig::Instrument* instrument = file->AddInstrument();      gig::Instrument* instrument = file->AddInstrument();
1252      __instrument_indexer++;      __instrument_indexer++;
1253      instrument->pInfo->Name =      instrument->pInfo->Name =
1254          "Unnamed Instrument " + ToString(__instrument_indexer);          _("Unnamed Instrument ") + ToString(__instrument_indexer);
1255      // update instrument tree view      // update instrument tree view
1256      Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append();      Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append();
1257      Gtk::TreeModel::Row rowInstr = *iterInstr;      Gtk::TreeModel::Row rowInstr = *iterInstr;
# Line 1322  void MainWindow::on_action_add_instrumen Line 1260  void MainWindow::on_action_add_instrumen
1260      file_changed();      file_changed();
1261  }  }
1262    
1263    void MainWindow::on_action_duplicate_instrument() {
1264        if (!file) return;
1265        
1266        // retrieve the currently selected instrument
1267        // (being the original instrument to be duplicated)
1268        Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection();
1269        Gtk::TreeModel::iterator itSelection = sel->get_selected();
1270        if (!itSelection) return;
1271        Gtk::TreeModel::Row row = *itSelection;
1272        gig::Instrument* instrOrig = row[m_Columns.m_col_instr];
1273        if (!instrOrig) return;
1274        
1275        // duplicate the orginal instrument
1276        gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig);
1277        instrNew->pInfo->Name =
1278            instrOrig->pInfo->Name + " (" + _("Copy") + ")";
1279            
1280        // update instrument tree view
1281        Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append();
1282        Gtk::TreeModel::Row rowInstr = *iterInstr;
1283        rowInstr[m_Columns.m_col_name] = instrNew->pInfo->Name.c_str();
1284        rowInstr[m_Columns.m_col_instr] = instrNew;
1285        file_changed();
1286    }
1287    
1288  void MainWindow::on_action_remove_instrument() {  void MainWindow::on_action_remove_instrument() {
1289      if (!file) return;      if (!file) return;
1290      if (file_is_shared) {      if (file_is_shared) {
# Line 1346  void MainWindow::on_action_remove_instru Line 1309  void MainWindow::on_action_remove_instru
1309              // remove respective row from instruments tree view              // remove respective row from instruments tree view
1310              m_refTreeModel->erase(it);              m_refTreeModel->erase(it);
1311              file_changed();              file_changed();
1312    
1313                instr = get_instrument();
1314                if (instr) {
1315                    instrumentProps.set_instrument(instr);
1316                } else {
1317                    instrumentProps.hide();
1318                }
1319          } catch (RIFF::Exception e) {          } catch (RIFF::Exception e) {
1320              Gtk::MessageDialog msg(*this, e.Message.c_str(), false, Gtk::MESSAGE_ERROR);              Gtk::MessageDialog msg(*this, e.Message.c_str(), false, Gtk::MESSAGE_ERROR);
1321              msg.run();              msg.run();
# Line 1356  void MainWindow::on_action_remove_instru Line 1326  void MainWindow::on_action_remove_instru
1326  void MainWindow::on_action_sample_properties() {  void MainWindow::on_action_sample_properties() {
1327      //TODO: show a dialog where the selected sample's properties can be edited      //TODO: show a dialog where the selected sample's properties can be edited
1328      Gtk::MessageDialog msg(      Gtk::MessageDialog msg(
1329          *this, "Sorry, yet to be implemented!", false, Gtk::MESSAGE_INFO          *this, _("Sorry, yet to be implemented!"), false, Gtk::MESSAGE_INFO
1330      );      );
1331      msg.run();      msg.run();
1332  }  }
# Line 1365  void MainWindow::on_action_add_group() { Line 1335  void MainWindow::on_action_add_group() {
1335      static int __sample_indexer = 0;      static int __sample_indexer = 0;
1336      if (!file) return;      if (!file) return;
1337      gig::Group* group = file->AddGroup();      gig::Group* group = file->AddGroup();
1338      group->Name = "Unnamed Group";      group->Name = _("Unnamed Group");
1339      if (__sample_indexer) group->Name += " " + ToString(__sample_indexer);      if (__sample_indexer) group->Name += " " + ToString(__sample_indexer);
1340      __sample_indexer++;      __sample_indexer++;
1341      // update sample tree view      // update sample tree view
# Line 1399  void MainWindow::on_action_add_sample() Line 1369  void MainWindow::on_action_add_sample()
1369      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1370      dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);      dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
1371      dialog.set_select_multiple(true);      dialog.set_select_multiple(true);
1372      Gtk::FileFilter soundfilter; // matches all file types supported by libsndfile  
1373        // matches all file types supported by libsndfile
1374    #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
1375        Gtk::FileFilter soundfilter;
1376    #else
1377        Glib::RefPtr<Gtk::FileFilter> soundfilter = Gtk::FileFilter::create();
1378    #endif
1379      const char* const supportedFileTypes[] = {      const char* const supportedFileTypes[] = {
1380          "*.wav", "*.WAV", "*.aiff", "*.AIFF", "*.aifc", "*.AIFC", "*.snd",          "*.wav", "*.WAV", "*.aiff", "*.AIFF", "*.aifc", "*.AIFC", "*.snd",
1381          "*.SND", "*.au", "*.AU", "*.paf", "*.PAF", "*.iff", "*.IFF",          "*.SND", "*.au", "*.AU", "*.paf", "*.PAF", "*.iff", "*.IFF",
# Line 1407  void MainWindow::on_action_add_sample() Line 1383  void MainWindow::on_action_add_sample()
1383          "*.W64", "*.pvf", "*.PVF", "*.xi", "*.XI", "*.htk", "*.HTK",          "*.W64", "*.pvf", "*.PVF", "*.xi", "*.XI", "*.htk", "*.HTK",
1384          "*.caf", "*.CAF", NULL          "*.caf", "*.CAF", NULL
1385      };      };
1386        const char* soundfiles = _("Sound Files");
1387        const char* allfiles = _("All Files");
1388    #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
1389      for (int i = 0; supportedFileTypes[i]; i++)      for (int i = 0; supportedFileTypes[i]; i++)
1390          soundfilter.add_pattern(supportedFileTypes[i]);          soundfilter.add_pattern(supportedFileTypes[i]);
1391      soundfilter.set_name("Sound Files");      soundfilter.set_name(soundfiles);
1392      Gtk::FileFilter allpassfilter; // matches every file  
1393        // matches every file
1394        Gtk::FileFilter allpassfilter;
1395      allpassfilter.add_pattern("*.*");      allpassfilter.add_pattern("*.*");
1396      allpassfilter.set_name("All Files");      allpassfilter.set_name(allfiles);
1397    #else
1398        for (int i = 0; supportedFileTypes[i]; i++)
1399            soundfilter->add_pattern(supportedFileTypes[i]);
1400        soundfilter->set_name(soundfiles);
1401    
1402        // matches every file
1403        Glib::RefPtr<Gtk::FileFilter> allpassfilter = Gtk::FileFilter::create();
1404        allpassfilter->add_pattern("*.*");
1405        allpassfilter->set_name(allfiles);
1406    #endif
1407      dialog.add_filter(soundfilter);      dialog.add_filter(soundfilter);
1408      dialog.add_filter(allpassfilter);      dialog.add_filter(allpassfilter);
1409        if (current_sample_dir != "") {
1410            dialog.set_current_folder(current_sample_dir);
1411        }
1412      if (dialog.run() == Gtk::RESPONSE_OK) {      if (dialog.run() == Gtk::RESPONSE_OK) {
1413            current_sample_dir = dialog.get_current_folder();
1414          Glib::ustring error_files;          Glib::ustring error_files;
1415          Glib::SListHandle<Glib::ustring> filenames = dialog.get_filenames();          std::vector<std::string> filenames = dialog.get_filenames();
1416          for (Glib::SListHandle<Glib::ustring>::iterator iter = filenames.begin();          for (std::vector<std::string>::iterator iter = filenames.begin();
1417               iter != filenames.end(); ++iter) {               iter != filenames.end(); ++iter) {
1418              printf("Adding sample %s\n",(*iter).c_str());              printf("Adding sample %s\n",(*iter).c_str());
1419              // use libsndfile to retrieve file informations              // use libsndfile to retrieve file informations
# Line 1426  void MainWindow::on_action_add_sample() Line 1421  void MainWindow::on_action_add_sample()
1421              info.format = 0;              info.format = 0;
1422              SNDFILE* hFile = sf_open((*iter).c_str(), SFM_READ, &info);              SNDFILE* hFile = sf_open((*iter).c_str(), SFM_READ, &info);
1423              try {              try {
1424                  if (!hFile) throw std::string("could not open file");                  if (!hFile) throw std::string(_("could not open file"));
1425                  int bitdepth;                  int bitdepth;
1426                  switch (info.format & 0xff) {                  switch (info.format & 0xff) {
1427                      case SF_FORMAT_PCM_S8:                      case SF_FORMAT_PCM_S8:
# Line 1442  void MainWindow::on_action_add_sample() Line 1437  void MainWindow::on_action_add_sample()
1437                          break;                          break;
1438                      default:                      default:
1439                          sf_close(hFile); // close sound file                          sf_close(hFile); // close sound file
1440                          throw std::string("format not supported"); // unsupported subformat (yet?)                          throw std::string(_("format not supported")); // unsupported subformat (yet?)
1441                  }                  }
1442                  // add a new sample to the .gig file                  // add a new sample to the .gig file
1443                  gig::Sample* sample = file->AddSample();                  gig::Sample* sample = file->AddSample();
# Line 1470  void MainWindow::on_action_add_sample() Line 1465  void MainWindow::on_action_add_sample()
1465                  {                  {
1466                      sample->MIDIUnityNote = instrument.basenote;                      sample->MIDIUnityNote = instrument.basenote;
1467    
 #if HAVE_SF_INSTRUMENT_LOOPS  
1468                      if (instrument.loop_count && instrument.loops[0].mode != SF_LOOP_NONE) {                      if (instrument.loop_count && instrument.loops[0].mode != SF_LOOP_NONE) {
1469                          sample->Loops = 1;                          sample->Loops = 1;
1470    
# Line 1490  void MainWindow::on_action_add_sample() Line 1484  void MainWindow::on_action_add_sample()
1484                          sample->LoopPlayCount = instrument.loops[0].count;                          sample->LoopPlayCount = instrument.loops[0].count;
1485                          sample->LoopSize = sample->LoopEnd - sample->LoopStart + 1;                          sample->LoopSize = sample->LoopEnd - sample->LoopStart + 1;
1486                      }                      }
 #endif  
1487                  }                  }
1488    
1489                  // schedule resizing the sample (which will be done                  // schedule resizing the sample (which will be done
# Line 1533  void MainWindow::on_action_replace_all_s Line 1526  void MainWindow::on_action_replace_all_s
1526      if (!file) return;      if (!file) return;
1527      Gtk::FileChooserDialog dialog(*this, _("Select Folder"),      Gtk::FileChooserDialog dialog(*this, _("Select Folder"),
1528                                    Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER);                                    Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER);
1529      Gtk::Label description(      const char* str =
1530          _("This is a very specific function. It tries to replace all samples "          _("This is a very specific function. It tries to replace all samples "
1531            "in the current gig file by samples located in the directory chosen "            "in the current gig file by samples located in the chosen "
1532            "by you above.\n\n"            "directory.\n\n"
1533            "It works like this: For each sample in the gig file it tries to "            "It works like this: For each sample in the gig file, it tries to "
1534            "find a sample file in the selected directory with the same name as "            "find a sample file in the selected directory with the same name as "
1535            "the sample in the gig file. Optionally you can add a filename "            "the sample in the gig file. Optionally, you can add a filename "
1536            "postfix below, which will be added to the filename expected to be "            "extension below, which will be added to the filename expected to be "
1537            "found. That is, assume you have a gig file with a sample called "            "found. That is, assume you have a gig file with a sample called "
1538            "'Snare', if you enter '.wav' below (like it's done by default), it "            "'Snare', if you enter '.wav' below (like it's done by default), it "
1539            "assumes to find a sample file called 'Snare.wav' and will replace "            "expects to find a sample file called 'Snare.wav' and will replace "
1540            "the sample in the gig file accordingly. If you don't need such a "            "the sample in the gig file accordingly. If you don't need an "
1541            "postfix, blank the field below. Any gig sample where no "            "extension, blank the field below. Any gig sample where no "
1542            "appropriate sample file could be found, will be reported and left "            "appropriate sample file could be found will be reported and left "
1543            "untouched.\n\n")            "untouched.\n");
1544      );  #if GTKMM_MAJOR_VERSION < 3
1545      description.set_line_wrap(true);      view::WrapLabel description(str);
1546    #else
1547        Gtk::Label description(str);
1548        description.set_line_wrap();
1549    #endif
1550      Gtk::HBox entryArea;      Gtk::HBox entryArea;
1551      Gtk::Label entryLabel( _("Add Filename Extension: "), Gtk::ALIGN_RIGHT);      Gtk::Label entryLabel( _("Add filename extension: "), Gtk::ALIGN_START);
1552      Gtk::Entry postfixEntryBox;      Gtk::Entry postfixEntryBox;
1553      postfixEntryBox.set_text(".wav");      postfixEntryBox.set_text(".wav");
1554      entryArea.pack_start(entryLabel);      entryArea.pack_start(entryLabel);
# Line 1559  void MainWindow::on_action_replace_all_s Line 1556  void MainWindow::on_action_replace_all_s
1556      dialog.get_vbox()->pack_start(description, Gtk::PACK_SHRINK);      dialog.get_vbox()->pack_start(description, Gtk::PACK_SHRINK);
1557      dialog.get_vbox()->pack_start(entryArea, Gtk::PACK_SHRINK);      dialog.get_vbox()->pack_start(entryArea, Gtk::PACK_SHRINK);
1558      description.show();      description.show();
1559      entryLabel.show();      entryArea.show_all();
     postfixEntryBox.show();  
     entryArea.show();  
1560      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1561      dialog.add_button(_("Select"), Gtk::RESPONSE_OK);      dialog.add_button(_("Select"), Gtk::RESPONSE_OK);
1562      dialog.set_select_multiple(false);      dialog.set_select_multiple(false);
1563      // fix label width (because Gtk by design doesn't      if (current_sample_dir != "") {
1564      // know anything about the parent's size)          dialog.set_current_folder(current_sample_dir);
1565  #if 0 //FIXME: doesn't work      }
     int dialogW, dialogH, labelW, labelH;  
     dialog.get_size_request(dialogW, dialogH);  
     description.get_size_request(labelW, labelH);  
     std::cout << "dialog(" << dialogW << "," << dialogH << ")\nlabel(" << labelW << "," << labelH << ")\n" << std::flush;  
     description.set_size_request(dialogW, labelH);  
 #endif  
1566      if (dialog.run() == Gtk::RESPONSE_OK)      if (dialog.run() == Gtk::RESPONSE_OK)
1567      {      {
1568            current_sample_dir = dialog.get_current_folder();
1569          Glib::ustring error_files;          Glib::ustring error_files;
1570          Glib::ustring folder = dialog.get_filename();          std::string folder = dialog.get_filename();
1571          for (gig::Sample* sample = file->GetFirstSample();          for (gig::Sample* sample = file->GetFirstSample();
1572               sample; sample = file->GetNextSample())               sample; sample = file->GetNextSample())
1573          {          {
# Line 1589  void MainWindow::on_action_replace_all_s Line 1579  void MainWindow::on_action_replace_all_s
1579              SNDFILE* hFile = sf_open(filename.c_str(), SFM_READ, &info);              SNDFILE* hFile = sf_open(filename.c_str(), SFM_READ, &info);
1580              try              try
1581              {              {
1582                  if (!hFile) throw std::string("could not open file");                  if (!hFile) throw std::string(_("could not open file"));
1583                  int bitdepth;                  int bitdepth;
1584                  switch (info.format & 0xff) {                  switch (info.format & 0xff) {
1585                      case SF_FORMAT_PCM_S8:                      case SF_FORMAT_PCM_S8:
# Line 1605  void MainWindow::on_action_replace_all_s Line 1595  void MainWindow::on_action_replace_all_s
1595                          break;                          break;
1596                      default:                      default:
1597                          sf_close(hFile);                          sf_close(hFile);
1598                          throw std::string("format not supported");                          throw std::string(_("format not supported"));
1599                  }                  }
1600                  SampleImportItem sched_item;                  SampleImportItem sched_item;
1601                  sched_item.gig_sample  = sample;                  sched_item.gig_sample  = sample;
# Line 1878  sigc::signal<void, gig::Region*>& MainWi Line 1868  sigc::signal<void, gig::Region*>& MainWi
1868      return region_changed_signal;      return region_changed_signal;
1869  }  }
1870    
1871    sigc::signal<void, gig::Sample*>& MainWindow::signal_sample_changed() {
1872        return sample_changed_signal;
1873    }
1874    
1875  sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/>& MainWindow::signal_sample_ref_changed() {  sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/>& MainWindow::signal_sample_ref_changed() {
1876      return sample_ref_changed_signal;      return sample_ref_changed_signal;
1877  }  }

Legend:
Removed from v.1714  
changed lines
  Added in v.2423

  ViewVC Help
Powered by ViewVC