/[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 1654 by schoenebeck, Wed Jan 30 02:20:48 2008 UTC revision 1673 by schoenebeck, Wed Feb 6 22:08:29 2008 UTC
# Line 208  MainWindow::MainWindow() : Line 208  MainWindow::MainWindow() :
208          Gtk::Action::create("RemoveSample", Gtk::Stock::REMOVE),          Gtk::Action::create("RemoveSample", Gtk::Stock::REMOVE),
209          sigc::mem_fun(*this, &MainWindow::on_action_remove_sample)          sigc::mem_fun(*this, &MainWindow::on_action_remove_sample)
210      );      );
211        actionGroup->add(
212            Gtk::Action::create("ReplaceAllSamplesInAllGroups", _("Replace All Samples In All Groups")),
213            sigc::mem_fun(*this, &MainWindow::on_action_replace_all_samples_in_all_groups)
214        );
215    
216      uiManager = Gtk::UIManager::create();      uiManager = Gtk::UIManager::create();
217      uiManager->insert_action_group(actionGroup);      uiManager->insert_action_group(actionGroup);
# Line 248  MainWindow::MainWindow() : Line 252  MainWindow::MainWindow() :
252          "    <menuitem action='SampleProperties'/>"          "    <menuitem action='SampleProperties'/>"
253          "    <menuitem action='AddGroup'/>"          "    <menuitem action='AddGroup'/>"
254          "    <menuitem action='AddSample'/>"          "    <menuitem action='AddSample'/>"
255            "    <menuitem action='ReplaceAllSamplesInAllGroups' />"
256          "    <separator/>"          "    <separator/>"
257          "    <menuitem action='RemoveSample'/>"          "    <menuitem action='RemoveSample'/>"
258          "  </popup>"          "  </popup>"
# Line 260  MainWindow::MainWindow() : Line 265  MainWindow::MainWindow() :
265      m_VBox.pack_start(*menuBar, Gtk::PACK_SHRINK);      m_VBox.pack_start(*menuBar, Gtk::PACK_SHRINK);
266      m_VBox.pack_start(m_HPaned);      m_VBox.pack_start(m_HPaned);
267      m_VBox.pack_start(m_RegionChooser, Gtk::PACK_SHRINK);      m_VBox.pack_start(m_RegionChooser, Gtk::PACK_SHRINK);
268        m_VBox.pack_start(m_RegionChooser.m_VirtKeybPropsBox, Gtk::PACK_SHRINK);
269      m_VBox.pack_start(m_DimRegionChooser, Gtk::PACK_SHRINK);      m_VBox.pack_start(m_DimRegionChooser, Gtk::PACK_SHRINK);
270      m_VBox.pack_start(m_StatusBar, Gtk::PACK_SHRINK);      m_VBox.pack_start(m_StatusBar, Gtk::PACK_SHRINK);
271    
# Line 1048  InstrumentProps::InstrumentProps() Line 1054  InstrumentProps::InstrumentProps()
1054        eFineTune("Fine tune", -8400, 8400),        eFineTune("Fine tune", -8400, 8400),
1055        ePitchbendRange("Pitchbend range", 0, 12),        ePitchbendRange("Pitchbend range", 0, 12),
1056        ePianoReleaseMode("Piano release mode"),        ePianoReleaseMode("Piano release mode"),
1057        eDimensionKeyRangeLow("Dimension key range low"),        eDimensionKeyRangeLow("Keyswitching range low"),
1058        eDimensionKeyRangeHigh("Dimension key range high"),        eDimensionKeyRangeHigh("Keyswitching range high"),
1059        update_model(0)        update_model(0)
1060  {  {
1061      set_title("Instrument Properties");      set_title("Instrument Properties");
1062    
1063        eDimensionKeyRangeLow.set_tip(
1064            _("start of the keyboard area which should switch the "
1065              "\"keyswitching\" dimension")
1066        );
1067        eDimensionKeyRangeHigh.set_tip(
1068            _("end of the keyboard area which should switch the "
1069              "\"keyswitching\" dimension")
1070        );
1071    
1072      connect(eIsDrum, &InstrumentProps::set_IsDrum);      connect(eIsDrum, &InstrumentProps::set_IsDrum);
1073      connect(eMIDIBank, &InstrumentProps::set_MIDIBank);      connect(eMIDIBank, &InstrumentProps::set_MIDIBank);
1074      connect(eMIDIProgram, &InstrumentProps::set_MIDIProgram);      connect(eMIDIProgram, &InstrumentProps::set_MIDIProgram);
# Line 1483  void MainWindow::on_action_add_sample() Line 1498  void MainWindow::on_action_add_sample()
1498      }      }
1499  }  }
1500    
1501    void MainWindow::on_action_replace_all_samples_in_all_groups()
1502    {
1503        if (!file) return;
1504        Gtk::FileChooserDialog dialog(*this, _("Select Folder"),
1505                                      Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER);
1506        Gtk::Label description(
1507            _("This is a very specific function. It tries to replace all samples "
1508              "in the current gig file by samples located in the directory chosen "
1509              "by you above.\n\n"
1510              "It works like this: For each sample in the gig file it tries to "
1511              "find a sample file in the selected directory with the same name as "
1512              "the sample in the gig file. Optionally you can add a filename "
1513              "postfix below, which will be added to the filename expected to be "
1514              "found. That is, assume you have a gig file with a sample called "
1515              "'Snare', if you enter '.wav' below (like it's done by default), it "
1516              "assumes to find a sample file called 'Snare.wav' and will replace "
1517              "the sample in the gig file accordingly. If you don't need such a "
1518              "postfix, blank the field below. Any gig sample where no "
1519              "appropriate sample file could be found, will be reported and left "
1520              "untouched.\n\n")
1521        );
1522        description.set_line_wrap(true);
1523        Gtk::HBox entryArea;
1524        Gtk::Label entryLabel( _("Add Filename Extension: "), Gtk::ALIGN_RIGHT);
1525        Gtk::Entry postfixEntryBox;
1526        postfixEntryBox.set_text(".wav");
1527        entryArea.pack_start(entryLabel);
1528        entryArea.pack_start(postfixEntryBox);
1529        dialog.get_vbox()->pack_start(description, Gtk::PACK_SHRINK);
1530        dialog.get_vbox()->pack_start(entryArea, Gtk::PACK_SHRINK);
1531        description.show();
1532        entryLabel.show();
1533        postfixEntryBox.show();
1534        entryArea.show();
1535        dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1536        dialog.add_button(_("Select"), Gtk::RESPONSE_OK);
1537        dialog.set_select_multiple(false);
1538        // fix label width (because Gtk by design doesn't
1539        // know anything about the parent's size)
1540    #if 0 //FIXME: doesn't work
1541        int dialogW, dialogH, labelW, labelH;
1542        dialog.get_size_request(dialogW, dialogH);
1543        description.get_size_request(labelW, labelH);
1544        std::cout << "dialog(" << dialogW << "," << dialogH << ")\nlabel(" << labelW << "," << labelH << ")\n" << std::flush;
1545        description.set_size_request(dialogW, labelH);
1546    #endif
1547        if (dialog.run() == Gtk::RESPONSE_OK)
1548        {
1549            Glib::ustring error_files;
1550            Glib::ustring folder = dialog.get_filename();
1551            for (gig::Sample* sample = file->GetFirstSample();
1552                 sample; sample = file->GetNextSample())
1553            {
1554                std::string filename =
1555                    folder + G_DIR_SEPARATOR_S + sample->pInfo->Name +
1556                    postfixEntryBox.get_text().raw();
1557                SF_INFO info;
1558                info.format = 0;
1559                SNDFILE* hFile = sf_open(filename.c_str(), SFM_READ, &info);
1560                try
1561                {
1562                    if (!hFile) throw std::string("could not open file");
1563                    int bitdepth;
1564                    switch (info.format & 0xff) {
1565                        case SF_FORMAT_PCM_S8:
1566                        case SF_FORMAT_PCM_16:
1567                        case SF_FORMAT_PCM_U8:
1568                            bitdepth = 16;
1569                            break;
1570                        case SF_FORMAT_PCM_24:
1571                        case SF_FORMAT_PCM_32:
1572                        case SF_FORMAT_FLOAT:
1573                        case SF_FORMAT_DOUBLE:
1574                            bitdepth = 24;
1575                            break;
1576                        default:
1577                            sf_close(hFile);
1578                            throw std::string("format not supported");
1579                    }
1580                    SampleImportItem sched_item;
1581                    sched_item.gig_sample  = sample;
1582                    sched_item.sample_path = filename;
1583                    m_SampleImportQueue.push_back(sched_item);
1584                    sf_close(hFile);
1585                    file_changed();
1586                }
1587                catch (std::string what)
1588                {
1589                    if (error_files.size()) error_files += "\n";
1590                        error_files += filename += " (" + what + ")";
1591                }
1592            }
1593            // show error message box when some file(s) could not be opened / added
1594            if (error_files.size()) {
1595                Glib::ustring txt =
1596                    _("Could not replace the following sample(s):\n") + error_files;
1597                Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR);
1598                msg.run();
1599            }
1600        }
1601    }
1602    
1603  void MainWindow::on_action_remove_sample() {  void MainWindow::on_action_remove_sample() {
1604      if (!file) return;      if (!file) return;
1605      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection();      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection();
# Line 1750  sigc::signal<void, int/*key*/, int/*velo Line 1867  sigc::signal<void, int/*key*/, int/*velo
1867  sigc::signal<void, int/*key*/, int/*velocity*/>& MainWindow::signal_note_off() {  sigc::signal<void, int/*key*/, int/*velocity*/>& MainWindow::signal_note_off() {
1868      return note_off_signal;      return note_off_signal;
1869  }  }
1870    
1871    sigc::signal<void, int/*key*/, int/*velocity*/>& MainWindow::signal_keyboard_key_hit() {
1872        return m_RegionChooser.signal_keyboard_key_hit();
1873    }
1874    
1875    sigc::signal<void, int/*key*/, int/*velocity*/>& MainWindow::signal_keyboard_key_released() {
1876        return m_RegionChooser.signal_keyboard_key_released();
1877    }

Legend:
Removed from v.1654  
changed lines
  Added in v.1673

  ViewVC Help
Powered by ViewVC