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 move_up_command_execute(Command_t *parent);
32
33 static CommandClass_t move_up_command_class = {
34 NULL, /* move_up_command_destruct */
35 move_up_command_execute,
36 NULL, /* move_up_command_undo */
37 NULL /* move_up_command_redo */
38 };
39
40 typedef struct {
41 Command_t parent;
42 ObjectList_t *list;
43 gboolean add;
44 } MoveUpCommand_t;
45
46 Command_t*
move_up_command_new(ObjectList_t * list)47 move_up_command_new(ObjectList_t *list)
48 {
49 MoveUpCommand_t *command = g_new(MoveUpCommand_t, 1);
50 command->list = list;
51 command->add = FALSE;
52 return command_init(&command->parent, _("Move Up"), &move_up_command_class);
53 }
54
55 static void
move_up_one_object(Object_t * obj,gpointer data)56 move_up_one_object(Object_t *obj, gpointer data)
57 {
58 MoveUpCommand_t *command = (MoveUpCommand_t*) data;
59
60 if (command->add) {
61 command_add_subcommand(&command->parent,
62 object_up_command_new(command->list, obj));
63 command->add = FALSE;
64 }
65 else {
66 command->add = TRUE;
67 }
68 }
69
70 static CmdExecuteValue_t
move_up_command_execute(Command_t * parent)71 move_up_command_execute(Command_t *parent)
72 {
73 MoveUpCommand_t *command = (MoveUpCommand_t*) parent;
74 gpointer id;
75
76 id = object_list_add_move_cb(command->list, move_up_one_object, command);
77 object_list_move_selected_up(command->list);
78 object_list_remove_move_cb(command->list, id);
79
80 return CMD_APPEND;
81 }
82