Normalize XML property name style, preserving old session loading (on load _ will be converted to -).

Still to go:  Non-consistent PBD tag names, colours.


git-svn-id: svn://localhost/ardour2/branches/3.0@3872 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
David Robillard 2008-10-05 23:14:48 +00:00
parent 14a40f32f6
commit 6b0d22268b
15 changed files with 61 additions and 56 deletions

View File

@ -463,16 +463,16 @@ ARDOUR_UI::set_transport_controllable_state (const XMLNode& node)
if ((prop = node.property ("stop")) != 0) {
stop_controllable->set_id (prop->value());
}
if ((prop = node.property ("goto_start")) != 0) {
if ((prop = node.property ("goto-start")) != 0) {
goto_start_controllable->set_id (prop->value());
}
if ((prop = node.property ("goto_end")) != 0) {
if ((prop = node.property ("goto-end")) != 0) {
goto_end_controllable->set_id (prop->value());
}
if ((prop = node.property ("auto_loop")) != 0) {
if ((prop = node.property ("auto-loop")) != 0) {
auto_loop_controllable->set_id (prop->value());
}
if ((prop = node.property ("play_selection")) != 0) {
if ((prop = node.property ("play-selection")) != 0) {
play_selection_controllable->set_id (prop->value());
}
if ((prop = node.property ("rec")) != 0) {

View File

@ -148,7 +148,7 @@ guint32
AudioTimeAxisView::show_at (double y, int& nth, Gtk::VBox *parent)
{
ensure_xml_node ();
xml_node->add_property ("shown_editor", "yes");
xml_node->add_property ("shown-editor", "yes");
return TimeAxisView::show_at (y, nth, parent);
}
@ -157,7 +157,7 @@ void
AudioTimeAxisView::hide ()
{
ensure_xml_node ();
xml_node->add_property ("shown_editor", "no");
xml_node->add_property ("shown-editor", "no");
TimeAxisView::hide ();
}

View File

@ -885,7 +885,7 @@ AutomationTimeAxisView::set_state (const XMLNode& node)
XMLProperty* type = (*iter)->property("automation-id");
if (type && type->value() == ARDOUR::EventTypeMap::instance().to_symbol(_control->parameter())) {
XMLProperty *shown = (*iter)->property("shown_editor");
XMLProperty *shown = (*iter)->property("shown-editor");
if (shown && shown->value() == "yes") {
set_marked_for_display(true);

View File

@ -2434,12 +2434,12 @@ Editor::set_state (const XMLNode& node)
} else {
g.base_width = atoi(geometry->property("x_size")->value());
g.base_height = atoi(geometry->property("y_size")->value());
x = atoi(geometry->property("x_pos")->value());
y = atoi(geometry->property("y_pos")->value());
xoff = atoi(geometry->property("x_off")->value());
yoff = atoi(geometry->property("y_off")->value());
g.base_width = atoi(geometry->property("x-size")->value());
g.base_height = atoi(geometry->property("y-size")->value());
x = atoi(geometry->property("x-pos")->value());
y = atoi(geometry->property("y-pos")->value());
xoff = atoi(geometry->property("x-off")->value());
yoff = atoi(geometry->property("y-off")->value());
}
set_default_size (g.base_width, g.base_height);
@ -2607,17 +2607,17 @@ Editor::get_state ()
XMLNode* geometry = new XMLNode ("geometry");
snprintf(buf, sizeof(buf), "%d", width);
geometry->add_property("x_size", string(buf));
geometry->add_property("x-size", string(buf));
snprintf(buf, sizeof(buf), "%d", height);
geometry->add_property("y_size", string(buf));
geometry->add_property("y-size", string(buf));
snprintf(buf, sizeof(buf), "%d", x);
geometry->add_property("x_pos", string(buf));
geometry->add_property("x-pos", string(buf));
snprintf(buf, sizeof(buf), "%d", y);
geometry->add_property("y_pos", string(buf));
geometry->add_property("y-pos", string(buf));
snprintf(buf, sizeof(buf), "%d", xoff);
geometry->add_property("x_off", string(buf));
geometry->add_property("x-off", string(buf));
snprintf(buf, sizeof(buf), "%d", yoff);
geometry->add_property("y_off", string(buf));
geometry->add_property("y-off", string(buf));
snprintf(buf,sizeof(buf), "%d",gtk_paned_get_position (static_cast<Paned*>(&edit_pane)->gobj()));
geometry->add_property("edit_pane_pos", string(buf));
@ -3920,8 +3920,8 @@ Editor::pane_allocation_handler (Allocation &alloc, Paned* which)
width = default_width;
height = default_height;
} else {
width = atoi(geometry->property("x_size")->value());
height = atoi(geometry->property("y_size")->value());
width = atoi(geometry->property("x-size")->value());
height = atoi(geometry->property("y-size")->value());
}
if (which == static_cast<Paned*> (&edit_pane)) {
@ -3930,7 +3930,7 @@ Editor::pane_allocation_handler (Allocation &alloc, Paned* which)
return;
}
if (!geometry || (prop = geometry->property ("edit_pane_pos")) == 0) {
if (!geometry || (prop = geometry->property ("edit-pane-pos")) == 0) {
/* initial allocation is 90% to canvas, 10% to notebook */
pos = (int) floor (alloc.get_width() * 0.90f);
snprintf (buf, sizeof(buf), "%d", pos);

View File

@ -175,7 +175,7 @@ guint32
MidiTimeAxisView::show_at (double y, int& nth, Gtk::VBox *parent)
{
ensure_xml_node ();
xml_node->add_property ("shown_editor", "yes");
xml_node->add_property ("shown-editor", "yes");
guint32 ret = TimeAxisView::show_at (y, nth, parent);
return ret;
@ -185,7 +185,7 @@ void
MidiTimeAxisView::hide ()
{
ensure_xml_node ();
xml_node->add_property ("shown_editor", "no");
xml_node->add_property ("shown-editor", "no");
TimeAxisView::hide ();
}

View File

@ -424,11 +424,11 @@ MixerStrip::set_stuff_from_route ()
/* if width is not set, it will be set by the MixerUI or editor */
if ((prop = xml_node->property ("strip_width")) != 0) {
if ((prop = xml_node->property ("strip-width")) != 0) {
set_width (Width (string_2_enum (prop->value(), _width)), this);
}
if ((prop = xml_node->property ("shown_mixer")) != 0) {
if ((prop = xml_node->property ("shown-mixer")) != 0) {
if (prop->value() == "no") {
_marked_for_display = false;
} else {
@ -459,7 +459,7 @@ MixerStrip::set_width (Width w, void* owner)
_width = w;
if (_width_owner == this) {
xml_node->add_property ("strip_width", enum_2_string (_width));
xml_node->add_property ("strip-width", enum_2_string (_width));
}
switch (w) {
@ -526,9 +526,9 @@ MixerStrip::set_packed (bool yn)
ensure_xml_node ();
if (_packed) {
xml_node->add_property ("shown_mixer", "yes");
xml_node->add_property ("shown-mixer", "yes");
} else {
xml_node->add_property ("shown_mixer", "no");
xml_node->add_property ("shown-mixer", "no");
}
}

View File

@ -1267,10 +1267,10 @@ Mixer_UI::set_state (const XMLNode& node)
} else {
m_width = atoi(geometry->property("x_size")->value().c_str());
m_height = atoi(geometry->property("y_size")->value().c_str());
m_root_x = atoi(geometry->property("x_pos")->value().c_str());
m_root_y = atoi(geometry->property("y_pos")->value().c_str());
m_width = atoi(geometry->property("x-size")->value().c_str());
m_height = atoi(geometry->property("y-size")->value().c_str());
m_root_x = atoi(geometry->property("x-pos")->value().c_str());
m_root_y = atoi(geometry->property("y-pos")->value().c_str());
}
set_window_pos_and_size ();
@ -1350,8 +1350,8 @@ Mixer_UI::pane_allocation_handler (Allocation& alloc, Gtk::Paned* which)
width = default_width;
height = default_height;
} else {
width = atoi(geometry->property("x_size")->value());
height = atoi(geometry->property("y_size")->value());
width = atoi(geometry->property("x-size")->value());
height = atoi(geometry->property("y-size")->value());
}
if (which == static_cast<Gtk::Paned*> (&rhs_pane1)) {
@ -1360,7 +1360,7 @@ Mixer_UI::pane_allocation_handler (Allocation& alloc, Gtk::Paned* which)
return;
}
if (!geometry || (prop = geometry->property("mixer_rhs_pane1_pos")) == 0) {
if (!geometry || (prop = geometry->property("mixer-rhs-pane1-pos")) == 0) {
pos = height / 3;
snprintf (buf, sizeof(buf), "%d", pos);
} else {
@ -1377,7 +1377,7 @@ Mixer_UI::pane_allocation_handler (Allocation& alloc, Gtk::Paned* which)
return;
}
if (!geometry || (prop = geometry->property("mixer_list_hpane_pos")) == 0) {
if (!geometry || (prop = geometry->property("mixer-list-hpane-pos")) == 0) {
pos = 75;
snprintf (buf, sizeof(buf), "%d", pos);
} else {

View File

@ -982,7 +982,7 @@ TimeAxisView::get_state ()
snprintf (buf, sizeof(buf), "%u", height);
node->add_property ("height", buf);
node->add_property ("marked_for_display", (_marked_for_display ? "1" : "0"));
node->add_property ("marked-for-display", (_marked_for_display ? "1" : "0"));
return *node;
}
@ -991,11 +991,11 @@ TimeAxisView::set_state (const XMLNode& node)
{
const XMLProperty *prop;
if ((prop = node.property ("marked_for_display")) != 0) {
if ((prop = node.property ("marked-for-display")) != 0) {
_marked_for_display = (prop->value() == "1");
}
if ((prop = node.property ("track_height")) != 0) {
if ((prop = node.property ("track-height")) != 0) {
if (prop->value() == "largest") {
set_height (hLargest);

View File

@ -171,7 +171,7 @@ AudioPlaylistImporter::move ()
boost::shared_ptr<Playlist> playlist;
// Update diskstream id
xml_playlist.property ("orig_diskstream_id")->set_value (diskstream_id.to_s());
xml_playlist.property ("orig-diskstream-id")->set_value (diskstream_id.to_s());
// Update region XML in playlist and prepare sources
xml_playlist.remove_nodes("Region");

View File

@ -227,11 +227,11 @@ AutomationList::state (bool full)
snprintf (buf, sizeof (buf), "%.12g", _default_value);
root->add_property ("default", buf);
snprintf (buf, sizeof (buf), "%.12g", _min_yval);
root->add_property ("min_yval", buf);
root->add_property ("min-yval", buf);
snprintf (buf, sizeof (buf), "%.12g", _max_yval);
root->add_property ("max_yval", buf);
root->add_property ("max-yval", buf);
snprintf (buf, sizeof (buf), "%.12g", _max_xval);
root->add_property ("max_xval", buf);
root->add_property ("max-xval", buf);
root->add_property ("interpolation-style", enum_2_string (_interpolation));

View File

@ -263,7 +263,7 @@ int MidiModel::DeltaCommand::set_state(const XMLNode& delta_command)
XMLNode& MidiModel::DeltaCommand::get_state()
{
XMLNode *delta_command = new XMLNode(DELTA_COMMAND_ELEMENT);
delta_command->add_property("midi_source", _model->midi_source()->id().to_s());
delta_command->add_property("midi-source", _model->midi_source()->id().to_s());
XMLNode *added_notes = delta_command->add_child(ADDED_NOTES_ELEMENT);
for_each(_added_notes.begin(), _added_notes.end(), sigc::compose(

View File

@ -1098,7 +1098,7 @@ Region::state (bool full_state)
break;
}
node->add_property ("first_edit", fe);
node->add_property ("first-edit", fe);
/* note: flags are stored by derived classes */

View File

@ -54,7 +54,7 @@ Session::memento_command_factory(XMLNode *n)
XMLNode *child = 0;
/* get id */
id = PBD::ID(n->property("obj_id")->value());
id = PBD::ID(n->property("obj-id")->value());
/* get before/after */
@ -81,7 +81,7 @@ Session::memento_command_factory(XMLNode *n)
}
/* create command */
string obj_T = n->property ("type_name")->value();
string obj_T = n->property ("type-name")->value();
if (obj_T == typeid (AudioRegion).name() || obj_T == typeid (MidiRegion).name() || obj_T == typeid (Region).name()) {
if (regions.count(id)) {
return new MementoCommand<Region>(*regions[id], before, after);

View File

@ -820,7 +820,7 @@ Session::load_state (string snapshot_name)
}
const XMLProperty* prop;
bool is_old = false;
bool is_old = false; // session is _very_ old (pre-2.0)
if ((prop = root.property ("version")) == 0) {
/* no version implies very old version of Ardour */
@ -3013,22 +3013,21 @@ Session::restore_history (string snapshot_name)
struct timeval tv;
ut->set_name(t->property("name")->value());
stringstream ss(t->property("tv_sec")->value());
stringstream ss(t->property("tv-sec")->value());
ss >> tv.tv_sec;
ss.str(t->property("tv_usec")->value());
ss.str(t->property("tv-usec")->value());
ss >> tv.tv_usec;
ut->set_timestamp(tv);
for (XMLNodeConstIterator child_it = t->children().begin();
child_it != t->children().end();
child_it++)
child_it != t->children().end(); child_it++)
{
XMLNode *n = *child_it;
Command *c;
if (n->name() == "MementoCommand" ||
n->name() == "MementoUndoCommand" ||
n->name() == "MementoRedoCommand") {
n->name() == "MementoUndoCommand" ||
n->name() == "MementoRedoCommand") {
if ((c = memento_command_factory(n))) {
ut->add_command(c);
@ -3041,7 +3040,7 @@ Session::restore_history (string snapshot_name)
}
} else if (n->name() == "DeltaCommand") {
PBD::ID id(n->property("midi_source")->value());
PBD::ID id(n->property("midi-source")->value());
boost::shared_ptr<MidiSource> midi_source =
boost::dynamic_pointer_cast<MidiSource, Source>(source_by_id(id));
if(midi_source) {

View File

@ -475,6 +475,12 @@ XMLProperty::XMLProperty(const string &n, const string &v)
: _name(n),
_value(v)
{
// Normalize property name (replace '_' with '-' as old session are inconsistent)
for (size_t i = 0; i < _name.length(); ++i) {
if (_name[i] == '_') {
_name[i] = '-';
}
}
}
XMLProperty::~XMLProperty()