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_cut.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-10-25  |  2.8 KB  |  100 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 "imap_cmd_cut.h"
  26. #include "libgimp/stdplugins-intl.h"
  27. #include "imap_main.h"
  28.  
  29. static void cut_command_destruct(Command_t *parent);
  30. static CmdExecuteValue_t cut_command_execute(Command_t *parent);
  31. static void cut_command_undo(Command_t *parent);
  32. static void cut_command_redo(Command_t *parent);
  33.  
  34. static CommandClass_t cut_command_class = {
  35.    cut_command_destruct,
  36.    cut_command_execute,
  37.    cut_command_undo,
  38.    cut_command_redo
  39. };
  40.  
  41. typedef struct {
  42.    Command_t      parent;
  43.    ObjectList_t *list;
  44.    ObjectList_t *paste_buffer;
  45. } CutCommand_t;
  46.  
  47. Command_t*
  48. cut_command_new(ObjectList_t *list)
  49. {
  50.    CutCommand_t *command = g_new(CutCommand_t, 1);
  51.    command->list = list;
  52.    command->paste_buffer = NULL;
  53.    return command_init(&command->parent, _("Cut"), &cut_command_class);
  54. }
  55.  
  56. static void
  57. cut_command_destruct(Command_t *parent)
  58. {
  59.    CutCommand_t *command = (CutCommand_t*) parent;
  60.    object_list_destruct(command->paste_buffer);
  61. }
  62.  
  63. static void
  64. remove_one_object(Object_t *obj, gpointer data)
  65. {
  66.    CutCommand_t *command = (CutCommand_t*) data;
  67.    command_add_subcommand(&command->parent,
  68.               delete_command_new(command->list, obj));
  69. }
  70.  
  71. static CmdExecuteValue_t
  72. cut_command_execute(Command_t *parent)
  73. {
  74.    CutCommand_t *command = (CutCommand_t*) parent;
  75.    gpointer id;
  76.  
  77.    command->paste_buffer = object_list_copy(command->paste_buffer, 
  78.                         get_paste_buffer());
  79.    id = object_list_add_remove_cb(command->list, remove_one_object, command);
  80.    object_list_cut(command->list);
  81.    object_list_remove_remove_cb(command->list, id);
  82.  
  83.    redraw_preview();        /* Fix me! */
  84.    return CMD_APPEND;
  85. }
  86.  
  87. static void
  88. cut_command_undo(Command_t *parent)
  89. {
  90.    CutCommand_t *command = (CutCommand_t*) parent;
  91.    object_list_copy(get_paste_buffer(), command->paste_buffer);
  92.    redraw_preview();        /* Fix me! */
  93. }
  94.  
  95. static void
  96. cut_command_redo(Command_t *command)
  97. {
  98.    redraw_preview();        /* Fix me! */
  99. }
  100.