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 select_prev_command_execute(Command_t *parent);
32
33 static CommandClass_t select_prev_command_class = {
34 NULL, /* select_prev_command_destruct */
35 select_prev_command_execute,
36 NULL, /* select_prev_command_undo */
37 NULL /* select_prev_command_redo */
38 };
39
40 typedef struct {
41 Command_t parent;
42 ObjectList_t *list;
43 } SelectPrevCommand_t;
44
45 Command_t*
select_prev_command_new(ObjectList_t * list)46 select_prev_command_new(ObjectList_t *list)
47 {
48 SelectPrevCommand_t *command = g_new(SelectPrevCommand_t, 1);
49 command->list = list;
50 return command_init(&command->parent, _("Select Previous"),
51 &select_prev_command_class);
52 }
53
54 static void
select_one_object(Object_t * obj,gpointer data)55 select_one_object(Object_t *obj, gpointer data)
56 {
57 SelectPrevCommand_t *command = (SelectPrevCommand_t*) data;
58 Command_t *sub_command;
59
60 sub_command = (obj->selected)
61 ? select_command_new(obj) : unselect_command_new(obj);
62 command_add_subcommand(&command->parent, sub_command);
63 }
64
65 static CmdExecuteValue_t
select_prev_command_execute(Command_t * parent)66 select_prev_command_execute(Command_t *parent)
67 {
68 SelectPrevCommand_t *command = (SelectPrevCommand_t*) parent;
69 ObjectList_t *list = command->list;
70 gpointer id;
71
72 id = object_list_add_select_cb(list, select_one_object, command);
73 object_list_select_prev(list);
74 object_list_remove_select_cb(list, id);
75 return CMD_APPEND;
76 }
77