QOF  0.7.5
qofundo-p.h
1 /***************************************************************************
2  * qofundo-p.h
3  *
4  * Thu Aug 25 09:20:14 2005
5  * Copyright 2005,2006 Neil Williams
6  * linux@codehelp.co.uk
7  ****************************************************************************/
8 /*
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA
22  */
23 
24 #ifndef _QOFUNDO_P_H
25 #define _QOFUNDO_P_H
26 
27 #include <qof.h>
28 #include "qofundo.h"
29 
41 typedef struct QofUndoEntity_t QofUndoEntity;
42 
54 typedef struct QofUndoOperation_t QofUndoOperation;
55 
56 typedef struct QofUndo_s
57 {
58  GList *undo_list;
59  GList *undo_cache;
60  gchar *undo_label;
61  gint index_position;
62  gboolean undo_operation_open;
63 } QofUndo;
64 
65 /* Undo is limited, not infinite. */
66 #define MAX_UNDO_LENGTH 300
67 
68 /* reads the data from this parameter to allow undo
69 
70 To be able to undo and then redo an action, QOF needs to know the
71 before and after states. Initially, the before state is the same as
72 the file but after that point, the state of the entity needs to be
73 tracked whenever it is opened for editing.
74 */
75 QofUndoEntity *
76 qof_prepare_undo (QofEntity * ent, const QofParam * param);
77 
78 /* Add the changes to be undone to the event.
79 
80 Designed to be used with g_list_foreach, simply adds
81 any number of undo_entity pointers (representing the
82 entity changes relating to this event) to the list
83 of changes for this event.
84 */
85 void
86 qof_undo_new_entry (gpointer event, gpointer changes);
87 
88 /* Add an undo event to the list.
89 
90 type holds the type of event that has just occurred.
91 
92 If the event follows a successful qof_commit_edit, then the
93 cached undo_entity changes are placed into this undo_event.
94 */
95 QofUndoOperation *
96 qof_undo_new_operation (QofBook * book, gchar * label);
97 
98 #endif /* _QOFUNDO_P_H */