1/* 2* Copyright (c) 2018 (https://github.com/phase1geo/Minder) 3* 4* This program is free software; you can redistribute it and/or 5* modify it under the terms of the GNU General Public 6* License as published by the Free Software Foundation; either 7* version 2 of the License, or (at your option) any later version. 8* 9* This program is distributed in the hope that it will be useful, 10* but WITHOUT ANY WARRANTY; without even the implied warranty of 11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12* General Public License for more details. 13* 14* You should have received a copy of the GNU General Public 15* License along with this program; if not, write to the 16* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17* Boston, MA 02110-1301 USA 18* 19* Authored by: Trevor Williams <phase1geo@gmail.com> 20*/ 21 22using Gtk; 23 24public class UndoNodeImage : UndoItem { 25 26 Node _node; 27 NodeImage? _old_image; 28 NodeImage? _new_image; 29 30 /* Constructor for a node name change */ 31 public UndoNodeImage( Node n, NodeImage? old_image ) { 32 base( _( "node image change" ) ); 33 _node = n; 34 _old_image = old_image; 35 _new_image = n.image; 36 } 37 38 /* Changes the node image, adjusts the layout and updates the UI */ 39 private void change( DrawArea da, NodeImage? img ) { 40 _node.set_image( da.image_manager, img ); 41 da.queue_draw(); 42 da.current_changed( da ); 43 da.auto_save(); 44 } 45 46 /* Undoes a node image change */ 47 public override void undo( DrawArea da ) { 48 change( da, _old_image ); 49 } 50 51 /* Redoes a node image change */ 52 public override void redo( DrawArea da ) { 53 change( da, _new_image ); 54 } 55 56} 57