static struct LayerVisibilityChange * undo_layer_visibility(Diagram *dia, Layer *layer, gboolean exclusive) { struct LayerVisibilityChange *change; GList *visibilities = NULL; int i; GPtrArray *layers = dia->data->layers; change = g_new0(struct LayerVisibilityChange, 1); change->change.apply = (UndoApplyFunc) layer_visibility_change_apply; change->change.revert = (UndoRevertFunc) layer_visibility_change_revert; change->change.free = (UndoFreeFunc) layer_visibility_change_free; for (i = 0; i < layers->len; i++) { Layer *temp_layer = (Layer *) g_ptr_array_index(layers, i); visibilities = g_list_append(visibilities, (gpointer)temp_layer->visible); } change->original_visibility = visibilities; change->layer = layer; change->is_exclusive = exclusive; undo_push_change(dia->undo, (Change *) change); return change; }
/** Create a new Change object for parenting/unparenting. * `parent' is TRUE if applying this change makes childobj a * child of parentobj. */ Change * undo_parenting(Diagram *dia, DiaObject* parentobj, DiaObject* childobj, gboolean parent) { struct ParentChange *parentchange = g_new0(struct ParentChange, 1); Change *change = (Change*)parentchange; change->apply = parent_change_apply; change->revert = parent_change_revert; change->free = parent_change_free; parentchange->parentobj = parentobj; parentchange->childobj = childobj; parentchange->parent = parent; DEBUG_PRINTF(("UNDO: Push new obj_change at %d\n", depth(dia->undo))); undo_push_change(dia->undo, change); return change; }
static Change * undo_layer(Diagram *dia, Layer *layer, enum LayerChangeType type, int index) { struct LayerChange *change; change = g_new0(struct LayerChange, 1); change->change.apply = (UndoApplyFunc) layer_change_apply; change->change.revert = (UndoRevertFunc) layer_change_revert; change->change.free = (UndoFreeFunc) layer_change_free; change->type = type; change->layer = layer; change->index = index; change->applied = 1; undo_push_change(dia->undo, (Change *) change); return (Change *)change; }
Change * undo_object_change(Diagram *dia, DiaObject *obj, ObjectChange *obj_change) { struct ObjectChangeChange *change; change = g_new0(struct ObjectChangeChange, 1); change->change.apply = (UndoApplyFunc) object_change_apply; change->change.revert = (UndoRevertFunc) object_change_revert; change->change.free = (UndoFreeFunc) object_change_free; change->obj = obj; change->obj_change = obj_change; DEBUG_PRINTF(("UNDO: Push new obj_change at %d\n", depth(dia->undo))); undo_push_change(dia->undo, (Change *) change); return (Change *)change; }
Change * undo_insert_objects(Diagram *dia, GList *obj_list, int applied) { struct InsertObjectsChange *change; change = g_new0(struct InsertObjectsChange, 1); change->change.apply = (UndoApplyFunc) insert_objects_apply; change->change.revert = (UndoRevertFunc) insert_objects_revert; change->change.free = (UndoFreeFunc) insert_objects_free; change->layer = dia->data->active_layer; change->obj_list = obj_list; change->applied = applied; DEBUG_PRINTF(("UNDO: Push new insert objects at %d\n", depth(dia->undo))); undo_push_change(dia->undo, (Change *) change); return (Change *)change; }
extern Change * undo_unconnect(Diagram *dia, DiaObject *obj, Handle *handle) { struct UnconnectChange *change; change = g_new0(struct UnconnectChange, 1); change->change.apply = (UndoApplyFunc) unconnect_apply; change->change.revert = (UndoRevertFunc) unconnect_revert; change->change.free = (UndoFreeFunc) unconnect_free; change->obj = obj; change->handle = handle; change->connectionpoint = handle->connected_to; DEBUG_PRINTF(("UNDO: Push new unconnect at %d\n", depth(dia->undo))); undo_push_change(dia->undo, (Change *) change); return (Change *)change; }
Change * undo_reorder_objects(Diagram *dia, GList *changed_list, GList *orig_list) { struct ReorderObjectsChange *change; change = g_new0(struct ReorderObjectsChange, 1); change->change.apply = (UndoApplyFunc) reorder_objects_apply; change->change.revert = (UndoRevertFunc) reorder_objects_revert; change->change.free = (UndoFreeFunc) reorder_objects_free; change->layer = dia->data->active_layer; change->changed_list = changed_list; change->original_objects = orig_list; change->reordered_objects = g_list_copy(dia->data->active_layer->objects); DEBUG_PRINTF(("UNDO: Push new reorder objects at %d\n", depth(dia->undo))); undo_push_change(dia->undo, (Change *) change); return (Change *)change; }
Change * undo_delete_objects(Diagram *dia, GList *obj_list) { struct DeleteObjectsChange *change; change = g_new0(struct DeleteObjectsChange, 1); change->change.apply = (UndoApplyFunc) delete_objects_apply; change->change.revert = (UndoRevertFunc) delete_objects_revert; change->change.free = (UndoFreeFunc) delete_objects_free; change->layer = dia->data->active_layer; change->obj_list = obj_list; change->original_objects = g_list_copy(dia->data->active_layer->objects); change->applied = 0; DEBUG_PRINTF(("UNDO: Push new delete objects at %d\n", depth(dia->undo))); undo_push_change(dia->undo, (Change *) change); return (Change *)change; }
extern Change * undo_move_objects(Diagram *dia, Point *orig_pos, Point *dest_pos, GList *obj_list) { struct MoveObjectsChange *change; change = g_new0(struct MoveObjectsChange, 1); change->change.apply = (UndoApplyFunc) move_objects_apply; change->change.revert = (UndoRevertFunc) move_objects_revert; change->change.free = (UndoFreeFunc) move_objects_free; change->orig_pos = orig_pos; change->dest_pos = dest_pos; change->obj_list = obj_list; DEBUG_PRINTF(("UNDO: Push new move objects at %d\n", depth(dia->undo))); undo_push_change(dia->undo, (Change *) change); return (Change *)change; }
Change * undo_move_object_other_layer(Diagram *dia, GList *selected_list, gboolean moving_up) { MoveObjectToLayerChange *movetolayerchange = g_new0(MoveObjectToLayerChange, 1); Change *change = (Change*)movetolayerchange; change->apply = (UndoApplyFunc) move_object_to_layer_apply; change->revert = (UndoRevertFunc) move_object_to_layer_revert; change->free = (UndoFreeFunc) move_object_to_layer_free; movetolayerchange->orig_layer = dia->data->active_layer; movetolayerchange->orig_list = g_list_copy(dia->data->active_layer->objects); movetolayerchange->objects = g_list_copy(selected_list); movetolayerchange->moving_up = moving_up; DEBUG_PRINTF(("UNDO: Push new obj_layer_change at %d\n", depth(dia->undo))); undo_push_change(dia->undo, change); return change; }
void undo_set_transactionpoint(UndoStack *stack) { Change *transaction; if (is_transactionpoint(stack->current_change)) return; DEBUG_PRINTF(("UNDO: Push new transactionpoint at %d\n", depth(stack))); transaction = new_transactionpoint(); undo_push_change(stack, transaction); stack->depth++; DEBUG_PRINTF(("Increasing stack depth to: %d\n", stack->depth)); if (prefs.undo_depth > 0) { while (stack->depth > prefs.undo_depth){ undo_delete_lowest_transaction(stack); } } }
Change * undo_ungroup_objects(Diagram *dia, GList *obj_list, DiaObject *group, int group_index) { struct UngroupObjectsChange *change; change = g_new0(struct UngroupObjectsChange, 1); change->change.apply = (UndoApplyFunc) ungroup_objects_apply; change->change.revert = (UndoRevertFunc) ungroup_objects_revert; change->change.free = (UndoFreeFunc) ungroup_objects_free; change->layer = dia->data->active_layer; change->group = group; change->obj_list = obj_list; change->group_index = group_index; change->applied = 1; DEBUG_PRINTF(("UNDO: Push new ungroup objects at %d\n", depth(dia->undo))); undo_push_change(dia->undo, (Change *) change); return (Change *)change; }
Change * undo_move_handle(Diagram *dia, Handle *handle, DiaObject *obj, Point orig_pos, Point dest_pos) { struct MoveHandleChange *change; change = g_new0(struct MoveHandleChange, 1); change->change.apply = (UndoApplyFunc) move_handle_apply; change->change.revert = (UndoRevertFunc) move_handle_revert; change->change.free = (UndoFreeFunc) move_handle_free; change->orig_pos = orig_pos; change->dest_pos = dest_pos; change->handle = handle; change->obj = obj; DEBUG_PRINTF(("UNDO: Push new move handle at %d\n", depth(dia->undo))); undo_push_change(dia->undo, (Change *) change); return (Change *)change; }