/[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 1225 by schoenebeck, Sun Jun 10 10:56:11 2007 UTC revision 2398 by persson, Sun Jan 13 09:14:29 2013 UTC
# Line 1  Line 1 
1  /*  /*
2   * Copyright (C) 2006, 2007 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 17  Line 17 
17   * 02110-1301 USA.   * 02110-1301 USA.
18   */   */
19    
 #include <libintl.h>  
20  #include <iostream>  #include <iostream>
21    #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  #if GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION >= 6  #include <gtkmm/toggleaction.h>
35  #define ABOUT_DIALOG  #if GTKMM_MAJOR_VERSION < 3
36  #include <gtkmm/aboutdialog.h>  #include "wrapLabel.hh"
37  #endif  #endif
38    
39    #include "global.h"
40    #include "compat.h"
41    
42  #include <stdio.h>  #include <stdio.h>
43  #include <sndfile.h>  #include <sndfile.h>
44    
45  #include "mainwindow.h"  #include "mainwindow.h"
46    
47  #define _(String) gettext(String)  #include "../../gfx/status_attached.xpm"
48    #include "../../gfx/status_detached.xpm"
49    
50  template<class T> inline std::string ToString(T o) {  template<class T> inline std::string ToString(T o) {
51      std::stringstream ss;      std::stringstream ss;
# Line 44  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    
56  MainWindow::MainWindow()  Table::Table(int x, int y) : Gtk::Table(x, y), rowno(0) {  }
57    
58    void Table::add(BoolEntry& boolentry)
59    {
60        attach(boolentry.widget, 0, 2, rowno, rowno + 1,
61               Gtk::FILL, Gtk::SHRINK);
62        rowno++;
63    }
64    
65    void Table::add(BoolEntryPlus6& boolentry)
66    {
67        attach(boolentry.widget, 0, 2, rowno, rowno + 1,
68               Gtk::FILL, Gtk::SHRINK);
69        rowno++;
70    }
71    
72    void Table::add(LabelWidget& prop)
73    {
74        attach(prop.label, 1, 2, rowno, rowno + 1,
75               Gtk::FILL, Gtk::SHRINK);
76        attach(prop.widget, 2, 3, rowno, rowno + 1,
77               Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
78        rowno++;
79    }
80    
81    MainWindow::MainWindow() :
82        dimreg_label(_("Changes apply to:")),
83        dimreg_all_regions(_("all regions")),
84        dimreg_all_dimregs(_("all dimension splits")),
85        dimreg_stereo(_("both channels"))
86  {  {
87  //    set_border_width(5);  //    set_border_width(5);
88  //    set_default_size(400, 200);  //    set_default_size(400, 200);
# Line 74  MainWindow::MainWindow() Line 112  MainWindow::MainWindow()
112      m_TreeViewNotebook.set_size_request(300);      m_TreeViewNotebook.set_size_request(300);
113    
114      m_HPaned.add1(m_TreeViewNotebook);      m_HPaned.add1(m_TreeViewNotebook);
115      m_HPaned.add2(dimreg_edit);      dimreg_hbox.add(dimreg_label);
116        dimreg_hbox.add(dimreg_all_regions);
117        dimreg_hbox.add(dimreg_all_dimregs);
118        dimreg_stereo.set_active();
119        dimreg_hbox.add(dimreg_stereo);
120        dimreg_vbox.add(dimreg_edit);
121        dimreg_vbox.pack_start(dimreg_hbox, Gtk::PACK_SHRINK);
122        m_HPaned.add2(dimreg_vbox);
123    
124    
125      m_TreeViewNotebook.append_page(m_ScrolledWindowSamples, "Samples");      m_TreeViewNotebook.append_page(m_ScrolledWindowSamples, _("Samples"));
126      m_TreeViewNotebook.append_page(m_ScrolledWindow, "Instruments");      m_TreeViewNotebook.append_page(m_ScrolledWindow, _("Instruments"));
127    
128    
129      actionGroup = Gtk::ActionGroup::create();      actionGroup = Gtk::ActionGroup::create();
# Line 99  MainWindow::MainWindow() Line 144  MainWindow::MainWindow()
144      action = Gtk::Action::create("SaveAs", Gtk::Stock::SAVE_AS);      action = Gtk::Action::create("SaveAs", Gtk::Stock::SAVE_AS);
145      action->property_label() = action->property_label() + "...";      action->property_label() = action->property_label() + "...";
146      actionGroup->add(action,      actionGroup->add(action,
147                       *(new Gtk::AccelKey("<shift><control>s")),                       Gtk::AccelKey("<shift><control>s"),
148                       sigc::mem_fun(                       sigc::mem_fun(
149                           *this, &MainWindow::on_action_file_save_as)                           *this, &MainWindow::on_action_file_save_as));
         );  
150      actionGroup->add(Gtk::Action::create("Properties",      actionGroup->add(Gtk::Action::create("Properties",
151                                           Gtk::Stock::PROPERTIES),                                           Gtk::Stock::PROPERTIES),
152                       sigc::mem_fun(                       sigc::mem_fun(
# Line 113  MainWindow::MainWindow() Line 157  MainWindow::MainWindow()
157                           *this, &MainWindow::show_instr_props));                           *this, &MainWindow::show_instr_props));
158      actionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT),      actionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT),
159                       sigc::mem_fun(                       sigc::mem_fun(
160                           *this, &MainWindow::hide));                           *this, &MainWindow::on_action_quit));
161      actionGroup->add(Gtk::Action::create("MenuInstrument", _("_Instrument")));      actionGroup->add(Gtk::Action::create("MenuInstrument", _("_Instrument")));
162    
163        actionGroup->add(Gtk::Action::create("MenuView", _("_View")));
164        Glib::RefPtr<Gtk::ToggleAction> toggle_action =
165            Gtk::ToggleAction::create("Statusbar", _("_Statusbar"));
166        toggle_action->set_active(true);
167        actionGroup->add(toggle_action,
168                         sigc::mem_fun(
169                             *this, &MainWindow::on_action_view_status_bar));
170    
171      action = Gtk::Action::create("MenuHelp", Gtk::Stock::HELP);      action = Gtk::Action::create("MenuHelp", Gtk::Stock::HELP);
172      actionGroup->add(Gtk::Action::create("MenuHelp",      actionGroup->add(Gtk::Action::create("MenuHelp",
173                                           action->property_label()));                                           action->property_label()));
 #ifdef ABOUT_DIALOG  
174      actionGroup->add(Gtk::Action::create("About", Gtk::Stock::ABOUT),      actionGroup->add(Gtk::Action::create("About", Gtk::Stock::ABOUT),
175                       sigc::mem_fun(                       sigc::mem_fun(
176                           *this, &MainWindow::on_action_help_about));                           *this, &MainWindow::on_action_help_about));
 #endif  
177      actionGroup->add(      actionGroup->add(
178          Gtk::Action::create("AddInstrument", _("Add _Instrument")),          Gtk::Action::create("AddInstrument", _("Add _Instrument")),
179          sigc::mem_fun(*this, &MainWindow::on_action_add_instrument)          sigc::mem_fun(*this, &MainWindow::on_action_add_instrument)
180      );      );
181      actionGroup->add(      actionGroup->add(
182            Gtk::Action::create("DupInstrument", _("_Duplicate Instrument")),
183            sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument)
184        );
185        actionGroup->add(
186          Gtk::Action::create("RemoveInstrument", Gtk::Stock::REMOVE),          Gtk::Action::create("RemoveInstrument", Gtk::Stock::REMOVE),
187          sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument)          sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument)
188      );      );
# Line 143  MainWindow::MainWindow() Line 197  MainWindow::MainWindow()
197          sigc::mem_fun(*this, &MainWindow::on_action_add_group)          sigc::mem_fun(*this, &MainWindow::on_action_add_group)
198      );      );
199      actionGroup->add(      actionGroup->add(
200          Gtk::Action::create("AddSample", _("Add _Sample(s)")),          Gtk::Action::create("AddSample", _("Add _Sample(s)...")),
201          sigc::mem_fun(*this, &MainWindow::on_action_add_sample)          sigc::mem_fun(*this, &MainWindow::on_action_add_sample)
202      );      );
203      actionGroup->add(      actionGroup->add(
204          Gtk::Action::create("RemoveSample", Gtk::Stock::REMOVE),          Gtk::Action::create("RemoveSample", Gtk::Stock::REMOVE),
205          sigc::mem_fun(*this, &MainWindow::on_action_remove_sample)          sigc::mem_fun(*this, &MainWindow::on_action_remove_sample)
206      );      );
207        actionGroup->add(
208            Gtk::Action::create("ReplaceAllSamplesInAllGroups",
209                                _("Replace All Samples in All Groups...")),
210            sigc::mem_fun(*this, &MainWindow::on_action_replace_all_samples_in_all_groups)
211        );
212    
213      uiManager = Gtk::UIManager::create();      uiManager = Gtk::UIManager::create();
214      uiManager->insert_action_group(actionGroup);      uiManager->insert_action_group(actionGroup);
215      // add_accel_group(uiManager->get_accel_group());      add_accel_group(uiManager->get_accel_group());
216    
217      Glib::ustring ui_info =      Glib::ustring ui_info =
218          "<ui>"          "<ui>"
# Line 171  MainWindow::MainWindow() Line 230  MainWindow::MainWindow()
230          "    </menu>"          "    </menu>"
231          "    <menu action='MenuInstrument'>"          "    <menu action='MenuInstrument'>"
232          "    </menu>"          "    </menu>"
233  #ifdef ABOUT_DIALOG          "    <menu action='MenuView'>"
234            "      <menuitem action='Statusbar'/>"
235            "    </menu>"
236          "    <menu action='MenuHelp'>"          "    <menu action='MenuHelp'>"
237          "      <menuitem action='About'/>"          "      <menuitem action='About'/>"
238          "    </menu>"          "    </menu>"
 #endif  
239          "  </menubar>"          "  </menubar>"
240          "  <popup name='PopupMenu'>"          "  <popup name='PopupMenu'>"
241          "    <menuitem action='InstrProperties'/>"          "    <menuitem action='InstrProperties'/>"
242          "    <menuitem action='AddInstrument'/>"          "    <menuitem action='AddInstrument'/>"
243            "    <menuitem action='DupInstrument'/>"
244          "    <separator/>"          "    <separator/>"
245          "    <menuitem action='RemoveInstrument'/>"          "    <menuitem action='RemoveInstrument'/>"
246          "  </popup>"          "  </popup>"
# Line 187  MainWindow::MainWindow() Line 248  MainWindow::MainWindow()
248          "    <menuitem action='SampleProperties'/>"          "    <menuitem action='SampleProperties'/>"
249          "    <menuitem action='AddGroup'/>"          "    <menuitem action='AddGroup'/>"
250          "    <menuitem action='AddSample'/>"          "    <menuitem action='AddSample'/>"
251            "    <menuitem action='ReplaceAllSamplesInAllGroups' />"
252          "    <separator/>"          "    <separator/>"
253          "    <menuitem action='RemoveSample'/>"          "    <menuitem action='RemoveSample'/>"
254          "  </popup>"          "  </popup>"
# Line 199  MainWindow::MainWindow() Line 261  MainWindow::MainWindow()
261      m_VBox.pack_start(*menuBar, Gtk::PACK_SHRINK);      m_VBox.pack_start(*menuBar, Gtk::PACK_SHRINK);
262      m_VBox.pack_start(m_HPaned);      m_VBox.pack_start(m_HPaned);
263      m_VBox.pack_start(m_RegionChooser, Gtk::PACK_SHRINK);      m_VBox.pack_start(m_RegionChooser, Gtk::PACK_SHRINK);
264        m_VBox.pack_start(m_RegionChooser.m_VirtKeybPropsBox, Gtk::PACK_SHRINK);
265      m_VBox.pack_start(m_DimRegionChooser, Gtk::PACK_SHRINK);      m_VBox.pack_start(m_DimRegionChooser, Gtk::PACK_SHRINK);
266        m_VBox.pack_start(m_StatusBar, Gtk::PACK_SHRINK);
267    
268        set_file_is_shared(false);
269    
270        // Status Bar:
271        m_StatusBar.pack_start(m_AttachedStateLabel, Gtk::PACK_SHRINK);
272        m_StatusBar.pack_start(m_AttachedStateImage, Gtk::PACK_SHRINK);
273        m_StatusBar.show();
274    
275      m_RegionChooser.signal_sel_changed().connect(      m_RegionChooser.signal_region_selected().connect(
276          sigc::mem_fun(*this, &MainWindow::region_changed) );          sigc::mem_fun(*this, &MainWindow::region_changed) );
277      m_DimRegionChooser.signal_sel_changed().connect(      m_DimRegionChooser.signal_dimregion_selected().connect(
278          sigc::mem_fun(*this, &MainWindow::dimreg_changed) );          sigc::mem_fun(*this, &MainWindow::dimreg_changed) );
279    
280    
# Line 232  MainWindow::MainWindow() Line 303  MainWindow::MainWindow()
303      );      );
304    
305      // 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
306      std::list<Gtk::TargetEntry> drag_target_gig_sample;      std::vector<Gtk::TargetEntry> drag_target_gig_sample;
307      drag_target_gig_sample.push_back( Gtk::TargetEntry("gig::Sample") );      drag_target_gig_sample.push_back(Gtk::TargetEntry("gig::Sample"));
308      m_TreeViewSamples.drag_source_set(drag_target_gig_sample);      m_TreeViewSamples.drag_source_set(drag_target_gig_sample);
309        m_TreeViewSamples.signal_drag_begin().connect(
310            sigc::mem_fun(*this, &MainWindow::on_sample_treeview_drag_begin)
311        );
312      m_TreeViewSamples.signal_drag_data_get().connect(      m_TreeViewSamples.signal_drag_data_get().connect(
313          sigc::mem_fun(*this, &MainWindow::on_sample_treeview_drag_data_get)          sigc::mem_fun(*this, &MainWindow::on_sample_treeview_drag_data_get)
314      );      );
# Line 242  MainWindow::MainWindow() Line 316  MainWindow::MainWindow()
316      dimreg_edit.wSample->signal_drag_data_received().connect(      dimreg_edit.wSample->signal_drag_data_received().connect(
317          sigc::mem_fun(*this, &MainWindow::on_sample_label_drop_drag_data_received)          sigc::mem_fun(*this, &MainWindow::on_sample_label_drop_drag_data_received)
318      );      );
319        dimreg_edit.signal_dimreg_changed().connect(
320            sigc::hide(sigc::mem_fun(*this, &MainWindow::file_changed)));
321        m_RegionChooser.signal_instrument_changed().connect(
322            sigc::mem_fun(*this, &MainWindow::file_changed));
323        m_DimRegionChooser.signal_region_changed().connect(
324            sigc::mem_fun(*this, &MainWindow::file_changed));
325        instrumentProps.signal_instrument_changed().connect(
326            sigc::mem_fun(*this, &MainWindow::file_changed));
327        propDialog.signal_info_changed().connect(
328            sigc::mem_fun(*this, &MainWindow::file_changed));
329    
330        dimreg_edit.signal_dimreg_to_be_changed().connect(
331            dimreg_to_be_changed_signal.make_slot());
332        dimreg_edit.signal_dimreg_changed().connect(
333            dimreg_changed_signal.make_slot());
334        dimreg_edit.signal_sample_ref_changed().connect(
335            sample_ref_changed_signal.make_slot());
336    
337        m_RegionChooser.signal_instrument_struct_to_be_changed().connect(
338            sigc::hide(
339                sigc::bind(
340                    file_structure_to_be_changed_signal.make_slot(),
341                    sigc::ref(this->file)
342                )
343            )
344        );
345        m_RegionChooser.signal_instrument_struct_changed().connect(
346            sigc::hide(
347                sigc::bind(
348                    file_structure_changed_signal.make_slot(),
349                    sigc::ref(this->file)
350                )
351            )
352        );
353        m_RegionChooser.signal_region_to_be_changed().connect(
354            region_to_be_changed_signal.make_slot());
355        m_RegionChooser.signal_region_changed_signal().connect(
356            region_changed_signal.make_slot());
357    
358        note_on_signal.connect(
359            sigc::mem_fun(m_RegionChooser, &RegionChooser::on_note_on_event));
360        note_off_signal.connect(
361            sigc::mem_fun(m_RegionChooser, &RegionChooser::on_note_off_event));
362    
363        dimreg_all_regions.signal_toggled().connect(
364            sigc::mem_fun(*this, &MainWindow::update_dimregs));
365        dimreg_all_dimregs.signal_toggled().connect(
366            sigc::mem_fun(*this, &MainWindow::dimreg_all_dimregs_toggled));
367        dimreg_stereo.signal_toggled().connect(
368            sigc::mem_fun(*this, &MainWindow::update_dimregs));
369    
370      file = 0;      file = 0;
371        file_is_changed = false;
372    
373      show_all_children();      show_all_children();
374    
375        // start with a new gig file by default
376        on_action_file_new();
377  }  }
378    
379  MainWindow::~MainWindow()  MainWindow::~MainWindow()
380  {  {
381  }  }
382    
383  void MainWindow::region_changed()  bool MainWindow::on_delete_event(GdkEventAny* event)
384  {  {
385      m_DimRegionChooser.set_region(m_RegionChooser.get_region());      return !file_is_shared && file_is_changed && !close_confirmation_dialog();
386  }  }
387    
388  void MainWindow::dimreg_changed()  void MainWindow::on_action_quit()
389  {  {
390      dimreg_edit.set_dim_region(m_DimRegionChooser.get_dimregion());      if (!file_is_shared && file_is_changed && !close_confirmation_dialog()) return;
391        hide();
392  }  }
393    
394  void MainWindow::on_sel_change()  void MainWindow::region_changed()
395    {
396        m_DimRegionChooser.set_region(m_RegionChooser.get_region());
397    }
398    
399    gig::Instrument* MainWindow::get_instrument()
400  {  {
401        gig::Instrument* instrument = 0;
402      Glib::RefPtr<Gtk::TreeSelection> tree_sel_ref = m_TreeView.get_selection();      Glib::RefPtr<Gtk::TreeSelection> tree_sel_ref = m_TreeView.get_selection();
403    
404      Gtk::TreeModel::iterator it = tree_sel_ref->get_selected();      Gtk::TreeModel::iterator it = tree_sel_ref->get_selected();
405      if (it) {      if (it) {
406          Gtk::TreeModel::Row row = *it;          Gtk::TreeModel::Row row = *it;
407          std::cout << row[m_Columns.m_col_name] << std::endl;          instrument = row[m_Columns.m_col_instr];
408        }
409        return instrument;
410    }
411    
412    void MainWindow::add_region_to_dimregs(gig::Region* region, bool stereo, bool all_dimregs)
413    {
414        if (all_dimregs) {
415            for (int i = 0 ; i < region->DimensionRegions ; i++) {
416                if (region->pDimensionRegions[i]) {
417                    dimreg_edit.dimregs.insert(region->pDimensionRegions[i]);
418                }
419            }
420        } else {
421            m_DimRegionChooser.get_dimregions(region, stereo, dimreg_edit.dimregs);
422        }
423    }
424    
425    void MainWindow::update_dimregs()
426    {
427        dimreg_edit.dimregs.clear();
428        bool all_regions = dimreg_all_regions.get_active();
429        bool stereo = dimreg_stereo.get_active();
430        bool all_dimregs = dimreg_all_dimregs.get_active();
431    
432          m_RegionChooser.set_instrument(row[m_Columns.m_col_instr]);      if (all_regions) {
433            gig::Instrument* instrument = get_instrument();
434            if (instrument) {
435                for (gig::Region* region = instrument->GetFirstRegion() ;
436                     region ;
437                     region = instrument->GetNextRegion()) {
438                    add_region_to_dimregs(region, stereo, all_dimregs);
439                }
440            }
441      } else {      } else {
442          m_RegionChooser.set_instrument(0);          gig::Region* region = m_RegionChooser.get_region();
443            if (region) {
444                add_region_to_dimregs(region, stereo, all_dimregs);
445            }
446      }      }
447  }  }
448    
449    void MainWindow::dimreg_all_dimregs_toggled()
450    {
451        dimreg_stereo.set_sensitive(!dimreg_all_dimregs.get_active());
452        update_dimregs();
453    }
454    
455    void MainWindow::dimreg_changed()
456    {
457        update_dimregs();
458        dimreg_edit.set_dim_region(m_DimRegionChooser.get_dimregion());
459    }
460    
461    void MainWindow::on_sel_change()
462    {
463        m_RegionChooser.set_instrument(get_instrument());
464    }
465    
466  void loader_progress_callback(gig::progress_t* progress)  void loader_progress_callback(gig::progress_t* progress)
467  {  {
468      Loader* loader = static_cast<Loader*>(progress->custom);      Loader* loader = static_cast<Loader*>(progress->custom);
# Line 286  void loader_progress_callback(gig::progr Line 472  void loader_progress_callback(gig::progr
472  void Loader::progress_callback(float fraction)  void Loader::progress_callback(float fraction)
473  {  {
474      {      {
475          Glib::Mutex::Lock lock(progressMutex);          Glib::Threads::Mutex::Lock lock(progressMutex);
476          progress = fraction;          progress = fraction;
477      }      }
478      progress_dispatcher();      progress_dispatcher();
# Line 294  void Loader::progress_callback(float fra Line 480  void Loader::progress_callback(float fra
480    
481  void Loader::thread_function()  void Loader::thread_function()
482  {  {
483      printf("thread_function self=%x\n", Glib::Thread::self());      printf("thread_function self=%x\n", Glib::Threads::Thread::self());
484      printf("Start %s\n", filename);      printf("Start %s\n", filename);
485      RIFF::File* riff = new RIFF::File(filename);      RIFF::File* riff = new RIFF::File(filename);
486      gig = new gig::File(riff);      gig = new gig::File(riff);
# Line 308  void Loader::thread_function() Line 494  void Loader::thread_function()
494  }  }
495    
496  Loader::Loader(const char* filename)  Loader::Loader(const char* filename)
497      : thread(0), filename(filename)      : filename(filename), thread(0)
498  {  {
499  }  }
500    
501  void Loader::launch()  void Loader::launch()
502  {  {
503    #ifdef OLD_THREADS
504      thread = Glib::Thread::create(sigc::mem_fun(*this, &Loader::thread_function), true);      thread = Glib::Thread::create(sigc::mem_fun(*this, &Loader::thread_function), true);
505    #else
506        thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Loader::thread_function));
507    #endif
508      printf("launch thread=%x\n", thread);      printf("launch thread=%x\n", thread);
509  }  }
510    
# Line 322  float Loader::get_progress() Line 512  float Loader::get_progress()
512  {  {
513      float res;      float res;
514      {      {
515          Glib::Mutex::Lock lock(progressMutex);          Glib::Threads::Mutex::Lock lock(progressMutex);
516          res = progress;          res = progress;
517      }      }
518      return res;      return res;
# Line 352  void MainWindow::__clear() { Line 542  void MainWindow::__clear() {
542      Gtk::MenuItem* instrument_menu =      Gtk::MenuItem* instrument_menu =
543          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuInstrument"));          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuInstrument"));
544      instrument_menu->hide();      instrument_menu->hide();
545      for (int i = 0; i < instrument_menu->get_submenu()->items().size(); i++) {      Gtk::Menu* menu = instrument_menu->get_submenu();
546          delete &instrument_menu->get_submenu()->items()[i];      while (menu->get_children().size()) {
547            Gtk::Widget* child = *menu->get_children().begin();
548            menu->remove(*child);
549            delete child;
550      }      }
     instrument_menu->get_submenu()->items().clear();  
551      // forget all samples that ought to be imported      // forget all samples that ought to be imported
552      m_SampleImportQueue.clear();      m_SampleImportQueue.clear();
553      // clear the samples and instruments tree views      // clear the samples and instruments tree views
554      m_refTreeModel->clear();      m_refTreeModel->clear();
555      m_refSamplesTreeModel->clear();      m_refSamplesTreeModel->clear();
556      // free libgig's gig::File instance      // free libgig's gig::File instance
557      if (file) {      if (file && !file_is_shared) delete file;
558          delete file;      file = NULL;
559          file = NULL;      set_file_is_shared(false);
     }  
560  }  }
561    
562  void MainWindow::on_action_file_new()  void MainWindow::on_action_file_new()
563  {  {
564        if (!file_is_shared && file_is_changed && !close_confirmation_dialog()) return;
565    
566        if (file_is_shared && !leaving_shared_mode_dialog()) return;
567    
568      // clear all GUI elements      // clear all GUI elements
569      __clear();      __clear();
570      // create a new .gig file (virtually yet)      // create a new .gig file (virtually yet)
571      gig::File* pFile = new gig::File;      gig::File* pFile = new gig::File;
572      // already add one new instrument by default      // already add one new instrument by default
573      gig::Instrument* pInstrument = pFile->AddInstrument();      gig::Instrument* pInstrument = pFile->AddInstrument();
574      pInstrument->pInfo->Name = "Unnamed Instrument";      pInstrument->pInfo->Name = _("Unnamed Instrument");
575      // update GUI with that new gig::File      // update GUI with that new gig::File
576      load_gig(pFile, NULL /*no file name yet*/);      load_gig(pFile, 0 /*no file name yet*/);
577    }
578    
579    bool MainWindow::close_confirmation_dialog()
580    {
581        gchar* msg = g_strdup_printf(_("Save changes to \"%s\" before closing?"),
582                                     Glib::filename_display_basename(filename).c_str());
583        Gtk::MessageDialog dialog(*this, msg, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE);
584        g_free(msg);
585        dialog.set_secondary_text(_("If you close without saving, your changes will be lost."));
586        dialog.add_button(_("Close _Without Saving"), Gtk::RESPONSE_NO);
587        dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
588        dialog.add_button(file_has_name ? Gtk::Stock::SAVE : Gtk::Stock::SAVE_AS, Gtk::RESPONSE_YES);
589        dialog.set_default_response(Gtk::RESPONSE_YES);
590        int response = dialog.run();
591        dialog.hide();
592        if (response == Gtk::RESPONSE_YES) return file_save();
593        return response != Gtk::RESPONSE_CANCEL;
594    }
595    
596    bool MainWindow::leaving_shared_mode_dialog() {
597        Glib::ustring msg = _("Detach from sampler and proceed working stand-alone?");
598        Gtk::MessageDialog dialog(*this, msg, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE);
599        dialog.set_secondary_text(
600            _("If you proceed to work on another instrument file, it won't be "
601              "used by the sampler until you tell the sampler explicitly to "
602              "load it."));
603        dialog.add_button(_("_Yes, Detach"), Gtk::RESPONSE_YES);
604        dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
605        dialog.set_default_response(Gtk::RESPONSE_CANCEL);
606        int response = dialog.run();
607        dialog.hide();
608        return response == Gtk::RESPONSE_YES;
609  }  }
610    
611  void MainWindow::on_action_file_open()  void MainWindow::on_action_file_open()
612  {  {
613        if (!file_is_shared && file_is_changed && !close_confirmation_dialog()) return;
614    
615        if (file_is_shared && !leaving_shared_mode_dialog()) return;
616    
617      Gtk::FileChooserDialog dialog(*this, _("Open file"));      Gtk::FileChooserDialog dialog(*this, _("Open file"));
618      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
619      dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);      dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
620        dialog.set_default_response(Gtk::RESPONSE_OK);
621    #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
622      Gtk::FileFilter filter;      Gtk::FileFilter filter;
623      filter.add_pattern("*.gig");      filter.add_pattern("*.gig");
624    #else
625        Glib::RefPtr<Gtk::FileFilter> filter = Gtk::FileFilter::create();
626        filter->add_pattern("*.gig");
627    #endif
628      dialog.set_filter(filter);      dialog.set_filter(filter);
629        if (current_gig_dir != "") {
630            dialog.set_current_folder(current_gig_dir);
631        }
632      if (dialog.run() == Gtk::RESPONSE_OK) {      if (dialog.run() == Gtk::RESPONSE_OK) {
633          printf("filename=%s\n", dialog.get_filename().c_str());          std::string filename = dialog.get_filename();
634          __clear();          printf("filename=%s\n", filename.c_str());
635          printf("on_action_file_open self=%x\n", Glib::Thread::self());          printf("on_action_file_open self=%x\n", Glib::Threads::Thread::self());
636          load_file(dialog.get_filename().c_str());          load_file(filename.c_str());
637            current_gig_dir = Glib::path_get_dirname(filename);
638      }      }
639  }  }
640    
641  void MainWindow::load_file(const char* name)  void MainWindow::load_file(const char* name)
642  {  {
643      load_dialog = new LoadDialog("Loading...", *this);      __clear();
644        load_dialog = new LoadDialog(_("Loading..."), *this);
645      load_dialog->show_all();      load_dialog->show_all();
646      loader = new Loader(strdup(name));      loader = new Loader(strdup(name));
647      loader->signal_progress().connect(      loader->signal_progress().connect(
# Line 416  void MainWindow::load_instrument(gig::In Line 658  void MainWindow::load_instrument(gig::In
658          msg.run();          msg.run();
659          Gtk::Main::quit();          Gtk::Main::quit();
660      }      }
661        // clear all GUI elements
662        __clear();
663        // load the instrument
664      gig::File* pFile = (gig::File*) instr->GetParent();      gig::File* pFile = (gig::File*) instr->GetParent();
665      load_gig(pFile, NULL /*file name*/);      load_gig(pFile, 0 /*file name*/, true /*shared instrument*/);
666      //TODO: automatically select the given instrument      //TODO: automatically select the given instrument
667  }  }
668    
# Line 429  void MainWindow::on_loader_progress() Line 674  void MainWindow::on_loader_progress()
674  void MainWindow::on_loader_finished()  void MainWindow::on_loader_finished()
675  {  {
676      printf("Loader finished!\n");      printf("Loader finished!\n");
677      printf("on_loader_finished self=%x\n", Glib::Thread::self());      printf("on_loader_finished self=%x\n", Glib::Threads::Thread::self());
678      load_gig(loader->gig, loader->filename);      load_gig(loader->gig, loader->filename);
679      load_dialog->hide();      load_dialog->hide();
680  }  }
681    
682  void MainWindow::on_action_file_save()  void MainWindow::on_action_file_save()
683  {  {
684      if (!file) return;      file_save();
685    }
686    
687    bool MainWindow::check_if_savable()
688    {
689        if (!file) return false;
690    
691        if (!file->GetFirstSample()) {
692            Gtk::MessageDialog(*this, _("The file could not be saved "
693                                        "because it contains no samples"),
694                               false, Gtk::MESSAGE_ERROR).run();
695            return false;
696        }
697    
698        for (gig::Instrument* instrument = file->GetFirstInstrument() ; instrument ;
699             instrument = file->GetNextInstrument()) {
700            if (!instrument->GetFirstRegion()) {
701                Gtk::MessageDialog(*this, _("The file could not be saved "
702                                            "because there are instruments "
703                                            "that have no regions"),
704                                   false, Gtk::MESSAGE_ERROR).run();
705                return false;
706            }
707        }
708        return true;
709    }
710    
711    bool MainWindow::file_save()
712    {
713        if (!check_if_savable()) return false;
714        if (!file_is_shared && !file_has_name) return file_save_as();
715    
716      std::cout << "Saving file\n" << std::flush;      std::cout << "Saving file\n" << std::flush;
717        file_structure_to_be_changed_signal.emit(this->file);
718      try {      try {
719          file->Save();          file->Save();
720            if (file_is_changed) {
721                set_title(get_title().substr(1));
722                file_is_changed = false;
723            }
724      } catch (RIFF::Exception e) {      } catch (RIFF::Exception e) {
725          Glib::ustring txt = "Could not save file: " + e.Message;          file_structure_changed_signal.emit(this->file);
726            Glib::ustring txt = _("Could not save file: ") + e.Message;
727          Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR);          Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR);
728          msg.run();          msg.run();
729          return;          return false;
730      }      }
731      std::cout << "Saving file done\n" << std::flush;      std::cout << "Saving file done\n" << std::flush;
732      __import_queued_samples();      __import_queued_samples();
733        file_structure_changed_signal.emit(this->file);
734        return true;
735  }  }
736    
737  void MainWindow::on_action_file_save_as()  void MainWindow::on_action_file_save_as()
738  {  {
739      if (!file) return;      if (!check_if_savable()) return;
740      Gtk::FileChooserDialog dialog(*this, "Open", Gtk::FILE_CHOOSER_ACTION_SAVE);      file_save_as();
741    }
742    
743    bool MainWindow::file_save_as()
744    {
745        Gtk::FileChooserDialog dialog(*this, _("Save as"), Gtk::FILE_CHOOSER_ACTION_SAVE);
746      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
747      dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK);      dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK);
748        dialog.set_default_response(Gtk::RESPONSE_OK);
749        dialog.set_do_overwrite_confirmation();
750    
751    #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
752      Gtk::FileFilter filter;      Gtk::FileFilter filter;
753      filter.add_pattern("*.gig");      filter.add_pattern("*.gig");
754    #else
755        Glib::RefPtr<Gtk::FileFilter> filter = Gtk::FileFilter::create();
756        filter->add_pattern("*.gig");
757    #endif
758      dialog.set_filter(filter);      dialog.set_filter(filter);
759    
760        // set initial dir and filename of the Save As dialog
761        // and prepare that initial filename as a copy of the gig
762        {
763            std::string basename = Glib::path_get_basename(filename);
764            std::string dir = Glib::path_get_dirname(filename);
765            basename = std::string(_("copy_of_")) + basename;
766            Glib::ustring copyFileName = Glib::build_filename(dir, basename);
767            if (Glib::path_is_absolute(filename)) {
768                dialog.set_filename(copyFileName);
769            } else {
770                if (current_gig_dir != "") dialog.set_current_folder(current_gig_dir);
771            }
772            dialog.set_current_name(Glib::filename_display_basename(copyFileName));
773        }
774    
775        // show warning in the dialog
776        Gtk::HBox descriptionArea;
777        descriptionArea.set_spacing(15);
778        Gtk::Image warningIcon(Gtk::Stock::DIALOG_WARNING, Gtk::IconSize(Gtk::ICON_SIZE_DIALOG));
779        descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK);
780    #if GTKMM_MAJOR_VERSION < 3
781        view::WrapLabel description;
782    #else
783        Gtk::Label description;
784        description.set_line_wrap();
785    #endif
786        description.set_markup(
787            _("\n<b>CAUTION:</b> You <b>MUST</b> use the "
788              "<span style=\"italic\">\"Save\"</span> dialog instead of "
789              "<span style=\"italic\">\"Save As...\"</span> if you want to save "
790              "to the same .gig file. Using "
791              "<span style=\"italic\">\"Save As...\"</span> for writing to the "
792              "same .gig file will end up in corrupted sample wave data!\n")
793        );
794        descriptionArea.pack_start(description);
795        dialog.get_vbox()->pack_start(descriptionArea, Gtk::PACK_SHRINK);
796        descriptionArea.show_all();
797    
798      if (dialog.run() == Gtk::RESPONSE_OK) {      if (dialog.run() == Gtk::RESPONSE_OK) {
799          printf("filename=%s\n", dialog.get_filename().c_str());          file_structure_to_be_changed_signal.emit(this->file);
800          try {          try {
801              file->Save(dialog.get_filename());              std::string filename = dialog.get_filename();
802                if (!Glib::str_has_suffix(filename, ".gig")) {
803                    filename += ".gig";
804                }
805                printf("filename=%s\n", filename.c_str());
806                file->Save(filename);
807                this->filename = filename;
808                current_gig_dir = Glib::path_get_dirname(filename);
809                set_title(Glib::filename_display_basename(filename));
810                file_has_name = true;
811                file_is_changed = false;
812          } catch (RIFF::Exception e) {          } catch (RIFF::Exception e) {
813              Glib::ustring txt = "Could not save file: " + e.Message;              file_structure_changed_signal.emit(this->file);
814                Glib::ustring txt = _("Could not save file: ") + e.Message;
815              Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR);              Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR);
816              msg.run();              msg.run();
817              return;              return false;
818          }          }
819          __import_queued_samples();          __import_queued_samples();
820            file_structure_changed_signal.emit(this->file);
821            return true;
822      }      }
823        return false;
824  }  }
825    
826  // actually write the sample(s)' data to the gig file  // actually write the sample(s)' data to the gig file
# Line 484  void MainWindow::__import_queued_samples Line 834  void MainWindow::__import_queued_samples
834          SF_INFO info;          SF_INFO info;
835          info.format = 0;          info.format = 0;
836          SNDFILE* hFile = sf_open((*iter).sample_path.c_str(), SFM_READ, &info);          SNDFILE* hFile = sf_open((*iter).sample_path.c_str(), SFM_READ, &info);
837            sf_command(hFile, SFC_SET_SCALE_FLOAT_INT_READ, 0, SF_TRUE);
838          try {          try {
839              if (!hFile) throw std::string("could not open file");              if (!hFile) throw std::string(_("could not open file"));
840              // determine sample's bit depth              // determine sample's bit depth
841              int bitdepth;              int bitdepth;
842              switch (info.format & 0xff) {              switch (info.format & 0xff) {
843                  case SF_FORMAT_PCM_S8:                  case SF_FORMAT_PCM_S8:
                     bitdepth = 16; // we simply convert to 16 bit for now  
                     break;  
844                  case SF_FORMAT_PCM_16:                  case SF_FORMAT_PCM_16:
845                    case SF_FORMAT_PCM_U8:
846                      bitdepth = 16;                      bitdepth = 16;
847                      break;                      break;
848                  case SF_FORMAT_PCM_24:                  case SF_FORMAT_PCM_24:
                     bitdepth = 32; // we simply convert to 32 bit for now  
                     break;  
849                  case SF_FORMAT_PCM_32:                  case SF_FORMAT_PCM_32:
                     bitdepth = 32;  
                     break;  
                 case SF_FORMAT_PCM_U8:  
                     bitdepth = 16; // we simply convert to 16 bit for now  
                     break;  
850                  case SF_FORMAT_FLOAT:                  case SF_FORMAT_FLOAT:
                     bitdepth = 32;  
                     break;  
851                  case SF_FORMAT_DOUBLE:                  case SF_FORMAT_DOUBLE:
852                      bitdepth = 32; // I guess we will always truncate this to 32 bit                      bitdepth = 24;
853                      break;                      break;
854                  default:                  default:
855                      sf_close(hFile); // close sound file                      sf_close(hFile); // close sound file
856                      throw std::string("format not supported"); // unsupported subformat (yet?)                      throw std::string(_("format not supported")); // unsupported subformat (yet?)
857              }              }
858              // allocate appropriate copy buffer (TODO: for now we copy  
859              // it in one piece, might be tough for very long samples)              const int bufsize = 10000;
             // and copy sample data into buffer  
             int8_t* buffer = NULL;  
860              switch (bitdepth) {              switch (bitdepth) {
861                  case 16:                  case 16: {
862                      buffer = new int8_t[2 * info.channels * info.frames];                      short* buffer = new short[bufsize * info.channels];
863                      // libsndfile does the conversion for us (if needed)                      sf_count_t cnt = info.frames;
864                      sf_readf_short(hFile, (short*) buffer, info.frames);                      while (cnt) {
865                            // libsndfile does the conversion for us (if needed)
866                            int n = sf_readf_short(hFile, buffer, bufsize);
867                            // write from buffer directly (physically) into .gig file
868                            iter->gig_sample->Write(buffer, n);
869                            cnt -= n;
870                        }
871                        delete[] buffer;
872                      break;                      break;
873                  case 32:                  }
874                      buffer = new int8_t[4 * info.channels * info.frames];                  case 24: {
875                      // libsndfile does the conversion for us (if needed)                      int* srcbuf = new int[bufsize * info.channels];
876                      sf_readf_int(hFile, (int*) buffer, info.frames);                      uint8_t* dstbuf = new uint8_t[bufsize * 3 * info.channels];
877                        sf_count_t cnt = info.frames;
878                        while (cnt) {
879                            // libsndfile returns 32 bits, convert to 24
880                            int n = sf_readf_int(hFile, srcbuf, bufsize);
881                            int j = 0;
882                            for (int i = 0 ; i < n * info.channels ; i++) {
883                                dstbuf[j++] = srcbuf[i] >> 8;
884                                dstbuf[j++] = srcbuf[i] >> 16;
885                                dstbuf[j++] = srcbuf[i] >> 24;
886                            }
887                            // write from buffer directly (physically) into .gig file
888                            iter->gig_sample->Write(dstbuf, n);
889                            cnt -= n;
890                        }
891                        delete[] srcbuf;
892                        delete[] dstbuf;
893                      break;                      break;
894                    }
895              }              }
             // write from buffer directly (physically) into .gig file  
             (*iter).gig_sample->Write(buffer, info.frames);  
896              // cleanup              // cleanup
897              sf_close(hFile);              sf_close(hFile);
898              delete[] buffer;              // let the sampler re-cache the sample if needed
899                sample_changed_signal.emit(iter->gig_sample);
900              // on success we remove the sample from the import queue,              // on success we remove the sample from the import queue,
901              // otherwise keep it, maybe it works the next time ?              // otherwise keep it, maybe it works the next time ?
902              std::list<SampleImportItem>::iterator cur = iter;              std::list<SampleImportItem>::iterator cur = iter;
# Line 549  void MainWindow::__import_queued_samples Line 911  void MainWindow::__import_queued_samples
911      }      }
912      // show error message box when some sample(s) could not be imported      // show error message box when some sample(s) could not be imported
913      if (error_files.size()) {      if (error_files.size()) {
914          Glib::ustring txt = "Could not import the following sample(s):\n" + error_files;          Glib::ustring txt = _("Could not import the following sample(s):\n") + error_files;
915          Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR);          Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR);
916          msg.run();          msg.run();
917      }      }
# Line 563  void MainWindow::on_action_file_properti Line 925  void MainWindow::on_action_file_properti
925    
926  void MainWindow::on_action_help_about()  void MainWindow::on_action_help_about()
927  {  {
 #ifdef ABOUT_DIALOG  
928      Gtk::AboutDialog dialog;      Gtk::AboutDialog dialog;
929    #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION >= 12) || GTKMM_MAJOR_VERSION > 2
930        dialog.set_program_name("Gigedit");
931    #else
932        dialog.set_name("Gigedit");
933    #endif
934      dialog.set_version(VERSION);      dialog.set_version(VERSION);
935        dialog.set_copyright("Copyright (C) 2006-2013 Andreas Persson");
936        dialog.set_comments(_(
937            "Released under the GNU General Public License.\n"
938            "\n"
939            "Please notice that this is still a very young instrument editor. "
940            "So better backup your Gigasampler files before editing them with "
941            "this application.\n"
942            "\n"
943            "Please report bugs to: http://bugs.linuxsampler.org")
944        );
945        dialog.set_website("http://www.linuxsampler.org");
946        dialog.set_website_label("http://www.linuxsampler.org");
947      dialog.run();      dialog.run();
 #endif  
948  }  }
949    
950  PropDialog::PropDialog()  PropDialog::PropDialog()
951      : table(2,1)      : eName(_("Name")),
952          eCreationDate(_("Creation date")),
953          eComments(_("Comments")),
954          eProduct(_("Product")),
955          eCopyright(_("Copyright")),
956          eArtists(_("Artists")),
957          eGenre(_("Genre")),
958          eKeywords(_("Keywords")),
959          eEngineer(_("Engineer")),
960          eTechnician(_("Technician")),
961          eSoftware(_("Software")),
962          eMedium(_("Medium")),
963          eSource(_("Source")),
964          eSourceForm(_("Source form")),
965          eCommissioned(_("Commissioned")),
966          eSubject(_("Subject")),
967          quitButton(Gtk::Stock::CLOSE),
968          table(2, 1),
969          update_model(0)
970  {  {
971        set_title(_("File Properties"));
972        eName.set_width_chars(50);
973    
974        connect(eName, &DLS::Info::Name);
975        connect(eCreationDate, &DLS::Info::CreationDate);
976        connect(eComments, &DLS::Info::Comments);
977        connect(eProduct, &DLS::Info::Product);
978        connect(eCopyright, &DLS::Info::Copyright);
979        connect(eArtists, &DLS::Info::Artists);
980        connect(eGenre, &DLS::Info::Genre);
981        connect(eKeywords, &DLS::Info::Keywords);
982        connect(eEngineer, &DLS::Info::Engineer);
983        connect(eTechnician, &DLS::Info::Technician);
984        connect(eSoftware, &DLS::Info::Software);
985        connect(eMedium, &DLS::Info::Medium);
986        connect(eSource, &DLS::Info::Source);
987        connect(eSourceForm, &DLS::Info::SourceForm);
988        connect(eCommissioned, &DLS::Info::Commissioned);
989        connect(eSubject, &DLS::Info::Subject);
990    
991        table.add(eName);
992        table.add(eCreationDate);
993        table.add(eComments);
994        table.add(eProduct);
995        table.add(eCopyright);
996        table.add(eArtists);
997        table.add(eGenre);
998        table.add(eKeywords);
999        table.add(eEngineer);
1000        table.add(eTechnician);
1001        table.add(eSoftware);
1002        table.add(eMedium);
1003        table.add(eSource);
1004        table.add(eSourceForm);
1005        table.add(eCommissioned);
1006        table.add(eSubject);
1007    
1008      table.set_col_spacings(5);      table.set_col_spacings(5);
1009      const char* propLabels[] = {      add(vbox);
1010          "Name:",      table.set_border_width(5);
1011          "CreationDate:",      vbox.add(table);
1012          "Comments:", // TODO: multiline      vbox.pack_start(buttonBox, Gtk::PACK_SHRINK);
1013          "Product:",      buttonBox.set_layout(Gtk::BUTTONBOX_END);
1014          "Copyright:",      buttonBox.set_border_width(5);
1015          "Artists:",      buttonBox.show();
1016          "Genre:",      buttonBox.pack_start(quitButton);
1017          "Keywords:",      quitButton.set_can_default();
1018          "Engineer:",      quitButton.grab_focus();
1019          "Technician:",      quitButton.signal_clicked().connect(
1020          "Software:", // TODO: readonly          sigc::mem_fun(*this, &PropDialog::hide));
         "Medium:",  
         "Source:",  
         "SourceForm:",  
         "Commissioned:",  
         "Subject:"  
     };  
     for (int i = 0 ; i < sizeof(propLabels) / sizeof(char*) ; i++) {  
         label[i].set_text(propLabels[i]);  
         label[i].set_alignment(Gtk::ALIGN_LEFT);  
         table.attach(label[i], 0, 1, i, i + 1, Gtk::FILL, Gtk::SHRINK);  
         table.attach(entry[i], 1, 2, i, i + 1, Gtk::FILL | Gtk::EXPAND,  
                      Gtk::SHRINK);  
     }  
1021    
1022      add(table);      quitButton.show();
1023      // add_button(Gtk::Stock::CANCEL, 0);      vbox.show();
     // add_button(Gtk::Stock::OK, 1);  
1024      show_all_children();      show_all_children();
1025  }  }
1026    
1027  void PropDialog::set_info(DLS::Info* info)  void PropDialog::set_info(DLS::Info* info)
1028  {  {
1029      entry[0].set_text(info->Name);      this->info = info;
1030      entry[1].set_text(info->CreationDate);      update_model++;
1031      entry[2].set_text(Glib::convert(info->Comments, "UTF-8", "ISO-8859-1"));      eName.set_value(info->Name);
1032      entry[3].set_text(info->Product);      eCreationDate.set_value(info->CreationDate);
1033      entry[4].set_text(info->Copyright);      eComments.set_value(info->Comments);
1034      entry[5].set_text(info->Artists);      eProduct.set_value(info->Product);
1035      entry[6].set_text(info->Genre);      eCopyright.set_value(info->Copyright);
1036      entry[7].set_text(info->Keywords);      eArtists.set_value(info->Artists);
1037      entry[8].set_text(info->Engineer);      eGenre.set_value(info->Genre);
1038      entry[9].set_text(info->Technician);      eKeywords.set_value(info->Keywords);
1039      entry[10].set_text(info->Software);      eEngineer.set_value(info->Engineer);
1040      entry[11].set_text(info->Medium);      eTechnician.set_value(info->Technician);
1041      entry[12].set_text(info->Source);      eSoftware.set_value(info->Software);
1042      entry[13].set_text(info->SourceForm);      eMedium.set_value(info->Medium);
1043      entry[14].set_text(info->Commissioned);      eSource.set_value(info->Source);
1044      entry[15].set_text(info->Subject);      eSourceForm.set_value(info->SourceForm);
1045  }      eCommissioned.set_value(info->Commissioned);
1046        eSubject.set_value(info->Subject);
1047  void InstrumentProps::add_prop(LabelWidget& prop)      update_model--;
1048  {  }
1049      table.attach(prop.label, 0, 1, rowno, rowno + 1,  
1050                   Gtk::FILL, Gtk::SHRINK);  sigc::signal<void>& PropDialog::signal_info_changed()
1051      table.attach(prop.widget, 1, 2, rowno, rowno + 1,  {
1052                   Gtk::FILL | Gtk::EXPAND, Gtk::SHRINK);      return info_changed;
1053      rowno++;  }
1054    
1055    void InstrumentProps::set_IsDrum(bool value)
1056    {
1057        instrument->IsDrum = value;
1058    }
1059    
1060    void InstrumentProps::set_MIDIBank(uint16_t value)
1061    {
1062        instrument->MIDIBank = value;
1063    }
1064    
1065    void InstrumentProps::set_MIDIProgram(uint32_t value)
1066    {
1067        instrument->MIDIProgram = value;
1068    }
1069    
1070    void InstrumentProps::set_DimensionKeyRange_low(uint8_t value)
1071    {
1072        instrument->DimensionKeyRange.low = value;
1073        if (value > instrument->DimensionKeyRange.high) {
1074            eDimensionKeyRangeHigh.set_value(value);
1075        }
1076    }
1077    
1078    void InstrumentProps::set_DimensionKeyRange_high(uint8_t value)
1079    {
1080        instrument->DimensionKeyRange.high = value;
1081        if (value < instrument->DimensionKeyRange.low) {
1082            eDimensionKeyRangeLow.set_value(value);
1083        }
1084  }  }
1085    
1086  InstrumentProps::InstrumentProps()  InstrumentProps::InstrumentProps()
1087      : table(2,1),      : update_model(0),
1088        quitButton(Gtk::Stock::CLOSE),        quitButton(Gtk::Stock::CLOSE),
1089        eName("Name"),        table(2,1),
1090        eIsDrum("IsDrum"),        eName(_("Name")),
1091        eMIDIBank("MIDIBank", 0, 16383),        eIsDrum(_("Is drum")),
1092        eMIDIProgram("MIDIProgram"),        eMIDIBank(_("MIDI bank"), 0, 16383),
1093        eAttenuation("Attenuation", 0, 96, 0, 1),        eMIDIProgram(_("MIDI program")),
1094        eGainPlus6("Gain +6dB", eAttenuation, -6),        eAttenuation(_("Attenuation"), 0, 96, 0, 1),
1095        eEffectSend("EffectSend", 0, 65535),        eGainPlus6(_("Gain +6dB"), eAttenuation, -6),
1096        eFineTune("FineTune", -8400, 8400),        eEffectSend(_("Effect send"), 0, 65535),
1097        ePitchbendRange("PitchbendRange", 0, 12),        eFineTune(_("Fine tune"), -8400, 8400),
1098        ePianoReleaseMode("PianoReleaseMode"),        ePitchbendRange(_("Pitchbend range"), 0, 12),
1099        eDimensionKeyRangeLow("DimensionKeyRangeLow"),        ePianoReleaseMode(_("Piano release mode")),
1100        eDimensionKeyRangeHigh("DimensionKeyRangeHigh")        eDimensionKeyRangeLow(_("Keyswitching range low")),
1101  {        eDimensionKeyRangeHigh(_("Keyswitching range high"))
1102      set_title("Instrument properties");  {
1103        set_title(_("Instrument Properties"));
1104    
1105        eDimensionKeyRangeLow.set_tip(
1106            _("start of the keyboard area which should switch the "
1107              "\"keyswitching\" dimension")
1108        );
1109        eDimensionKeyRangeHigh.set_tip(
1110            _("end of the keyboard area which should switch the "
1111              "\"keyswitching\" dimension")
1112        );
1113    
1114        connect(eIsDrum, &InstrumentProps::set_IsDrum);
1115        connect(eMIDIBank, &InstrumentProps::set_MIDIBank);
1116        connect(eMIDIProgram, &InstrumentProps::set_MIDIProgram);
1117        connect(eAttenuation, &gig::Instrument::Attenuation);
1118        connect(eGainPlus6, &gig::Instrument::Attenuation);
1119        connect(eEffectSend, &gig::Instrument::EffectSend);
1120        connect(eFineTune, &gig::Instrument::FineTune);
1121        connect(ePitchbendRange, &gig::Instrument::PitchbendRange);
1122        connect(ePianoReleaseMode, &gig::Instrument::PianoReleaseMode);
1123        connect(eDimensionKeyRangeLow,
1124                &InstrumentProps::set_DimensionKeyRange_low);
1125        connect(eDimensionKeyRangeHigh,
1126                &InstrumentProps::set_DimensionKeyRange_high);
1127    
     rowno = 0;  
1128      table.set_col_spacings(5);      table.set_col_spacings(5);
1129    
1130      add_prop(eName);      table.add(eName);
1131      add_prop(eIsDrum);      table.add(eIsDrum);
1132      add_prop(eMIDIBank);      table.add(eMIDIBank);
1133      add_prop(eMIDIProgram);      table.add(eMIDIProgram);
1134      add_prop(eAttenuation);      table.add(eAttenuation);
1135      add_prop(eGainPlus6);      table.add(eGainPlus6);
1136      add_prop(eEffectSend);      table.add(eEffectSend);
1137      add_prop(eFineTune);      table.add(eFineTune);
1138      add_prop(ePitchbendRange);      table.add(ePitchbendRange);
1139      add_prop(ePianoReleaseMode);      table.add(ePianoReleaseMode);
1140      add_prop(eDimensionKeyRangeLow);      table.add(eDimensionKeyRangeLow);
1141      add_prop(eDimensionKeyRangeHigh);      table.add(eDimensionKeyRangeHigh);
   
     eDimensionKeyRangeLow.signal_value_changed().connect(  
         sigc::mem_fun(*this, &InstrumentProps::key_range_low_changed));  
     eDimensionKeyRangeHigh.signal_value_changed().connect(  
         sigc::mem_fun(*this, &InstrumentProps::key_range_high_changed));  
1142    
1143      add(vbox);      add(vbox);
1144      table.set_border_width(5);      table.set_border_width(5);
# Line 683  InstrumentProps::InstrumentProps() Line 1149  InstrumentProps::InstrumentProps()
1149      buttonBox.set_border_width(5);      buttonBox.set_border_width(5);
1150      buttonBox.show();      buttonBox.show();
1151      buttonBox.pack_start(quitButton);      buttonBox.pack_start(quitButton);
1152      quitButton.set_flags(Gtk::CAN_DEFAULT);      quitButton.set_can_default();
1153      quitButton.grab_focus();      quitButton.grab_focus();
1154    
1155      quitButton.signal_clicked().connect(      quitButton.signal_clicked().connect(
# Line 696  InstrumentProps::InstrumentProps() Line 1162  InstrumentProps::InstrumentProps()
1162    
1163  void InstrumentProps::set_instrument(gig::Instrument* instrument)  void InstrumentProps::set_instrument(gig::Instrument* instrument)
1164  {  {
1165      update_gui = false;      this->instrument = instrument;
1166      eName.set_ptr(&instrument->pInfo->Name);  
1167      eIsDrum.set_ptr(&instrument->IsDrum);      update_model++;
1168      eMIDIBank.set_ptr(&instrument->MIDIBank);      eName.set_value(instrument->pInfo->Name);
1169      eMIDIProgram.set_ptr(&instrument->MIDIProgram);      eIsDrum.set_value(instrument->IsDrum);
1170      eAttenuation.set_ptr(&instrument->Attenuation);      eMIDIBank.set_value(instrument->MIDIBank);
1171      eGainPlus6.set_ptr(&instrument->Attenuation);      eMIDIProgram.set_value(instrument->MIDIProgram);
1172      eEffectSend.set_ptr(&instrument->EffectSend);      eAttenuation.set_value(instrument->Attenuation);
1173      eFineTune.set_ptr(&instrument->FineTune);      eGainPlus6.set_value(instrument->Attenuation);
1174      ePitchbendRange.set_ptr(&instrument->PitchbendRange);      eEffectSend.set_value(instrument->EffectSend);
1175      ePianoReleaseMode.set_ptr(&instrument->PianoReleaseMode);      eFineTune.set_value(instrument->FineTune);
1176      eDimensionKeyRangeLow.set_ptr(&instrument->DimensionKeyRange.low);      ePitchbendRange.set_value(instrument->PitchbendRange);
1177      eDimensionKeyRangeHigh.set_ptr(&instrument->DimensionKeyRange.high);      ePianoReleaseMode.set_value(instrument->PianoReleaseMode);
1178      update_gui = true;      eDimensionKeyRangeLow.set_value(instrument->DimensionKeyRange.low);
1179        eDimensionKeyRangeHigh.set_value(instrument->DimensionKeyRange.high);
1180        update_model--;
1181  }  }
1182    
1183  void InstrumentProps::key_range_low_changed()  sigc::signal<void>& InstrumentProps::signal_instrument_changed()
1184  {  {
1185      double l = eDimensionKeyRangeLow.get_value();      return instrument_changed;
     double h = eDimensionKeyRangeHigh.get_value();  
     if (h < l) eDimensionKeyRangeHigh.set_value(l);  
1186  }  }
1187    
1188  void InstrumentProps::key_range_high_changed()  void MainWindow::file_changed()
1189  {  {
1190      double l = eDimensionKeyRangeLow.get_value();      if (file && !file_is_changed) {
1191      double h = eDimensionKeyRangeHigh.get_value();          set_title("*" + get_title());
1192      if (h < l) eDimensionKeyRangeLow.set_value(h);          file_is_changed = true;
1193        }
1194  }  }
1195    
1196  void MainWindow::load_gig(gig::File* gig, const char* filename)  void MainWindow::load_gig(gig::File* gig, const char* filename, bool isSharedInstrument)
1197  {  {
1198      file = gig;      file = 0;
1199        set_file_is_shared(isSharedInstrument);
1200    
1201      if (filename) {      this->filename = filename ? filename : _("Unsaved Gig File");
1202          const char *basename = strrchr(filename, '/');      set_title(Glib::filename_display_basename(this->filename));
1203          basename = basename ? basename + 1 : filename;      file_has_name = filename;
1204          set_title(basename);      file_is_changed = false;
     } else {  
         set_title("unnamed");  
     }  
1205    
1206      propDialog.set_info(gig->pInfo);      propDialog.set_info(gig->pInfo);
1207    
# Line 785  void MainWindow::load_gig(gig::File* gig Line 1250  void MainWindow::load_gig(gig::File* gig
1250          }          }
1251      }      }
1252    
1253        file = gig;
1254    
1255      // select the first instrument      // select the first instrument
1256      Glib::RefPtr<Gtk::TreeSelection> tree_sel_ref = m_TreeView.get_selection();      Glib::RefPtr<Gtk::TreeSelection> tree_sel_ref = m_TreeView.get_selection();
1257      tree_sel_ref->select(Gtk::TreePath("0"));      tree_sel_ref->select(Gtk::TreePath("0"));
# Line 792  void MainWindow::load_gig(gig::File* gig Line 1259  void MainWindow::load_gig(gig::File* gig
1259    
1260  void MainWindow::show_instr_props()  void MainWindow::show_instr_props()
1261  {  {
1262      Glib::RefPtr<Gtk::TreeSelection> tree_sel_ref = m_TreeView.get_selection();      gig::Instrument* instrument = get_instrument();
1263      Gtk::TreeModel::iterator it = tree_sel_ref->get_selected();      if (instrument)
     if (it)  
1264      {      {
1265          Gtk::TreeModel::Row row = *it;          instrumentProps.set_instrument(instrument);
1266          if (row[m_Columns.m_col_instr])          instrumentProps.show();
1267          {          instrumentProps.deiconify();
1268              instrumentProps.set_instrument(row[m_Columns.m_col_instr]);      }
1269              instrumentProps.show();  }
1270              instrumentProps.deiconify();  
1271          }  void MainWindow::on_action_view_status_bar() {
1272        Gtk::CheckMenuItem* item =
1273            dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/Statusbar"));
1274        if (!item) {
1275            std::cerr << "/MenuBar/MenuView/Statusbar == NULL\n";
1276            return;
1277      }      }
1278        if (item->get_active()) m_StatusBar.show();
1279        else                    m_StatusBar.hide();
1280  }  }
1281    
1282  void MainWindow::on_button_release(GdkEventButton* button)  void MainWindow::on_button_release(GdkEventButton* button)
# Line 852  void MainWindow::on_action_add_instrumen Line 1325  void MainWindow::on_action_add_instrumen
1325      gig::Instrument* instrument = file->AddInstrument();      gig::Instrument* instrument = file->AddInstrument();
1326      __instrument_indexer++;      __instrument_indexer++;
1327      instrument->pInfo->Name =      instrument->pInfo->Name =
1328          "Unnamed Instrument " + ToString(__instrument_indexer);          _("Unnamed Instrument ") + ToString(__instrument_indexer);
1329      // update instrument tree view      // update instrument tree view
1330      Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append();      Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append();
1331      Gtk::TreeModel::Row rowInstr = *iterInstr;      Gtk::TreeModel::Row rowInstr = *iterInstr;
1332      rowInstr[m_Columns.m_col_name] = instrument->pInfo->Name.c_str();      rowInstr[m_Columns.m_col_name] = instrument->pInfo->Name.c_str();
1333      rowInstr[m_Columns.m_col_instr] = instrument;      rowInstr[m_Columns.m_col_instr] = instrument;
1334        file_changed();
1335    }
1336    
1337    void MainWindow::on_action_duplicate_instrument() {
1338        if (!file) return;
1339        
1340        // retrieve the currently selected instrument
1341        // (being the original instrument to be duplicated)
1342        Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection();
1343        Gtk::TreeModel::iterator itSelection = sel->get_selected();
1344        if (!itSelection) return;
1345        Gtk::TreeModel::Row row = *itSelection;
1346        gig::Instrument* instrOrig = row[m_Columns.m_col_instr];
1347        if (!instrOrig) return;
1348        
1349        // duplicate the orginal instrument
1350        gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig);
1351        instrNew->pInfo->Name =
1352            instrOrig->pInfo->Name + " (" + _("Copy") + ")";
1353            
1354        // update instrument tree view
1355        Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append();
1356        Gtk::TreeModel::Row rowInstr = *iterInstr;
1357        rowInstr[m_Columns.m_col_name] = instrNew->pInfo->Name.c_str();
1358        rowInstr[m_Columns.m_col_instr] = instrNew;
1359        file_changed();
1360  }  }
1361    
1362  void MainWindow::on_action_remove_instrument() {  void MainWindow::on_action_remove_instrument() {
1363      if (!file) return;      if (!file) return;
1364        if (file_is_shared) {
1365            Gtk::MessageDialog msg(
1366                *this,
1367                 _("You cannot delete an instrument from this file, since it's "
1368                   "currently used by the sampler."),
1369                 false, Gtk::MESSAGE_INFO
1370            );
1371            msg.run();
1372            return;
1373        }
1374    
1375      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection();      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection();
1376      Gtk::TreeModel::iterator it = sel->get_selected();      Gtk::TreeModel::iterator it = sel->get_selected();
1377      if (it) {      if (it) {
# Line 872  void MainWindow::on_action_remove_instru Line 1382  void MainWindow::on_action_remove_instru
1382              if (instr) file->DeleteInstrument(instr);              if (instr) file->DeleteInstrument(instr);
1383              // remove respective row from instruments tree view              // remove respective row from instruments tree view
1384              m_refTreeModel->erase(it);              m_refTreeModel->erase(it);
1385                file_changed();
1386          } catch (RIFF::Exception e) {          } catch (RIFF::Exception e) {
1387              Gtk::MessageDialog msg(*this, e.Message.c_str(), false, Gtk::MESSAGE_ERROR);              Gtk::MessageDialog msg(*this, e.Message.c_str(), false, Gtk::MESSAGE_ERROR);
1388              msg.run();              msg.run();
# Line 882  void MainWindow::on_action_remove_instru Line 1393  void MainWindow::on_action_remove_instru
1393  void MainWindow::on_action_sample_properties() {  void MainWindow::on_action_sample_properties() {
1394      //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
1395      Gtk::MessageDialog msg(      Gtk::MessageDialog msg(
1396          *this, "Sorry, yet to be implemented!", false, Gtk::MESSAGE_INFO          *this, _("Sorry, yet to be implemented!"), false, Gtk::MESSAGE_INFO
1397      );      );
1398      msg.run();      msg.run();
1399  }  }
# Line 891  void MainWindow::on_action_add_group() { Line 1402  void MainWindow::on_action_add_group() {
1402      static int __sample_indexer = 0;      static int __sample_indexer = 0;
1403      if (!file) return;      if (!file) return;
1404      gig::Group* group = file->AddGroup();      gig::Group* group = file->AddGroup();
1405      group->Name = "Unnamed Group";      group->Name = _("Unnamed Group");
1406      if (__sample_indexer) group->Name += " " + ToString(__sample_indexer);      if (__sample_indexer) group->Name += " " + ToString(__sample_indexer);
1407      __sample_indexer++;      __sample_indexer++;
1408      // update sample tree view      // update sample tree view
# Line 900  void MainWindow::on_action_add_group() { Line 1411  void MainWindow::on_action_add_group() {
1411      rowGroup[m_SamplesModel.m_col_name] = group->Name.c_str();      rowGroup[m_SamplesModel.m_col_name] = group->Name.c_str();
1412      rowGroup[m_SamplesModel.m_col_sample] = NULL;      rowGroup[m_SamplesModel.m_col_sample] = NULL;
1413      rowGroup[m_SamplesModel.m_col_group] = group;      rowGroup[m_SamplesModel.m_col_group] = group;
1414        file_changed();
1415  }  }
1416    
1417  void MainWindow::on_action_add_sample() {  void MainWindow::on_action_add_sample() {
# Line 924  void MainWindow::on_action_add_sample() Line 1436  void MainWindow::on_action_add_sample()
1436      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1437      dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);      dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
1438      dialog.set_select_multiple(true);      dialog.set_select_multiple(true);
1439      Gtk::FileFilter soundfilter; // matches all file types supported by libsndfile  
1440      const char* supportedFileTypes[] = {      // matches all file types supported by libsndfile
1441    #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
1442        Gtk::FileFilter soundfilter;
1443    #else
1444        Glib::RefPtr<Gtk::FileFilter> soundfilter = Gtk::FileFilter::create();
1445    #endif
1446        const char* const supportedFileTypes[] = {
1447          "*.wav", "*.WAV", "*.aiff", "*.AIFF", "*.aifc", "*.AIFC", "*.snd",          "*.wav", "*.WAV", "*.aiff", "*.AIFF", "*.aifc", "*.AIFC", "*.snd",
1448          "*.SND", "*.au", "*.AU", "*.paf", "*.PAF", "*.iff", "*.IFF",          "*.SND", "*.au", "*.AU", "*.paf", "*.PAF", "*.iff", "*.IFF",
1449          "*.svx", "*.SVX", "*.sf", "*.SF", "*.voc", "*.VOC", "*.w64",          "*.svx", "*.SVX", "*.sf", "*.SF", "*.voc", "*.VOC", "*.w64",
1450          "*.W64", "*.pvf", "*.PVF", "*.xi", "*.XI", "*.htk", "*.HTK",          "*.W64", "*.pvf", "*.PVF", "*.xi", "*.XI", "*.htk", "*.HTK",
1451          "*.caf", "*.CAF", NULL          "*.caf", "*.CAF", NULL
1452      };      };
1453        const char* soundfiles = _("Sound Files");
1454        const char* allfiles = _("All Files");
1455    #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
1456      for (int i = 0; supportedFileTypes[i]; i++)      for (int i = 0; supportedFileTypes[i]; i++)
1457          soundfilter.add_pattern(supportedFileTypes[i]);          soundfilter.add_pattern(supportedFileTypes[i]);
1458      soundfilter.set_name("Sound Files");      soundfilter.set_name(soundfiles);
1459      Gtk::FileFilter allpassfilter; // matches every file  
1460        // matches every file
1461        Gtk::FileFilter allpassfilter;
1462      allpassfilter.add_pattern("*.*");      allpassfilter.add_pattern("*.*");
1463      allpassfilter.set_name("All Files");      allpassfilter.set_name(allfiles);
1464    #else
1465        for (int i = 0; supportedFileTypes[i]; i++)
1466            soundfilter->add_pattern(supportedFileTypes[i]);
1467        soundfilter->set_name(soundfiles);
1468    
1469        // matches every file
1470        Glib::RefPtr<Gtk::FileFilter> allpassfilter = Gtk::FileFilter::create();
1471        allpassfilter->add_pattern("*.*");
1472        allpassfilter->set_name(allfiles);
1473    #endif
1474      dialog.add_filter(soundfilter);      dialog.add_filter(soundfilter);
1475      dialog.add_filter(allpassfilter);      dialog.add_filter(allpassfilter);
1476        if (current_sample_dir != "") {
1477            dialog.set_current_folder(current_sample_dir);
1478        }
1479      if (dialog.run() == Gtk::RESPONSE_OK) {      if (dialog.run() == Gtk::RESPONSE_OK) {
1480            current_sample_dir = dialog.get_current_folder();
1481          Glib::ustring error_files;          Glib::ustring error_files;
1482          Glib::SListHandle<Glib::ustring> filenames = dialog.get_filenames();          std::vector<std::string> filenames = dialog.get_filenames();
1483          for (Glib::SListHandle<Glib::ustring>::iterator iter = filenames.begin();          for (std::vector<std::string>::iterator iter = filenames.begin();
1484               iter != filenames.end(); ++iter) {               iter != filenames.end(); ++iter) {
1485              printf("Adding sample %s\n",(*iter).c_str());              printf("Adding sample %s\n",(*iter).c_str());
1486              // use libsndfile to retrieve file informations              // use libsndfile to retrieve file informations
# Line 951  void MainWindow::on_action_add_sample() Line 1488  void MainWindow::on_action_add_sample()
1488              info.format = 0;              info.format = 0;
1489              SNDFILE* hFile = sf_open((*iter).c_str(), SFM_READ, &info);              SNDFILE* hFile = sf_open((*iter).c_str(), SFM_READ, &info);
1490              try {              try {
1491                  if (!hFile) throw std::string("could not open file");                  if (!hFile) throw std::string(_("could not open file"));
1492                  int bitdepth;                  int bitdepth;
1493                  switch (info.format & 0xff) {                  switch (info.format & 0xff) {
1494                      case SF_FORMAT_PCM_S8:                      case SF_FORMAT_PCM_S8:
                         bitdepth = 16; // we simply convert to 16 bit for now  
                         break;  
1495                      case SF_FORMAT_PCM_16:                      case SF_FORMAT_PCM_16:
1496                        case SF_FORMAT_PCM_U8:
1497                          bitdepth = 16;                          bitdepth = 16;
1498                          break;                          break;
1499                      case SF_FORMAT_PCM_24:                      case SF_FORMAT_PCM_24:
                         bitdepth = 32; // we simply convert to 32 bit for now  
                         break;  
1500                      case SF_FORMAT_PCM_32:                      case SF_FORMAT_PCM_32:
                         bitdepth = 32;  
                         break;  
                     case SF_FORMAT_PCM_U8:  
                         bitdepth = 16; // we simply convert to 16 bit for now  
                         break;  
1501                      case SF_FORMAT_FLOAT:                      case SF_FORMAT_FLOAT:
                         bitdepth = 32;  
                         break;  
1502                      case SF_FORMAT_DOUBLE:                      case SF_FORMAT_DOUBLE:
1503                          bitdepth = 32; // I guess we will always truncate this to 32 bit                          bitdepth = 24;
1504                          break;                          break;
1505                      default:                      default:
1506                          sf_close(hFile); // close sound file                          sf_close(hFile); // close sound file
1507                          throw std::string("format not supported"); // unsupported subformat (yet?)                          throw std::string(_("format not supported")); // unsupported subformat (yet?)
1508                  }                  }
1509                  // add a new sample to the .gig file                  // add a new sample to the .gig file
1510                  gig::Sample* sample = file->AddSample();                  gig::Sample* sample = file->AddSample();
1511                  // file name without path                  // file name without path
1512                  sample->pInfo->Name = (*iter).substr((*iter).rfind('/') + 1).raw();                  Glib::ustring filename = Glib::filename_display_basename(*iter);
1513                    // remove file extension if there is one
1514                    for (int i = 0; supportedFileTypes[i]; i++) {
1515                        if (Glib::str_has_suffix(filename, supportedFileTypes[i] + 1)) {
1516                            filename.erase(filename.length() - strlen(supportedFileTypes[i] + 1));
1517                            break;
1518                        }
1519                    }
1520                    sample->pInfo->Name = filename;
1521                  sample->Channels = info.channels;                  sample->Channels = info.channels;
1522                  sample->BitDepth = bitdepth;                  sample->BitDepth = bitdepth;
1523                  sample->FrameSize = bitdepth / 8/*1 byte are 8 bits*/ * info.channels;                  sample->FrameSize = bitdepth / 8/*1 byte are 8 bits*/ * info.channels;
1524                  sample->SamplesPerSecond = info.samplerate;                  sample->SamplesPerSecond = info.samplerate;
1525                    sample->AverageBytesPerSecond = sample->FrameSize * sample->SamplesPerSecond;
1526                    sample->BlockAlign = sample->FrameSize;
1527                    sample->SamplesTotal = info.frames;
1528    
1529                    SF_INSTRUMENT instrument;
1530                    if (sf_command(hFile, SFC_GET_INSTRUMENT,
1531                                   &instrument, sizeof(instrument)) != SF_FALSE)
1532                    {
1533                        sample->MIDIUnityNote = instrument.basenote;
1534    
1535                        if (instrument.loop_count && instrument.loops[0].mode != SF_LOOP_NONE) {
1536                            sample->Loops = 1;
1537    
1538                            switch (instrument.loops[0].mode) {
1539                            case SF_LOOP_FORWARD:
1540                                sample->LoopType = gig::loop_type_normal;
1541                                break;
1542                            case SF_LOOP_BACKWARD:
1543                                sample->LoopType = gig::loop_type_backward;
1544                                break;
1545                            case SF_LOOP_ALTERNATING:
1546                                sample->LoopType = gig::loop_type_bidirectional;
1547                                break;
1548                            }
1549                            sample->LoopStart = instrument.loops[0].start;
1550                            sample->LoopEnd = instrument.loops[0].end;
1551                            sample->LoopPlayCount = instrument.loops[0].count;
1552                            sample->LoopSize = sample->LoopEnd - sample->LoopStart + 1;
1553                        }
1554                    }
1555    
1556                  // schedule resizing the sample (which will be done                  // schedule resizing the sample (which will be done
1557                  // physically when File::Save() is called)                  // physically when File::Save() is called)
1558                  sample->Resize(info.frames);                  sample->Resize(info.frames);
# Line 1002  void MainWindow::on_action_add_sample() Line 1568  void MainWindow::on_action_add_sample()
1568                  Gtk::TreeModel::iterator iterSample =                  Gtk::TreeModel::iterator iterSample =
1569                      m_refSamplesTreeModel->append(row.children());                      m_refSamplesTreeModel->append(row.children());
1570                  Gtk::TreeModel::Row rowSample = *iterSample;                  Gtk::TreeModel::Row rowSample = *iterSample;
1571                  rowSample[m_SamplesModel.m_col_name]   = sample->pInfo->Name.c_str();                  rowSample[m_SamplesModel.m_col_name]   = filename;
1572                  rowSample[m_SamplesModel.m_col_sample] = sample;                  rowSample[m_SamplesModel.m_col_sample] = sample;
1573                  rowSample[m_SamplesModel.m_col_group]  = NULL;                  rowSample[m_SamplesModel.m_col_group]  = NULL;
1574                  // close sound file                  // close sound file
1575                  sf_close(hFile);                  sf_close(hFile);
1576                    file_changed();
1577              } catch (std::string what) { // remember the files that made trouble (and their cause)              } catch (std::string what) { // remember the files that made trouble (and their cause)
1578                  if (error_files.size()) error_files += "\n";                  if (error_files.size()) error_files += "\n";
1579                  error_files += *iter += " (" + what + ")";                  error_files += *iter += " (" + what + ")";
# Line 1014  void MainWindow::on_action_add_sample() Line 1581  void MainWindow::on_action_add_sample()
1581          }          }
1582          // show error message box when some file(s) could not be opened / added          // show error message box when some file(s) could not be opened / added
1583          if (error_files.size()) {          if (error_files.size()) {
1584              Glib::ustring txt = "Could not add the following sample(s):\n" + error_files;              Glib::ustring txt = _("Could not add the following sample(s):\n") + error_files;
1585                Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR);
1586                msg.run();
1587            }
1588        }
1589    }
1590    
1591    void MainWindow::on_action_replace_all_samples_in_all_groups()
1592    {
1593        if (!file) return;
1594        Gtk::FileChooserDialog dialog(*this, _("Select Folder"),
1595                                      Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER);
1596        const char* str =
1597            _("This is a very specific function. It tries to replace all samples "
1598              "in the current gig file by samples located in the chosen "
1599              "directory.\n\n"
1600              "It works like this: For each sample in the gig file, it tries to "
1601              "find a sample file in the selected directory with the same name as "
1602              "the sample in the gig file. Optionally, you can add a filename "
1603              "extension below, which will be added to the filename expected to be "
1604              "found. That is, assume you have a gig file with a sample called "
1605              "'Snare', if you enter '.wav' below (like it's done by default), it "
1606              "expects to find a sample file called 'Snare.wav' and will replace "
1607              "the sample in the gig file accordingly. If you don't need an "
1608              "extension, blank the field below. Any gig sample where no "
1609              "appropriate sample file could be found will be reported and left "
1610              "untouched.\n");
1611    #if GTKMM_MAJOR_VERSION < 3
1612        view::WrapLabel description(str);
1613    #else
1614        Gtk::Label description(str);
1615        description.set_line_wrap();
1616    #endif
1617        Gtk::HBox entryArea;
1618        Gtk::Label entryLabel( _("Add filename extension: "), Gtk::ALIGN_START);
1619        Gtk::Entry postfixEntryBox;
1620        postfixEntryBox.set_text(".wav");
1621        entryArea.pack_start(entryLabel);
1622        entryArea.pack_start(postfixEntryBox);
1623        dialog.get_vbox()->pack_start(description, Gtk::PACK_SHRINK);
1624        dialog.get_vbox()->pack_start(entryArea, Gtk::PACK_SHRINK);
1625        description.show();
1626        entryArea.show_all();
1627        dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1628        dialog.add_button(_("Select"), Gtk::RESPONSE_OK);
1629        dialog.set_select_multiple(false);
1630        if (current_sample_dir != "") {
1631            dialog.set_current_folder(current_sample_dir);
1632        }
1633        if (dialog.run() == Gtk::RESPONSE_OK)
1634        {
1635            current_sample_dir = dialog.get_current_folder();
1636            Glib::ustring error_files;
1637            std::string folder = dialog.get_filename();
1638            for (gig::Sample* sample = file->GetFirstSample();
1639                 sample; sample = file->GetNextSample())
1640            {
1641                std::string filename =
1642                    folder + G_DIR_SEPARATOR_S + sample->pInfo->Name +
1643                    postfixEntryBox.get_text().raw();
1644                SF_INFO info;
1645                info.format = 0;
1646                SNDFILE* hFile = sf_open(filename.c_str(), SFM_READ, &info);
1647                try
1648                {
1649                    if (!hFile) throw std::string(_("could not open file"));
1650                    int bitdepth;
1651                    switch (info.format & 0xff) {
1652                        case SF_FORMAT_PCM_S8:
1653                        case SF_FORMAT_PCM_16:
1654                        case SF_FORMAT_PCM_U8:
1655                            bitdepth = 16;
1656                            break;
1657                        case SF_FORMAT_PCM_24:
1658                        case SF_FORMAT_PCM_32:
1659                        case SF_FORMAT_FLOAT:
1660                        case SF_FORMAT_DOUBLE:
1661                            bitdepth = 24;
1662                            break;
1663                        default:
1664                            sf_close(hFile);
1665                            throw std::string(_("format not supported"));
1666                    }
1667                    SampleImportItem sched_item;
1668                    sched_item.gig_sample  = sample;
1669                    sched_item.sample_path = filename;
1670                    m_SampleImportQueue.push_back(sched_item);
1671                    sf_close(hFile);
1672                    file_changed();
1673                }
1674                catch (std::string what)
1675                {
1676                    if (error_files.size()) error_files += "\n";
1677                        error_files += filename += " (" + what + ")";
1678                }
1679            }
1680            // show error message box when some file(s) could not be opened / added
1681            if (error_files.size()) {
1682                Glib::ustring txt =
1683                    _("Could not replace the following sample(s):\n") + error_files;
1684              Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR);              Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR);
1685              msg.run();              msg.run();
1686          }          }
# Line 1040  void MainWindow::on_action_remove_sample Line 1706  void MainWindow::on_action_remove_sample
1706                       pSample; pSample = group->GetNextSample()) {                       pSample; pSample = group->GetNextSample()) {
1707                      members.push_back(pSample);                      members.push_back(pSample);
1708                  }                  }
1709                    // notify everybody that we're going to remove these samples
1710                    samples_to_be_removed_signal.emit(members);
1711                  // delete the group in the .gig file including the                  // delete the group in the .gig file including the
1712                  // samples that belong to the group                  // samples that belong to the group
1713                  file->DeleteGroup(group);                  file->DeleteGroup(group);
1714                    // notify that we're done with removal
1715                    samples_removed_signal.emit();
1716                  // if sample(s) were just previously added, remove                  // if sample(s) were just previously added, remove
1717                  // them from the import queue                  // them from the import queue
1718                  for (std::list<gig::Sample*>::iterator member = members.begin();                  for (std::list<gig::Sample*>::iterator member = members.begin();
# Line 1057  void MainWindow::on_action_remove_sample Line 1727  void MainWindow::on_action_remove_sample
1727                          }                          }
1728                      }                      }
1729                  }                  }
1730                    file_changed();
1731              } else if (sample) {              } else if (sample) {
1732                    // notify everybody that we're going to remove this sample
1733                    std::list<gig::Sample*> lsamples;
1734                    lsamples.push_back(sample);
1735                    samples_to_be_removed_signal.emit(lsamples);
1736                  // remove sample from the .gig file                  // remove sample from the .gig file
1737                  file->DeleteSample(sample);                  file->DeleteSample(sample);
1738                    // notify that we're done with removal
1739                    samples_removed_signal.emit();
1740                  // if sample was just previously added, remove it from                  // if sample was just previously added, remove it from
1741                  // the import queue                  // the import queue
1742                  for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin();                  for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin();
# Line 1071  void MainWindow::on_action_remove_sample Line 1748  void MainWindow::on_action_remove_sample
1748                          break;                          break;
1749                      }                      }
1750                  }                  }
1751                    dimreg_changed();
1752                    file_changed();
1753              }              }
1754              // remove respective row(s) from samples tree view              // remove respective row(s) from samples tree view
1755              m_refSamplesTreeModel->erase(it);              m_refSamplesTreeModel->erase(it);
1756          } catch (RIFF::Exception e) {          } catch (RIFF::Exception e) {
1757                // pretend we're done with removal (i.e. to avoid dead locks)
1758                samples_removed_signal.emit();
1759                // show error message
1760              Gtk::MessageDialog msg(*this, e.Message.c_str(), false, Gtk::MESSAGE_ERROR);              Gtk::MessageDialog msg(*this, e.Message.c_str(), false, Gtk::MESSAGE_ERROR);
1761              msg.run();              msg.run();
1762          }          }
1763      }      }
1764  }  }
1765    
1766    // For some reason drag_data_get gets called two times for each
1767    // drag'n'drop (at least when target is an Entry). This work-around
1768    // makes sure the code in drag_data_get and drop_drag_data_received is
1769    // only executed once, as drag_begin only gets called once.
1770    void MainWindow::on_sample_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context)
1771    {
1772        first_call_to_drag_data_get = true;
1773    }
1774    
1775  void MainWindow::on_sample_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&,  void MainWindow::on_sample_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&,
1776                                                    Gtk::SelectionData& selection_data, guint, guint)                                                    Gtk::SelectionData& selection_data, guint, guint)
1777  {  {
1778        if (!first_call_to_drag_data_get) return;
1779        first_call_to_drag_data_get = false;
1780    
1781      // get selected sample      // get selected sample
1782      gig::Sample* sample = NULL;      gig::Sample* sample = NULL;
1783      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection();      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection();
# Line 1101  void MainWindow::on_sample_label_drop_dr Line 1795  void MainWindow::on_sample_label_drop_dr
1795      const Glib::RefPtr<Gdk::DragContext>& context, int, int,      const Glib::RefPtr<Gdk::DragContext>& context, int, int,
1796      const Gtk::SelectionData& selection_data, guint, guint time)      const Gtk::SelectionData& selection_data, guint, guint time)
1797  {  {
     gig::DimensionRegion* dimregion = m_DimRegionChooser.get_dimregion();  
1798      gig::Sample* sample = *((gig::Sample**) selection_data.get_data());      gig::Sample* sample = *((gig::Sample**) selection_data.get_data());
1799    
1800      if (sample && dimregion && selection_data.get_length() == sizeof(gig::Sample*)) {      if (sample && selection_data.get_length() == sizeof(gig::Sample*)) {
1801          if (sample != dimregion->pSample) {          std::cout << "Drop received sample \"" <<
1802              dimregion->pSample = sample;              sample->pInfo->Name << "\"" << std::endl;
1803              dimreg_edit.wSample->set_text(dimregion->pSample->pInfo->Name.c_str());          // drop success
1804              std::cout << "Drop received sample \"" <<          context->drop_reply(true, time);
1805                  dimregion->pSample->pInfo->Name.c_str() << "\"" << std::endl;  
1806              // drop success          //TODO: we should better move most of the following code to DimRegionEdit::set_sample()
1807              context->drop_reply(true, time);  
1808              return;          // notify everybody that we're going to alter the region
1809            gig::Region* region = m_RegionChooser.get_region();
1810            region_to_be_changed_signal.emit(region);
1811    
1812            // find the samplechannel dimension
1813            gig::dimension_def_t* stereo_dimension = 0;
1814            for (int i = 0 ; i < region->Dimensions ; i++) {
1815                if (region->pDimensionDefinitions[i].dimension ==
1816                    gig::dimension_samplechannel) {
1817                    stereo_dimension = &region->pDimensionDefinitions[i];
1818                    break;
1819                }
1820            }
1821            bool channels_changed = false;
1822            if (sample->Channels == 1 && stereo_dimension) {
1823                // remove the samplechannel dimension
1824                region->DeleteDimension(stereo_dimension);
1825                channels_changed = true;
1826                region_changed();
1827            }
1828            dimreg_edit.set_sample(sample);
1829    
1830            if (sample->Channels == 2 && !stereo_dimension) {
1831                // add samplechannel dimension
1832                gig::dimension_def_t dim;
1833                dim.dimension = gig::dimension_samplechannel;
1834                dim.bits = 1;
1835                dim.zones = 2;
1836                region->AddDimension(&dim);
1837                channels_changed = true;
1838                region_changed();
1839          }          }
1840            if (channels_changed) {
1841                // unmap all samples with wrong number of channels
1842                // TODO: maybe there should be a warning dialog for this
1843                for (int i = 0 ; i < region->DimensionRegions ; i++) {
1844                    gig::DimensionRegion* d = region->pDimensionRegions[i];
1845                    if (d->pSample && d->pSample->Channels != sample->Channels) {
1846                        gig::Sample* oldref = d->pSample;
1847                        d->pSample = NULL;
1848                        sample_ref_changed_signal.emit(oldref, NULL);
1849                    }
1850                }
1851            }
1852    
1853            // notify we're done with altering
1854            region_changed_signal.emit(region);
1855    
1856            file_changed();
1857    
1858            return;
1859      }      }
1860      // drop failed      // drop failed
1861      context->drop_reply(false, time);      context->drop_reply(false, time);
# Line 1127  void MainWindow::sample_name_changed(con Line 1869  void MainWindow::sample_name_changed(con
1869      gig::Group* group   = row[m_SamplesModel.m_col_group];      gig::Group* group   = row[m_SamplesModel.m_col_group];
1870      gig::Sample* sample = row[m_SamplesModel.m_col_sample];      gig::Sample* sample = row[m_SamplesModel.m_col_sample];
1871      if (group) {      if (group) {
1872          group->Name = name;          if (group->Name != name) {
1873                group->Name = name;
1874                printf("group name changed\n");
1875                file_changed();
1876            }
1877      } else if (sample) {      } else if (sample) {
1878          sample->pInfo->Name = name.raw();          if (sample->pInfo->Name != name.raw()) {
1879                sample->pInfo->Name = name.raw();
1880                printf("sample name changed\n");
1881                file_changed();
1882            }
1883      }      }
1884  }  }
1885    
# Line 1139  void MainWindow::instrument_name_changed Line 1889  void MainWindow::instrument_name_changed
1889      Gtk::TreeModel::Row row = *iter;      Gtk::TreeModel::Row row = *iter;
1890      Glib::ustring name = row[m_Columns.m_col_name];      Glib::ustring name = row[m_Columns.m_col_name];
1891      gig::Instrument* instrument = row[m_Columns.m_col_instr];      gig::Instrument* instrument = row[m_Columns.m_col_instr];
1892      if (instrument) instrument->pInfo->Name = name.raw();      if (instrument && instrument->pInfo->Name != name.raw()) {
1893            instrument->pInfo->Name = name.raw();
1894            file_changed();
1895        }
1896    }
1897    
1898    void MainWindow::set_file_is_shared(bool b) {
1899        this->file_is_shared = b;
1900    
1901        if (file_is_shared) {
1902            m_AttachedStateLabel.set_label(_("live-mode"));
1903            m_AttachedStateImage.set(
1904                Gdk::Pixbuf::create_from_xpm_data(status_attached_xpm)
1905            );
1906        } else {
1907            m_AttachedStateLabel.set_label(_("stand-alone"));
1908            m_AttachedStateImage.set(
1909                Gdk::Pixbuf::create_from_xpm_data(status_detached_xpm)
1910            );
1911        }
1912    }
1913    
1914    sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() {
1915        return file_structure_to_be_changed_signal;
1916    }
1917    
1918    sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_changed() {
1919        return file_structure_changed_signal;
1920    }
1921    
1922    sigc::signal<void, std::list<gig::Sample*> >& MainWindow::signal_samples_to_be_removed() {
1923        return samples_to_be_removed_signal;
1924    }
1925    
1926    sigc::signal<void>& MainWindow::signal_samples_removed() {
1927        return samples_removed_signal;
1928    }
1929    
1930    sigc::signal<void, gig::Region*>& MainWindow::signal_region_to_be_changed() {
1931        return region_to_be_changed_signal;
1932    }
1933    
1934    sigc::signal<void, gig::Region*>& MainWindow::signal_region_changed() {
1935        return region_changed_signal;
1936    }
1937    
1938    sigc::signal<void, gig::Sample*>& MainWindow::signal_sample_changed() {
1939        return sample_changed_signal;
1940    }
1941    
1942    sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/>& MainWindow::signal_sample_ref_changed() {
1943        return sample_ref_changed_signal;
1944    }
1945    
1946    sigc::signal<void, gig::DimensionRegion*>& MainWindow::signal_dimreg_to_be_changed() {
1947        return dimreg_to_be_changed_signal;
1948    }
1949    
1950    sigc::signal<void, gig::DimensionRegion*>& MainWindow::signal_dimreg_changed() {
1951        return dimreg_changed_signal;
1952    }
1953    
1954    sigc::signal<void, int/*key*/, int/*velocity*/>& MainWindow::signal_note_on() {
1955        return note_on_signal;
1956    }
1957    
1958    sigc::signal<void, int/*key*/, int/*velocity*/>& MainWindow::signal_note_off() {
1959        return note_off_signal;
1960    }
1961    
1962    sigc::signal<void, int/*key*/, int/*velocity*/>& MainWindow::signal_keyboard_key_hit() {
1963        return m_RegionChooser.signal_keyboard_key_hit();
1964    }
1965    
1966    sigc::signal<void, int/*key*/, int/*velocity*/>& MainWindow::signal_keyboard_key_released() {
1967        return m_RegionChooser.signal_keyboard_key_released();
1968  }  }

Legend:
Removed from v.1225  
changed lines
  Added in v.2398

  ViewVC Help
Powered by ViewVC