--- gigedit/trunk/src/gigedit/mainwindow.cpp 2012/03/04 09:01:40 2325 +++ gigedit/trunk/src/gigedit/mainwindow.cpp 2013/01/13 09:14:29 2398 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006-2011 Andreas Persson + * Copyright (C) 2006-2013 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 @@ -32,7 +32,9 @@ #include #include #include +#if GTKMM_MAJOR_VERSION < 3 #include "wrapLabel.hh" +#endif #include "global.h" #include "compat.h" @@ -177,6 +179,10 @@ sigc::mem_fun(*this, &MainWindow::on_action_add_instrument) ); actionGroup->add( + Gtk::Action::create("DupInstrument", _("_Duplicate Instrument")), + sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument) + ); + actionGroup->add( Gtk::Action::create("RemoveInstrument", Gtk::Stock::REMOVE), sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument) ); @@ -234,6 +240,7 @@ " " " " " " + " " " " " " " " @@ -493,7 +500,11 @@ void Loader::launch() { - thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Loader::thread_function), true); +#ifdef OLD_THREADS + thread = Glib::Thread::create(sigc::mem_fun(*this, &Loader::thread_function), true); +#else + thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Loader::thread_function)); +#endif printf("launch thread=%x\n", thread); } @@ -766,7 +777,12 @@ descriptionArea.set_spacing(15); Gtk::Image warningIcon(Gtk::Stock::DIALOG_WARNING, Gtk::IconSize(Gtk::ICON_SIZE_DIALOG)); descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK); +#if GTKMM_MAJOR_VERSION < 3 view::WrapLabel description; +#else + Gtk::Label description; + description.set_line_wrap(); +#endif description.set_markup( _("\nCAUTION: You MUST use the " "\"Save\" dialog instead of " @@ -818,6 +834,7 @@ SF_INFO info; info.format = 0; SNDFILE* hFile = sf_open((*iter).sample_path.c_str(), SFM_READ, &info); + sf_command(hFile, SFC_SET_SCALE_FLOAT_INT_READ, 0, SF_TRUE); try { if (!hFile) throw std::string(_("could not open file")); // determine sample's bit depth @@ -915,7 +932,7 @@ dialog.set_name("Gigedit"); #endif dialog.set_version(VERSION); - dialog.set_copyright("Copyright (C) 2006-2011 Andreas Persson"); + dialog.set_copyright("Copyright (C) 2006-2013 Andreas Persson"); dialog.set_comments(_( "Released under the GNU General Public License.\n" "\n" @@ -1317,6 +1334,31 @@ file_changed(); } +void MainWindow::on_action_duplicate_instrument() { + if (!file) return; + + // retrieve the currently selected instrument + // (being the original instrument to be duplicated) + Glib::RefPtr sel = m_TreeView.get_selection(); + Gtk::TreeModel::iterator itSelection = sel->get_selected(); + if (!itSelection) return; + Gtk::TreeModel::Row row = *itSelection; + gig::Instrument* instrOrig = row[m_Columns.m_col_instr]; + if (!instrOrig) return; + + // duplicate the orginal instrument + gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig); + instrNew->pInfo->Name = + instrOrig->pInfo->Name + " (" + _("Copy") + ")"; + + // update instrument tree view + Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append(); + Gtk::TreeModel::Row rowInstr = *iterInstr; + rowInstr[m_Columns.m_col_name] = instrNew->pInfo->Name.c_str(); + rowInstr[m_Columns.m_col_instr] = instrNew; + file_changed(); +} + void MainWindow::on_action_remove_instrument() { if (!file) return; if (file_is_shared) { @@ -1490,7 +1532,6 @@ { sample->MIDIUnityNote = instrument.basenote; -#if HAVE_SF_INSTRUMENT_LOOPS if (instrument.loop_count && instrument.loops[0].mode != SF_LOOP_NONE) { sample->Loops = 1; @@ -1510,7 +1551,6 @@ sample->LoopPlayCount = instrument.loops[0].count; sample->LoopSize = sample->LoopEnd - sample->LoopStart + 1; } -#endif } // schedule resizing the sample (which will be done @@ -1553,7 +1593,7 @@ if (!file) return; Gtk::FileChooserDialog dialog(*this, _("Select Folder"), Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER); - view::WrapLabel description( + const char* str = _("This is a very specific function. It tries to replace all samples " "in the current gig file by samples located in the chosen " "directory.\n\n" @@ -1567,8 +1607,13 @@ "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") - ); + "untouched.\n"); +#if GTKMM_MAJOR_VERSION < 3 + view::WrapLabel description(str); +#else + Gtk::Label description(str); + description.set_line_wrap(); +#endif Gtk::HBox entryArea; Gtk::Label entryLabel( _("Add filename extension: "), Gtk::ALIGN_START); Gtk::Entry postfixEntryBox;