Updated versions in prep for a new version
[geda-gaf.git] / gschem / src / o_copy.c
blob5e1811c52f504b7bd0cc0e1db4e9eb65f13d47db
1 /* gEDA - GPL Electronic Design Automation
2 * gschem - gEDA Schematic Capture
3 * Copyright (C) 1998-2008 Ales Hvezda
4 * Copyright (C) 1998-2008 gEDA Contributors (see ChangeLog for details)
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
20 #include <config.h>
22 #include <stdio.h>
23 #include <string.h>
25 #include "gschem.h"
27 #ifdef HAVE_LIBDMALLOC
28 #include <dmalloc.h>
29 #endif
32 /*! \todo Finish function documentation!!!
33 * \brief
34 * \par Function Description
37 void o_copy_start(GSCHEM_TOPLEVEL *w_current, int w_x, int w_y)
39 TOPLEVEL *toplevel = w_current->toplevel;
40 GList *s_current;
42 /* Copy the objects into the buffer at their current position,
43 * with future motion relative to the mouse origin, (w_x, w_y). */
45 w_current->first_wx = w_x;
46 w_current->first_wy = w_y;
48 if (!o_select_selected (w_current))
49 return;
51 s_current = geda_list_get_glist( toplevel->page_current->selection_list );
53 if (toplevel->page_current->place_list != NULL) {
54 s_delete_object_glist(toplevel, toplevel->page_current->place_list);
55 toplevel->page_current->place_list = NULL;
58 toplevel->page_current->place_list =
59 o_glist_copy_all (toplevel, s_current,
60 toplevel->page_current->place_list,
61 SELECTION_FLAG);
63 w_current->inside_action = 1;
64 i_set_state(w_current, COPY);
65 o_place_start (w_current, w_x, w_y);
69 /*! \todo Finish function documentation!!!
70 * \brief
71 * \par Function Description
74 static void o_copy_end_generic(GSCHEM_TOPLEVEL *w_current, int multiple)
76 GList *new_objects;
77 GList *iter;
78 OBJECT *object;
80 o_place_end (w_current, w_current->second_wx, w_current->second_wy, multiple, &new_objects);
82 /* Run the copy component hook for all new components */
83 for (iter = new_objects;
84 iter != NULL;
85 iter = g_list_next (iter)) {
86 object = iter->data;
87 if ( (object->type == OBJ_COMPLEX) &&
88 (scm_hook_empty_p(copy_component_hook) == SCM_BOOL_F)) {
89 scm_run_hook(copy_component_hook,
90 scm_cons (g_make_attrib_smob_list(w_current, object),
91 SCM_EOL));
95 g_list_free (new_objects);
99 /*! \todo Finish function documentation!!!
100 * \brief
101 * \par Function Description
104 void o_copy_end(GSCHEM_TOPLEVEL *w_current)
106 o_copy_end_generic (w_current, FALSE);
110 /*! \todo Finish function documentation!!!
111 * \brief
112 * \par Function Description
115 void o_copy_multiple_end(GSCHEM_TOPLEVEL *w_current)
117 o_copy_end_generic (w_current, TRUE);