1 /* 2 * gnm-command-impl.h : 3 * 4 * Copyright (C) 1999-2008 Jody Goldberg (jody@gnome.org) 5 * Copyright (C) 2002-2008 Morten Welinder (terra@gnome.org) 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License as 9 * published by the Free Software Foundation; either version 2 of the 10 * License, or (at your option) version 3. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 20 * USA 21 */ 22 #ifndef GNM_COMMAND_IMPL_H 23 #define GNM_COMMAND_IMPL_H 24 25 #include <gnumeric.h> 26 #include <gsf/gsf-impl-utils.h> 27 #include <glib-object.h> 28 29 G_BEGIN_DECLS 30 typedef struct { 31 GObject parent; 32 33 /* primary sheet associated with command, or NULL. */ 34 Sheet *sheet; 35 36 /* See truncate_undo_info. */ 37 int size; 38 39 /* A string to put in the menu */ 40 char const *cmd_descriptor; 41 42 /* State of workbook before the commands was undo. */ 43 guint64 state_before_do; 44 } GnmCommand; 45 46 typedef gboolean (* UndoCmd) (GnmCommand *self, WorkbookControl *wbc); 47 typedef gboolean (* RedoCmd) (GnmCommand *self, WorkbookControl *wbc); 48 typedef void (* RepeatCmd) (GnmCommand const *orig, WorkbookControl *wbc); 49 50 typedef struct { 51 GObjectClass parent_class; 52 53 UndoCmd undo_cmd; 54 RedoCmd redo_cmd; 55 RepeatCmd repeat_cmd; 56 } GnmCommandClass; 57 58 GType gnm_command_get_type (void); 59 void gnm_command_finalize (GObject *obj); 60 gboolean gnm_command_push_undo (WorkbookControl *wbc, GObject *obj); 61 62 #define GNM_COMMAND_TYPE (gnm_command_get_type ()) 63 #define MAKE_GNM_COMMAND(type, func, repeat) \ 64 static gboolean \ 65 func ## _undo (GnmCommand *me, WorkbookControl *wbc); \ 66 static gboolean \ 67 func ## _redo (GnmCommand *me, WorkbookControl *wbc); \ 68 static void \ 69 func ## _finalize (GObject *object); \ 70 static void \ 71 func ## _class_init (GnmCommandClass *parent) \ 72 { \ 73 parent->undo_cmd = (UndoCmd)& func ## _undo; \ 74 parent->redo_cmd = (RedoCmd)& func ## _redo; \ 75 parent->repeat_cmd = repeat; \ 76 parent->parent_class.finalize = & func ## _finalize; \ 77 } \ 78 typedef GnmCommandClass type ## Class; \ 79 static GSF_CLASS (type, func, \ 80 func ## _class_init, NULL, GNM_COMMAND_TYPE) 81 82 G_END_DECLS 83 84 #endif /* GNM_COMMAND_IMPL_H */ 85