GUI: Dead kittens.
[gnumeric.git] / src / gnm-command-impl.h
blob5edf5424b0ee6472cc3fbc65bc2cb2ab681fc315
1 /* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3 * gnm-command-impl.h :
5 * Copyright (C) 1999-2008 Jody Goldberg (jody@gnome.org)
6 * Copyright (C) 2002-2008 Morten Welinder (terra@gnome.org)
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of the
11 * License, or (at your option) version 3.
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.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
21 * USA
23 #ifndef GNM_COMMAND_IMPL_H
24 #define GNM_COMMAND_IMPL_H
26 #include "gnumeric.h"
27 #include <gsf/gsf-impl-utils.h>
28 #include <glib-object.h>
30 G_BEGIN_DECLS
31 typedef struct {
32 GObject parent;
34 /* primary sheet associated with command, or NULL. */
35 Sheet *sheet;
37 /* See truncate_undo_info. */
38 int size;
40 /* A string to put in the menu */
41 char const *cmd_descriptor;
43 /* State of workbook before the commands was undo. */
44 gboolean workbook_modified_before_do;
45 } GnmCommand;
47 typedef gboolean (* UndoCmd) (GnmCommand *self, WorkbookControl *wbc);
48 typedef gboolean (* RedoCmd) (GnmCommand *self, WorkbookControl *wbc);
49 typedef void (* RepeatCmd) (GnmCommand const *orig, WorkbookControl *wbc);
51 typedef struct {
52 GObjectClass parent_class;
54 UndoCmd undo_cmd;
55 RedoCmd redo_cmd;
56 RepeatCmd repeat_cmd;
57 } GnmCommandClass;
59 GType gnm_command_get_type (void);
60 void gnm_command_finalize (GObject *obj);
61 gboolean gnm_command_push_undo (WorkbookControl *wbc, GObject *obj);
63 #define GNM_COMMAND_TYPE (gnm_command_get_type ())
64 #define MAKE_GNM_COMMAND(type, func, repeat) \
65 static gboolean \
66 func ## _undo (GnmCommand *me, WorkbookControl *wbc); \
67 static gboolean \
68 func ## _redo (GnmCommand *me, WorkbookControl *wbc); \
69 static void \
70 func ## _finalize (GObject *object); \
71 static void \
72 func ## _class_init (GnmCommandClass *parent) \
73 { \
74 parent->undo_cmd = (UndoCmd)& func ## _undo; \
75 parent->redo_cmd = (RedoCmd)& func ## _redo; \
76 parent->repeat_cmd = repeat; \
77 parent->parent_class.finalize = & func ## _finalize; \
78 } \
79 typedef GnmCommandClass type ## Class; \
80 static GSF_CLASS (type, func, \
81 func ## _class_init, NULL, GNM_COMMAND_TYPE)
83 G_END_DECLS
85 #endif /* GNM_COMMAND_IMPL_H */