home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2002 April / pcpro0402.iso / essentials / graphics / Gimp / gimp-src-20001226.exe / src / gimp / plug-ins / imagemap / imap_cmd_delete.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-10-25  |  2.5 KB  |  81 lines

  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 "imap_cmd_delete.h"
  25. #include "libgimp/stdplugins-intl.h"
  26. #include "imap_main.h"
  27.  
  28. static void delete_command_destruct(Command_t *parent);
  29. static CmdExecuteValue_t delete_command_execute(Command_t *parent);
  30. static void delete_command_undo(Command_t *parent);
  31.  
  32. static CommandClass_t delete_command_class = {
  33.    delete_command_destruct,
  34.    delete_command_execute,
  35.    delete_command_undo,
  36.    NULL                /* delete_command_redo */
  37. };
  38.  
  39. typedef struct {
  40.    Command_t parent;
  41.    ObjectList_t *list;
  42.    Object_t     *obj;
  43.    gint         position;
  44.    gboolean     changed;
  45. } DeleteCommand_t;
  46.  
  47. Command_t* 
  48. delete_command_new(ObjectList_t *list, Object_t *obj)
  49. {
  50.    DeleteCommand_t *command = g_new(DeleteCommand_t, 1);
  51.    command->list = list;
  52.    command->obj = object_ref(obj);
  53.    return command_init(&command->parent, _("Delete"), 
  54.                &delete_command_class);
  55. }
  56.  
  57. static void
  58. delete_command_destruct(Command_t *parent)
  59. {
  60.    DeleteCommand_t *command = (DeleteCommand_t*) parent;
  61.    object_unref(command->obj);
  62. }
  63.  
  64. static CmdExecuteValue_t
  65. delete_command_execute(Command_t *parent)
  66. {
  67.    DeleteCommand_t *command = (DeleteCommand_t*) parent;
  68.    command->changed = object_list_get_changed(command->list);
  69.    command->position = object_get_position_in_list(command->obj);
  70.    object_list_remove(command->list, command->obj);
  71.    return CMD_APPEND;
  72. }
  73.  
  74. static void
  75. delete_command_undo(Command_t *parent)
  76. {
  77.    DeleteCommand_t *command = (DeleteCommand_t*) parent;
  78.    object_list_insert(command->list, command->position, command->obj);
  79.    object_list_set_changed(command->list, command->changed);
  80. }
  81.