imap_cmd_create.c 2.29 KB
Newer Older
Sven Neumann's avatar
Sven Neumann committed
1
/*
2
 * This is a plug-in for GIMP.
Sven Neumann's avatar
Sven Neumann committed
3 4 5
 *
 * Generates clickable image maps.
 *
6
 * Copyright (C) 1998-2003 Maurits Rijk  lpeek.mrijk@consunet.nl
Sven Neumann's avatar
Sven Neumann committed
7
 *
8
 * This program is free software: you can redistribute it and/or modify
Sven Neumann's avatar
Sven Neumann committed
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
Sven Neumann's avatar
Sven Neumann committed
11 12 13 14 15 16 17 18
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * 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/>.
Sven Neumann's avatar
Sven Neumann committed
20 21 22
 *
 */

23 24
#include "config.h"

25 26
#include <gtk/gtk.h>

27
#include "imap_commands.h"
28

Sven Neumann's avatar
Sven Neumann committed
29 30
#include "imap_main.h"

31 32
#include "libgimp/stdplugins-intl.h"

33
static CmdExecuteValue_t create_command_execute(Command_t *parent);
Sven Neumann's avatar
Sven Neumann committed
34 35 36 37 38 39 40
static void create_command_destruct(Command_t *parent);
static void create_command_undo(Command_t *parent);

static CommandClass_t create_command_class = {
   create_command_destruct,
   create_command_execute,
   create_command_undo,
41
   NULL                         /* create_command_redo */
Sven Neumann's avatar
Sven Neumann committed
42 43 44
};

typedef struct {
45
   Command_t     parent;
Sven Neumann's avatar
Sven Neumann committed
46
   ObjectList_t *list;
47 48
   Object_t     *obj;
   gboolean      changed;
Sven Neumann's avatar
Sven Neumann committed
49 50
} CreateCommand_t;

51
Command_t*
Sven Neumann's avatar
Sven Neumann committed
52 53 54 55 56
create_command_new(ObjectList_t *list, Object_t *obj)
{
   CreateCommand_t *command = g_new(CreateCommand_t, 1);
   command->list = list;
   command->obj = object_ref(obj);
57
   return command_init(&command->parent, _("Create"), &create_command_class);
Sven Neumann's avatar
Sven Neumann committed
58 59 60 61 62 63 64 65 66
}

static void
create_command_destruct(Command_t *parent)
{
   CreateCommand_t *command = (CreateCommand_t*) parent;
   object_unref(command->obj);
}

67
static CmdExecuteValue_t
Sven Neumann's avatar
Sven Neumann committed
68 69 70 71 72
create_command_execute(Command_t *parent)
{
   CreateCommand_t *command = (CreateCommand_t*) parent;
   command->changed = object_list_get_changed(command->list);
   object_list_append(command->list, object_ref(command->obj));
73
   return CMD_APPEND;
Sven Neumann's avatar
Sven Neumann committed
74 75 76 77 78 79 80 81 82
}

static void
create_command_undo(Command_t *parent)
{
   CreateCommand_t *command = (CreateCommand_t*) parent;
   object_list_remove(command->list, command->obj);
   object_list_set_changed(command->list, command->changed);
}