~ubuntu-branches/ubuntu/hoary/gimp/hoary

« back to all changes in this revision

Viewing changes to plug-ins/imagemap/imap_cmd_delete.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2005-04-04 14:51:23 UTC
  • Revision ID: james.westby@ubuntu.com-20050404145123-9py049eeelfymur8
Tags: upstream-2.2.2
ImportĀ upstreamĀ versionĀ 2.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This is a plug-in for the GIMP.
 
3
 *
 
4
 * Generates clickable image maps.
 
5
 *
 
6
 * Copyright (C) 1998-1999 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 2 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, write to the Free Software
 
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
21
 *
 
22
 */
 
23
 
 
24
#include "config.h"
 
25
 
 
26
#include <gtk/gtk.h>
 
27
 
 
28
#include "imap_commands.h"
 
29
 
 
30
#include "libgimp/stdplugins-intl.h"
 
31
 
 
32
static void delete_command_destruct(Command_t *parent);
 
33
static CmdExecuteValue_t delete_command_execute(Command_t *parent);
 
34
static void delete_command_undo(Command_t *parent);
 
35
 
 
36
static CommandClass_t delete_command_class = {
 
37
   delete_command_destruct,
 
38
   delete_command_execute,
 
39
   delete_command_undo,
 
40
   NULL                         /* delete_command_redo */
 
41
};
 
42
 
 
43
typedef struct {
 
44
   Command_t parent;
 
45
   ObjectList_t *list;
 
46
   Object_t     *obj;
 
47
   gint          position;
 
48
   gboolean      changed;
 
49
} DeleteCommand_t;
 
50
 
 
51
Command_t* 
 
52
delete_command_new(ObjectList_t *list, Object_t *obj)
 
53
{
 
54
   DeleteCommand_t *command = g_new(DeleteCommand_t, 1);
 
55
   command->list = list;
 
56
   command->obj = object_ref(obj);
 
57
   return command_init(&command->parent, _("Delete"), 
 
58
                       &delete_command_class);
 
59
}
 
60
 
 
61
static void
 
62
delete_command_destruct(Command_t *parent)
 
63
{
 
64
   DeleteCommand_t *command = (DeleteCommand_t*) parent;
 
65
   object_unref(command->obj);
 
66
}
 
67
 
 
68
static CmdExecuteValue_t
 
69
delete_command_execute(Command_t *parent)
 
70
{
 
71
   DeleteCommand_t *command = (DeleteCommand_t*) parent;
 
72
   command->changed = object_list_get_changed(command->list);
 
73
   command->position = object_get_position_in_list(command->obj);
 
74
   object_list_remove(command->list, command->obj);
 
75
   return CMD_APPEND;
 
76
}
 
77
 
 
78
static void
 
79
delete_command_undo(Command_t *parent)
 
80
{
 
81
   DeleteCommand_t *command = (DeleteCommand_t*) parent;
 
82
   object_list_insert(command->list, command->position, command->obj);
 
83
   object_list_set_changed(command->list, command->changed);
 
84
}