/[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 2442 by persson, Sun Apr 14 07:29:59 2013 UTC revision 2536 by schoenebeck, Mon Apr 21 17:49:17 2014 UTC
# Line 1  Line 1 
1  /*  /*
2   * Copyright (C) 2006-2013 Andreas Persson   * Copyright (C) 2006-2014 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 89  MainWindow::MainWindow() : Line 89  MainWindow::MainWindow() :
89      dimreg_vbox.pack_start(dimreg_hbox, Gtk::PACK_SHRINK);      dimreg_vbox.pack_start(dimreg_hbox, Gtk::PACK_SHRINK);
90      m_HPaned.add2(dimreg_vbox);      m_HPaned.add2(dimreg_vbox);
91    
92        dimreg_label.set_tooltip_text(_("To automatically apply your changes above globally to the entire instrument, check all 3 check boxes on the right."));
93        dimreg_all_regions.set_tooltip_text(_("If checked: all changes you perform above will automatically be applied to all regions of this instrument as well."));
94        dimreg_all_dimregs.set_tooltip_text(_("If checked: all changes you perform above will automatically be applied as well to all dimension splits of the region selected below."));
95        dimreg_stereo.set_tooltip_text(_("If checked: all changes you perform above will automatically be applied to both audio channel splits (only if a \"stereo\" dimension is defined below)."));
96    
97      m_TreeViewNotebook.append_page(m_ScrolledWindowSamples, _("Samples"));      m_TreeViewNotebook.append_page(m_ScrolledWindowSamples, _("Samples"));
98      m_TreeViewNotebook.append_page(m_ScrolledWindow, _("Instruments"));      m_TreeViewNotebook.append_page(m_ScrolledWindow, _("Instruments"));
# Line 123  MainWindow::MainWindow() : Line 127  MainWindow::MainWindow() :
127                                           Gtk::Stock::PROPERTIES),                                           Gtk::Stock::PROPERTIES),
128                       sigc::mem_fun(                       sigc::mem_fun(
129                           *this, &MainWindow::show_instr_props));                           *this, &MainWindow::show_instr_props));
130        actionGroup->add(Gtk::Action::create("MidiRules",
131                                             _("_Midi Rules")),
132                         sigc::mem_fun(
133                             *this, &MainWindow::show_midi_rules));
134      actionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT),      actionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT),
135                       sigc::mem_fun(                       sigc::mem_fun(
136                           *this, &MainWindow::on_action_quit));                           *this, &MainWindow::on_action_quit));
137      actionGroup->add(Gtk::Action::create("MenuInstrument", _("_Instrument")));      actionGroup->add(Gtk::Action::create("MenuInstrument", _("_Instrument")));
138    
139      actionGroup->add(Gtk::Action::create("MenuView", _("_View")));  
140        actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit")));
141    
142      Glib::RefPtr<Gtk::ToggleAction> toggle_action =      Glib::RefPtr<Gtk::ToggleAction> toggle_action =
143            Gtk::ToggleAction::create("CopySampleUnity", _("Copy Sample's _Unity Note"));
144        toggle_action->set_active(true);
145        actionGroup->add(toggle_action);
146    
147        toggle_action =
148            Gtk::ToggleAction::create("CopySampleTune", _("Copy Sample's _Fine Tune"));
149        toggle_action->set_active(true);
150        actionGroup->add(toggle_action);
151    
152        toggle_action =
153            Gtk::ToggleAction::create("CopySampleLoop", _("Copy Sample's _Loop Points"));
154        toggle_action->set_active(true);
155        actionGroup->add(toggle_action);
156    
157    
158        actionGroup->add(Gtk::Action::create("MenuView", _("_View")));
159        toggle_action =
160          Gtk::ToggleAction::create("Statusbar", _("_Statusbar"));          Gtk::ToggleAction::create("Statusbar", _("_Statusbar"));
161      toggle_action->set_active(true);      toggle_action->set_active(true);
162      actionGroup->add(toggle_action,      actionGroup->add(toggle_action,
# Line 196  MainWindow::MainWindow() : Line 223  MainWindow::MainWindow() :
223          "      <separator/>"          "      <separator/>"
224          "      <menuitem action='Quit'/>"          "      <menuitem action='Quit'/>"
225          "    </menu>"          "    </menu>"
226            "    <menu action='MenuEdit'>"
227            "      <menuitem action='CopySampleUnity'/>"
228            "      <menuitem action='CopySampleTune'/>"
229            "      <menuitem action='CopySampleLoop'/>"
230            "    </menu>"
231          "    <menu action='MenuInstrument'>"          "    <menu action='MenuInstrument'>"
232          "    </menu>"          "    </menu>"
233          "    <menu action='MenuView'>"          "    <menu action='MenuView'>"
# Line 207  MainWindow::MainWindow() : Line 239  MainWindow::MainWindow() :
239          "  </menubar>"          "  </menubar>"
240          "  <popup name='PopupMenu'>"          "  <popup name='PopupMenu'>"
241          "    <menuitem action='InstrProperties'/>"          "    <menuitem action='InstrProperties'/>"
242            "    <menuitem action='MidiRules'/>"
243          "    <menuitem action='AddInstrument'/>"          "    <menuitem action='AddInstrument'/>"
244          "    <menuitem action='DupInstrument'/>"          "    <menuitem action='DupInstrument'/>"
245          "    <separator/>"          "    <separator/>"
# Line 224  MainWindow::MainWindow() : Line 257  MainWindow::MainWindow() :
257      uiManager->add_ui_from_string(ui_info);      uiManager->add_ui_from_string(ui_info);
258    
259      popup_menu = dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/PopupMenu"));      popup_menu = dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/PopupMenu"));
260        
261        // Set tooltips for menu items (for some reason, setting a tooltip on the
262        // respective Gtk::Action objects above will simply be ignored, no matter
263        // if using Gtk::Action::set_tooltip() or passing the tooltip string on
264        // Gtk::Action::create()).
265        {
266            Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(
267                uiManager->get_widget("/MenuBar/MenuEdit/CopySampleUnity"));
268            item->set_tooltip_text(_("Used when dragging a sample to a region's sample reference field. You may disable this for example if you want to replace an existing sample in a region with a new sample, but don't want that the region's current unity note setting will be altered by this action."));
269        }
270        {
271            Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(
272                uiManager->get_widget("/MenuBar/MenuEdit/CopySampleTune"));
273            item->set_tooltip_text(_("Used when dragging a sample to a region's sample reference field. You may disable this for example if you want to replace an existing sample in a region with a new sample, but don't want that the region's current sample playback tuning will be altered by this action."));
274        }
275        {
276            Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(
277                uiManager->get_widget("/MenuBar/MenuEdit/CopySampleLoop"));
278            item->set_tooltip_text(_("Used when dragging a sample to a region's sample reference field. You may disable this for example if you want to replace an existing sample in a region with a new sample, but don't want that the region's current loop informations to be altered by this action."));
279        }
280    
281      instrument_menu = static_cast<Gtk::MenuItem*>(      instrument_menu = static_cast<Gtk::MenuItem*>(
282          uiManager->get_widget("/MenuBar/MenuInstrument"))->get_submenu();          uiManager->get_widget("/MenuBar/MenuInstrument"))->get_submenu();
# Line 252  MainWindow::MainWindow() : Line 305  MainWindow::MainWindow() :
305      // Create the Tree model:      // Create the Tree model:
306      m_refTreeModel = Gtk::ListStore::create(m_Columns);      m_refTreeModel = Gtk::ListStore::create(m_Columns);
307      m_TreeView.set_model(m_refTreeModel);      m_TreeView.set_model(m_refTreeModel);
308        m_TreeView.set_tooltip_text(_("Right click here for actions on instruments & MIDI Rules."));
309      instrument_name_connection = m_refTreeModel->signal_row_changed().connect(      instrument_name_connection = m_refTreeModel->signal_row_changed().connect(
310          sigc::mem_fun(*this, &MainWindow::instrument_name_changed)          sigc::mem_fun(*this, &MainWindow::instrument_name_changed)
311      );      );
# Line 263  MainWindow::MainWindow() : Line 317  MainWindow::MainWindow() :
317      // create samples treeview (including its data model)      // create samples treeview (including its data model)
318      m_refSamplesTreeModel = SamplesTreeStore::create(m_SamplesModel);      m_refSamplesTreeModel = SamplesTreeStore::create(m_SamplesModel);
319      m_TreeViewSamples.set_model(m_refSamplesTreeModel);      m_TreeViewSamples.set_model(m_refSamplesTreeModel);
320        m_TreeViewSamples.set_tooltip_text(_("To actually use a sample, drag it from this list view to \"Sample\" -> \"Sample:\" on the region's settings pane on the right.\n\nRight click here for more actions on samples."));
321      // m_TreeViewSamples.set_reorderable();      // m_TreeViewSamples.set_reorderable();
322      m_TreeViewSamples.append_column_editable("Samples", m_SamplesModel.m_col_name);      m_TreeViewSamples.append_column_editable("Samples", m_SamplesModel.m_col_name);
323      m_TreeViewSamples.set_headers_visible(false);      m_TreeViewSamples.set_headers_visible(false);
# Line 297  MainWindow::MainWindow() : Line 352  MainWindow::MainWindow() :
352          sigc::mem_fun(*this, &MainWindow::file_changed));          sigc::mem_fun(*this, &MainWindow::file_changed));
353      propDialog.signal_changed().connect(      propDialog.signal_changed().connect(
354          sigc::mem_fun(*this, &MainWindow::file_changed));          sigc::mem_fun(*this, &MainWindow::file_changed));
355        midiRules.signal_changed().connect(
356            sigc::mem_fun(*this, &MainWindow::file_changed));
357    
358      dimreg_edit.signal_dimreg_to_be_changed().connect(      dimreg_edit.signal_dimreg_to_be_changed().connect(
359          dimreg_to_be_changed_signal.make_slot());          dimreg_to_be_changed_signal.make_slot());
# Line 545  void MainWindow::on_action_file_new() Line 602  void MainWindow::on_action_file_new()
602      gig::File* pFile = new gig::File;      gig::File* pFile = new gig::File;
603      // already add one new instrument by default      // already add one new instrument by default
604      gig::Instrument* pInstrument = pFile->AddInstrument();      gig::Instrument* pInstrument = pFile->AddInstrument();
605      pInstrument->pInfo->Name = _("Unnamed Instrument");      pInstrument->pInfo->Name = gig_from_utf8(_("Unnamed Instrument"));
606      // update GUI with that new gig::File      // update GUI with that new gig::File
607      load_gig(pFile, 0 /*no file name yet*/);      load_gig(pFile, 0 /*no file name yet*/);
608  }  }
# Line 906  void MainWindow::on_action_help_about() Line 963  void MainWindow::on_action_help_about()
963      dialog.set_name("Gigedit");      dialog.set_name("Gigedit");
964  #endif  #endif
965      dialog.set_version(VERSION);      dialog.set_version(VERSION);
966      dialog.set_copyright("Copyright (C) 2006-2013 Andreas Persson");      dialog.set_copyright("Copyright (C) 2006-2014 Andreas Persson");
967      dialog.set_comments(_(      const std::string sComment =
968          "Released under the GNU General Public License.\n"          _("Built " __DATE__ "\nUsing ") +
969          "\n"          ::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" +
970          "Please notice that this is still a very young instrument editor. "          _(
971          "So better backup your Gigasampler files before editing them with "              "Gigedit is released under the GNU General Public License.\n"
972          "this application.\n"              "\n"
973          "\n"              "Please notice that this is still a very young instrument editor. "
974          "Please report bugs to: http://bugs.linuxsampler.org")              "So better backup your Gigasampler files before editing them with "
975      );              "this application.\n"
976                "\n"
977                "Please report bugs to: http://bugs.linuxsampler.org"
978            );
979        dialog.set_comments(sComment.c_str());
980      dialog.set_website("http://www.linuxsampler.org");      dialog.set_website("http://www.linuxsampler.org");
981      dialog.set_website_label("http://www.linuxsampler.org");      dialog.set_website_label("http://www.linuxsampler.org");
982      dialog.run();      dialog.run();
# Line 1003  void PropDialog::set_info(DLS::Info* inf Line 1064  void PropDialog::set_info(DLS::Info* inf
1064  }  }
1065    
1066    
1067    void InstrumentProps::set_Name(const gig::String& name)
1068    {
1069        m->pInfo->Name = name;
1070    }
1071    
1072    void InstrumentProps::update_name()
1073    {
1074        update_model++;
1075        eName.set_value(m->pInfo->Name);
1076        update_model--;
1077    }
1078    
1079  void InstrumentProps::set_IsDrum(bool value)  void InstrumentProps::set_IsDrum(bool value)
1080  {  {
1081      m->IsDrum = value;      m->IsDrum = value;
# Line 1045  InstrumentProps::InstrumentProps() : Line 1118  InstrumentProps::InstrumentProps() :
1118            "\"keyswitching\" dimension")            "\"keyswitching\" dimension")
1119      );      );
1120    
1121        connect(eName, &InstrumentProps::set_Name);
1122      connect(eIsDrum, &InstrumentProps::set_IsDrum);      connect(eIsDrum, &InstrumentProps::set_IsDrum);
1123      connect(eMIDIBank, &InstrumentProps::set_MIDIBank);      connect(eMIDIBank, &InstrumentProps::set_MIDIBank);
1124      connect(eMIDIProgram, &InstrumentProps::set_MIDIProgram);      connect(eMIDIProgram, &InstrumentProps::set_MIDIProgram);
# Line 1057  InstrumentProps::InstrumentProps() : Line 1131  InstrumentProps::InstrumentProps() :
1131      connect(eDimensionKeyRangeLow, eDimensionKeyRangeHigh,      connect(eDimensionKeyRangeLow, eDimensionKeyRangeHigh,
1132              &gig::Instrument::DimensionKeyRange);              &gig::Instrument::DimensionKeyRange);
1133    
1134        eName.signal_value_changed().connect(sig_name_changed.make_slot());
1135    
1136      table.set_col_spacings(5);      table.set_col_spacings(5);
1137    
1138      table.add(eName);      table.add(eName);
# Line 1097  void InstrumentProps::set_instrument(gig Line 1173  void InstrumentProps::set_instrument(gig
1173      update(instrument);      update(instrument);
1174    
1175      update_model++;      update_model++;
1176        eName.set_value(instrument->pInfo->Name);
1177      eIsDrum.set_value(instrument->IsDrum);      eIsDrum.set_value(instrument->IsDrum);
1178      eMIDIBank.set_value(instrument->MIDIBank);      eMIDIBank.set_value(instrument->MIDIBank);
1179      eMIDIProgram.set_value(instrument->MIDIProgram);      eMIDIProgram.set_value(instrument->MIDIProgram);
# Line 1127  void MainWindow::load_gig(gig::File* gig Line 1204  void MainWindow::load_gig(gig::File* gig
1204      instrument_name_connection.block();      instrument_name_connection.block();
1205      for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ;      for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ;
1206           instrument = gig->GetNextInstrument()) {           instrument = gig->GetNextInstrument()) {
1207          Glib::ustring name(instrument->pInfo->Name);          Glib::ustring name(gig_to_utf8(instrument->pInfo->Name));
1208    
1209          Gtk::TreeModel::iterator iter = m_refTreeModel->append();          Gtk::TreeModel::iterator iter = m_refTreeModel->append();
1210          Gtk::TreeModel::Row row = *iter;          Gtk::TreeModel::Row row = *iter;
# Line 1143  void MainWindow::load_gig(gig::File* gig Line 1220  void MainWindow::load_gig(gig::File* gig
1220          if (group->Name != "") {          if (group->Name != "") {
1221              Gtk::TreeModel::iterator iterGroup = m_refSamplesTreeModel->append();              Gtk::TreeModel::iterator iterGroup = m_refSamplesTreeModel->append();
1222              Gtk::TreeModel::Row rowGroup = *iterGroup;              Gtk::TreeModel::Row rowGroup = *iterGroup;
1223              rowGroup[m_SamplesModel.m_col_name]   = group->Name.c_str();              rowGroup[m_SamplesModel.m_col_name]   = gig_to_utf8(group->Name);
1224              rowGroup[m_SamplesModel.m_col_group]  = group;              rowGroup[m_SamplesModel.m_col_group]  = group;
1225              rowGroup[m_SamplesModel.m_col_sample] = NULL;              rowGroup[m_SamplesModel.m_col_sample] = NULL;
1226              for (gig::Sample* sample = group->GetFirstSample();              for (gig::Sample* sample = group->GetFirstSample();
# Line 1151  void MainWindow::load_gig(gig::File* gig Line 1228  void MainWindow::load_gig(gig::File* gig
1228                  Gtk::TreeModel::iterator iterSample =                  Gtk::TreeModel::iterator iterSample =
1229                      m_refSamplesTreeModel->append(rowGroup.children());                      m_refSamplesTreeModel->append(rowGroup.children());
1230                  Gtk::TreeModel::Row rowSample = *iterSample;                  Gtk::TreeModel::Row rowSample = *iterSample;
1231                  rowSample[m_SamplesModel.m_col_name]   = sample->pInfo->Name.c_str();                  rowSample[m_SamplesModel.m_col_name] =
1232                        gig_to_utf8(sample->pInfo->Name);
1233                  rowSample[m_SamplesModel.m_col_sample] = sample;                  rowSample[m_SamplesModel.m_col_sample] = sample;
1234                  rowSample[m_SamplesModel.m_col_group]  = NULL;                  rowSample[m_SamplesModel.m_col_group]  = NULL;
1235              }              }
# Line 1163  void MainWindow::load_gig(gig::File* gig Line 1241  void MainWindow::load_gig(gig::File* gig
1241      // select the first instrument      // select the first instrument
1242      m_TreeView.get_selection()->select(Gtk::TreePath("0"));      m_TreeView.get_selection()->select(Gtk::TreePath("0"));
1243    
1244        instr_props_set_instrument();
1245      gig::Instrument* instrument = get_instrument();      gig::Instrument* instrument = get_instrument();
1246      if (instrument) {      if (instrument) {
1247            midiRules.set_instrument(instrument);
1248        }
1249    }
1250    
1251    bool MainWindow::instr_props_set_instrument()
1252    {
1253        instrumentProps.signal_name_changed().clear();
1254    
1255        Gtk::TreeModel::const_iterator it =
1256            m_TreeView.get_selection()->get_selected();
1257        if (it) {
1258            Gtk::TreeModel::Row row = *it;
1259            gig::Instrument* instrument = row[m_Columns.m_col_instr];
1260    
1261          instrumentProps.set_instrument(instrument);          instrumentProps.set_instrument(instrument);
1262    
1263            // make sure instrument tree is updated when user changes the
1264            // instrument name in instrument properties window
1265            instrumentProps.signal_name_changed().connect(
1266                sigc::bind(
1267                    sigc::mem_fun(*this,
1268                                  &MainWindow::instr_name_changed_by_instr_props),
1269                    it));
1270        } else {
1271            instrumentProps.hide();
1272      }      }
1273        return it;
1274  }  }
1275    
1276  void MainWindow::show_instr_props()  void MainWindow::show_instr_props()
1277  {  {
1278      gig::Instrument* instrument = get_instrument();      if (instr_props_set_instrument()) {
     if (instrument)  
     {  
         instrumentProps.set_instrument(instrument);  
1279          instrumentProps.show();          instrumentProps.show();
1280          instrumentProps.deiconify();          instrumentProps.deiconify();
1281      }      }
1282  }  }
1283    
1284    void MainWindow::instr_name_changed_by_instr_props(Gtk::TreeModel::iterator& it)
1285    {
1286        Gtk::TreeModel::Row row = *it;
1287        Glib::ustring name = row[m_Columns.m_col_name];
1288    
1289        gig::Instrument* instrument = row[m_Columns.m_col_instr];
1290        Glib::ustring gigname(gig_to_utf8(instrument->pInfo->Name));
1291        if (gigname != name) {
1292            row[m_Columns.m_col_name] = gigname;
1293        }
1294    }
1295    
1296    void MainWindow::show_midi_rules()
1297    {
1298        if (gig::Instrument* instrument = get_instrument())
1299        {
1300            midiRules.set_instrument(instrument);
1301            midiRules.show();
1302            midiRules.deiconify();
1303        }
1304    }
1305    
1306  void MainWindow::on_action_view_status_bar() {  void MainWindow::on_action_view_status_bar() {
1307      Gtk::CheckMenuItem* item =      Gtk::CheckMenuItem* item =
1308          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/Statusbar"));          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/Statusbar"));
# Line 1191  void MainWindow::on_action_view_status_b Line 1314  void MainWindow::on_action_view_status_b
1314      else                    m_StatusBar.hide();      else                    m_StatusBar.hide();
1315  }  }
1316    
1317    bool MainWindow::is_copy_samples_unity_note_enabled() const {
1318        Gtk::CheckMenuItem* item =
1319            dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleUnity"));
1320        if (!item) {
1321            std::cerr << "/MenuBar/MenuEdit/CopySampleUnity == NULL\n";
1322            return true;
1323        }
1324        return item->get_active();
1325    }
1326    
1327    bool MainWindow::is_copy_samples_fine_tune_enabled() const {
1328        Gtk::CheckMenuItem* item =
1329            dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleTune"));
1330        if (!item) {
1331            std::cerr << "/MenuBar/MenuEdit/CopySampleTune == NULL\n";
1332            return true;
1333        }
1334        return item->get_active();
1335    }
1336    
1337    bool MainWindow::is_copy_samples_loop_enabled() const {
1338        Gtk::CheckMenuItem* item =
1339            dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleLoop"));
1340        if (!item) {
1341            std::cerr << "/MenuBar/MenuEdit/CopySampleLoop == NULL\n";
1342            return true;
1343        }
1344        return item->get_active();
1345    }
1346    
1347  void MainWindow::on_button_release(GdkEventButton* button)  void MainWindow::on_button_release(GdkEventButton* button)
1348  {  {
1349      if (button->type == GDK_2BUTTON_PRESS) {      if (button->type == GDK_2BUTTON_PRESS) {
1350          show_instr_props();          show_instr_props();
1351      } else if (button->type == GDK_BUTTON_PRESS && button->button == 3) {      } else if (button->type == GDK_BUTTON_PRESS && button->button == 3) {
1352            // gig v2 files have no midi rules
1353            static_cast<Gtk::MenuItem*>(
1354                uiManager->get_widget("/PopupMenu/MidiRules"))->set_sensitive(
1355                    !(file->pVersion && file->pVersion->major == 2));
1356          popup_menu->popup(button->button, button->time);          popup_menu->popup(button->button, button->time);
1357      }      }
1358  }  }
# Line 1276  void MainWindow::remove_instrument_from_ Line 1433  void MainWindow::remove_instrument_from_
1433  }  }
1434    
1435  void MainWindow::add_instrument(gig::Instrument* instrument) {  void MainWindow::add_instrument(gig::Instrument* instrument) {
1436      const char* name = instrument->pInfo->Name.c_str();      const Glib::ustring name(gig_to_utf8(instrument->pInfo->Name));
1437    
1438      // update instrument tree view      // update instrument tree view
1439      instrument_name_connection.block();      instrument_name_connection.block();
# Line 1298  void MainWindow::on_action_add_instrumen Line 1455  void MainWindow::on_action_add_instrumen
1455      if (!file) return;      if (!file) return;
1456      gig::Instrument* instrument = file->AddInstrument();      gig::Instrument* instrument = file->AddInstrument();
1457      __instrument_indexer++;      __instrument_indexer++;
1458      instrument->pInfo->Name =      instrument->pInfo->Name = gig_from_utf8(_("Unnamed Instrument ") +
1459          _("Unnamed Instrument ") + ToString(__instrument_indexer);                                              ToString(__instrument_indexer));
1460    
1461      add_instrument(instrument);      add_instrument(instrument);
1462  }  }
# Line 1319  void MainWindow::on_action_duplicate_ins Line 1476  void MainWindow::on_action_duplicate_ins
1476      // duplicate the orginal instrument      // duplicate the orginal instrument
1477      gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig);      gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig);
1478      instrNew->pInfo->Name =      instrNew->pInfo->Name =
1479          instrOrig->pInfo->Name + " (" + _("Copy") + ")";          instrOrig->pInfo->Name +
1480            gig_from_utf8(Glib::ustring(" (") + _("Copy") + ")");
1481    
1482      add_instrument(instrNew);      add_instrument(instrNew);
1483  }  }
# Line 1366  void MainWindow::on_action_remove_instru Line 1524  void MainWindow::on_action_remove_instru
1524                      Gtk::TreePath(ToString(index)));                      Gtk::TreePath(ToString(index)));
1525              }              }
1526  #endif  #endif
1527                instr_props_set_instrument();
1528              instr = get_instrument();              instr = get_instrument();
1529              if (instr) {              if (instr) {
1530                  instrumentProps.set_instrument(instr);                  midiRules.set_instrument(instr);
1531              } else {              } else {
1532                  instrumentProps.hide();                  midiRules.hide();
1533              }              }
1534          } catch (RIFF::Exception e) {          } catch (RIFF::Exception e) {
1535              Gtk::MessageDialog msg(*this, e.Message.c_str(), false, Gtk::MESSAGE_ERROR);              Gtk::MessageDialog msg(*this, e.Message.c_str(), false, Gtk::MESSAGE_ERROR);
# Line 1391  void MainWindow::on_action_add_group() { Line 1550  void MainWindow::on_action_add_group() {
1550      static int __sample_indexer = 0;      static int __sample_indexer = 0;
1551      if (!file) return;      if (!file) return;
1552      gig::Group* group = file->AddGroup();      gig::Group* group = file->AddGroup();
1553      group->Name = _("Unnamed Group");      group->Name = gig_from_utf8(_("Unnamed Group"));
1554      if (__sample_indexer) group->Name += " " + ToString(__sample_indexer);      if (__sample_indexer) group->Name += " " + ToString(__sample_indexer);
1555      __sample_indexer++;      __sample_indexer++;
1556      // update sample tree view      // update sample tree view
1557      Gtk::TreeModel::iterator iterGroup = m_refSamplesTreeModel->append();      Gtk::TreeModel::iterator iterGroup = m_refSamplesTreeModel->append();
1558      Gtk::TreeModel::Row rowGroup = *iterGroup;      Gtk::TreeModel::Row rowGroup = *iterGroup;
1559      rowGroup[m_SamplesModel.m_col_name] = group->Name.c_str();      rowGroup[m_SamplesModel.m_col_name] = gig_to_utf8(group->Name);
1560      rowGroup[m_SamplesModel.m_col_sample] = NULL;      rowGroup[m_SamplesModel.m_col_sample] = NULL;
1561      rowGroup[m_SamplesModel.m_col_group] = group;      rowGroup[m_SamplesModel.m_col_group] = group;
1562      file_changed();      file_changed();
# Line 1506  void MainWindow::on_action_add_sample() Line 1665  void MainWindow::on_action_add_sample()
1665                          break;                          break;
1666                      }                      }
1667                  }                  }
1668                  sample->pInfo->Name = filename;                  sample->pInfo->Name = gig_from_utf8(filename);
1669                  sample->Channels = info.channels;                  sample->Channels = info.channels;
1670                  sample->BitDepth = bitdepth;                  sample->BitDepth = bitdepth;
1671                  sample->FrameSize = bitdepth / 8/*1 byte are 8 bits*/ * info.channels;                  sample->FrameSize = bitdepth / 8/*1 byte are 8 bits*/ * info.channels;
# Line 1520  void MainWindow::on_action_add_sample() Line 1679  void MainWindow::on_action_add_sample()
1679                                 &instrument, sizeof(instrument)) != SF_FALSE)                                 &instrument, sizeof(instrument)) != SF_FALSE)
1680                  {                  {
1681                      sample->MIDIUnityNote = instrument.basenote;                      sample->MIDIUnityNote = instrument.basenote;
1682                        sample->FineTune      = instrument.detune;
1683    
1684                      if (instrument.loop_count && instrument.loops[0].mode != SF_LOOP_NONE) {                      if (instrument.loop_count && instrument.loops[0].mode != SF_LOOP_NONE) {
1685                          sample->Loops = 1;                          sample->Loops = 1;
# Line 1557  void MainWindow::on_action_add_sample() Line 1717  void MainWindow::on_action_add_sample()
1717                  Gtk::TreeModel::iterator iterSample =                  Gtk::TreeModel::iterator iterSample =
1718                      m_refSamplesTreeModel->append(row.children());                      m_refSamplesTreeModel->append(row.children());
1719                  Gtk::TreeModel::Row rowSample = *iterSample;                  Gtk::TreeModel::Row rowSample = *iterSample;
1720                  rowSample[m_SamplesModel.m_col_name]   = filename;                  rowSample[m_SamplesModel.m_col_name] =
1721                        gig_to_utf8(sample->pInfo->Name);
1722                  rowSample[m_SamplesModel.m_col_sample] = sample;                  rowSample[m_SamplesModel.m_col_sample] = sample;
1723                  rowSample[m_SamplesModel.m_col_group]  = NULL;                  rowSample[m_SamplesModel.m_col_group]  = NULL;
1724                  // close sound file                  // close sound file
# Line 1628  void MainWindow::on_action_replace_all_s Line 1789  void MainWindow::on_action_replace_all_s
1789               sample; sample = file->GetNextSample())               sample; sample = file->GetNextSample())
1790          {          {
1791              std::string filename =              std::string filename =
1792                  folder + G_DIR_SEPARATOR_S + sample->pInfo->Name +                  folder + G_DIR_SEPARATOR_S +
1793                  postfixEntryBox.get_text().raw();                  Glib::filename_from_utf8(gig_to_utf8(sample->pInfo->Name) +
1794                                             postfixEntryBox.get_text());
1795              SF_INFO info;              SF_INFO info;
1796              info.format = 0;              info.format = 0;
1797              SNDFILE* hFile = sf_open(filename.c_str(), SFM_READ, &info);              SNDFILE* hFile = sf_open(filename.c_str(), SFM_READ, &info);
# Line 1663  void MainWindow::on_action_replace_all_s Line 1825  void MainWindow::on_action_replace_all_s
1825              catch (std::string what)              catch (std::string what)
1826              {              {
1827                  if (!error_files.empty()) error_files += "\n";                  if (!error_files.empty()) error_files += "\n";
1828                      error_files += filename += " (" + what + ")";                  error_files += Glib::filename_to_utf8(filename) +
1829                        " (" + what + ")";
1830              }              }
1831          }          }
1832          // 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
# Line 1688  void MainWindow::on_action_remove_sample Line 1851  void MainWindow::on_action_remove_sample
1851          try {          try {
1852              // remove group or sample from the gig file              // remove group or sample from the gig file
1853              if (group) {              if (group) {
1854                  // temporarily remember the samples that bolong to                  // temporarily remember the samples that belong to
1855                  // that group (we need that to clean the queue)                  // that group (we need that to clean the queue)
1856                  std::list<gig::Sample*> members;                  std::list<gig::Sample*> members;
1857                  for (gig::Sample* pSample = group->GetFirstSample();                  for (gig::Sample* pSample = group->GetFirstSample();
# Line 1814  void MainWindow::on_sample_label_drop_dr Line 1977  void MainWindow::on_sample_label_drop_dr
1977              channels_changed = true;              channels_changed = true;
1978              region_changed();              region_changed();
1979          }          }
1980          dimreg_edit.set_sample(sample);          dimreg_edit.set_sample(
1981                sample,
1982                is_copy_samples_unity_note_enabled(),
1983                is_copy_samples_fine_tune_enabled(),
1984                is_copy_samples_loop_enabled()
1985            );
1986    
1987          if (sample->Channels == 2 && !stereo_dimension) {          if (sample->Channels == 2 && !stereo_dimension) {
1988              // add samplechannel dimension              // add samplechannel dimension
# Line 1857  void MainWindow::sample_name_changed(con Line 2025  void MainWindow::sample_name_changed(con
2025      Glib::ustring name  = row[m_SamplesModel.m_col_name];      Glib::ustring name  = row[m_SamplesModel.m_col_name];
2026      gig::Group* group   = row[m_SamplesModel.m_col_group];      gig::Group* group   = row[m_SamplesModel.m_col_group];
2027      gig::Sample* sample = row[m_SamplesModel.m_col_sample];      gig::Sample* sample = row[m_SamplesModel.m_col_sample];
2028        gig::String gigname(gig_from_utf8(name));
2029      if (group) {      if (group) {
2030          if (group->Name != name) {          if (group->Name != gigname) {
2031              group->Name = name;              group->Name = gigname;
2032              printf("group name changed\n");              printf("group name changed\n");
2033              file_changed();              file_changed();
2034          }          }
2035      } else if (sample) {      } else if (sample) {
2036          if (sample->pInfo->Name != name.raw()) {          if (sample->pInfo->Name != gigname) {
2037              sample->pInfo->Name = name.raw();              sample->pInfo->Name = gigname;
2038              printf("sample name changed\n");              printf("sample name changed\n");
2039              file_changed();              file_changed();
2040          }          }
# Line 1893  void MainWindow::instrument_name_changed Line 2062  void MainWindow::instrument_name_changed
2062    
2063      // change name in gig      // change name in gig
2064      gig::Instrument* instrument = row[m_Columns.m_col_instr];      gig::Instrument* instrument = row[m_Columns.m_col_instr];
2065      if (instrument && instrument->pInfo->Name != name.raw()) {      gig::String gigname(gig_from_utf8(name));
2066          instrument->pInfo->Name = name.raw();      if (instrument && instrument->pInfo->Name != gigname) {
2067            instrument->pInfo->Name = gigname;
2068    
2069            // change name in the instrument properties window
2070            if (instrumentProps.get_instrument() == instrument) {
2071                instrumentProps.update_name();
2072            }
2073    
2074          file_changed();          file_changed();
2075      }      }
2076  }  }

Legend:
Removed from v.2442  
changed lines
  Added in v.2536

  ViewVC Help
Powered by ViewVC