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 UndoConnectionAdd : UndoItem { 25 26 Connection _connection; 27 28 /* Constructor for adding a connection */ 29 public UndoConnectionAdd( Connection connection ) { 30 base( _( "add connection" ) ); 31 _connection = connection; 32 } 33 34 /* Undoes a connection change */ 35 public override void undo( DrawArea da ) { 36 da.get_connections().remove_connection( _connection, false ); 37 da.set_current_connection( null ); 38 da.queue_draw(); 39 da.auto_save(); 40 } 41 42 /* Redoes a connection change */ 43 public override void redo( DrawArea da ) { 44 da.get_connections().add_connection( _connection ); 45 da.set_current_connection( _connection ); 46 da.queue_draw(); 47 da.auto_save(); 48 } 49 50} 51