--- gigedit/trunk/src/gigedit/mainwindow.cpp 2008/03/06 20:50:04 1714 +++ gigedit/trunk/src/gigedit/mainwindow.cpp 2009/03/01 22:26:36 1853 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006 - 2008 Andreas Persson + * Copyright (C) 2006-2009 Andreas Persson * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -26,6 +26,7 @@ #include #include #include +#include "wrapLabel.hh" #include "global.h" @@ -129,8 +130,8 @@ m_HPaned.add2(dimreg_vbox); - m_TreeViewNotebook.append_page(m_ScrolledWindowSamples, "Samples"); - m_TreeViewNotebook.append_page(m_ScrolledWindow, "Instruments"); + m_TreeViewNotebook.append_page(m_ScrolledWindowSamples, _("Samples")); + m_TreeViewNotebook.append_page(m_ScrolledWindow, _("Instruments")); actionGroup = Gtk::ActionGroup::create(); @@ -202,7 +203,7 @@ sigc::mem_fun(*this, &MainWindow::on_action_add_group) ); actionGroup->add( - Gtk::Action::create("AddSample", _("Add _Sample(s)")), + Gtk::Action::create("AddSample", _("Add _Sample(s)...")), sigc::mem_fun(*this, &MainWindow::on_action_add_sample) ); actionGroup->add( @@ -210,7 +211,8 @@ sigc::mem_fun(*this, &MainWindow::on_action_remove_sample) ); actionGroup->add( - Gtk::Action::create("ReplaceAllSamplesInAllGroups", _("Replace All Samples In All Groups")), + Gtk::Action::create("ReplaceAllSamplesInAllGroups", + _("Replace All Samples in All Groups...")), sigc::mem_fun(*this, &MainWindow::on_action_replace_all_samples_in_all_groups) ); @@ -569,7 +571,7 @@ gig::File* pFile = new gig::File; // already add one new instrument by default gig::Instrument* pInstrument = pFile->AddInstrument(); - pInstrument->pInfo->Name = "Unnamed Instrument"; + pInstrument->pInfo->Name = _("Unnamed Instrument"); // update GUI with that new gig::File load_gig(pFile, 0 /*no file name yet*/); } @@ -624,22 +626,22 @@ Gtk::FileFilter filter; filter.add_pattern("*.gig"); dialog.set_filter(filter); - if (current_dir != "") { - dialog.set_current_folder(current_dir); + if (current_gig_dir != "") { + dialog.set_current_folder(current_gig_dir); } if (dialog.run() == Gtk::RESPONSE_OK) { std::string filename = dialog.get_filename(); printf("filename=%s\n", filename.c_str()); printf("on_action_file_open self=%x\n", Glib::Thread::self()); load_file(filename.c_str()); - current_dir = Glib::path_get_dirname(filename); + current_gig_dir = Glib::path_get_dirname(filename); } } void MainWindow::load_file(const char* name) { __clear(); - load_dialog = new LoadDialog("Loading...", *this); + load_dialog = new LoadDialog(_("Loading..."), *this); load_dialog->show_all(); loader = new Loader(strdup(name)); loader->signal_progress().connect( @@ -758,12 +760,12 @@ { std::string basename = Glib::path_get_basename(filename); std::string dir = Glib::path_get_dirname(filename); - basename = std::string("copy_of_") + basename; + basename = std::string(_("copy_of_")) + basename; Glib::ustring copyFileName = Glib::build_filename(dir, basename); if (Glib::path_is_absolute(filename)) { dialog.set_filename(copyFileName); } else { - if (current_dir != "") dialog.set_current_folder(current_dir); + if (current_gig_dir != "") dialog.set_current_folder(current_gig_dir); } dialog.set_current_name(Glib::filename_display_basename(copyFileName)); } @@ -773,8 +775,7 @@ descriptionArea.set_spacing(15); Gtk::Image warningIcon(Gtk::Stock::DIALOG_WARNING, Gtk::IconSize(Gtk::ICON_SIZE_DIALOG)); descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK); - warningIcon.show(); - Gtk::Label description; + view::WrapLabel description; description.set_markup( _("\nCAUTION: You MUST use the " "\"Save\" dialog instead of " @@ -783,11 +784,9 @@ "\"Save As...\" for writing to the " "same .gig file will end up in corrupted sample wave data!\n") ); - description.set_line_wrap(true); - descriptionArea.pack_start(description, Gtk::PACK_SHRINK); - description.show(); + descriptionArea.pack_start(description); dialog.get_vbox()->pack_start(descriptionArea, Gtk::PACK_SHRINK); - descriptionArea.show(); + descriptionArea.show_all(); if (dialog.run() == Gtk::RESPONSE_OK) { file_structure_to_be_changed_signal.emit(this->file); @@ -799,7 +798,7 @@ printf("filename=%s\n", filename.c_str()); file->Save(filename); this->filename = filename; - current_dir = Glib::path_get_dirname(filename); + current_gig_dir = Glib::path_get_dirname(filename); set_title(Glib::filename_display_basename(filename)); file_has_name = true; file_is_changed = false; @@ -829,7 +828,7 @@ info.format = 0; SNDFILE* hFile = sf_open((*iter).sample_path.c_str(), SFM_READ, &info); try { - if (!hFile) throw std::string("could not open file"); + if (!hFile) throw std::string(_("could not open file")); // determine sample's bit depth int bitdepth; switch (info.format & 0xff) { @@ -846,7 +845,7 @@ break; default: sf_close(hFile); // close sound file - throw std::string("format not supported"); // unsupported subformat (yet?) + throw std::string(_("format not supported")); // unsupported subformat (yet?) } const int bufsize = 10000; @@ -888,6 +887,8 @@ } // cleanup sf_close(hFile); + // let the sampler re-cache the sample if needed + sample_changed_signal.emit(iter->gig_sample); // on success we remove the sample from the import queue, // otherwise keep it, maybe it works the next time ? std::list::iterator cur = iter; @@ -919,15 +920,15 @@ #ifdef ABOUT_DIALOG Gtk::AboutDialog dialog; dialog.set_version(VERSION); - dialog.set_copyright("Copyright (C) 2006,2007 Andreas Persson"); - dialog.set_comments( + dialog.set_copyright("Copyright (C) 2006-2009 Andreas Persson"); + dialog.set_comments(_( "Released under the GNU General Public License.\n" "\n" "Please notice that this is still a very young instrument editor. " "So better backup your Gigasampler files before editing them with " "this application.\n" "\n" - "Please report bugs to: http://bugs.linuxsampler.org" + "Please report bugs to: http://bugs.linuxsampler.org") ); dialog.set_website("http://www.linuxsampler.org"); dialog.set_website_label("http://www.linuxsampler.org"); @@ -937,26 +938,26 @@ PropDialog::PropDialog() : table(2,1), - eName("Name"), - eCreationDate("Creation date"), - eComments("Comments"), - eProduct("Product"), - eCopyright("Copyright"), - eArtists("Artists"), - eGenre("Genre"), - eKeywords("Keywords"), - eEngineer("Engineer"), - eTechnician("Technician"), - eSoftware("Software"), - eMedium("Medium"), - eSource("Source"), - eSourceForm("Source form"), - eCommissioned("Commissioned"), - eSubject("Subject"), + eName(_("Name")), + eCreationDate(_("Creation date")), + eComments(_("Comments")), + eProduct(_("Product")), + eCopyright(_("Copyright")), + eArtists(_("Artists")), + eGenre(_("Genre")), + eKeywords(_("Keywords")), + eEngineer(_("Engineer")), + eTechnician(_("Technician")), + eSoftware(_("Software")), + eMedium(_("Medium")), + eSource(_("Source")), + eSourceForm(_("Source form")), + eCommissioned(_("Commissioned")), + eSubject(_("Subject")), quitButton(Gtk::Stock::CLOSE), update_model(0) { - set_title("File Properties"); + set_title(_("File Properties")); eName.set_width_chars(50); connect(eName, &DLS::Info::Name); @@ -1074,21 +1075,21 @@ InstrumentProps::InstrumentProps() : table(2,1), quitButton(Gtk::Stock::CLOSE), - eName("Name"), - eIsDrum("Is drum"), - eMIDIBank("MIDI bank", 0, 16383), - eMIDIProgram("MIDI program"), - eAttenuation("Attenuation", 0, 96, 0, 1), - eGainPlus6("Gain +6dB", eAttenuation, -6), - eEffectSend("Effect send", 0, 65535), - eFineTune("Fine tune", -8400, 8400), - ePitchbendRange("Pitchbend range", 0, 12), - ePianoReleaseMode("Piano release mode"), - eDimensionKeyRangeLow("Keyswitching range low"), - eDimensionKeyRangeHigh("Keyswitching range high"), + eName(_("Name")), + eIsDrum(_("Is drum")), + eMIDIBank(_("MIDI bank"), 0, 16383), + eMIDIProgram(_("MIDI program")), + eAttenuation(_("Attenuation"), 0, 96, 0, 1), + eGainPlus6(_("Gain +6dB"), eAttenuation, -6), + eEffectSend(_("Effect send"), 0, 65535), + eFineTune(_("Fine tune"), -8400, 8400), + ePitchbendRange(_("Pitchbend range"), 0, 12), + ePianoReleaseMode(_("Piano release mode")), + eDimensionKeyRangeLow(_("Keyswitching range low")), + eDimensionKeyRangeHigh(_("Keyswitching range high")), update_model(0) { - set_title("Instrument Properties"); + set_title(_("Instrument Properties")); eDimensionKeyRangeLow.set_tip( _("start of the keyboard area which should switch the " @@ -1313,7 +1314,7 @@ gig::Instrument* instrument = file->AddInstrument(); __instrument_indexer++; instrument->pInfo->Name = - "Unnamed Instrument " + ToString(__instrument_indexer); + _("Unnamed Instrument ") + ToString(__instrument_indexer); // update instrument tree view Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append(); Gtk::TreeModel::Row rowInstr = *iterInstr; @@ -1356,7 +1357,7 @@ void MainWindow::on_action_sample_properties() { //TODO: show a dialog where the selected sample's properties can be edited Gtk::MessageDialog msg( - *this, "Sorry, yet to be implemented!", false, Gtk::MESSAGE_INFO + *this, _("Sorry, yet to be implemented!"), false, Gtk::MESSAGE_INFO ); msg.run(); } @@ -1365,7 +1366,7 @@ static int __sample_indexer = 0; if (!file) return; gig::Group* group = file->AddGroup(); - group->Name = "Unnamed Group"; + group->Name = _("Unnamed Group"); if (__sample_indexer) group->Name += " " + ToString(__sample_indexer); __sample_indexer++; // update sample tree view @@ -1409,13 +1410,17 @@ }; for (int i = 0; supportedFileTypes[i]; i++) soundfilter.add_pattern(supportedFileTypes[i]); - soundfilter.set_name("Sound Files"); + soundfilter.set_name(_("Sound Files")); Gtk::FileFilter allpassfilter; // matches every file allpassfilter.add_pattern("*.*"); - allpassfilter.set_name("All Files"); + allpassfilter.set_name(_("All Files")); dialog.add_filter(soundfilter); dialog.add_filter(allpassfilter); + if (current_sample_dir != "") { + dialog.set_current_folder(current_sample_dir); + } if (dialog.run() == Gtk::RESPONSE_OK) { + current_sample_dir = dialog.get_current_folder(); Glib::ustring error_files; Glib::SListHandle filenames = dialog.get_filenames(); for (Glib::SListHandle::iterator iter = filenames.begin(); @@ -1426,7 +1431,7 @@ info.format = 0; SNDFILE* hFile = sf_open((*iter).c_str(), SFM_READ, &info); try { - if (!hFile) throw std::string("could not open file"); + if (!hFile) throw std::string(_("could not open file")); int bitdepth; switch (info.format & 0xff) { case SF_FORMAT_PCM_S8: @@ -1442,7 +1447,7 @@ break; default: sf_close(hFile); // close sound file - throw std::string("format not supported"); // unsupported subformat (yet?) + throw std::string(_("format not supported")); // unsupported subformat (yet?) } // add a new sample to the .gig file gig::Sample* sample = file->AddSample(); @@ -1533,25 +1538,24 @@ if (!file) return; Gtk::FileChooserDialog dialog(*this, _("Select Folder"), Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER); - Gtk::Label description( + view::WrapLabel description( _("This is a very specific function. It tries to replace all samples " - "in the current gig file by samples located in the directory chosen " - "by you above.\n\n" - "It works like this: For each sample in the gig file it tries to " + "in the current gig file by samples located in the chosen " + "directory.\n\n" + "It works like this: For each sample in the gig file, it tries to " "find a sample file in the selected directory with the same name as " - "the sample in the gig file. Optionally you can add a filename " - "postfix below, which will be added to the filename expected to be " + "the sample in the gig file. Optionally, you can add a filename " + "extension below, which will be added to the filename expected to be " "found. That is, assume you have a gig file with a sample called " "'Snare', if you enter '.wav' below (like it's done by default), it " - "assumes to find a sample file called 'Snare.wav' and will replace " - "the sample in the gig file accordingly. If you don't need such a " - "postfix, blank the field below. Any gig sample where no " - "appropriate sample file could be found, will be reported and left " - "untouched.\n\n") + "expects to find a sample file called 'Snare.wav' and will replace " + "the sample in the gig file accordingly. If you don't need an " + "extension, blank the field below. Any gig sample where no " + "appropriate sample file could be found will be reported and left " + "untouched.\n") ); - description.set_line_wrap(true); Gtk::HBox entryArea; - Gtk::Label entryLabel( _("Add Filename Extension: "), Gtk::ALIGN_RIGHT); + Gtk::Label entryLabel( _("Add filename extension: "), Gtk::ALIGN_RIGHT); Gtk::Entry postfixEntryBox; postfixEntryBox.set_text(".wav"); entryArea.pack_start(entryLabel); @@ -1559,23 +1563,16 @@ dialog.get_vbox()->pack_start(description, Gtk::PACK_SHRINK); dialog.get_vbox()->pack_start(entryArea, Gtk::PACK_SHRINK); description.show(); - entryLabel.show(); - postfixEntryBox.show(); - entryArea.show(); + entryArea.show_all(); dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); dialog.add_button(_("Select"), Gtk::RESPONSE_OK); dialog.set_select_multiple(false); - // fix label width (because Gtk by design doesn't - // know anything about the parent's size) -#if 0 //FIXME: doesn't work - int dialogW, dialogH, labelW, labelH; - dialog.get_size_request(dialogW, dialogH); - description.get_size_request(labelW, labelH); - std::cout << "dialog(" << dialogW << "," << dialogH << ")\nlabel(" << labelW << "," << labelH << ")\n" << std::flush; - description.set_size_request(dialogW, labelH); -#endif + if (current_sample_dir != "") { + dialog.set_current_folder(current_sample_dir); + } if (dialog.run() == Gtk::RESPONSE_OK) { + current_sample_dir = dialog.get_current_folder(); Glib::ustring error_files; Glib::ustring folder = dialog.get_filename(); for (gig::Sample* sample = file->GetFirstSample(); @@ -1589,7 +1586,7 @@ SNDFILE* hFile = sf_open(filename.c_str(), SFM_READ, &info); try { - if (!hFile) throw std::string("could not open file"); + if (!hFile) throw std::string(_("could not open file")); int bitdepth; switch (info.format & 0xff) { case SF_FORMAT_PCM_S8: @@ -1605,7 +1602,7 @@ break; default: sf_close(hFile); - throw std::string("format not supported"); + throw std::string(_("format not supported")); } SampleImportItem sched_item; sched_item.gig_sample = sample; @@ -1878,6 +1875,10 @@ return region_changed_signal; } +sigc::signal& MainWindow::signal_sample_changed() { + return sample_changed_signal; +} + sigc::signal& MainWindow::signal_sample_ref_changed() { return sample_ref_changed_signal; }