--- gigedit/trunk/src/gigedit/mainwindow.cpp 2013/04/28 06:07:22 2445 +++ gigedit/trunk/src/gigedit/mainwindow.cpp 2013/09/05 00:49:13 2464 @@ -128,8 +128,33 @@ *this, &MainWindow::on_action_quit)); actionGroup->add(Gtk::Action::create("MenuInstrument", _("_Instrument"))); - actionGroup->add(Gtk::Action::create("MenuView", _("_View"))); + + actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit"))); + Glib::RefPtr toggle_action = + Gtk::ToggleAction::create("CopySampleUnity", _("Copy Sample's _Unity Note"), "ffaga"); + toggle_action->set_active(true); + //FIXME: doesn't work, why? + toggle_action->set_tooltip(_("Used when dragging a sample to a region's sample reference field.")); + actionGroup->add(toggle_action); + + toggle_action = + Gtk::ToggleAction::create("CopySampleTune", _("Copy Sample's _Fine Tune")); + toggle_action->set_active(true); + //FIXME: doesn't work, why? + toggle_action->set_tooltip(_("Used when dragging a sample to a region's sample reference field.")); + actionGroup->add(toggle_action); + + toggle_action = + Gtk::ToggleAction::create("CopySampleLoop", _("Copy Sample's _Loop Points")); + toggle_action->set_active(true); + //FIXME: doesn't work, why? + toggle_action->set_tooltip(_("Used when dragging a sample to a region's sample reference field.")); + actionGroup->add(toggle_action); + + + actionGroup->add(Gtk::Action::create("MenuView", _("_View"))); + toggle_action = Gtk::ToggleAction::create("Statusbar", _("_Statusbar")); toggle_action->set_active(true); actionGroup->add(toggle_action, @@ -196,6 +221,11 @@ " " " " " " + " " + " " + " " + " " + " " " " " " " " @@ -545,7 +575,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 = gig_from_utf8(_("Unnamed Instrument")); // update GUI with that new gig::File load_gig(pFile, 0 /*no file name yet*/); } @@ -1143,7 +1173,7 @@ instrument_name_connection.block(); for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ; instrument = gig->GetNextInstrument()) { - Glib::ustring name(instrument->pInfo->Name); + Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); Gtk::TreeModel::iterator iter = m_refTreeModel->append(); Gtk::TreeModel::Row row = *iter; @@ -1159,7 +1189,7 @@ if (group->Name != "") { Gtk::TreeModel::iterator iterGroup = m_refSamplesTreeModel->append(); Gtk::TreeModel::Row rowGroup = *iterGroup; - rowGroup[m_SamplesModel.m_col_name] = group->Name.c_str(); + rowGroup[m_SamplesModel.m_col_name] = gig_to_utf8(group->Name); rowGroup[m_SamplesModel.m_col_group] = group; rowGroup[m_SamplesModel.m_col_sample] = NULL; for (gig::Sample* sample = group->GetFirstSample(); @@ -1167,7 +1197,8 @@ Gtk::TreeModel::iterator iterSample = m_refSamplesTreeModel->append(rowGroup.children()); Gtk::TreeModel::Row rowSample = *iterSample; - rowSample[m_SamplesModel.m_col_name] = sample->pInfo->Name.c_str(); + rowSample[m_SamplesModel.m_col_name] = + gig_to_utf8(sample->pInfo->Name); rowSample[m_SamplesModel.m_col_sample] = sample; rowSample[m_SamplesModel.m_col_group] = NULL; } @@ -1221,8 +1252,9 @@ Glib::ustring name = row[m_Columns.m_col_name]; gig::Instrument* instrument = row[m_Columns.m_col_instr]; - if (instrument->pInfo->Name != name) { - row[m_Columns.m_col_name] = instrument->pInfo->Name; + Glib::ustring gigname(gig_to_utf8(instrument->pInfo->Name)); + if (gigname != name) { + row[m_Columns.m_col_name] = gigname; } } @@ -1237,6 +1269,36 @@ else m_StatusBar.hide(); } +bool MainWindow::is_copy_samples_unity_note_enabled() const { + Gtk::CheckMenuItem* item = + dynamic_cast(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleUnity")); + if (!item) { + std::cerr << "/MenuBar/MenuEdit/CopySampleUnity == NULL\n"; + return true; + } + return item->get_active(); +} + +bool MainWindow::is_copy_samples_fine_tune_enabled() const { + Gtk::CheckMenuItem* item = + dynamic_cast(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleTune")); + if (!item) { + std::cerr << "/MenuBar/MenuEdit/CopySampleTune == NULL\n"; + return true; + } + return item->get_active(); +} + +bool MainWindow::is_copy_samples_loop_enabled() const { + Gtk::CheckMenuItem* item = + dynamic_cast(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleLoop")); + if (!item) { + std::cerr << "/MenuBar/MenuEdit/CopySampleLoop == NULL\n"; + return true; + } + return item->get_active(); +} + void MainWindow::on_button_release(GdkEventButton* button) { if (button->type == GDK_2BUTTON_PRESS) { @@ -1322,7 +1384,7 @@ } void MainWindow::add_instrument(gig::Instrument* instrument) { - const char* name = instrument->pInfo->Name.c_str(); + const Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); // update instrument tree view instrument_name_connection.block(); @@ -1344,8 +1406,8 @@ if (!file) return; gig::Instrument* instrument = file->AddInstrument(); __instrument_indexer++; - instrument->pInfo->Name = - _("Unnamed Instrument ") + ToString(__instrument_indexer); + instrument->pInfo->Name = gig_from_utf8(_("Unnamed Instrument ") + + ToString(__instrument_indexer)); add_instrument(instrument); } @@ -1365,7 +1427,8 @@ // duplicate the orginal instrument gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig); instrNew->pInfo->Name = - instrOrig->pInfo->Name + " (" + _("Copy") + ")"; + instrOrig->pInfo->Name + + gig_from_utf8(Glib::ustring(" (") + _("Copy") + ")"); add_instrument(instrNew); } @@ -1432,13 +1495,13 @@ static int __sample_indexer = 0; if (!file) return; gig::Group* group = file->AddGroup(); - group->Name = _("Unnamed Group"); + group->Name = gig_from_utf8(_("Unnamed Group")); if (__sample_indexer) group->Name += " " + ToString(__sample_indexer); __sample_indexer++; // update sample tree view Gtk::TreeModel::iterator iterGroup = m_refSamplesTreeModel->append(); Gtk::TreeModel::Row rowGroup = *iterGroup; - rowGroup[m_SamplesModel.m_col_name] = group->Name.c_str(); + rowGroup[m_SamplesModel.m_col_name] = gig_to_utf8(group->Name); rowGroup[m_SamplesModel.m_col_sample] = NULL; rowGroup[m_SamplesModel.m_col_group] = group; file_changed(); @@ -1547,7 +1610,7 @@ break; } } - sample->pInfo->Name = filename; + sample->pInfo->Name = gig_from_utf8(filename); sample->Channels = info.channels; sample->BitDepth = bitdepth; sample->FrameSize = bitdepth / 8/*1 byte are 8 bits*/ * info.channels; @@ -1598,7 +1661,8 @@ Gtk::TreeModel::iterator iterSample = m_refSamplesTreeModel->append(row.children()); Gtk::TreeModel::Row rowSample = *iterSample; - rowSample[m_SamplesModel.m_col_name] = filename; + rowSample[m_SamplesModel.m_col_name] = + gig_to_utf8(sample->pInfo->Name); rowSample[m_SamplesModel.m_col_sample] = sample; rowSample[m_SamplesModel.m_col_group] = NULL; // close sound file @@ -1669,8 +1733,9 @@ sample; sample = file->GetNextSample()) { std::string filename = - folder + G_DIR_SEPARATOR_S + sample->pInfo->Name + - postfixEntryBox.get_text().raw(); + folder + G_DIR_SEPARATOR_S + + Glib::filename_from_utf8(gig_to_utf8(sample->pInfo->Name) + + postfixEntryBox.get_text()); SF_INFO info; info.format = 0; SNDFILE* hFile = sf_open(filename.c_str(), SFM_READ, &info); @@ -1704,7 +1769,8 @@ catch (std::string what) { if (!error_files.empty()) error_files += "\n"; - error_files += filename += " (" + what + ")"; + error_files += Glib::filename_to_utf8(filename) + + " (" + what + ")"; } } // show error message box when some file(s) could not be opened / added @@ -1729,7 +1795,7 @@ try { // remove group or sample from the gig file if (group) { - // temporarily remember the samples that bolong to + // temporarily remember the samples that belong to // that group (we need that to clean the queue) std::list members; for (gig::Sample* pSample = group->GetFirstSample(); @@ -1855,7 +1921,12 @@ channels_changed = true; region_changed(); } - dimreg_edit.set_sample(sample); + dimreg_edit.set_sample( + sample, + is_copy_samples_unity_note_enabled(), + is_copy_samples_fine_tune_enabled(), + is_copy_samples_loop_enabled() + ); if (sample->Channels == 2 && !stereo_dimension) { // add samplechannel dimension @@ -1898,15 +1969,16 @@ Glib::ustring name = row[m_SamplesModel.m_col_name]; gig::Group* group = row[m_SamplesModel.m_col_group]; gig::Sample* sample = row[m_SamplesModel.m_col_sample]; + gig::String gigname(gig_from_utf8(name)); if (group) { - if (group->Name != name) { - group->Name = name; + if (group->Name != gigname) { + group->Name = gigname; printf("group name changed\n"); file_changed(); } } else if (sample) { - if (sample->pInfo->Name != name.raw()) { - sample->pInfo->Name = name.raw(); + if (sample->pInfo->Name != gigname) { + sample->pInfo->Name = gigname; printf("sample name changed\n"); file_changed(); } @@ -1934,8 +2006,9 @@ // change name in gig gig::Instrument* instrument = row[m_Columns.m_col_instr]; - if (instrument && instrument->pInfo->Name != name.raw()) { - instrument->pInfo->Name = name.raw(); + gig::String gigname(gig_from_utf8(name)); + if (instrument && instrument->pInfo->Name != gigname) { + instrument->pInfo->Name = gigname; // change name in the instrument properties window if (instrumentProps.get_instrument() == instrument) {