/[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 1328 by schoenebeck, Fri Sep 7 21:18:31 2007 UTC revision 1533 by persson, Sat Dec 1 10:21:07 2007 UTC
# Line 17  Line 17 
17   * 02110-1301 USA.   * 02110-1301 USA.
18   */   */
19    
 #include <libintl.h>  
20  #include <iostream>  #include <iostream>
21    
22  #include <gtkmm/filechooserdialog.h>  #include <gtkmm/filechooserdialog.h>
# Line 25  Line 24 
24  #include <gtkmm/stock.h>  #include <gtkmm/stock.h>
25  #include <gtkmm/targetentry.h>  #include <gtkmm/targetentry.h>
26  #include <gtkmm/main.h>  #include <gtkmm/main.h>
27    #include <gtkmm/toggleaction.h>
28    
29    #include "global.h"
30    
31  #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION >= 6) || GTKMM_MAJOR_VERSION > 2  #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION >= 6) || GTKMM_MAJOR_VERSION > 2
32  #define ABOUT_DIALOG  #define ABOUT_DIALOG
# Line 48  Glib::ustring filename_display_basename( Line 50  Glib::ustring filename_display_basename(
50    
51  #include "mainwindow.h"  #include "mainwindow.h"
52    
53  #define _(String) gettext(String)  #include "../../gfx/status_attached.xpm"
54    #include "../../gfx/status_detached.xpm"
55    
56  template<class T> inline std::string ToString(T o) {  template<class T> inline std::string ToString(T o) {
57      std::stringstream ss;      std::stringstream ss;
# Line 56  template<class T> inline std::string ToS Line 59  template<class T> inline std::string ToS
59      return ss.str();      return ss.str();
60  }  }
61    
62  MainWindow::MainWindow()  MainWindow::MainWindow() :
63        dimreg_label(_("Changes apply to:")),
64        dimreg_all_regions(_("all regions")),
65        dimreg_all_dimregs(_("all dimension splits")),
66        dimreg_stereo(_("both channels"))
67  {  {
68  //    set_border_width(5);  //    set_border_width(5);
69  //    set_default_size(400, 200);  //    set_default_size(400, 200);
# Line 86  MainWindow::MainWindow() Line 93  MainWindow::MainWindow()
93      m_TreeViewNotebook.set_size_request(300);      m_TreeViewNotebook.set_size_request(300);
94    
95      m_HPaned.add1(m_TreeViewNotebook);      m_HPaned.add1(m_TreeViewNotebook);
96      m_HPaned.add2(dimreg_edit);      dimreg_hbox.add(dimreg_label);
97        dimreg_hbox.add(dimreg_all_regions);
98        dimreg_hbox.add(dimreg_all_dimregs);
99        dimreg_stereo.set_active();
100        dimreg_hbox.add(dimreg_stereo);
101        dimreg_vbox.add(dimreg_edit);
102        dimreg_vbox.add(dimreg_hbox);
103        m_HPaned.add2(dimreg_vbox);
104    
105    
106      m_TreeViewNotebook.append_page(m_ScrolledWindowSamples, "Samples");      m_TreeViewNotebook.append_page(m_ScrolledWindowSamples, "Samples");
# Line 127  MainWindow::MainWindow() Line 141  MainWindow::MainWindow()
141                           *this, &MainWindow::on_action_quit));                           *this, &MainWindow::on_action_quit));
142      actionGroup->add(Gtk::Action::create("MenuInstrument", _("_Instrument")));      actionGroup->add(Gtk::Action::create("MenuInstrument", _("_Instrument")));
143    
144        actionGroup->add(Gtk::Action::create("MenuView", _("_View")));
145        Glib::RefPtr<Gtk::ToggleAction> toggle_action =
146            Gtk::ToggleAction::create("Statusbar", _("_Statusbar"));
147        toggle_action->set_active(true);
148        actionGroup->add(toggle_action,
149                         sigc::mem_fun(
150                             *this, &MainWindow::on_action_view_status_bar));
151    
152      action = Gtk::Action::create("MenuHelp", Gtk::Stock::HELP);      action = Gtk::Action::create("MenuHelp", Gtk::Stock::HELP);
153      actionGroup->add(Gtk::Action::create("MenuHelp",      actionGroup->add(Gtk::Action::create("MenuHelp",
154                                           action->property_label()));                                           action->property_label()));
# Line 182  MainWindow::MainWindow() Line 204  MainWindow::MainWindow()
204          "    </menu>"          "    </menu>"
205          "    <menu action='MenuInstrument'>"          "    <menu action='MenuInstrument'>"
206          "    </menu>"          "    </menu>"
207            "    <menu action='MenuView'>"
208            "      <menuitem action='Statusbar'/>"
209            "    </menu>"
210  #ifdef ABOUT_DIALOG  #ifdef ABOUT_DIALOG
211          "    <menu action='MenuHelp'>"          "    <menu action='MenuHelp'>"
212          "      <menuitem action='About'/>"          "      <menuitem action='About'/>"
# Line 211  MainWindow::MainWindow() Line 236  MainWindow::MainWindow()
236      m_VBox.pack_start(m_HPaned);      m_VBox.pack_start(m_HPaned);
237      m_VBox.pack_start(m_RegionChooser, Gtk::PACK_SHRINK);      m_VBox.pack_start(m_RegionChooser, Gtk::PACK_SHRINK);
238      m_VBox.pack_start(m_DimRegionChooser, Gtk::PACK_SHRINK);      m_VBox.pack_start(m_DimRegionChooser, Gtk::PACK_SHRINK);
239        m_VBox.pack_start(m_StatusBar, Gtk::PACK_SHRINK);
240    
241        // Status Bar:
242        m_StatusBar.pack_start(m_AttachedStateLabel, Gtk::PACK_SHRINK);
243        m_StatusBar.pack_start(m_AttachedStateImage, Gtk::PACK_SHRINK);
244        m_StatusBar.show();
245    
246      m_RegionChooser.signal_region_selected().connect(      m_RegionChooser.signal_region_selected().connect(
247          sigc::mem_fun(*this, &MainWindow::region_changed) );          sigc::mem_fun(*this, &MainWindow::region_changed) );
# Line 293  MainWindow::MainWindow() Line 324  MainWindow::MainWindow()
324      m_RegionChooser.signal_region_changed_signal().connect(      m_RegionChooser.signal_region_changed_signal().connect(
325          region_changed_signal.make_slot());          region_changed_signal.make_slot());
326    
327        dimreg_all_regions.signal_toggled().connect(
328            sigc::mem_fun(*this, &MainWindow::update_dimregs));
329        dimreg_all_dimregs.signal_toggled().connect(
330            sigc::mem_fun(*this, &MainWindow::dimreg_all_dimregs_toggled));
331        dimreg_stereo.signal_toggled().connect(
332            sigc::mem_fun(*this, &MainWindow::update_dimregs));
333    
334      file = 0;      file = 0;
335      file_is_changed = false;      file_is_changed = false;
336        set_file_is_shared(false);
337    
338      show_all_children();      show_all_children();
339    
# Line 308  MainWindow::~MainWindow() Line 347  MainWindow::~MainWindow()
347    
348  bool MainWindow::on_delete_event(GdkEventAny* event)  bool MainWindow::on_delete_event(GdkEventAny* event)
349  {  {
350      return file_is_changed && !close_confirmation_dialog();      return !file_is_shared && file_is_changed && !close_confirmation_dialog();
351  }  }
352    
353  void MainWindow::on_action_quit()  void MainWindow::on_action_quit()
354  {  {
355      if (file_is_changed && !close_confirmation_dialog()) return;      if (!file_is_shared && file_is_changed && !close_confirmation_dialog()) return;
356      hide();      hide();
357  }  }
358    
# Line 322  void MainWindow::region_changed() Line 361  void MainWindow::region_changed()
361      m_DimRegionChooser.set_region(m_RegionChooser.get_region());      m_DimRegionChooser.set_region(m_RegionChooser.get_region());
362  }  }
363    
364  void MainWindow::dimreg_changed()  gig::Instrument* MainWindow::get_instrument()
 {  
     dimreg_edit.set_dim_region(m_DimRegionChooser.get_dimregion());  
 }  
   
 void MainWindow::on_sel_change()  
365  {  {
366        gig::Instrument* instrument = 0;
367      Glib::RefPtr<Gtk::TreeSelection> tree_sel_ref = m_TreeView.get_selection();      Glib::RefPtr<Gtk::TreeSelection> tree_sel_ref = m_TreeView.get_selection();
368    
369      Gtk::TreeModel::iterator it = tree_sel_ref->get_selected();      Gtk::TreeModel::iterator it = tree_sel_ref->get_selected();
370      if (it) {      if (it) {
371          Gtk::TreeModel::Row row = *it;          Gtk::TreeModel::Row row = *it;
372          std::cout << row[m_Columns.m_col_name] << std::endl;          instrument = row[m_Columns.m_col_instr];
373        }
374        return instrument;
375    }
376    
377    void MainWindow::add_region_to_dimregs(gig::Region* region, bool stereo, bool all_dimregs)
378    {
379        if (all_dimregs) {
380            for (int i = 0 ; i < region->DimensionRegions ; i++) {
381                if (region->pDimensionRegions[i]) {
382                    dimreg_edit.dimregs.insert(region->pDimensionRegions[i]);
383                }
384            }
385        } else {
386            m_DimRegionChooser.get_dimregions(region, stereo, dimreg_edit.dimregs);
387        }
388    }
389    
390    void MainWindow::update_dimregs()
391    {
392        dimreg_edit.dimregs.clear();
393        bool all_regions = dimreg_all_regions.get_active();
394        bool stereo = dimreg_stereo.get_active();
395        bool all_dimregs = dimreg_all_dimregs.get_active();
396    
397          m_RegionChooser.set_instrument(row[m_Columns.m_col_instr]);      if (all_regions) {
398            gig::Instrument* instrument = get_instrument();
399            if (instrument) {
400                for (gig::Region* region = instrument->GetFirstRegion() ;
401                     region ;
402                     region = instrument->GetNextRegion()) {
403                    add_region_to_dimregs(region, stereo, all_dimregs);
404                }
405            }
406      } else {      } else {
407          m_RegionChooser.set_instrument(0);          gig::Region* region = m_RegionChooser.get_region();
408            if (region) {
409                add_region_to_dimregs(region, stereo, all_dimregs);
410            }
411      }      }
412  }  }
413    
414    void MainWindow::dimreg_all_dimregs_toggled()
415    {
416        dimreg_stereo.set_sensitive(!dimreg_all_dimregs.get_active());
417        update_dimregs();
418    }
419    
420    void MainWindow::dimreg_changed()
421    {
422        update_dimregs();
423        dimreg_edit.set_dim_region(m_DimRegionChooser.get_dimregion());
424    }
425    
426    void MainWindow::on_sel_change()
427    {
428        m_RegionChooser.set_instrument(get_instrument());
429    }
430    
431  void loader_progress_callback(gig::progress_t* progress)  void loader_progress_callback(gig::progress_t* progress)
432  {  {
433      Loader* loader = static_cast<Loader*>(progress->custom);      Loader* loader = static_cast<Loader*>(progress->custom);
# Line 427  void MainWindow::__clear() { Line 513  void MainWindow::__clear() {
513      m_refTreeModel->clear();      m_refTreeModel->clear();
514      m_refSamplesTreeModel->clear();      m_refSamplesTreeModel->clear();
515      // free libgig's gig::File instance      // free libgig's gig::File instance
516      if (file) {      if (file && !file_is_shared) delete file;
517          delete file;      file = NULL;
518          file = NULL;      set_file_is_shared(false);
     }  
519  }  }
520    
521  void MainWindow::on_action_file_new()  void MainWindow::on_action_file_new()
522  {  {
523      if (file_is_changed && !close_confirmation_dialog()) return;      if (!file_is_shared && file_is_changed && !close_confirmation_dialog()) return;
524    
525        if (file_is_shared && !leaving_shared_mode_dialog()) return;
526    
527      // clear all GUI elements      // clear all GUI elements
528      __clear();      __clear();
# Line 467  bool MainWindow::close_confirmation_dial Line 554  bool MainWindow::close_confirmation_dial
554      return response != Gtk::RESPONSE_CANCEL;      return response != Gtk::RESPONSE_CANCEL;
555  }  }
556    
557    bool MainWindow::leaving_shared_mode_dialog() {
558        Glib::ustring msg = _("Detach from sampler and proceed working stand-alone?");
559        Gtk::MessageDialog dialog(*this, msg, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE);
560    #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION >= 6) || GTKMM_MAJOR_VERSION > 2
561        dialog.set_secondary_text(
562            _("If you proceed to work on another instrument file, it won't be "
563              "used by the sampler until you tell the sampler explicitly to "
564              "load it.")
565       );
566    #endif
567        dialog.add_button(_("_Yes, Detach"), Gtk::RESPONSE_YES);
568        dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
569        dialog.set_default_response(Gtk::RESPONSE_CANCEL);
570        int response = dialog.run();
571        dialog.hide();
572        return response == Gtk::RESPONSE_YES;
573    }
574    
575  void MainWindow::on_action_file_open()  void MainWindow::on_action_file_open()
576  {  {
577      if (file_is_changed && !close_confirmation_dialog()) return;      if (!file_is_shared && file_is_changed && !close_confirmation_dialog()) return;
578    
579        if (file_is_shared && !leaving_shared_mode_dialog()) return;
580    
581      Gtk::FileChooserDialog dialog(*this, _("Open file"));      Gtk::FileChooserDialog dialog(*this, _("Open file"));
582      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
# Line 514  void MainWindow::load_instrument(gig::In Line 621  void MainWindow::load_instrument(gig::In
621      __clear();      __clear();
622      // load the instrument      // load the instrument
623      gig::File* pFile = (gig::File*) instr->GetParent();      gig::File* pFile = (gig::File*) instr->GetParent();
624      load_gig(pFile, 0 /*file name*/);      load_gig(pFile, 0 /*file name*/, true /*shared instrument*/);
625      //TODO: automatically select the given instrument      //TODO: automatically select the given instrument
626  }  }
627    
# Line 563  bool MainWindow::check_if_savable() Line 670  bool MainWindow::check_if_savable()
670  bool MainWindow::file_save()  bool MainWindow::file_save()
671  {  {
672      if (!check_if_savable()) return false;      if (!check_if_savable()) return false;
673      if (!file_has_name) return file_save_as();      if (!file_is_shared && !file_has_name) return file_save_as();
674    
675      std::cout << "Saving file\n" << std::flush;      std::cout << "Saving file\n" << std::flush;
676      file_structure_to_be_changed_signal.emit(this->file);      file_structure_to_be_changed_signal.emit(this->file);
# Line 575  bool MainWindow::file_save() Line 682  bool MainWindow::file_save()
682          }          }
683      } catch (RIFF::Exception e) {      } catch (RIFF::Exception e) {
684          file_structure_changed_signal.emit(this->file);          file_structure_changed_signal.emit(this->file);
685          Glib::ustring txt = "Could not save file: " + e.Message;          Glib::ustring txt = _("Could not save file: ") + e.Message;
686          Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR);          Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR);
687          msg.run();          msg.run();
688          return false;          return false;
# Line 630  bool MainWindow::file_save_as() Line 737  bool MainWindow::file_save_as()
737              file_is_changed = false;              file_is_changed = false;
738          } catch (RIFF::Exception e) {          } catch (RIFF::Exception e) {
739              file_structure_changed_signal.emit(this->file);              file_structure_changed_signal.emit(this->file);
740              Glib::ustring txt = "Could not save file: " + e.Message;              Glib::ustring txt = _("Could not save file: ") + e.Message;
741              Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR);              Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR);
742              msg.run();              msg.run();
743              return false;              return false;
# Line 727  void MainWindow::__import_queued_samples Line 834  void MainWindow::__import_queued_samples
834      }      }
835      // show error message box when some sample(s) could not be imported      // show error message box when some sample(s) could not be imported
836      if (error_files.size()) {      if (error_files.size()) {
837          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;
838          Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR);          Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR);
839          msg.run();          msg.run();
840      }      }
# Line 744  void MainWindow::on_action_help_about() Line 851  void MainWindow::on_action_help_about()
851  #ifdef ABOUT_DIALOG  #ifdef ABOUT_DIALOG
852      Gtk::AboutDialog dialog;      Gtk::AboutDialog dialog;
853      dialog.set_version(VERSION);      dialog.set_version(VERSION);
854        dialog.set_copyright("Copyright (C) 2006,2007 Andreas Persson");
855        dialog.set_comments(
856            "Released under the GNU General Public License.\n"
857            "\n"
858            "Please notice that this is still a very young instrument editor. "
859            "So better backup your Gigasampler files before editing them with "
860            "this application.\n"
861            "\n"
862            "Please report bugs to: http://bugs.linuxsampler.org"
863        );
864        dialog.set_website("http://www.linuxsampler.org");
865        dialog.set_website_label("http://www.linuxsampler.org");
866      dialog.run();      dialog.run();
867  #endif  #endif
868  }  }
# Line 804  void PropDialog::set_info(DLS::Info* inf Line 923  void PropDialog::set_info(DLS::Info* inf
923      entry[15].set_text(info->Subject);      entry[15].set_text(info->Subject);
924  }  }
925    
926    void InstrumentProps::set_IsDrum(bool value)
927    {
928        instrument->IsDrum = value;
929    }
930    
931    void InstrumentProps::set_MIDIBank(uint16_t value)
932    {
933        instrument->MIDIBank = value;
934    }
935    
936    void InstrumentProps::set_MIDIProgram(uint32_t value)
937    {
938        instrument->MIDIProgram = value;
939    }
940    
941    void InstrumentProps::set_DimensionKeyRange_low(uint8_t value)
942    {
943        instrument->DimensionKeyRange.low = value;
944        if (value > instrument->DimensionKeyRange.high) {
945            eDimensionKeyRangeHigh.set_value(value);
946        }
947    }
948    
949    void InstrumentProps::set_DimensionKeyRange_high(uint8_t value)
950    {
951        instrument->DimensionKeyRange.high = value;
952        if (value < instrument->DimensionKeyRange.low) {
953            eDimensionKeyRangeLow.set_value(value);
954        }
955    }
956    
957  void InstrumentProps::add_prop(BoolEntry& boolentry)  void InstrumentProps::add_prop(BoolEntry& boolentry)
958  {  {
959      table.attach(boolentry.widget, 0, 2, rowno, rowno + 1,      table.attach(boolentry.widget, 0, 2, rowno, rowno + 1,
960                   Gtk::FILL, Gtk::SHRINK);                   Gtk::FILL, Gtk::SHRINK);
961      rowno++;      rowno++;
     boolentry.signal_changed_by_user().connect(instrument_changed.make_slot());  
962  }  }
963    
964  void InstrumentProps::add_prop(BoolEntryPlus6& boolentry)  void InstrumentProps::add_prop(BoolEntryPlus6& boolentry)
# Line 817  void InstrumentProps::add_prop(BoolEntry Line 966  void InstrumentProps::add_prop(BoolEntry
966      table.attach(boolentry.widget, 0, 2, rowno, rowno + 1,      table.attach(boolentry.widget, 0, 2, rowno, rowno + 1,
967                   Gtk::FILL, Gtk::SHRINK);                   Gtk::FILL, Gtk::SHRINK);
968      rowno++;      rowno++;
     boolentry.signal_changed_by_user().connect(instrument_changed.make_slot());  
969  }  }
970    
971  void InstrumentProps::add_prop(LabelWidget& prop)  void InstrumentProps::add_prop(LabelWidget& prop)
# Line 827  void InstrumentProps::add_prop(LabelWidg Line 975  void InstrumentProps::add_prop(LabelWidg
975      table.attach(prop.widget, 1, 2, rowno, rowno + 1,      table.attach(prop.widget, 1, 2, rowno, rowno + 1,
976                   Gtk::FILL | Gtk::EXPAND, Gtk::SHRINK);                   Gtk::FILL | Gtk::EXPAND, Gtk::SHRINK);
977      rowno++;      rowno++;
     prop.signal_changed_by_user().connect(instrument_changed.make_slot());  
978  }  }
979    
980  InstrumentProps::InstrumentProps()  InstrumentProps::InstrumentProps()
# Line 844  InstrumentProps::InstrumentProps() Line 991  InstrumentProps::InstrumentProps()
991        ePitchbendRange("Pitchbend range", 0, 12),        ePitchbendRange("Pitchbend range", 0, 12),
992        ePianoReleaseMode("Piano release mode"),        ePianoReleaseMode("Piano release mode"),
993        eDimensionKeyRangeLow("Dimension key range low"),        eDimensionKeyRangeLow("Dimension key range low"),
994        eDimensionKeyRangeHigh("Dimension key range high")        eDimensionKeyRangeHigh("Dimension key range high"),
995          update_model(0)
996  {  {
997      set_title("Instrument properties");      set_title("Instrument properties");
998    
999        connect(eIsDrum, &InstrumentProps::set_IsDrum);
1000        connect(eMIDIBank, &InstrumentProps::set_MIDIBank);
1001        connect(eMIDIProgram, &InstrumentProps::set_MIDIProgram);
1002        connect(eAttenuation, &gig::Instrument::Attenuation);
1003        connect(eGainPlus6, &gig::Instrument::Attenuation);
1004        connect(eEffectSend, &gig::Instrument::EffectSend);
1005        connect(eFineTune, &gig::Instrument::FineTune);
1006        connect(ePitchbendRange, &gig::Instrument::PitchbendRange);
1007        connect(ePianoReleaseMode, &gig::Instrument::PianoReleaseMode);
1008        connect(eDimensionKeyRangeLow,
1009                &InstrumentProps::set_DimensionKeyRange_low);
1010        connect(eDimensionKeyRangeHigh,
1011                &InstrumentProps::set_DimensionKeyRange_high);
1012    
1013      rowno = 0;      rowno = 0;
1014      table.set_col_spacings(5);      table.set_col_spacings(5);
1015    
# Line 864  InstrumentProps::InstrumentProps() Line 1026  InstrumentProps::InstrumentProps()
1026      add_prop(eDimensionKeyRangeLow);      add_prop(eDimensionKeyRangeLow);
1027      add_prop(eDimensionKeyRangeHigh);      add_prop(eDimensionKeyRangeHigh);
1028    
     eDimensionKeyRangeLow.signal_changed_by_user().connect(  
         sigc::mem_fun(*this, &InstrumentProps::key_range_low_changed));  
     eDimensionKeyRangeHigh.signal_changed_by_user().connect(  
         sigc::mem_fun(*this, &InstrumentProps::key_range_high_changed));  
   
1029      add(vbox);      add(vbox);
1030      table.set_border_width(5);      table.set_border_width(5);
1031      vbox.pack_start(table);      vbox.pack_start(table);
# Line 891  InstrumentProps::InstrumentProps() Line 1048  InstrumentProps::InstrumentProps()
1048    
1049  void InstrumentProps::set_instrument(gig::Instrument* instrument)  void InstrumentProps::set_instrument(gig::Instrument* instrument)
1050  {  {
1051      eName.set_ptr(&instrument->pInfo->Name);      this->instrument = instrument;
     eIsDrum.set_ptr(&instrument->IsDrum);  
     eMIDIBank.set_ptr(&instrument->MIDIBank);  
     eMIDIProgram.set_ptr(&instrument->MIDIProgram);  
     eAttenuation.set_ptr(&instrument->Attenuation);  
     eGainPlus6.set_ptr(&instrument->Attenuation);  
     eEffectSend.set_ptr(&instrument->EffectSend);  
     eFineTune.set_ptr(&instrument->FineTune);  
     ePitchbendRange.set_ptr(&instrument->PitchbendRange);  
     ePianoReleaseMode.set_ptr(&instrument->PianoReleaseMode);  
     eDimensionKeyRangeLow.set_ptr(0);  
     eDimensionKeyRangeHigh.set_ptr(0);  
     eDimensionKeyRangeLow.set_ptr(&instrument->DimensionKeyRange.low);  
     eDimensionKeyRangeHigh.set_ptr(&instrument->DimensionKeyRange.high);  
 }  
   
 void InstrumentProps::key_range_low_changed()  
 {  
     double l = eDimensionKeyRangeLow.get_value();  
     double h = eDimensionKeyRangeHigh.get_value();  
     if (h < l) eDimensionKeyRangeHigh.set_value(l);  
 }  
1052    
1053  void InstrumentProps::key_range_high_changed()      update_model++;
1054  {      eName.set_ptr(&instrument->pInfo->Name);
1055      double l = eDimensionKeyRangeLow.get_value();      eIsDrum.set_value(instrument->IsDrum);
1056      double h = eDimensionKeyRangeHigh.get_value();      eMIDIBank.set_value(instrument->MIDIBank);
1057      if (h < l) eDimensionKeyRangeLow.set_value(h);      eMIDIProgram.set_value(instrument->MIDIProgram);
1058        eAttenuation.set_value(instrument->Attenuation);
1059        eGainPlus6.set_value(instrument->Attenuation);
1060        eEffectSend.set_value(instrument->EffectSend);
1061        eFineTune.set_value(instrument->FineTune);
1062        ePitchbendRange.set_value(instrument->PitchbendRange);
1063        ePianoReleaseMode.set_value(instrument->PianoReleaseMode);
1064        eDimensionKeyRangeLow.set_value(instrument->DimensionKeyRange.low);
1065        eDimensionKeyRangeHigh.set_value(instrument->DimensionKeyRange.high);
1066        update_model--;
1067  }  }
1068    
1069  sigc::signal<void> InstrumentProps::signal_instrument_changed()  sigc::signal<void>& InstrumentProps::signal_instrument_changed()
1070  {  {
1071      return instrument_changed;      return instrument_changed;
1072  }  }
# Line 934  void MainWindow::file_changed() Line 1079  void MainWindow::file_changed()
1079      }      }
1080  }  }
1081    
1082  void MainWindow::load_gig(gig::File* gig, const char* filename)  void MainWindow::load_gig(gig::File* gig, const char* filename, bool isSharedInstrument)
1083  {  {
1084      file = 0;      file = 0;
1085        set_file_is_shared(isSharedInstrument);
1086    
1087      this->filename = filename ? filename : _("Unsaved Gig File");      this->filename = filename ? filename : _("Unsaved Gig File");
1088      set_title(Glib::filename_display_basename(this->filename));      set_title(Glib::filename_display_basename(this->filename));
# Line 999  void MainWindow::load_gig(gig::File* gig Line 1145  void MainWindow::load_gig(gig::File* gig
1145    
1146  void MainWindow::show_instr_props()  void MainWindow::show_instr_props()
1147  {  {
1148      Glib::RefPtr<Gtk::TreeSelection> tree_sel_ref = m_TreeView.get_selection();      gig::Instrument* instrument = get_instrument();
1149      Gtk::TreeModel::iterator it = tree_sel_ref->get_selected();      if (instrument)
     if (it)  
1150      {      {
1151          Gtk::TreeModel::Row row = *it;          instrumentProps.set_instrument(instrument);
1152          if (row[m_Columns.m_col_instr])          instrumentProps.show();
1153          {          instrumentProps.deiconify();
             instrumentProps.set_instrument(row[m_Columns.m_col_instr]);  
             instrumentProps.show();  
             instrumentProps.deiconify();  
         }  
1154      }      }
1155  }  }
1156    
1157    void MainWindow::on_action_view_status_bar() {
1158        Gtk::CheckMenuItem* item =
1159            dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/Statusbar"));
1160        if (!item) {
1161            std::cerr << "/MenuBar/MenuView/Statusbar == NULL\n";
1162            return;
1163        }
1164        if (item->get_active()) m_StatusBar.show();
1165        else                    m_StatusBar.hide();
1166    }
1167    
1168  void MainWindow::on_button_release(GdkEventButton* button)  void MainWindow::on_button_release(GdkEventButton* button)
1169  {  {
1170      if (button->type == GDK_2BUTTON_PRESS) {      if (button->type == GDK_2BUTTON_PRESS) {
# Line 1070  void MainWindow::on_action_add_instrumen Line 1222  void MainWindow::on_action_add_instrumen
1222    
1223  void MainWindow::on_action_remove_instrument() {  void MainWindow::on_action_remove_instrument() {
1224      if (!file) return;      if (!file) return;
1225        if (file_is_shared) {
1226            Gtk::MessageDialog msg(
1227                *this,
1228                 _("You cannot delete an instrument from this file, since it's "
1229                   "currently used by the sampler."),
1230                 false, Gtk::MESSAGE_INFO
1231            );
1232            msg.run();
1233            return;
1234        }
1235    
1236      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection();      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection();
1237      Gtk::TreeModel::iterator it = sel->get_selected();      Gtk::TreeModel::iterator it = sel->get_selected();
1238      if (it) {      if (it) {
# Line 1256  void MainWindow::on_action_add_sample() Line 1419  void MainWindow::on_action_add_sample()
1419          }          }
1420          // 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
1421          if (error_files.size()) {          if (error_files.size()) {
1422              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;
1423              Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR);              Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR);
1424              msg.run();              msg.run();
1425          }          }
# Line 1429  void MainWindow::on_sample_label_drop_dr Line 1592  void MainWindow::on_sample_label_drop_dr
1592          // notify we're done with altering          // notify we're done with altering
1593          region_changed_signal.emit(region);          region_changed_signal.emit(region);
1594    
1595            file_changed();
1596    
1597          return;          return;
1598      }      }
1599      // drop failed      // drop failed
# Line 1469  void MainWindow::instrument_name_changed Line 1634  void MainWindow::instrument_name_changed
1634      }      }
1635  }  }
1636    
1637  sigc::signal<void, gig::File*> MainWindow::signal_file_structure_to_be_changed() {  void MainWindow::set_file_is_shared(bool b) {
1638        this->file_is_shared = b;
1639    
1640        if (file_is_shared) {
1641            m_AttachedStateLabel.set_label(_("live-mode"));
1642            m_AttachedStateImage.set(
1643                Gdk::Pixbuf::create_from_xpm_data(status_attached_xpm)
1644            );
1645        } else {
1646            m_AttachedStateLabel.set_label(_("stand-alone"));
1647            m_AttachedStateImage.set(
1648                Gdk::Pixbuf::create_from_xpm_data(status_detached_xpm)
1649            );
1650        }
1651    }
1652    
1653    sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() {
1654      return file_structure_to_be_changed_signal;      return file_structure_to_be_changed_signal;
1655  }  }
1656    
1657  sigc::signal<void, gig::File*> MainWindow::signal_file_structure_changed() {  sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_changed() {
1658      return file_structure_changed_signal;      return file_structure_changed_signal;
1659  }  }
1660    
1661  sigc::signal<void, std::list<gig::Sample*> > MainWindow::signal_samples_to_be_removed() {  sigc::signal<void, std::list<gig::Sample*> >& MainWindow::signal_samples_to_be_removed() {
1662      return samples_to_be_removed_signal;      return samples_to_be_removed_signal;
1663  }  }
1664    
1665  sigc::signal<void> MainWindow::signal_samples_removed() {  sigc::signal<void>& MainWindow::signal_samples_removed() {
1666      return samples_removed_signal;      return samples_removed_signal;
1667  }  }
1668    
1669  sigc::signal<void, gig::Region*> MainWindow::signal_region_to_be_changed() {  sigc::signal<void, gig::Region*>& MainWindow::signal_region_to_be_changed() {
1670      return region_to_be_changed_signal;      return region_to_be_changed_signal;
1671  }  }
1672    
1673  sigc::signal<void, gig::Region*> MainWindow::signal_region_changed() {  sigc::signal<void, gig::Region*>& MainWindow::signal_region_changed() {
1674      return region_changed_signal;      return region_changed_signal;
1675  }  }
1676    
1677  sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/> MainWindow::signal_sample_ref_changed() {  sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/>& MainWindow::signal_sample_ref_changed() {
1678      return sample_ref_changed_signal;      return sample_ref_changed_signal;
1679  }  }
1680    
1681  sigc::signal<void, gig::DimensionRegion*> MainWindow::signal_dimreg_to_be_changed() {  sigc::signal<void, gig::DimensionRegion*>& MainWindow::signal_dimreg_to_be_changed() {
1682      return dimreg_to_be_changed_signal;      return dimreg_to_be_changed_signal;
1683  }  }
1684    
1685  sigc::signal<void, gig::DimensionRegion*> MainWindow::signal_dimreg_changed() {  sigc::signal<void, gig::DimensionRegion*>& MainWindow::signal_dimreg_changed() {
1686      return dimreg_changed_signal;      return dimreg_changed_signal;
1687  }  }

Legend:
Removed from v.1328  
changed lines
  Added in v.1533

  ViewVC Help
Powered by ViewVC