GOUndo: GOffice Reference Manual

## GOUndo GOUndo — Generic Undo support |

## Functions

void | (*GOUndoBinaryFunc) ()
void | (*GOUndoUnaryFunc) ()
GOUndo * | go_undo_binary_new ()
GOUndo * | go_undo_combine ()
void | go_undo_group_add ()
GOUndoGroup * | go_undo_group_new ()
GOUndo * | go_undo_unary_new ()
void | go_undo_undo ()
void | go_undo_undo_with_data ()

## Types and Values

struct | GOUndo
struct | GOUndoBinary
struct | GOUndoBinaryClass
struct | GOUndoClass
struct | GOUndoGroup
struct | GOUndoGroupClass
struct | GOUndoUnary
struct | GOUndoUnaryClass

## Object Hierarchy

        GObject
        ╰── GOUndo
            ├── GOUndoBinary
            ├── GOUndoGroup
            ╰── GOUndoUnary

## Description

GOUndo objects are closures that allow for implementing generic undo support in a application.

The undo operation can either be a single operations or a compound operations. Easy support is available for undo operations that need one ("unary") or two ("binary") data pointers. The undo object handles the life cycle of the data pointers.

## Functions

### GOUndoBinaryFunc ()

    void
    (*GOUndoBinaryFunc) (gpointer a,
                         gpointer b,
                         gpointer data);

### GOUndoUnaryFunc ()

    void
    (*GOUndoUnaryFunc) (gpointer a,
                        gpointer data);

### go_undo_binary_new ()

    GOUndo *
    go_undo_binary_new (gpointer a,
                        gpointer b,
                        GOUndoBinaryFunc undo,
                        GFreeFunc fa,
                        GFreeFunc fb);

This function creates a new undo object for undo operations of two arguments. (In addition, an undo-time argument is added for context.)

#### Parameters

a | first argument for undo operation |
b | second argument for undo operation |
undo | function to call with arguments `a` and `b` for undo. | [scope async][not nullable]
fa | function to free `a` . | [scope async][nullable]
fb | function to free `b` . | [scope async][nullable]

#### Returns

a new undo object.

[transfer full]

### go_undo_combine ()

    GOUndo *
    go_undo_combine (GOUndo *a,
                     GOUndo *b);

This function combines two undo operations into one. For convenience, either argument may be `NULL` in which case the other is returned.

#### Parameters

a | first undo operation. | [transfer full][nullable]
b | last undo operation. | [transfer full][nullable]

#### Returns

the combination of two undo operations.

[transfer full][nullable]

### go_undo_group_add ()

    void
    go_undo_group_add (GOUndoGroup *g,
                       GOUndo *u);

This function adds `u` to `g` .

#### Parameters

g | undo group |
u | undo object. | [transfer full]

### go_undo_group_new ()

    GOUndoGroup *
    go_undo_group_new (void);

This function creates a new undo group for compounding undo objects.

#### Returns

a new, empty undo group.

### go_undo_unary_new ()

    GOUndo *
    go_undo_unary_new (gpointer a,
                       GOUndoUnaryFunc undo,
                       GFreeFunc fa);

This function creates a new undo object for undo operations of one argument. (In addition, an undo-time argument is added for context.)

#### Parameters

a | argument for undo operation |
undo | function to call with argument `a` for undo. | [scope async][not nullable]
fa | function to free `a` . | [scope async][nullable]

#### Returns

a new undo object.

[transfer full]

### go_undo_undo ()

    void
    go_undo_undo (GOUndo *u);

Execute the stored undo operation.

#### Parameters

u | undo object |

### go_undo_undo_with_data ()

    void
    go_undo_undo_with_data (GOUndo *u,
                            gpointer data);

Execute the stored undo operation. `data` is supplied to the undo operation as an extra argument. It is meant not to affect the undo operation in any way, but rather supply a context through which progress and errors can be reported.

#### Parameters

u | undo object |
data | user data |

## Types and Values

### struct GOUndo

    struct GOUndo;

### struct GOUndoBinary

    struct GOUndoBinary;

### struct GOUndoBinaryClass

    struct GOUndoBinaryClass {
    	GOUndoClass base;
    };

#### Members

GOUndoClass `base`; | base class. |

### struct GOUndoClass

    struct GOUndoClass {
    	GObjectClass base;

    	void (*undo) (GOUndo *u, gpointer data);
    };

#### Members

GObjectClass `base`; | base class. |
`undo` () | undo. }; |

### struct GOUndoGroup

    struct GOUndoGroup;

### struct GOUndoGroupClass

    struct GOUndoGroupClass {
    	GOUndoClass base;
    };

#### Members

GOUndoClass `base`; | base class. |

### struct GOUndoUnary

    struct GOUndoUnary;

### struct GOUndoUnaryClass

    struct GOUndoUnaryClass {
    	GOUndoClass base;
    };

#### Members

GOUndoClass `base`; | base class. |