settings for a new session
*/
session->save_state ("");
+ session->save_history ();
}
/* there is too much going on, in too many threads, for us to
}
if ((ret = session->save_state (name)) != 0) {
+ session->save_history();
return ret;
}
}
case 1:
session->save_state ("");
+ session->save_history();
break;
}
}
XMLNode& get_state (void);
int set_state (const XMLNode&);
+ PBD::ID id() { return _id; }
protected:
+ PBD::ID _id;
string _name;
guint32 _height;
uint32_t _line_color;
XMLNode& get_state ();
int set_state (const XMLNode& );
+ PBD::ID id() { return _id; }
+
void set_mouse_mode (Editing::MouseMode, bool force=true);
void step_mouse_mode (bool next);
Editing::MouseMode current_mouse_mode () { return mouse_mode; }
ARDOUR::AudioEngine& engine;
bool constructed;
+ PBD::ID _id;
+
PlaylistSelector* _playlist_selector;
void set_frames_per_unit (double);
void remove_point (ControlPoint&);
+ PBD::ID id() { return _id; }
private:
AudioRegionView& rv;
UndoAction get_memento();
+
+ PBD::ID _id;
};
XMLNode &get_state(void);
int set_state (const XMLNode &s);
+ PBD::ID id() { return _id; }
+
void set_max_xval (double);
double get_max_xval() const { return max_xval; }
};
protected:
+ PBD::ID _id;
struct State : public ARDOUR::StateManager::State {
AutomationEventList events;
XMLNode& get_state (void);
int set_state (const XMLNode&);
+ PBD::ID id() { return _id; }
+
private:
+ PBD::ID _id;
string _name;
jack_nframes_t _start;
jack_nframes_t _end;
XMLNode& get_state (void);
int set_state (const XMLNode&);
+ PBD::ID id() { return _id; }
Location* auto_loop_location () const;
Location* auto_punch_location () const;
Change restore_state (StateManager::State&);
StateManager::State* state_factory (std::string why) const;
+
+ PBD::ID _id;
};
} // namespace ARDOUR
EditMode get_edit_mode() const { return _edit_mode; }
void set_edit_mode (EditMode);
+ PBD::ID id() { return _id; }
/* Editing operations */
void add_region (const Region&, jack_nframes_t position, float times = 1, bool with_save = true);
void unset_freeze_child (Playlist*);
void timestamp_layer_op (Region&);
+
+ PBD::ID _id;
};
} /* namespace ARDOUR */
int save_state (string snapshot_name, bool pending = false);
int restore_state (string snapshot_name);
int save_template (string template_name);
+ int save_history ();
static int rename_template (string old_name, string new_name);
XMLNode& get_state (void);
int set_state (const XMLNode&);
+ PBD::ID id();
void dump (std::ostream&) const;
void clear ();
void save_state (std::string why);
+ PBD::ID _id;
+
};
}; /* namespace ARDOUR */
if (get_record_enabled() && get_punch_in()) {
/* capture start has been changed, so save new pending state */
save_state ("", true);
+ save_history();
}
}
*/
save_state ("", true);
+ save_history();
if (_transport_speed) {
if (!punch_in) {
set_dirty();
save_state (_current_snapshot_name);
+ save_history();
DiskstreamAdded (dstream); /* EMIT SIGNAL */
}
*/
save_state (_current_snapshot_name);
+ save_history();
}
SourceRemoved(source); /* EMIT SIGNAL */
_state_of_the_state = Clean;
if (save_state (_current_snapshot_name)) {
+ save_history();
return -1;
}
}
if (state_was_pending) {
save_state (_current_snapshot_name);
+ save_history();
remove_pending_capture_state ();
state_was_pending = false;
}
Session::auto_save()
{
save_state (_current_snapshot_name);
+ save_history();
}
RouteGroup *
Stateful::add_instant_xml (node, dir);
Config->add_instant_xml (node, get_user_ardour_path());
}
+
+
+int
+Session::save_history ()
+{
+ XMLTree tree;
+ string xml_path;
+ string bak_path;
+
+ tree.set_root (&history.get_state());
+
+ xml_path = _path + _current_snapshot_name + ".history";
+
+ bak_path = xml_path + ".bak";
+
+ if ((access (xml_path.c_str(), F_OK) == 0) &&
+ (rename (xml_path.c_str(), bak_path.c_str())))
+ {
+ error << _("could not backup old history file, current history not saved.") << endmsg;
+ return -1;
+ }
+
+ if (!tree.write (xml_path))
+ {
+ error << string_compose (_("history could not be saved to %1"), xml_path) << endmsg;
+
+ /* don't leave a corrupt file lying around if it is
+ * possible to fix.
+ */
+
+ if (unlink (xml_path.c_str()))
+ {
+ error << string_compose (_("could not remove corrupt history file %1"), xml_path) << endmsg;
+ } else {
+ if (rename (bak_path.c_str(), xml_path.c_str()))
+ {
+ error << string_compose (_("could not restore history file from backup %1"), bak_path) << endmsg;
+ }
+ }
+
+ return -1;
+ }
+
+ return 0;
+}
if ((post_transport_work & PostTransportLocate) && get_record_enabled()) {
/* capture start has been changed, so save pending state */
save_state ("", true);
+ save_history();
}
/* always try to get rid of this */
if ((ret = IO::set_name (str, src)) == 0) {
_session.save_state ("");
+ _session.save_history();
}
return ret;
}
XMLNode &Command::get_state()
{
XMLNode *node = new XMLNode ("Command");
- // TODO
+ node->add_content("WARNING: Somebody forgot to subclass Command.");
return *node;
}
#include <inttypes.h>
#include <pbd/id.h>
+#include <string>
using namespace std;
using namespace PBD;
snprintf (buf, 16, "%" PRIu64, id);
}
+string ID::to_s() const
+{
+ char buf[16]; // see print()
+ print(buf);
+ return string(buf);
+}
+
ID&
ID::operator= (string str)
{
}
void print (char* buf) const;
+ std::string to_s() const;
static uint64_t counter() { return _counter; }
static void init_counter (uint64_t val) { _counter = val; }
#define __lib_pbd_memento_command_h__
#include <pbd/command.h>
+#include <pbd/xml++.h>
#include <sigc++/slot.h>
/** This command class is initialized with before and after mementos
virtual XMLNode &get_state()
{
XMLNode *node = new XMLNode("MementoCommand");
- // obj.id
- // key is "MementoCommand" or something
- // before and after mementos
+ node->add_property("obj_id", obj.id().to_s());
+ node->add_child_nocopy(before);
+ node->add_child_nocopy(after);
return *node;
}
// TODO does this need a copy constructor?
void undo() { obj.set_state(before); }
virtual XMLNode &get_state()
{
- XMLNode *node = new XMLNode("MementoUndoCommand"); // XXX
- // obj.id
- // key is "MementoCommand" or something
- // before and after mementos
+ XMLNode *node = new XMLNode("MementoUndoCommand");
+ node->add_property("obj_id", obj.id().to_s());
+ node->add_child_nocopy(before);
return *node;
}
protected:
void undo() { /* noop */ }
virtual XMLNode &get_state()
{
- XMLNode *node = new XMLNode("MementoUndoCommand");
- // obj.id
- // key is "MementoCommand" or something
- // before and after mementos
+ XMLNode *node = new XMLNode("MementoRedoCommand");
+ node->add_property("obj_id", obj.id().to_s());
+ node->add_child_nocopy(after);
return *node;
}
protected:
void clear_undo ();
void clear_redo ();
+ XMLNode &get_state();
+ void save_state();
private:
list<UndoTransaction> UndoList;
list<UndoTransaction> RedoList;
#include <pbd/undo.h>
#include <pbd/xml++.h>
+#include <string>
using namespace std;
using namespace sigc;
XMLNode &UndoTransaction::get_state()
{
XMLNode *node = new XMLNode ("UndoTransaction");
- // TODO
+
+ list<Command*>::iterator it;
+ for (it=actions.begin(); it!=actions.end(); it++)
+ node->add_child_nocopy((*it)->get_state());
+
return *node;
}
RedoList.clear ();
UndoList.clear ();
}
+
+XMLNode & UndoHistory::get_state()
+{
+ XMLNode *node = new XMLNode ("UndoHistory");
+
+ list<UndoTransaction>::iterator it;
+ for (it=UndoList.begin(); it != UndoList.end(); it++)
+ node->add_child_nocopy(it->get_state());
+
+ return *node;
+}
BasicUI::save_state ()
{
session->save_state ("");
+ session->save_history();
}
void