1 /*
2 * This is a plug-in for GIMP.
3 *
4 * Generates clickable image maps.
5 *
6 * Copyright (C) 1998-2003 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 #include "config.h"
24
25 #include <gtk/gtk.h>
26
27 #include "imap_commands.h"
28
29 #include "libgimp/stdplugins-intl.h"
30
31 static CmdExecuteValue_t paste_command_execute(Command_t *parent);
32
33 static CommandClass_t paste_command_class = {
34 NULL, /* paste_command_destruct, */
35 paste_command_execute,
36 NULL, /* paste_command_undo */
37 NULL /* paste_command_redo */
38 };
39
40 typedef struct {
41 Command_t parent;
42 ObjectList_t *list;
43 } PasteCommand_t;
44
45 Command_t*
paste_command_new(ObjectList_t * list)46 paste_command_new(ObjectList_t *list)
47 {
48 PasteCommand_t *command = g_new(PasteCommand_t, 1);
49 command->list = list;
50 return command_init(&command->parent, _("Paste"), &paste_command_class);
51 }
52
53 static void
paste_one_object(Object_t * obj,gpointer data)54 paste_one_object(Object_t *obj, gpointer data)
55 {
56 PasteCommand_t *command = (PasteCommand_t*) data;
57 command_add_subcommand(&command->parent,
58 create_command_new(command->list, obj));
59 }
60
61 static CmdExecuteValue_t
paste_command_execute(Command_t * parent)62 paste_command_execute(Command_t *parent)
63 {
64 PasteCommand_t *command = (PasteCommand_t*) parent;
65 gpointer id;
66
67 id = object_list_add_add_cb(command->list, paste_one_object, command);
68 object_list_paste(command->list);
69 object_list_remove_add_cb(command->list, id);
70 return CMD_APPEND;
71 }
72