Top | ![]() |
![]() |
![]() |
![]() |
BtChangeLog * | bt_change_log_new () |
gboolean | bt_change_log_is_active () |
void | bt_change_log_add () |
void | bt_change_log_redo () |
void | bt_change_log_undo () |
void | bt_change_log_start_group () |
void | bt_change_log_end_group () |
gboolean | bt_change_log_recover () |
void | bt_change_log_register () |
Tracks edits actions since last save. Provides undo/redo. Supports grouping
of edits into single undo/redo items (see bt_change_log_start_group()
).
Edit actions are logged to disk under the users-cache directory for crash recovery. Groups are logged atomically, when they are closed (to have a recoverable log).
Logs are reset when saving a song. The log is removed when a song is closed.
BtEditApplication checks for left-over logs at startup and uses BtCrashRecoverDialog to offer a list of recoverable songs to the user.
When running the application with BT_DEBUG_CHANGE_LOG=1 and if debugging is enabled, one will get extra comments in the edit journal.
BtChangeLog *
bt_change_log_new (void
);
Create a new instance on first call and return a reference later on.
gboolean
bt_change_log_is_active (BtChangeLog *self
);
Checks if the changelog journalling is active. Should be checked before adding entries to avoid logging when e.g. loading a song.
void bt_change_log_add (BtChangeLog *self
,BtChangeLogger *owner
,gchar *undo_data
,gchar *redo_data
);
Add a new change to the change log. Changes are passed as serialized strings.
The change-log takes ownership of undo_data
and redo_data
.
void
bt_change_log_start_group (BtChangeLog *self
);
Open a new group. All further bt_change_log_add()
calls will add to the
active group. The group needs to be closed using bt_change_log_end_group()
.
Groups can be nested.
A top-level group is undone or redone with a single bt_change_log_undo()
or
bt_change_log_redo()
call.
One would start and finish such a group in the first signal handler that triggered the change.
void
bt_change_log_end_group (BtChangeLog *self
);
Closed the last group opened with bt_change_log_start_group()
. Usually
a group would be closed in the same local scope where it was opened.
gboolean bt_change_log_recover (BtChangeLog *self
,const gchar *log_name
);
Recover the given song.
Return: TRUE
for successful recovery.
void bt_change_log_register (BtChangeLog *self
,BtChangeLogger *logger
);
Register a change-logger for use in change log replay.