gschem
|
00001 /* gEDA - GPL Electronic Design Automation 00002 * gschem - gEDA Schematic Capture 00003 * Copyright (C) 1998-2010 Ales Hvezda 00004 * Copyright (C) 1998-2011 gEDA Contributors (see ChangeLog for details) 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00019 */ 00020 #include <config.h> 00021 00022 #include <stdio.h> 00023 00024 #include "gschem.h" 00025 00026 #ifdef HAVE_LIBDMALLOC 00027 #include <dmalloc.h> 00028 #endif 00029 00038 void o_delete (GSCHEM_TOPLEVEL *w_current, OBJECT *object) 00039 { 00040 TOPLEVEL *toplevel = w_current->toplevel; 00041 00042 g_return_if_fail (object != NULL); 00043 00044 o_selection_remove (toplevel, toplevel->page_current->selection_list, object); 00045 s_page_remove (toplevel, toplevel->page_current, object); 00046 g_run_hook_object (w_current, "%remove-objects-hook", object); 00047 s_delete_object (toplevel, object); 00048 00049 toplevel->page_current->CHANGED = 1; 00050 } 00051 00059 void o_delete_selected (GSCHEM_TOPLEVEL *w_current) 00060 { 00061 TOPLEVEL *toplevel = w_current->toplevel; 00062 SELECTION *selection = toplevel->page_current->selection_list; 00063 GList *to_remove; 00064 GList *iter; 00065 00066 g_return_if_fail (o_select_selected (w_current)); 00067 00068 to_remove = g_list_copy (geda_list_get_glist (selection)); 00069 00070 for (iter = to_remove; iter != NULL; iter = g_list_next (iter)) { 00071 OBJECT *obj = (OBJECT *) iter->data; 00072 o_selection_remove (toplevel, selection, obj); 00073 s_page_remove (toplevel, toplevel->page_current, obj); 00074 } 00075 00076 g_run_hook_object_list (w_current, "%remove-objects-hook", to_remove); 00077 00078 for (iter = to_remove; iter != NULL; iter = g_list_next (iter)) { 00079 s_delete_object (toplevel, (OBJECT *) iter->data); 00080 } 00081 00082 g_list_free (to_remove); 00083 00084 w_current->inside_action = 0; 00085 o_undo_savestate (w_current, UNDO_ALL); 00086 i_update_menus (w_current); 00087 }