00001 /*************************************************************************** 00002 * qofundo-p.h 00003 * 00004 * Thu Aug 25 09:20:14 2005 00005 * Copyright 2005,2006 Neil Williams 00006 * linux@codehelp.co.uk 00007 ****************************************************************************/ 00008 /* 00009 * This program is free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * This program is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 * GNU General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU General Public License 00020 * along with this program; if not, write to the Free Software 00021 * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA 00022 */ 00023 00024 #ifndef _QOFUNDO_P_H 00025 #define _QOFUNDO_P_H 00026 00027 #include <qof.h> 00028 #include "qofundo.h" 00029 00041 typedef struct QofUndoEntity_t QofUndoEntity; 00042 00054 typedef struct QofUndoOperation_t QofUndoOperation; 00055 00056 typedef struct QofUndo_s 00057 { 00058 GList *undo_list; 00059 GList *undo_cache; 00060 gchar *undo_label; 00061 gint index_position; 00062 gboolean undo_operation_open; 00063 } QofUndo; 00064 00065 /* Undo is limited, not infinite. */ 00066 #define MAX_UNDO_LENGTH 300 00067 00068 /* reads the data from this parameter to allow undo 00069 00070 To be able to undo and then redo an action, QOF needs to know the 00071 before and after states. Initially, the before state is the same as 00072 the file but after that point, the state of the entity needs to be 00073 tracked whenever it is opened for editing. 00074 */ 00075 QofUndoEntity * 00076 qof_prepare_undo (QofEntity * ent, const QofParam * param); 00077 00078 /* Add the changes to be undone to the event. 00079 00080 Designed to be used with g_list_foreach, simply adds 00081 any number of undo_entity pointers (representing the 00082 entity changes relating to this event) to the list 00083 of changes for this event. 00084 */ 00085 void 00086 qof_undo_new_entry (gpointer event, gpointer changes); 00087 00088 /* Add an undo event to the list. 00089 00090 type holds the type of event that has just occurred. 00091 00092 If the event follows a successful qof_commit_edit, then the 00093 cached undo_entity changes are placed into this undo_event. 00094 */ 00095 QofUndoOperation * 00096 qof_undo_new_operation (QofBook * book, gchar * label); 00097 00098 #endif /* _QOFUNDO_P_H */