1 /* 2 * This is a plug-in for GIMP. 3 * 4 * Generates clickable image maps. 5 * 6 * Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl 7 * 8 * This program is free software: you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 3 of the License, or 11 * (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program. If not, see <https://www.gnu.org/licenses/>. 20 * 21 */ 22 23 #ifndef _IMAP_COMMAND_H 24 #define _IMAP_COMMAND_H 25 26 #include "imap_object.h" 27 28 #define DEFAULT_UNDO_LEVELS 10 29 30 typedef struct CommandClass_t CommandClass_t; 31 typedef struct Command_t Command_t; 32 typedef struct CommandList_t CommandList_t; 33 34 typedef enum {CMD_APPEND, CMD_DESTRUCT, CMD_IGNORE} CmdExecuteValue_t; 35 36 struct CommandClass_t { 37 void (*destruct)(Command_t*); 38 CmdExecuteValue_t (*execute)(Command_t*); 39 void (*undo)(Command_t*); 40 void (*redo)(Command_t*); 41 }; 42 43 struct Command_t { 44 CommandClass_t *class; 45 CommandList_t *sub_commands; 46 const gchar *name; 47 gboolean locked; 48 }; 49 50 51 typedef Command_t* (*CommandFactory_t)(void); 52 53 typedef void (*CommandListCallbackFunc_t)(Command_t*, gpointer); 54 55 typedef struct { 56 CommandListCallbackFunc_t func; 57 gpointer data; 58 } CommandListCB_t; 59 60 typedef struct { 61 GList *list; 62 } CommandListCallback_t; 63 64 struct CommandList_t { 65 CommandList_t *parent; 66 gint undo_levels; 67 GList *list; 68 GList *undo; /* Pointer to current undo command */ 69 GList *redo; /* Pointer to current redo command */ 70 CommandListCallback_t update_cb; 71 }; 72 73 CommandList_t *command_list_new(gint undo_levels); 74 void command_list_destruct(CommandList_t *list); 75 void command_list_set_undo_level(gint level); 76 void command_list_add(Command_t *command); 77 void command_list_remove_all(void); 78 void command_list_undo(CommandList_t *list); 79 void command_list_undo_all(CommandList_t *list); 80 void command_list_redo(CommandList_t *list); 81 void command_list_redo_all(CommandList_t *list); 82 void command_list_add_update_cb(CommandListCallbackFunc_t func, gpointer data); 83 Command_t *command_list_get_redo_command(void); 84 85 Command_t *command_new(void (*func)(void)); 86 Command_t *command_init(Command_t *command, const gchar *name, 87 CommandClass_t *class); 88 void command_execute(Command_t *command); 89 void command_undo(Command_t *command); 90 void command_redo(Command_t *command); 91 void command_set_name(Command_t *command, const gchar *name); 92 void command_add_subcommand(Command_t *command, Command_t *sub_command); 93 94 void last_command_undo(void); 95 void last_command_redo(void); 96 97 void subcommand_list_add(CommandList_t *list, Command_t *command); 98 Command_t *subcommand_start(const gchar *name); 99 void subcommand_end(void); 100 101 #define command_lock(command) ((command)->locked = TRUE) 102 103 #endif /* _IMAP_COMMAND_H */ 104