Normalize XML property name style, preserving old session loading (on load _ will...
authorDavid Robillard <d@drobilla.net>
Sun, 5 Oct 2008 23:14:48 +0000 (23:14 +0000)
committerDavid Robillard <d@drobilla.net>
Sun, 5 Oct 2008 23:14:48 +0000 (23:14 +0000)
Still to go:  Non-consistent PBD tag names, colours.

git-svn-id: svn://localhost/ardour2/branches/3.0@3872 d708f5d6-7413-0410-9779-e7cbd77b26cf

15 files changed:
gtk2_ardour/ardour_ui.cc
gtk2_ardour/audio_time_axis.cc
gtk2_ardour/automation_time_axis.cc
gtk2_ardour/editor.cc
gtk2_ardour/midi_time_axis.cc
gtk2_ardour/mixer_strip.cc
gtk2_ardour/mixer_ui.cc
gtk2_ardour/time_axis_view.cc
libs/ardour/audio_playlist_importer.cc
libs/ardour/automation_list.cc
libs/ardour/midi_model.cc
libs/ardour/region.cc
libs/ardour/session_command.cc
libs/ardour/session_state.cc
libs/pbd/xml++.cc

index 13b38b1ed469fd991e391deb3f58220ed8c625d7..bf1a5bb5b45a7e5cc749ec97d3f59a9572afb9d5 100644 (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) {
index 20a5be2dcf23ccaa56279f99306d1b99f768201d..0e1bf202040fec2b762254447eea327b6c1f8934 100644 (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 ();
 }
index acb0921b7f8c00c6b8a817abb0122ce5071b9708..f2144131ad86a548bd65d78256d16f0a0e60d24e 100644 (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);
index 38b13b8aabc01a0701db9de80f1dd4934e087b2f..a04df8d1ad76bfc8180fea0421d28e1407fad8ba 100644 (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);
index ef66779f47401769c217c6db8091ad526e5d21f9..9453a05611c45ec4e7efdce44efbfc55190163fa 100644 (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 ();
 }
index f98469eb7b4a313d424a680b429a75411309d2f1..373babf417d47a4cc0701b73c13a96851e032d31 100644 (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");
        }
 }
 
index 64e8ea09092d7ea5cb1ec6617cf9e39ea5628c05..2b4eb09e16b531dc4e1c800783c76ffc8e310444 100644 (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 {
index 9db77c164976fc7d15f9800c4fd99b17d911fe07..f36a6b71c0386d3c95abbeb2deaaab534f06e2b0 100644 (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);
index d6a2b2f9fbc8245c407035b3866c0da9758f5f33..d7b6ea42fc04a2f81a3c3c09318b965cc4d6dd41 100644 (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");
index 6e2d95962893f1c8fd4c85aba31c02935147ef83..68bbd1716244434c47f252ef24380658e41f5cca 100644 (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));
 
index 1f23ee9561481c72b5c6300600d5413402b9ebe6..539881e51c9147e776087c5d7692e39c38cce8dd 100644 (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(
index 7adc9b80ab21e6f7939497e299f7ee49bc88d114..79bdb76aeee973d9c60444defd1b1497d422f71b 100644 (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 */
 
index b696f7d410a6b0f6c3ed61a6b4bc6e1e96239b6b..bda3475a305d19f1344e3b95c51faece04643693 100644 (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);
index 3d5e7fb24e37da9442284c228289cb3ec152e7e0..310df3cbed710763db6c5c28e5d8f55d82b27161 100644 (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) {
index 9643b5d3a831a905600a5f555d3b908b3c7759f0..a42923132bc3042eef8d12fef9a5f32e04dc56a1 100644 (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()