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 send_to_back_command_execute(Command_t *parent);
32
33 static CommandClass_t send_to_back_command_class = {
34 NULL, /* send_to_back_command_destruct, */
35 send_to_back_command_execute,
36 NULL, /* send_to_back_command_undo */
37 NULL /* send_to_back_command_redo */
38 };
39
40 typedef struct {
41 Command_t parent;
42 ObjectList_t *list;
43 } SendToBackCommand_t;
44
45 Command_t*
send_to_back_command_new(ObjectList_t * list)46 send_to_back_command_new(ObjectList_t *list)
47 {
48 SendToBackCommand_t *command = g_new(SendToBackCommand_t, 1);
49 command->list = list;
50 return command_init(&command->parent, _("Send To Back"),
51 &send_to_back_command_class);
52 }
53
54 static void
remove_one_object(Object_t * obj,gpointer data)55 remove_one_object(Object_t *obj, gpointer data)
56 {
57 SendToBackCommand_t *command = (SendToBackCommand_t*) data;
58 command_add_subcommand(&command->parent,
59 delete_command_new(command->list, obj));
60 }
61
62 static void
add_one_object(Object_t * obj,gpointer data)63 add_one_object(Object_t *obj, gpointer data)
64 {
65 SendToBackCommand_t *command = (SendToBackCommand_t*) data;
66 command_add_subcommand(&command->parent,
67 create_command_new(command->list, obj));
68 }
69
70 static CmdExecuteValue_t
send_to_back_command_execute(Command_t * parent)71 send_to_back_command_execute(Command_t *parent)
72 {
73 SendToBackCommand_t *command = (SendToBackCommand_t*) parent;
74 gpointer id1, id2;
75
76 id1 = object_list_add_remove_cb(command->list, remove_one_object, command);
77 id2 = object_list_add_add_cb(command->list, add_one_object, command);
78
79 object_list_send_to_back(command->list);
80 object_list_remove_remove_cb(command->list, id1);
81 object_list_remove_add_cb(command->list, id2);
82 return CMD_APPEND;
83 }
84