Undo, redo

From Buzztrax

Jump to: navigation, search

The editor app. needs undo/redo. As a side effect handling undo/redo makes it easy to detect when the song has been changed. If there is nothing to undo since last save (load), it has not been changed ;).

Existing implementations


GUndo manages a sequence of actions. Echo action has callbacks for undo/redo and free. One can link toolbar/menu items to the sequence and the allow to go back and forth.

Everytime we add an action, we would need to pack the data + some context into a struct. When an action is added, it refs all related objects.

The GUndoSequence is a default implementation of the GUndoHistory Iface. We could have our own (GUndoSequence subclass?) that also write the history to a log file. This can be used for crash recovery. We can use the BtPersistence Iface to serialize the data objects. Maybe we just need two more callback for a new action (serialize/deserialize). It could store/restore the context and use BtPersistence for the objects.


add a machine

bt_setup_add_machine(setup, machine)

  • object: machine
  • parent: setup
  • undo: bt_setup_remove_machine(setup, machine)
  • redo: bt_setup_add_machine(setup, machine)
  • free: g_object_unref(machine)

remove a machine

bt_setup_remove_machine(setup, machine)

  • object: machine
  • parent: setup
  • undo: bt_setup_add_machine(setup, machine)
  • redo: bt_setup_remove_machine(setup, machine)
  • free: g_object_unref(machine)

entering something in a pattern

bt_pattern_set_global_event(pattern, tick, param, value)

  • object: value, old_value, tick, param
  • parent: pattern
  • undo: bt_pattern_set_global_event(patter, tick, param, old_value)
  • redo: bt_pattern_set_global_event(patter, tick, param, value)
  • free: ...


Undo/Redo Links

Support Us


GStreamer Logo
Become a Friend of GNOME
Linux Sound Logo
GNU Library Public Licence
GNU Free Documentation License 1.2