From 6b0d22268b85f7033eb7ddcfe9e50e21b86eec34 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 5 Oct 2008 23:14:48 +0000 Subject: 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 --- gtk2_ardour/ardour_ui.cc | 8 ++++---- gtk2_ardour/audio_time_axis.cc | 4 ++-- gtk2_ardour/automation_time_axis.cc | 2 +- gtk2_ardour/editor.cc | 30 +++++++++++++++--------------- gtk2_ardour/midi_time_axis.cc | 4 ++-- gtk2_ardour/mixer_strip.cc | 10 +++++----- gtk2_ardour/mixer_ui.cc | 16 ++++++++-------- gtk2_ardour/time_axis_view.cc | 6 +++--- libs/ardour/audio_playlist_importer.cc | 2 +- libs/ardour/automation_list.cc | 6 +++--- libs/ardour/midi_model.cc | 2 +- libs/ardour/region.cc | 2 +- libs/ardour/session_command.cc | 4 ++-- libs/ardour/session_state.cc | 15 +++++++-------- libs/pbd/xml++.cc | 6 ++++++ 15 files changed, 61 insertions(+), 56 deletions(-) diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index 13b38b1ed4..bf1a5bb5b4 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -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) { diff --git a/gtk2_ardour/audio_time_axis.cc b/gtk2_ardour/audio_time_axis.cc index 20a5be2dcf..0e1bf20204 100644 --- a/gtk2_ardour/audio_time_axis.cc +++ b/gtk2_ardour/audio_time_axis.cc @@ -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 (); } diff --git a/gtk2_ardour/automation_time_axis.cc b/gtk2_ardour/automation_time_axis.cc index acb0921b7f..f2144131ad 100644 --- a/gtk2_ardour/automation_time_axis.cc +++ b/gtk2_ardour/automation_time_axis.cc @@ -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); diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 38b13b8aab..a04df8d1ad 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -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(&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 (&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); diff --git a/gtk2_ardour/midi_time_axis.cc b/gtk2_ardour/midi_time_axis.cc index ef66779f47..9453a05611 100644 --- a/gtk2_ardour/midi_time_axis.cc +++ b/gtk2_ardour/midi_time_axis.cc @@ -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 (); } diff --git a/gtk2_ardour/mixer_strip.cc b/gtk2_ardour/mixer_strip.cc index f98469eb7b..373babf417 100644 --- a/gtk2_ardour/mixer_strip.cc +++ b/gtk2_ardour/mixer_strip.cc @@ -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"); } } diff --git a/gtk2_ardour/mixer_ui.cc b/gtk2_ardour/mixer_ui.cc index 64e8ea0909..2b4eb09e16 100644 --- a/gtk2_ardour/mixer_ui.cc +++ b/gtk2_ardour/mixer_ui.cc @@ -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 (&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 { diff --git a/gtk2_ardour/time_axis_view.cc b/gtk2_ardour/time_axis_view.cc index 9db77c1649..f36a6b71c0 100644 --- a/gtk2_ardour/time_axis_view.cc +++ b/gtk2_ardour/time_axis_view.cc @@ -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); diff --git a/libs/ardour/audio_playlist_importer.cc b/libs/ardour/audio_playlist_importer.cc index d6a2b2f9fb..d7b6ea42fc 100644 --- a/libs/ardour/audio_playlist_importer.cc +++ b/libs/ardour/audio_playlist_importer.cc @@ -171,7 +171,7 @@ AudioPlaylistImporter::move () boost::shared_ptr 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"); diff --git a/libs/ardour/automation_list.cc b/libs/ardour/automation_list.cc index 6e2d959628..68bbd17162 100644 --- a/libs/ardour/automation_list.cc +++ b/libs/ardour/automation_list.cc @@ -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)); diff --git a/libs/ardour/midi_model.cc b/libs/ardour/midi_model.cc index 1f23ee9561..539881e51c 100644 --- a/libs/ardour/midi_model.cc +++ b/libs/ardour/midi_model.cc @@ -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( diff --git a/libs/ardour/region.cc b/libs/ardour/region.cc index 7adc9b80ab..79bdb76aee 100644 --- a/libs/ardour/region.cc +++ b/libs/ardour/region.cc @@ -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 */ diff --git a/libs/ardour/session_command.cc b/libs/ardour/session_command.cc index b696f7d410..bda3475a30 100644 --- a/libs/ardour/session_command.cc +++ b/libs/ardour/session_command.cc @@ -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(*regions[id], before, after); diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 3d5e7fb24e..310df3cbed 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -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 midi_source = boost::dynamic_pointer_cast(source_by_id(id)); if(midi_source) { diff --git a/libs/pbd/xml++.cc b/libs/pbd/xml++.cc index 9643b5d3a8..a42923132b 100644 --- a/libs/pbd/xml++.cc +++ b/libs/pbd/xml++.cc @@ -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() -- cgit v1.2.3