#include "mackie_control_protocol.h"
#include "device_profile.h"
-#include "i18n.h"
+#include "pbd/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<std::string,DeviceProfile> 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)
{
}
void
DeviceProfile::reload_device_profiles ()
{
- DeviceProfile dp;
vector<string> s;
vector<string> devprofiles;
Searchpath spath (devprofile_search_path());
for (vector<string>::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;
}
/* name is mandatory */
-
+
if ((child = node.child ("Name")) == 0 || (prop = child->property ("value")) == 0) {
return -1;
} else {
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;
}
}
}
+ edited = false;
+
return 0;
}
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()) {
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
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());
error << string_compose ("MCP profile not saved to %1", fullpath) << endmsg;
}
}
-