Use Glib instead of pbd/filesystem.h in GenericMidiControlProtocol
[ardour.git] / libs / surfaces / generic_midi / generic_midi_control_protocol.cc
index c2220c6fde236438bb9d18fc8fde39ab02744364..fab6431c0894c3f4964eb35737043748a05eafcb 100644 (file)
@@ -22,6 +22,7 @@
 #include <sstream>
 #include <algorithm>
 
+#include <glibmm/fileutils.h>
 #include <glibmm/miscutils.h>
 
 #include "pbd/controllable_descriptor.h"
@@ -55,6 +56,7 @@ using namespace std;
 GenericMidiControlProtocol::GenericMidiControlProtocol (Session& s)
        : ControlProtocol (s, _("Generic MIDI"))
        , _motorised (false)
+       , _threshold (10)
        , gui (0)
 {
        _input_port = MIDI::Manager::instance()->midi_input_port ();
@@ -104,34 +106,32 @@ static const char * const midimap_env_variable_name = "ARDOUR_MIDIMAPS_PATH";
 static const char* const midi_map_dir_name = "midi_maps";
 static const char* const midi_map_suffix = ".map";
 
-static sys::path
+static std::string
 system_midi_map_search_path ()
 {
        bool midimap_path_defined = false;
-        sys::path spath_env (Glib::getenv (midimap_env_variable_name, midimap_path_defined));
+       std::string spath_env (Glib::getenv (midimap_env_variable_name, midimap_path_defined));
 
        if (midimap_path_defined) {
                return spath_env;
        }
 
-       SearchPath spath (system_data_search_path());
+       SearchPath spath (ardour_data_search_path());
        spath.add_subdirectory_to_paths(midi_map_dir_name);
 
        // just return the first directory in the search path that exists
-       SearchPath::const_iterator i = std::find_if(spath.begin(), spath.end(), sys::exists);
-
-       if (i == spath.end()) return sys::path();
-
-       return *i;
+       for (SearchPath::const_iterator i = spath.begin(); i != spath.end(); ++i) {
+               if (Glib::file_test (*i, Glib::FILE_TEST_EXISTS)) {
+                       return *i;
+               }
+       }
+       return std::string();
 }
 
-static sys::path
+static std::string
 user_midi_map_directory ()
 {
-       sys::path p(user_config_directory());
-       p /= midi_map_dir_name;
-
-       return p;
+       return Glib::build_filename (user_config_directory(), midi_map_dir_name);
 }
 
 static bool
@@ -544,13 +544,9 @@ GenericMidiControlProtocol::set_state (const XMLNode& node, int version)
                        
                        if ((prop = (*niter)->property ("id")) != 0) {
 
-                                cerr << "Looking for MIDI Controllable with ID " << prop->value() << endl;
-                               
                                ID id = prop->value ();
                                Controllable* c = Controllable::by_id (id);
 
-                                cerr << "\tresult = " << c << endl;
-                               
                                if (c) {
                                        MIDIControllable* mc = new MIDIControllable (this, *_input_port, *c, false);
                                         
@@ -647,6 +643,13 @@ GenericMidiControlProtocol::load_bindings (const string& xmlpath)
                        } else {
                                _motorised = false;
                        }
+
+                       if ((prop = (*citer)->property ("threshold")) != 0) {
+                               _threshold = atoi (prop->value ());
+                       } else {
+                               _threshold = 10;
+                       }
+
                }
 
                if ((*citer)->name() == "Binding") {
@@ -1011,3 +1014,9 @@ GenericMidiControlProtocol::set_motorised (bool m)
 {
        _motorised = m;
 }
+
+void
+GenericMidiControlProtocol::set_threshold (int t)
+{
+       _threshold = t;
+}