X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fsurfaces%2Fmackie%2Fdevice_profile.cc;h=f67aa3cddd25ad491fea8d441a0dd884febc4dd7;hb=d0746b8378689268c0fc09e7c9155282ae6c7c38;hp=269ff36acac5a839c2fe77647497fa058b2cba70;hpb=547689a0552661108806a4028960f32d1b20adf8;p=ardour.git diff --git a/libs/surfaces/mackie/device_profile.cc b/libs/surfaces/mackie/device_profile.cc index 269ff36aca..f67aa3cddd 100644 --- a/libs/surfaces/mackie/device_profile.cc +++ b/libs/surfaces/mackie/device_profile.cc @@ -35,16 +35,21 @@ #include "i18n.h" -using namespace Mackie; using namespace PBD; using namespace ARDOUR; +using namespace ArdourSurface; +using namespace Mackie; + using std::string; using std::vector; std::map DeviceProfile::device_profiles; +const std::string DeviceProfile::edited_indicator (" (edited)"); +const std::string DeviceProfile::default_profile_name ("User"); DeviceProfile::DeviceProfile (const string& n) : _name (n) + , edited (false) { } @@ -88,12 +93,11 @@ devprofile_filter (const string &str, void* /*arg*/) void DeviceProfile::reload_device_profiles () { - DeviceProfile dp; vector s; vector devprofiles; Searchpath spath (devprofile_search_path()); - find_files_matching_filter (devprofiles, spath.to_string(), devprofile_filter, 0, false, true); + find_files_matching_filter (devprofiles, spath, devprofile_filter, 0, false, true); device_profiles.clear (); if (devprofiles.empty()) { @@ -103,6 +107,7 @@ DeviceProfile::reload_device_profiles () for (vector::iterator i = devprofiles.begin(); i != devprofiles.end(); ++i) { string fullpath = *i; + DeviceProfile dp; // has to be initial every loop or info from last added. XMLTree tree; @@ -133,7 +138,7 @@ DeviceProfile::set_state (const XMLNode& node, int /* version */) } /* name is mandatory */ - + if ((child = node.child ("Name")) == 0 || (prop = child->property ("value")) == 0) { return -1; } else { @@ -155,7 +160,7 @@ DeviceProfile::set_state (const XMLNode& node, int /* version */) int id = Button::name_to_id (prop->value()); if (id < 0) { - error << string_compose ("Unknow button ID \"%1\"", prop->value()) << endmsg; + error << string_compose ("Unknown button ID \"%1\"", prop->value()) << endmsg; continue; } @@ -189,6 +194,8 @@ DeviceProfile::set_state (const XMLNode& node, int /* version */) } } + edited = false; + return 0; } @@ -198,7 +205,7 @@ DeviceProfile::get_state () const XMLNode* node = new XMLNode ("MackieDeviceProfile"); XMLNode* child = new XMLNode ("Name"); - child->add_property ("value", _name); + child->add_property ("value", name()); node->add_child_nocopy (*child); if (_button_map.empty()) { @@ -290,13 +297,31 @@ DeviceProfile::set_button_action (Button::ID id, int modifier_state, const strin i->second.plain = action; } + edited = true; + save (); } -const string& +string +DeviceProfile::name_when_edited (string const& base) +{ + return string_compose ("%1 %2", base, edited_indicator); +} + +string DeviceProfile::name() const { - return _name; + if (edited) { + if (_name.find (edited_indicator) == string::npos) { + /* modify name to included edited indicator */ + return name_when_edited (_name); + } else { + /* name already contains edited indicator */ + return _name; + } + } else { + return _name; + } } void @@ -336,8 +361,8 @@ DeviceProfile::save () return; } - fullpath = Glib::build_filename (fullpath, legalize_for_path (_name) + ".profile"); - + fullpath = Glib::build_filename (fullpath, string_compose ("%1%2", legalize_for_path (name()), devprofile_suffix)); + XMLTree tree; tree.set_root (&get_state()); @@ -345,4 +370,3 @@ DeviceProfile::save () error << string_compose ("MCP profile not saved to %1", fullpath) << endmsg; } } -