2 Copyright (C) 2008 Hans Baier
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include <sigc++/sigc++.h>
22 #include <boost/shared_ptr.hpp>
24 #include "midi_patch_manager.h"
25 #include "pbd/file_utils.h"
26 #include "ardour/session.h"
27 #include "ardour/session_directory.h"
31 using namespace ARDOUR;
33 using namespace MIDI::Name;
35 using namespace PBD::sys;
37 MidiPatchManager* MidiPatchManager::_manager = 0;
40 MidiPatchManager::set_session (Session& s)
43 _session->GoingAway.connect (mem_fun (*this, &MidiPatchManager::drop_session));
49 MidiPatchManager::refresh()
53 path path_to_patches = _session->session_directory().midi_patch_path();
55 if(!exists(path_to_patches)) {
59 assert(is_directory(path_to_patches));
61 Glib::PatternSpec pattern(Glib::ustring("*.midnam"));
64 find_matching_files_in_directory(path_to_patches, pattern, result);
66 for(vector<path>::iterator i = result.begin(); i != result.end(); ++i) {
67 boost::shared_ptr<MIDINameDocument> document(new MIDINameDocument(i->to_string()));
68 _documents.push_back(document);
73 MidiPatchManager::drop_session ()