1 /* gEDA - GPL Electronic Design Automation
2 * gschem - gEDA Schematic Capture
3 * Copyright (C) 1998-2010 Ales Hvezda
4 * Copyright (C) 1998-2010 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
32 #ifdef HAVE_LIBDMALLOC
37 #define DELIMITERS ", "
39 /*! \todo Finish function documentation!!!
41 * \par Function Description
44 /* Egil Kvaleberg <egil@kvaleberg.no> on October 7, 2002 -
45 * Initiate the gschemdoc utility to provide the used with as much
46 * documentation on the symbol (i.e. component) as we can manage.
48 static void initiate_gschemdoc(const char* documentation
,const char *device
,
50 const char* symfile
, const char *sympath
)
57 if (!documentation
) documentation
="";
58 if (!device
) device
="";
60 if (!symfile
) symfile
="";
61 if (!sympath
) sympath
="";
63 s_log_message( _("Documentation for [%s,%s,%s,%s]\n"),
64 documentation
,device
,value
,symfile
);
67 if ((pid
= fork()) < 0) {
68 fprintf(stderr
, _("Could not fork\n"));
69 } else if (pid
== 0) {
70 /* daughter process */
72 /* assume gschemdoc is part of path */
73 char *gschemdoc
= "gschemdoc";
75 execlp(gschemdoc
, gschemdoc
, documentation
, device
, value
, symfile
, sympath
, NULL
);
77 /* if we return, then nothing happened */
78 fprintf(stderr
, _("Could not invoke %s\n"), gschemdoc
);
82 s_log_message(_("Documentation commands not supported under MinGW.\n"));
86 /*! \todo Finish function documentation!!!
88 * \par Function Description
91 /* every i_callback functions have the same footprint */
92 #define DEFINE_I_CALLBACK(name) \
93 void i_callback_ ## name(gpointer data, \
94 guint callback_action, \
97 /*! \section callback-intro Callback Functions
98 * right now, all callbacks except for the ones on the File menu have
99 * the middle button shortcut. Let me (Ales) know if we should also
100 * shortcut the File button
103 /*! \section file-menu File Menu Callback Functions */
104 /*! \todo Finish function documentation!!!
106 * \par Function Description
109 * don't use the widget parameter on this function, or do some checking...
110 * since there is a call: widget = NULL, data = 0 (will be w_current hack)
111 * \todo This should be renamed to page_new perhaps...
113 DEFINE_I_CALLBACK(file_new
)
115 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*)data
;
118 exit_if_null (w_current
);
120 /* create a new page */
121 page
= x_window_open_page (w_current
, NULL
);
122 x_window_set_current_page (w_current
, page
);
123 s_log_message (_("New page created [%s]\n"), page
->page_filename
);
126 /*! \todo Finish function documentation!!!
128 * \par Function Description
131 * don't use the widget parameter on this function, or do some checking...
132 * since there is a call: widget = NULL, data = 0 (will be w_current hack)
134 void i_callback_toolbar_file_new(GtkWidget
* widget
, gpointer data
)
136 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
137 exit_if_null(w_current
);
138 if (!w_current
->window
) return;
140 i_callback_file_new(data
, 0, NULL
);
143 /*! \todo Finish function documentation!!!
145 * \par Function Description
148 DEFINE_I_CALLBACK(file_new_window
)
150 GSCHEM_TOPLEVEL
*w_current
;
153 w_current
= gschem_toplevel_new ();
154 w_current
->toplevel
= s_toplevel_new ();
156 w_current
->toplevel
->load_newer_backup_func
= x_fileselect_load_backup
;
157 w_current
->toplevel
->load_newer_backup_data
= w_current
;
159 o_text_set_rendered_bounds_func (w_current
->toplevel
,
160 o_text_get_rendered_bounds
, w_current
);
162 /* Damage notifications should invalidate the object on screen */
163 o_set_change_notify_funcs (w_current
->toplevel
,
164 (ChangeNotifyFunc
) o_invalidate
,
165 (ChangeNotifyFunc
) o_invalidate
, w_current
);
167 x_window_setup (w_current
);
169 page
= x_window_open_page (w_current
, NULL
);
170 x_window_set_current_page (w_current
, page
);
171 s_log_message (_("New Window created [%s]\n"), page
->page_filename
);
174 /*! \todo Finish function documentation!!!
176 * \par Function Description
179 * don't use the widget parameter on this function, or do some
181 * since there is a call: widget = NULL, data = 0 (will be w_current)
182 * \todo This should be renamed to page_open perhaps...
184 DEFINE_I_CALLBACK(file_open
)
186 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
188 exit_if_null(w_current
);
190 x_fileselect_open (w_current
);
193 /*! \todo Finish function documentation!!!
195 * \par Function Description
198 * don't use the widget parameter on this function, or do some
200 * since there is a call: widget = NULL, data = 0 (will be w_current)
201 * \todo This should be renamed to page_open perhaps...
203 void i_callback_toolbar_file_open(GtkWidget
* widget
, gpointer data
)
205 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
206 exit_if_null(w_current
);
207 if (!w_current
->window
) return;
209 i_callback_file_open(data
, 0, NULL
);
212 /*! \todo Finish function documentation!!!
214 * \par Function Description
217 DEFINE_I_CALLBACK(file_script
)
219 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
221 exit_if_null(w_current
);
222 setup_script_selector(w_current
);
225 /*! \todo Finish function documentation!!!
227 * \par Function Description
230 * don't use the widget parameter on this function, or do some
232 * since there is a call: widget = NULL, data = 0 (will be w_current)
234 DEFINE_I_CALLBACK(file_save
)
236 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
238 exit_if_null(w_current
);
240 /*! \todo probably there should be a flag that says whether
241 * page_filename is derived from untitled_name or specified by
242 * a user. Some twisted people might name their files like
245 if (strstr(w_current
->toplevel
->page_current
->page_filename
,
246 w_current
->toplevel
->untitled_name
)) {
247 x_fileselect_save (w_current
);
249 x_window_save_page (w_current
,
250 w_current
->toplevel
->page_current
,
251 w_current
->toplevel
->page_current
->page_filename
);
255 /*! \todo Finish function documentation!!!
257 * \par Function Description
260 * don't use the widget parameter on this function, or do some
262 * since there is a call: widget = NULL, data = 0 (will be w_current)
263 * \todo This should be renamed to page_open perhaps...
265 void i_callback_toolbar_file_save(GtkWidget
* widget
, gpointer data
)
267 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
268 exit_if_null(w_current
);
269 if (!w_current
->window
) return;
271 i_callback_file_save(data
, 0, NULL
);
274 /*! \todo Finish function documentation!!!
276 * \par Function Description
279 * don't use the widget parameter on this function, or do some checking...
280 * since there is a call: widget = NULL, data = 0 (will be w_current)
282 DEFINE_I_CALLBACK(file_save_all
)
284 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
286 exit_if_null(w_current
);
288 if (s_page_save_all(w_current
->toplevel
)) {
289 i_set_state_msg(w_current
, SELECT
, _("Failed to Save All"));
291 i_set_state_msg(w_current
, SELECT
, _("Saved All"));
294 i_update_toolbar(w_current
);
295 x_pagesel_update (w_current
);
296 i_update_menus(w_current
);
299 /*! \todo Finish function documentation!!!
301 * \par Function Description
304 DEFINE_I_CALLBACK(file_save_as
)
306 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
308 exit_if_null(w_current
);
309 x_fileselect_save (w_current
);
312 /*! \todo Finish function documentation!!!
314 * \par Function Description
317 DEFINE_I_CALLBACK(file_print
)
319 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
320 char *base
=NULL
, *filename
;
321 char *ps_filename
=NULL
;
323 exit_if_null(w_current
);
324 exit_if_null(w_current
->toplevel
->page_current
->page_filename
);
327 filename
= w_current
->toplevel
->page_current
->page_filename
;
329 /* get the base file name */
330 if (g_str_has_suffix(filename
, ".sch")) {
331 /* the filename ends with ".sch", remove it */
332 base
= g_strndup(filename
, strlen(filename
) - strlen(".sch"));
334 /* the filename does not end with .sch */
335 base
= g_strdup (filename
);
338 /* add ".ps" tp the base filename */
339 ps_filename
= g_strconcat (base
, ".ps", NULL
);
342 if (output_filename
) {
343 x_print_setup(w_current
, output_filename
);
345 x_print_setup(w_current
, ps_filename
);
351 /*! \todo Finish function documentation!!!
353 * \par Function Description
356 DEFINE_I_CALLBACK(file_write_png
)
358 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
360 exit_if_null(w_current
);
362 x_image_setup(w_current
);
365 /*! \todo Finish function documentation!!!
367 * \par Function Description
370 * don't use the widget parameter on this function, or do some
372 * since there is a call: widget = NULL, data = 0 (will be w_current)
373 * this function closes a window
375 DEFINE_I_CALLBACK(file_close
)
377 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
379 exit_if_null(w_current
);
381 s_log_message(_("Closing Window\n"));
382 x_window_close(w_current
);
385 /*! \todo Finish function documentation!!!
387 * \par Function Description
388 * This function is called when you send a delete event to gschem
391 * Also DON'T ref the widget parameter since they can be null
392 * \todo Need a cleaner way of doing this. This routine is used by the
393 * delete event signals
395 int i_callback_close(gpointer data
, guint callback_action
, GtkWidget
*widget
)
397 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
399 exit_if_null(w_current
);
400 i_callback_file_close(w_current
, 0, widget
);
404 /*! \todo Finish function documentation!!!
406 * \par Function Description
409 DEFINE_I_CALLBACK(file_quit
)
411 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
413 exit_if_null(w_current
);
414 x_window_close_all(w_current
);
417 /*! \section edit-menu Edit Menu Callback Functions */
418 /*! \todo Finish function documentation!!!
420 * \par Function Description
423 DEFINE_I_CALLBACK(edit_undo
)
425 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
427 /* If we're cancelling from a move action, re-wind the
428 * page contents back to their state before we started.
430 * It "might" be nice to sub-undo rotates / zoom changes
431 * made whilst moving components, but when the undo code
432 * hits s_page_delete(), the place list objects are free'd.
433 * Since they are also contained in the schematic page, a
434 * crash occurs when the page objects are free'd.
436 if (w_current
->inside_action
&&
437 (w_current
->event_state
== MOVE
||
438 w_current
->event_state
== ENDMOVE
)) {
439 i_callback_cancel (w_current
, 0, NULL
);
441 w_current
->toplevel
->DONT_REDRAW
= 0;
442 o_undo_callback(w_current
, UNDO_ACTION
);
446 /*! \todo Finish function documentation!!!
448 * \par Function Description
451 * don't use the widget parameter on this function, or do some checking...
452 * since there is a call: widget = NULL, data = 0 (will be w_current hack)
454 void i_callback_toolbar_edit_undo(GtkWidget
* widget
, gpointer data
)
456 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
457 exit_if_null(w_current
);
458 if (!w_current
->window
) return;
460 i_callback_edit_undo(data
, 0, NULL
);
463 /*! \todo Finish function documentation!!!
465 * \par Function Description
468 DEFINE_I_CALLBACK(edit_redo
)
470 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
472 w_current
->toplevel
->DONT_REDRAW
= 0;
473 o_undo_callback(w_current
, REDO_ACTION
);
476 /*! \todo Finish function documentation!!!
478 * \par Function Description
481 * don't use the widget parameter on this function, or do some checking...
482 * since there is a call: widget = NULL, data = 0 (will be w_current hack)
484 void i_callback_toolbar_edit_redo(GtkWidget
* widget
, gpointer data
)
486 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
487 exit_if_null(w_current
);
488 if (!w_current
->window
) return;
490 i_callback_edit_redo(data
, 0, NULL
);
493 /*! \todo Finish function documentation!!!
495 * \par Function Description
498 * Select also does not update the middle button shortcut.
500 DEFINE_I_CALLBACK(edit_select
)
502 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
503 o_redraw_cleanstates(w_current
);
505 /* this is probably the only place this should be */
506 i_set_state(w_current
, SELECT
);
507 i_update_toolbar(w_current
);
508 w_current
->inside_action
= 0;
511 /*! \todo Finish function documentation!!!
513 * \par Function Description
516 * don't use the widget parameter on this function, or do some checking...
517 * since there is a call: widget = NULL, data = 0 (will be w_current hack)
519 void i_callback_toolbar_edit_select(GtkWidget
* widget
, gpointer data
)
521 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
522 exit_if_null(w_current
);
523 if (!w_current
->window
) return;
525 if (GTK_TOGGLE_BUTTON (widget
)->active
) {
526 if (!o_invalidate_rubber (w_current
)) {
527 i_callback_cancel(w_current
, 0, NULL
);
529 i_callback_edit_select(data
, 0, NULL
);
533 /*! \todo Finish function documentation!!!
535 * \par Function Description
538 DEFINE_I_CALLBACK(edit_copy
)
540 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
542 exit_if_null(w_current
);
544 i_update_middle_button(w_current
, i_callback_edit_copy
, _("Copy"));
545 if (o_select_return_first_object(w_current
)) {
546 o_redraw_cleanstates(w_current
);
547 i_set_state(w_current
, STARTCOPY
);
549 i_set_state_msg(w_current
, SELECT
, _("Select objs first"));
553 /*! \todo Finish function documentation!!!
555 * \par Function Description
558 DEFINE_I_CALLBACK(edit_copy_hotkey
)
560 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
563 exit_if_null(w_current
);
565 if (!x_event_get_pointer_position(w_current
, TRUE
, &wx
, &wy
))
568 i_update_middle_button(w_current
, i_callback_edit_copy_hotkey
, _("Copy"));
569 if (o_select_return_first_object(w_current
)) {
570 o_redraw_cleanstates(w_current
);
571 w_current
->event_state
= COPY
;
572 o_copy_start(w_current
, wx
, wy
);
573 w_current
->event_state
= ENDCOPY
;
574 w_current
->inside_action
= 1;
578 /*! \todo Finish function documentation!!!
580 * \par Function Description
583 DEFINE_I_CALLBACK(edit_mcopy
)
585 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
587 exit_if_null(w_current
);
589 i_update_middle_button(w_current
, i_callback_edit_copy
, _("Multiple Copy"));
590 if (o_select_return_first_object(w_current
)) {
591 o_redraw_cleanstates(w_current
);
592 i_set_state(w_current
, STARTMCOPY
);
594 i_set_state_msg(w_current
, SELECT
, _("Select objs first"));
598 /*! \todo Finish function documentation!!!
600 * \par Function Description
603 DEFINE_I_CALLBACK(edit_mcopy_hotkey
)
605 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
608 exit_if_null(w_current
);
610 if (!x_event_get_pointer_position(w_current
, TRUE
, &wx
, &wy
))
613 i_update_middle_button(w_current
, i_callback_edit_mcopy_hotkey
, _("Multiple Copy"));
614 if (o_select_return_first_object(w_current
)) {
615 o_redraw_cleanstates(w_current
);
616 w_current
->event_state
= MCOPY
;
617 o_copy_start(w_current
, wx
, wy
);
618 w_current
->event_state
= ENDMCOPY
;
619 w_current
->inside_action
= 1;
623 /*! \todo Finish function documentation!!!
625 * \par Function Description
628 DEFINE_I_CALLBACK(edit_move
)
630 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
632 exit_if_null(w_current
);
634 i_update_middle_button(w_current
, i_callback_edit_move
, _("Move"));
635 if (o_select_return_first_object(w_current
)) {
636 o_redraw_cleanstates(w_current
);
637 i_set_state(w_current
, STARTMOVE
);
639 i_set_state_msg(w_current
, SELECT
, _("Select objs first"));
643 /*! \todo Finish function documentation!!!
645 * \par Function Description
648 DEFINE_I_CALLBACK(edit_move_hotkey
)
650 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
653 exit_if_null(w_current
);
655 if (!x_event_get_pointer_position(w_current
, TRUE
, &wx
, &wy
))
658 i_update_middle_button(w_current
, i_callback_edit_move_hotkey
, _("Move"));
659 if (o_select_return_first_object(w_current
)) {
660 o_redraw_cleanstates(w_current
);
661 o_move_start(w_current
, wx
, wy
);
662 w_current
->event_state
= ENDMOVE
;
663 w_current
->inside_action
= 1;
667 /*! \todo Finish function documentation!!!
669 * \par Function Description
672 DEFINE_I_CALLBACK(edit_delete
)
674 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
676 exit_if_null(w_current
);
678 i_update_middle_button(w_current
, i_callback_edit_delete
, _("Delete"));
680 if (o_select_return_first_object(w_current
)) {
681 o_redraw_cleanstates(w_current
);
682 o_delete_selected(w_current
);
683 /* if you delete the objects you must go into select
684 * mode after the delete */
685 w_current
->inside_action
= 0;
686 i_set_state(w_current
, SELECT
);
687 i_update_toolbar(w_current
);
688 i_update_menus(w_current
);
692 /*! \todo Finish function documentation!!!
694 * \par Function Description
697 DEFINE_I_CALLBACK(edit_edit
)
699 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
701 exit_if_null(w_current
);
703 i_update_middle_button(w_current
, i_callback_edit_edit
, _("Edit"));
704 o_edit(w_current
, geda_list_get_glist( w_current
->toplevel
->page_current
->selection_list
) );
707 /*! \todo Finish function documentation!!!
709 * \par Function Description
712 DEFINE_I_CALLBACK(edit_pin_type
)
714 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
716 exit_if_null(w_current
);
718 i_update_middle_button (w_current
, i_callback_edit_pin_type
, _("Edit pin type"));
720 x_dialog_edit_pin_type (w_current
,
721 geda_list_get_glist (w_current
->toplevel
->
722 page_current
->selection_list
));
725 /*! \todo Finish function documentation!!!
727 * \par Function Description
730 DEFINE_I_CALLBACK(edit_text
)
732 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
735 exit_if_null(w_current
);
737 i_update_middle_button(w_current
, i_callback_edit_text
, _("Edit Text"));
738 object
= o_select_return_first_object(w_current
);
740 if (object
->type
== OBJ_TEXT
) {
741 o_text_edit(w_current
, object
);
746 /*! \todo Finish function documentation!!!
748 * \par Function Description
751 DEFINE_I_CALLBACK(edit_slot
)
753 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
756 exit_if_null(w_current
);
758 object
= o_select_return_first_object(w_current
);
760 i_update_middle_button(w_current
, i_callback_edit_slot
, _("Slot"));
762 o_slot_start(w_current
, object
);
766 /*! \todo Finish function documentation!!!
768 * \par Function Description
771 DEFINE_I_CALLBACK(edit_color
)
773 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
775 exit_if_null(w_current
);
777 i_update_middle_button(w_current
, i_callback_edit_color
, _("Color"));
779 color_edit_dialog(w_current
);
782 /*! \todo Finish function documentation!!!
784 * \par Function Description
785 * This function rotate all objects in the selection list by 90 degrees.
788 DEFINE_I_CALLBACK(edit_rotate_90
)
790 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
792 exit_if_null(w_current
);
794 /* If inside an appropriate action, send a button 2 released,
795 * so rotating will be handled by x_event.c */
796 if ( w_current
->inside_action
&&
797 (w_current
->event_state
== ENDCOMP
||
798 w_current
->event_state
== ENDTEXT
||
799 w_current
->event_state
== ENDMOVE
||
800 w_current
->event_state
== ENDCOPY
||
801 w_current
->event_state
== ENDMCOPY
||
802 w_current
->event_state
== ENDPASTE
)) {
805 event
= gdk_event_new(GDK_BUTTON_RELEASE
);
806 ((GdkEventButton
*) event
)->button
= 2;
807 x_event_button_released (NULL
, (GdkEventButton
*) event
, w_current
);
808 gdk_event_free(event
);
813 i_set_state(w_current
, ENDROTATEP
);
814 i_update_middle_button(w_current
, i_callback_edit_rotate_90
, _("Rotate"));
817 /*! \todo Finish function documentation!!!
819 * \par Function Description
820 * This function rotate all objects in the selection list by 90 degrees.
823 DEFINE_I_CALLBACK(edit_rotate_90_hotkey
)
825 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
829 exit_if_null(w_current
);
831 if (!x_event_get_pointer_position(w_current
, TRUE
, &wx
, &wy
))
834 /* If inside an appropriate action, send a button 2 released,
835 * so rotating will be handled by x_event.c */
836 if ( w_current
->inside_action
&&
837 (w_current
->event_state
== ENDCOMP
||
838 w_current
->event_state
== ENDTEXT
||
839 w_current
->event_state
== ENDMOVE
||
840 w_current
->event_state
== ENDCOPY
||
841 w_current
->event_state
== ENDMCOPY
||
842 w_current
->event_state
== ENDPASTE
)) {
845 event
= gdk_event_new(GDK_BUTTON_RELEASE
);
846 ((GdkEventButton
*) event
)->button
= 2;
847 x_event_button_released (NULL
, (GdkEventButton
*) event
, w_current
);
848 gdk_event_free(event
);
853 o_redraw_cleanstates(w_current
);
855 object_list
= geda_list_get_glist( w_current
->toplevel
->page_current
->selection_list
);
858 i_update_middle_button(w_current
,
859 i_callback_edit_rotate_90_hotkey
, _("Rotate"));
860 /* Allow o_rotate_world_update to redraw the objects */
861 w_current
->toplevel
->DONT_REDRAW
= 0;
862 o_rotate_world_update(w_current
, wx
, wy
, 90, object_list
);
865 w_current
->event_state
= SELECT
;
866 w_current
->inside_action
= 0;
867 i_update_toolbar(w_current
);
870 /*! \todo Finish function documentation!!!
872 * \par Function Description
875 DEFINE_I_CALLBACK(edit_mirror
)
877 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
879 exit_if_null(w_current
);
881 i_set_state(w_current
, ENDMIRROR
);
882 i_update_middle_button(w_current
, i_callback_edit_mirror
, _("Mirror"));
885 /*! \todo Finish function documentation!!!
887 * \par Function Description
890 DEFINE_I_CALLBACK(edit_mirror_hotkey
)
892 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
896 exit_if_null(w_current
);
898 if (!x_event_get_pointer_position(w_current
, TRUE
, &wx
, &wy
))
901 o_redraw_cleanstates(w_current
);
903 object_list
= geda_list_get_glist( w_current
->toplevel
->page_current
->selection_list
);
906 i_update_middle_button(w_current
,
907 i_callback_edit_mirror_hotkey
, _("Mirror"));
908 o_mirror_world_update(w_current
, wx
, wy
, object_list
);
911 w_current
->event_state
= SELECT
;
912 w_current
->inside_action
= 0;
913 i_update_toolbar(w_current
);
916 /*! \todo Finish function documentation!!!
918 * \par Function Description
919 * This function locks all objects in selection list.
922 DEFINE_I_CALLBACK(edit_lock
)
924 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
926 exit_if_null(w_current
);
928 i_update_middle_button(w_current
, i_callback_edit_lock
, _("Lock"));
930 if (o_select_return_first_object(w_current
)) {
935 /*! \todo Finish function documentation!!!
937 * \par Function Description
938 * Thus function unlocks all objects in selection list.
940 DEFINE_I_CALLBACK(edit_unlock
)
942 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
944 exit_if_null(w_current
);
946 i_update_middle_button(w_current
, i_callback_edit_unlock
, _("Unlock"));
947 if (o_select_return_first_object(w_current
)) {
952 /*! \todo Finish function documentation!!!
954 * \par Function Description
957 DEFINE_I_CALLBACK(edit_translate
)
959 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
961 exit_if_null(w_current
);
963 i_update_middle_button(w_current
,
964 i_callback_edit_translate
, _("Translate"));
966 if (w_current
->snap
== SNAP_OFF
) {
967 s_log_message(_("WARNING: Do not translate with snap off!\n"));
968 s_log_message(_("WARNING: Turning snap on and continuing "
969 "with translate.\n"));
970 w_current
->snap
= SNAP_GRID
;
971 i_show_state(w_current
, NULL
); /* update status on screen */
974 if (w_current
->snap_size
!= 100) {
975 s_log_message(_("WARNING: Snap grid size is "
976 "not equal to 100!\n"));
977 s_log_message(_("WARNING: If you are translating a symbol "
978 "to the origin, the snap grid size should be "
982 translate_dialog(w_current
);
985 DEFINE_I_CALLBACK(edit_invoke_macro
)
987 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
989 exit_if_null(w_current
);
991 gtk_widget_show(w_current
->macro_box
);
992 gtk_widget_grab_focus(w_current
->macro_entry
);
995 /*! \todo Finish function documentation!!!
997 * \par Function Description
998 * This function embedds all objects in selection list
1001 DEFINE_I_CALLBACK(edit_embed
)
1003 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1006 exit_if_null(w_current
);
1008 i_update_middle_button(w_current
, i_callback_edit_embed
, _("Embed"));
1009 /* anything selected ? */
1010 if (o_select_selected(w_current
)) {
1011 /* yes, embed each selected component */
1013 geda_list_get_glist( w_current
->toplevel
->page_current
->selection_list
);
1015 while (s_current
!= NULL
) {
1016 o_current
= (OBJECT
*) s_current
->data
;
1017 g_assert (o_current
!= NULL
);
1018 if ( (o_current
->type
== OBJ_COMPLEX
) ||
1019 (o_current
->type
== OBJ_PICTURE
) ) {
1020 o_embed (w_current
->toplevel
, o_current
);
1022 s_current
= g_list_next(s_current
);
1024 o_undo_savestate(w_current
, UNDO_ALL
);
1026 /* nothing selected, go back to select state */
1027 o_redraw_cleanstates(w_current
);
1028 w_current
->inside_action
= 0;
1029 i_set_state(w_current
, SELECT
);
1034 /*! \todo Finish function documentation!!!
1036 * \par Function Description
1037 * This function unembedds all objects in selection list.
1040 DEFINE_I_CALLBACK(edit_unembed
)
1042 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1045 exit_if_null(w_current
);
1047 i_update_middle_button(w_current
, i_callback_edit_unembed
, _("Unembed"));
1048 /* anything selected ? */
1049 if (o_select_selected(w_current
)) {
1050 /* yes, unembed each selected component */
1052 geda_list_get_glist( w_current
->toplevel
->page_current
->selection_list
);
1054 while (s_current
!= NULL
) {
1055 o_current
= (OBJECT
*) s_current
->data
;
1056 g_assert (o_current
!= NULL
);
1057 if ( (o_current
->type
== OBJ_COMPLEX
) ||
1058 (o_current
->type
== OBJ_PICTURE
) ) {
1059 o_unembed (w_current
->toplevel
, o_current
);
1061 s_current
= g_list_next(s_current
);
1063 o_undo_savestate(w_current
, UNDO_ALL
);
1065 /* nothing selected, go back to select state */
1066 o_redraw_cleanstates(w_current
);
1067 w_current
->inside_action
= 0;
1068 i_set_state(w_current
, SELECT
);
1073 /*! \todo Finish function documentation!!!
1075 * \par Function Description
1076 * This function updates components
1079 DEFINE_I_CALLBACK(edit_update
)
1081 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1082 TOPLEVEL
*toplevel
= w_current
->toplevel
;
1084 GList
*selected_components
= NULL
;
1087 g_return_if_fail (w_current
!= NULL
);
1089 i_update_middle_button(w_current
, i_callback_edit_update
, _("Update"));
1090 if (o_select_selected(w_current
)) {
1092 /* Updating components modifies the selection. Therefore, create a
1093 * new list of only the OBJECTs we want to update from the current
1094 * selection, then iterate over that new list to perform the
1096 selection
= geda_list_get_glist (toplevel
->page_current
->selection_list
);
1097 for (iter
= selection
; iter
!= NULL
; iter
= g_list_next (iter
)) {
1098 OBJECT
*o_current
= (OBJECT
*) iter
->data
;
1099 if (o_current
!= NULL
&& o_current
->type
== OBJ_COMPLEX
) {
1100 selected_components
= g_list_prepend (selected_components
, o_current
);
1103 for (iter
= selected_components
; iter
!= NULL
; iter
= g_list_next (iter
)) {
1104 OBJECT
*o_current
= (OBJECT
*) iter
->data
;
1105 iter
->data
= o_update_component (w_current
, o_current
);
1107 g_list_free (selected_components
);
1110 /* nothing selected, go back to select state */
1111 o_redraw_cleanstates(w_current
);
1112 w_current
->inside_action
= 0;
1113 i_set_state(w_current
, SELECT
);
1118 /*! \todo Finish function documentation!!!
1120 * \par Function Description
1123 DEFINE_I_CALLBACK(edit_show_hidden
)
1125 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1127 exit_if_null(w_current
);
1129 /* This is a new addition 3/15 to prevent this from executing
1130 * inside an action */
1131 if (w_current
->inside_action
)
1134 i_update_middle_button(w_current
,
1135 i_callback_edit_show_hidden
,
1138 o_edit_show_hidden (w_current
,
1139 s_page_objects (w_current
->toplevel
->page_current
));
1142 /*! \todo Finish function documentation!!!
1144 * \par Function Description
1147 DEFINE_I_CALLBACK(edit_make_visible
)
1149 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1151 exit_if_null(w_current
);
1153 /* This is a new addition 3/15 to prevent this from executing
1154 * inside an action */
1155 if (w_current
->inside_action
)
1158 i_update_middle_button(w_current
,
1159 i_callback_edit_make_visible
,
1162 o_edit_make_visible (w_current
,
1163 s_page_objects (w_current
->toplevel
->page_current
));
1166 /*! \todo Finish function documentation!!!
1168 * \par Function Description
1171 DEFINE_I_CALLBACK(edit_find
)
1173 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1175 exit_if_null(w_current
);
1177 /* This is a new addition 3/15 to prevent this from executing
1178 * inside an action */
1179 if (w_current
->inside_action
)
1182 find_text_dialog(w_current
);
1185 /*! \todo Finish function documentation!!!
1187 * \par Function Description
1190 DEFINE_I_CALLBACK(edit_hide_text
)
1192 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1194 exit_if_null(w_current
);
1196 /* This is a new addition 3/15 to prevent this from executing
1197 * inside an action */
1198 if (w_current
->inside_action
)
1201 hide_text_dialog(w_current
);
1204 /*! \todo Finish function documentation!!!
1206 * \par Function Description
1209 DEFINE_I_CALLBACK(edit_show_text
)
1211 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1213 exit_if_null(w_current
);
1215 /* This is a new addition 3/15 to prevent this from executing
1216 * inside an action */
1217 if (w_current
->inside_action
)
1220 show_text_dialog(w_current
);
1223 /*! \todo Finish function documentation!!!
1225 * \par Function Description
1228 DEFINE_I_CALLBACK(edit_autonumber_text
)
1230 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1232 exit_if_null(w_current
);
1234 /* This is a new addition 3/15 to prevent this from executing
1235 * inside an action */
1236 if (w_current
->inside_action
)
1239 autonumber_text_dialog(w_current
);
1242 /*! \todo Finish function documentation!!!
1244 * \par Function Description
1247 DEFINE_I_CALLBACK(edit_linetype
)
1249 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1251 exit_if_null(w_current
);
1253 line_type_dialog(w_current
);
1256 /*! \todo Finish function documentation!!!
1258 * \par Function Description
1261 DEFINE_I_CALLBACK(edit_filltype
)
1263 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1265 exit_if_null(w_current
);
1267 fill_type_dialog(w_current
);
1270 /*! \section view-menu View Menu Callback Functions */
1271 /*! \todo Finish function documentation!!!
1273 * \par Function Description
1276 * repeat middle shortcut doesn't make sense on redraw, just hit right
1279 DEFINE_I_CALLBACK(view_redraw
)
1281 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1283 exit_if_null(w_current
);
1284 o_invalidate_all (w_current
);
1287 /*! \todo Finish function documentation!!!
1289 * \par Function Description
1292 * repeat middle shortcut would get into the way of what user is try to do
1294 DEFINE_I_CALLBACK(view_zoom_full
)
1296 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1298 exit_if_null(w_current
);
1300 /* scroll bar stuff */
1301 a_zoom(w_current
, ZOOM_FULL
, DONTCARE
, 0);
1303 if (w_current
->undo_panzoom
) {
1304 o_undo_savestate(w_current
, UNDO_VIEWPORT_ONLY
);
1308 /*! \todo Finish function documentation!!!
1310 * \par Function Description
1313 * repeat middle shortcut would get into the way of what user is try to do
1315 DEFINE_I_CALLBACK(view_zoom_extents
)
1317 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1319 exit_if_null(w_current
);
1321 /* scroll bar stuff */
1322 a_zoom_extents (w_current
,
1323 s_page_objects (w_current
->toplevel
->page_current
), 0);
1324 if (w_current
->undo_panzoom
) {
1325 o_undo_savestate(w_current
, UNDO_VIEWPORT_ONLY
);
1329 /*! \todo Finish function documentation!!!
1331 * \par Function Description
1334 * repeat middle shortcut would get into the way of what user is try to do
1336 DEFINE_I_CALLBACK(view_zoom_box
)
1338 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1340 exit_if_null(w_current
);
1342 o_redraw_cleanstates(w_current
);
1343 w_current
->inside_action
= 0;
1344 i_set_state(w_current
, ZOOMBOXSTART
);
1347 /*! \todo Finish function documentation!!!
1349 * \par Function Description
1352 DEFINE_I_CALLBACK(view_zoom_box_hotkey
)
1354 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1357 exit_if_null(w_current
);
1359 if (!x_event_get_pointer_position(w_current
, FALSE
, &wx
, &wy
))
1362 o_redraw_cleanstates(w_current
);
1363 a_zoom_box_start(w_current
, wx
, wy
);
1365 w_current
->inside_action
= 1;
1366 i_set_state(w_current
, ZOOMBOXEND
);
1369 /*! \todo Finish function documentation!!!
1371 * \par Function Description
1374 * repeat middle shortcut would get into the way of what user is try to do
1376 DEFINE_I_CALLBACK(view_zoom_in
)
1378 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1380 exit_if_null(w_current
);
1382 a_zoom(w_current
, ZOOM_IN
, MENU
, 0);
1384 if (w_current
->undo_panzoom
) {
1385 o_undo_savestate(w_current
, UNDO_VIEWPORT_ONLY
);
1389 /*! \todo Finish function documentation!!!
1391 * \par Function Description
1394 * repeat middle shortcut would get into the way of what user is try to do
1396 DEFINE_I_CALLBACK(view_zoom_out
)
1398 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1400 exit_if_null(w_current
);
1402 a_zoom(w_current
, ZOOM_OUT
, MENU
, 0);
1404 if (w_current
->undo_panzoom
) {
1405 o_undo_savestate(w_current
, UNDO_VIEWPORT_ONLY
);
1409 /*! \todo Finish function documentation!!!
1411 * \par Function Description
1414 * repeat middle shortcut would get into the way of what user is try
1417 DEFINE_I_CALLBACK(view_zoom_in_hotkey
)
1419 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1421 exit_if_null(w_current
);
1423 a_zoom(w_current
, ZOOM_IN
, HOTKEY
, 0);
1425 if (w_current
->undo_panzoom
) {
1426 o_undo_savestate(w_current
, UNDO_VIEWPORT_ONLY
);
1430 /*! \todo Finish function documentation!!!
1432 * \par Function Description
1435 * repeat middle shortcut would get into the way of what user is try to do
1437 DEFINE_I_CALLBACK(view_zoom_out_hotkey
)
1439 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1441 exit_if_null(w_current
);
1443 a_zoom(w_current
, ZOOM_OUT
, HOTKEY
, 0);
1445 if (w_current
->undo_panzoom
) {
1446 o_undo_savestate(w_current
, UNDO_VIEWPORT_ONLY
);
1450 /*! \todo Finish function documentation!!!
1452 * \par Function Description
1455 DEFINE_I_CALLBACK(view_pan
)
1457 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1459 exit_if_null(w_current
);
1461 o_redraw_cleanstates(w_current
);
1462 w_current
->inside_action
= 0;
1463 i_set_state(w_current
, STARTPAN
);
1465 /* I don't know if this would get in the way */
1466 i_update_middle_button(w_current
, i_callback_view_pan
, _("Pan"));
1469 /*! \brief Scheme callback function that moves the viewport to the left.
1471 * The distance can be set with "keyboardpan-gain" scheme callback.
1473 DEFINE_I_CALLBACK(view_pan_left
)
1475 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1477 exit_if_null(w_current
);
1479 a_pan_mouse(w_current
, w_current
->keyboardpan_gain
, 0);
1482 /*! \brief Scheme callback function that moves the viewport to the right.
1484 * The distance can be set with "keyboardpan-gain" scheme callback.
1486 DEFINE_I_CALLBACK(view_pan_right
)
1488 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1490 exit_if_null(w_current
);
1492 /* yes, that's a negative sign there */
1493 a_pan_mouse(w_current
, -w_current
->keyboardpan_gain
, 0);
1496 /*! \brief Scheme callback function that moves the viewport up.
1498 * The distance can be set with "keyboardpan-gain" scheme callback.
1500 DEFINE_I_CALLBACK(view_pan_up
)
1502 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1504 exit_if_null(w_current
);
1506 a_pan_mouse(w_current
, 0, w_current
->keyboardpan_gain
);
1509 /*! \brief Scheme callback function that moves the viewport down.
1511 * The distance can be set with "keyboardpan-gain" scheme callback.
1513 DEFINE_I_CALLBACK(view_pan_down
)
1515 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1517 exit_if_null(w_current
);
1519 /* yes, that's a negative sign there */
1520 a_pan_mouse(w_current
, 0, -w_current
->keyboardpan_gain
);
1523 /*! \todo Finish function documentation!!!
1525 * \par Function Description
1528 DEFINE_I_CALLBACK(view_pan_hotkey
)
1530 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1533 exit_if_null(w_current
);
1535 if (!x_event_get_pointer_position(w_current
, FALSE
, &wx
, &wy
))
1538 i_update_middle_button(w_current
, i_callback_view_pan_hotkey
, _("Pan"));
1540 a_pan(w_current
, wx
, wy
);
1542 if (w_current
->undo_panzoom
) {
1543 o_undo_savestate(w_current
, UNDO_VIEWPORT_ONLY
);
1547 /*! \todo Finish function documentation!!!
1549 * \par Function Description
1552 DEFINE_I_CALLBACK (view_dark_colors
)
1554 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1557 /* Change the scheme here */
1558 g_scm_c_eval_string_protected ("(load (build-path geda-rc-path \"gschem-colormap-darkbg\"))");
1559 x_color_allocate ();
1561 o_invalidate_all (w_current
);
1564 /*! \todo Finish function documentation!!!
1566 * \par Function Description
1569 DEFINE_I_CALLBACK (view_light_colors
)
1571 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1574 /* Change the scheme here */
1575 g_scm_c_eval_string_protected ("(load (build-path geda-rc-path \"gschem-colormap-lightbg\"))");
1576 x_color_allocate ();
1578 o_invalidate_all (w_current
);
1581 /*! \todo Finish function documentation!!!
1583 * \par Function Description
1586 DEFINE_I_CALLBACK (view_bw_colors
)
1588 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1591 /* Change the scheme here */
1592 g_scm_c_eval_string_protected ("(load (build-path geda-rc-path \"gschem-colormap-bw\"))");
1593 x_color_allocate ();
1595 o_invalidate_all (w_current
);
1598 /*! \section page-menu Page Menu Callback Functions */
1599 /*! \todo Finish function documentation!!!
1601 * \par Function Description
1604 DEFINE_I_CALLBACK(page_manager
)
1606 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1608 exit_if_null(w_current
);
1610 x_pagesel_open (w_current
);
1613 /*! \todo Finish function documentation!!!
1615 * \par Function Description
1618 DEFINE_I_CALLBACK(page_next
)
1620 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*)data
;
1621 TOPLEVEL
*toplevel
= w_current
->toplevel
;
1622 PAGE
*p_current
= toplevel
->page_current
;
1626 exit_if_null(w_current
);
1628 iter
= g_list_find( geda_list_get_glist( toplevel
->pages
), p_current
);
1629 iter
= g_list_next( iter
);
1635 if (w_current
->enforce_hierarchy
) {
1636 p_new
= s_hierarchy_find_next_page(toplevel
->pages
, p_current
);
1638 p_new
= (PAGE
*)iter
->data
;
1641 if (p_new
== NULL
|| p_new
== p_current
) {
1645 x_window_set_current_page (w_current
, p_new
);
1648 /*! \todo Finish function documentation!!!
1650 * \par Function Description
1653 DEFINE_I_CALLBACK(page_prev
)
1655 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*)data
;
1656 TOPLEVEL
*toplevel
= w_current
->toplevel
;
1657 PAGE
*p_current
= toplevel
->page_current
;
1661 exit_if_null(w_current
);
1663 iter
= g_list_find( geda_list_get_glist( toplevel
->pages
), p_current
);
1664 iter
= g_list_previous( iter
);
1669 p_new
= (PAGE
*)iter
->data
;
1671 if (w_current
->enforce_hierarchy
) {
1672 p_new
= s_hierarchy_find_prev_page(toplevel
->pages
, p_current
);
1674 p_new
= (PAGE
*)iter
->data
;
1677 if (p_new
== NULL
|| p_new
== p_current
) {
1681 x_window_set_current_page (w_current
, p_new
);
1684 /*! \todo Finish function documentation!!!
1686 * \par Function Description
1689 DEFINE_I_CALLBACK(page_new
)
1691 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*)data
;
1694 exit_if_null(w_current
);
1696 /* create a new page */
1697 page
= x_window_open_page (w_current
, NULL
);
1698 x_window_set_current_page (w_current
, page
);
1699 s_log_message (_("New page created [%s]\n"), page
->page_filename
);
1702 /*! \todo Finish function documentation!!!
1704 * \par Function Description
1707 DEFINE_I_CALLBACK(page_close
)
1709 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1711 exit_if_null(w_current
);
1713 if (w_current
->toplevel
->page_current
->CHANGED
) {
1714 x_dialog_close_changed_page (w_current
, w_current
->toplevel
->page_current
);
1716 x_window_close_page (w_current
, w_current
->toplevel
->page_current
);
1721 /*! \todo Finish function documentation!!!
1723 * \par Function Description
1725 * \bug may have memory leak?
1727 DEFINE_I_CALLBACK(page_revert
)
1729 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1737 exit_if_null(w_current
);
1739 dialog
= gtk_message_dialog_new ((GtkWindow
*) w_current
->main_window
,
1740 GTK_DIALOG_DESTROY_WITH_PARENT
,
1741 GTK_MESSAGE_QUESTION
,
1743 _("Really revert page?"));
1745 /* Set the alternative button order (ok, cancel, help) for other systems */
1746 gtk_dialog_set_alternative_button_order(GTK_DIALOG(dialog
),
1751 response
= gtk_dialog_run (GTK_DIALOG (dialog
));
1752 gtk_widget_destroy (dialog
);
1754 if (response
!= GTK_RESPONSE_YES
)
1757 /* save this for later */
1758 filename
= g_strdup (w_current
->toplevel
->page_current
->page_filename
);
1759 page_control
= w_current
->toplevel
->page_current
->page_control
;
1760 up
= w_current
->toplevel
->page_current
->up
;
1762 /* delete the page, then re-open the file as a new page */
1763 s_page_delete (w_current
->toplevel
, w_current
->toplevel
->page_current
);
1765 page
= x_window_open_page (w_current
, filename
);
1767 /* make sure we maintain the hierarchy info */
1768 page
->page_control
= page_control
;
1771 x_window_set_current_page (w_current
, page
);
1774 /*! \todo Finish function documentation!!!
1776 * \par Function Description
1779 DEFINE_I_CALLBACK(page_discard
)
1781 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*)data
;
1783 exit_if_null(w_current
);
1785 x_window_close_page (w_current
, w_current
->toplevel
->page_current
);
1788 /*! \todo Finish function documentation!!!
1790 * \par Function Description
1793 DEFINE_I_CALLBACK(page_print
)
1795 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1797 s_page_print_all(w_current
->toplevel
);
1800 /*! \section clipboard-menu Clipboard Menu Callback Functions */
1801 /*! \brief Copy selection to clipboard.
1802 * \par Function Description
1803 * Copies the current selection to the clipboard, via buffer 0.
1805 DEFINE_I_CALLBACK(clipboard_copy
)
1807 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1809 exit_if_null (w_current
);
1810 if (!o_select_selected (w_current
)) return;
1812 i_update_middle_button (w_current
, i_callback_clipboard_copy
,
1813 _("Copy to clipboard"));
1815 o_buffer_copy (w_current
, 0);
1816 x_clipboard_set (w_current
, object_buffer
[0]);
1819 /*! \brief Cut selection to clipboard.
1820 * \par Function Description
1821 * Cut the current selection to the clipboard, via buffer 0.
1823 DEFINE_I_CALLBACK(clipboard_cut
)
1825 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1827 exit_if_null (w_current
);
1828 if (!o_select_selected (w_current
)) return;
1830 i_update_middle_button (w_current
, i_callback_clipboard_cut
,
1831 _("Cut to clipboard"));
1833 o_buffer_cut (w_current
, 0);
1834 x_clipboard_set (w_current
, object_buffer
[0]);
1837 /*! \brief Start pasting clipboard contents.
1838 * \par Function Description
1839 * Cut the current selection to the clipboard, via buffer 0.
1841 DEFINE_I_CALLBACK(clipboard_paste
)
1843 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1844 TOPLEVEL
*toplevel
= w_current
->toplevel
;
1845 GList
*object_list
= NULL
;
1847 exit_if_null(w_current
);
1849 i_update_middle_button (w_current
, i_callback_buffer_paste1
, _("Paste from clipboard"));
1851 object_list
= x_clipboard_get (w_current
);
1853 if (object_list
!= NULL
) {
1854 s_delete_object_glist (toplevel
, object_buffer
[0]);
1855 object_buffer
[0] = object_list
;
1856 o_redraw_cleanstates (w_current
);
1857 w_current
->buffer_number
= 0;
1858 w_current
->inside_action
= 1;
1859 i_set_state (w_current
, STARTPASTE
);
1861 i_set_state_msg (w_current
, SELECT
, _("Empty buffer"));
1865 /*! \brief Start pasting clipboard contents (hotkey version)
1866 * \par Function Description
1867 * It's not entirely clear what the difference is between this and
1868 * i_callback_clipboard_paste()...
1870 DEFINE_I_CALLBACK(clipboard_paste_hotkey
)
1872 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1873 TOPLEVEL
*toplevel
= w_current
->toplevel
;
1874 GList
*object_list
= NULL
;
1877 exit_if_null (w_current
);
1879 if (!x_event_get_pointer_position (w_current
, TRUE
, &wx
, &wy
))
1882 object_list
= x_clipboard_get (w_current
);
1884 if (object_list
== NULL
) return;
1885 s_delete_object_glist (toplevel
, object_buffer
[0]);
1886 object_buffer
[0] = object_list
;
1888 o_buffer_paste_start (w_current
, wx
, wy
, 0);
1891 /*! \section buffer-menu Buffer Menu Callback Functions */
1892 /*! \todo Finish function documentation!!!
1894 * \par Function Description
1897 DEFINE_I_CALLBACK(buffer_copy1
)
1899 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1901 exit_if_null(w_current
);
1903 if (!o_select_selected (w_current
))
1906 i_update_middle_button(w_current
, i_callback_buffer_copy1
, _("Copy 1"));
1907 o_buffer_copy(w_current
, 0);
1908 i_update_menus(w_current
);
1911 /*! \todo Finish function documentation!!!
1913 * \par Function Description
1916 DEFINE_I_CALLBACK(buffer_copy2
)
1918 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1920 exit_if_null(w_current
);
1922 if (!o_select_selected (w_current
))
1925 i_update_middle_button(w_current
, i_callback_buffer_copy2
, _("Copy 2"));
1926 o_buffer_copy(w_current
, 1);
1927 i_update_menus(w_current
);
1930 /*! \todo Finish function documentation!!!
1932 * \par Function Description
1935 DEFINE_I_CALLBACK(buffer_copy3
)
1937 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1939 exit_if_null(w_current
);
1941 if (!o_select_selected (w_current
))
1944 i_update_middle_button(w_current
, i_callback_buffer_copy3
, _("Copy 3"));
1945 o_buffer_copy(w_current
, 2);
1946 i_update_menus(w_current
);
1949 /*! \todo Finish function documentation!!!
1951 * \par Function Description
1954 DEFINE_I_CALLBACK(buffer_copy4
)
1956 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1958 exit_if_null(w_current
);
1960 if (!o_select_selected (w_current
))
1963 i_update_middle_button(w_current
, i_callback_buffer_copy4
, _("Copy 4"));
1964 o_buffer_copy(w_current
, 3);
1965 i_update_menus(w_current
);
1968 /*! \todo Finish function documentation!!!
1970 * \par Function Description
1973 DEFINE_I_CALLBACK(buffer_copy5
)
1975 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1977 exit_if_null(w_current
);
1979 if (!o_select_selected (w_current
))
1982 i_update_middle_button(w_current
, i_callback_buffer_copy5
, _("Copy 5"));
1983 o_buffer_copy(w_current
, 4);
1984 i_update_menus(w_current
);
1987 /*! \todo Finish function documentation!!!
1989 * \par Function Description
1992 DEFINE_I_CALLBACK(buffer_cut1
)
1994 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1996 exit_if_null(w_current
);
1998 if (!o_select_selected (w_current
))
2001 i_update_middle_button(w_current
, i_callback_buffer_cut1
, _("Cut 1"));
2002 o_buffer_cut(w_current
, 0);
2003 i_update_menus(w_current
);
2006 /*! \todo Finish function documentation!!!
2008 * \par Function Description
2011 DEFINE_I_CALLBACK(buffer_cut2
)
2013 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2015 exit_if_null(w_current
);
2017 if (!o_select_selected (w_current
))
2020 i_update_middle_button(w_current
, i_callback_buffer_cut2
, _("Cut 2"));
2021 o_buffer_cut(w_current
, 1);
2022 i_update_menus(w_current
);
2025 /*! \todo Finish function documentation!!!
2027 * \par Function Description
2030 DEFINE_I_CALLBACK(buffer_cut3
)
2032 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2034 exit_if_null(w_current
);
2036 if (!o_select_selected (w_current
))
2039 i_update_middle_button(w_current
, i_callback_buffer_cut3
, _("Cut 3"));
2040 o_buffer_cut(w_current
, 2);
2041 i_update_menus(w_current
);
2044 /*! \todo Finish function documentation!!!
2046 * \par Function Description
2049 DEFINE_I_CALLBACK(buffer_cut4
)
2051 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2053 exit_if_null(w_current
);
2055 if (!o_select_selected (w_current
))
2058 i_update_middle_button(w_current
, i_callback_buffer_cut4
, _("Cut 4"));
2059 o_buffer_cut(w_current
, 3);
2060 i_update_menus(w_current
);
2063 /*! \todo Finish function documentation!!!
2065 * \par Function Description
2068 DEFINE_I_CALLBACK(buffer_cut5
)
2070 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2072 exit_if_null(w_current
);
2074 if (!o_select_selected (w_current
))
2077 i_update_middle_button(w_current
, i_callback_buffer_cut5
, _("Cut 5"));
2078 o_buffer_cut(w_current
, 4);
2079 i_update_menus(w_current
);
2082 /*! \todo Finish function documentation!!!
2084 * \par Function Description
2087 DEFINE_I_CALLBACK(buffer_paste1
)
2089 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2091 exit_if_null(w_current
);
2093 i_update_middle_button(w_current
, i_callback_buffer_paste1
, _("Paste 1"));
2094 if (object_buffer
[0] != NULL
) {
2095 o_redraw_cleanstates(w_current
);
2096 w_current
->buffer_number
= 0;
2097 w_current
->inside_action
= 1;
2098 i_set_state(w_current
, STARTPASTE
);
2100 i_set_state_msg(w_current
, SELECT
, _("Empty buffer"));
2104 /*! \todo Finish function documentation!!!
2106 * \par Function Description
2109 DEFINE_I_CALLBACK(buffer_paste2
)
2111 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2113 exit_if_null(w_current
);
2115 i_update_middle_button(w_current
, i_callback_buffer_paste2
, _("Paste 2"));
2116 if (object_buffer
[1] != NULL
) {
2117 o_redraw_cleanstates(w_current
);
2118 w_current
->buffer_number
= 1;
2119 w_current
->inside_action
= 1;
2120 i_set_state(w_current
, STARTPASTE
);
2122 i_set_state_msg(w_current
, SELECT
, _("Empty buffer"));
2126 /*! \todo Finish function documentation!!!
2128 * \par Function Description
2131 DEFINE_I_CALLBACK(buffer_paste3
)
2133 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2135 exit_if_null(w_current
);
2137 i_update_middle_button(w_current
, i_callback_buffer_paste3
, _("Paste 3"));
2138 if (object_buffer
[2] != NULL
) {
2139 o_redraw_cleanstates(w_current
);
2140 w_current
->buffer_number
= 2;
2141 w_current
->inside_action
= 1;
2142 i_set_state(w_current
, STARTPASTE
);
2144 i_set_state_msg(w_current
, SELECT
, _("Empty buffer"));
2148 /*! \todo Finish function documentation!!!
2150 * \par Function Description
2153 DEFINE_I_CALLBACK(buffer_paste4
)
2155 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2157 exit_if_null(w_current
);
2159 i_update_middle_button(w_current
, i_callback_buffer_paste4
, _("Paste 4"));
2160 if (object_buffer
[3] != NULL
) {
2161 o_redraw_cleanstates(w_current
);
2162 w_current
->buffer_number
= 3;
2163 w_current
->inside_action
= 1;
2164 i_set_state(w_current
, STARTPASTE
);
2166 i_set_state_msg(w_current
, SELECT
, _("Empty buffer"));
2170 /*! \todo Finish function documentation!!!
2172 * \par Function Description
2175 DEFINE_I_CALLBACK(buffer_paste5
)
2177 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2179 exit_if_null(w_current
);
2181 i_update_middle_button(w_current
, i_callback_buffer_paste5
, _("Paste 5"));
2182 if (object_buffer
[4] != NULL
) {
2183 o_redraw_cleanstates(w_current
);
2184 w_current
->buffer_number
= 4;
2185 w_current
->inside_action
= 1;
2186 i_set_state(w_current
, STARTPASTE
);
2188 i_set_state_msg(w_current
, SELECT
, _("Empty buffer"));
2192 /*! \todo Finish function documentation!!!
2194 * \par Function Description
2197 DEFINE_I_CALLBACK(buffer_paste1_hotkey
)
2199 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2202 exit_if_null(w_current
);
2204 if (object_buffer
[0] == NULL
) {
2208 if (!x_event_get_pointer_position(w_current
, TRUE
, &wx
, &wy
))
2211 o_buffer_paste_start(w_current
, wx
, wy
, 0);
2214 /*! \todo Finish function documentation!!!
2216 * \par Function Description
2219 DEFINE_I_CALLBACK(buffer_paste2_hotkey
)
2221 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2224 exit_if_null(w_current
);
2226 if (object_buffer
[1] == NULL
) {
2230 if (!x_event_get_pointer_position(w_current
, TRUE
, &wx
, &wy
))
2233 o_buffer_paste_start(w_current
, wx
, wy
, 1);
2236 /*! \todo Finish function documentation!!!
2238 * \par Function Description
2241 DEFINE_I_CALLBACK(buffer_paste3_hotkey
)
2243 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2246 exit_if_null(w_current
);
2248 if (object_buffer
[2] == NULL
) {
2252 if (!x_event_get_pointer_position(w_current
, TRUE
, &wx
, &wy
))
2255 o_buffer_paste_start(w_current
, wx
, wy
, 2);
2258 /*! \todo Finish function documentation!!!
2260 * \par Function Description
2263 DEFINE_I_CALLBACK(buffer_paste4_hotkey
)
2265 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2268 exit_if_null(w_current
);
2270 if (object_buffer
[3] == NULL
) {
2274 if (!x_event_get_pointer_position(w_current
, TRUE
, &wx
, &wy
))
2277 o_buffer_paste_start(w_current
, wx
, wy
, 3);
2280 /*! \todo Finish function documentation!!!
2282 * \par Function Description
2285 DEFINE_I_CALLBACK(buffer_paste5_hotkey
)
2287 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2290 exit_if_null(w_current
);
2292 if (object_buffer
[4] == NULL
) {
2296 if (!x_event_get_pointer_position(w_current
, TRUE
, &wx
, &wy
))
2299 o_buffer_paste_start(w_current
, wx
, wy
, 4);
2302 /*! \section add-menu Add Menu Callback Functions */
2303 /*! \todo Finish function documentation!!!
2305 * \par Function Description
2308 DEFINE_I_CALLBACK(add_component
)
2310 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2312 exit_if_null(w_current
);
2314 o_redraw_cleanstates (w_current
);
2315 x_compselect_open (w_current
);
2317 i_update_middle_button(w_current
,
2318 i_callback_add_component
, _("Component"));
2320 i_set_state(w_current
, SELECT
);
2321 i_update_toolbar(w_current
);
2324 /*! \todo Finish function documentation!!!
2326 * \par Function Description
2329 * don't use the widget parameter on this function, or do some checking...
2330 * since there is a call: widget = NULL, data = 0 (will be w_current hack)
2332 void i_callback_toolbar_add_component(GtkWidget
* widget
, gpointer data
)
2334 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2335 exit_if_null(w_current
);
2336 if (!w_current
->window
) return;
2338 i_callback_add_component(data
, 0, NULL
);
2341 /*! \todo Finish function documentation!!!
2343 * \par Function Description
2346 DEFINE_I_CALLBACK(add_attribute
)
2348 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2350 exit_if_null(w_current
);
2352 attrib_edit_dialog(w_current
, NULL
, FROM_MENU
);
2353 i_update_middle_button(w_current
, i_callback_add_attribute
,
2356 i_set_state(w_current
, SELECT
);
2357 i_update_toolbar(w_current
);
2360 /*! \todo Finish function documentation!!!
2362 * \par Function Description
2365 DEFINE_I_CALLBACK(add_attribute_hotkey
)
2367 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2369 exit_if_null(w_current
);
2371 attrib_edit_dialog(w_current
, NULL
, FROM_HOTKEY
);
2372 i_update_middle_button(w_current
, i_callback_add_attribute_hotkey
,
2375 i_set_state(w_current
, SELECT
);
2376 i_update_toolbar(w_current
);
2379 /*! \todo Finish function documentation!!!
2381 * \par Function Description
2384 DEFINE_I_CALLBACK(add_net
)
2386 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2388 exit_if_null(w_current
);
2390 o_redraw_cleanstates(w_current
);
2391 o_invalidate_rubber (w_current
);
2392 o_net_reset(w_current
);
2395 i_update_middle_button(w_current
, i_callback_add_net
, _("Net"));
2396 i_set_state(w_current
, STARTDRAWNET
);
2397 i_update_toolbar(w_current
);
2398 /* somewhere you need to nearest point locking... */
2399 w_current
->inside_action
= 0;
2402 /*! \todo Finish function documentation!!!
2404 * \par Function Description
2407 DEFINE_I_CALLBACK(add_net_hotkey
)
2409 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2412 exit_if_null(w_current
);
2414 if (!x_event_get_pointer_position(w_current
, TRUE
, &wx
, &wy
))
2417 o_redraw_cleanstates(w_current
);
2418 o_invalidate_rubber (w_current
);
2419 o_net_reset(w_current
);
2422 i_update_middle_button(w_current
, i_callback_add_net_hotkey
, _("Net"));
2423 i_set_state(w_current
, STARTDRAWNET
);
2424 i_update_toolbar(w_current
);
2426 o_net_start(w_current
, wx
, wy
);
2428 w_current
->event_state
=DRAWNET
;
2429 w_current
->inside_action
= 1;
2432 /*! \todo Finish function documentation!!!
2434 * \par Function Description
2437 * don't use the widget parameter on this function, or do some checking...
2438 * since there is a call: widget = NULL, data = 0 (will be w_current hack)
2440 void i_callback_toolbar_add_net(GtkWidget
* widget
, gpointer data
)
2442 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2443 exit_if_null(w_current
);
2444 if (!w_current
->window
) return;
2446 if (GTK_TOGGLE_BUTTON (widget
)->active
) {
2447 i_callback_add_net(data
, 0, NULL
);
2451 /*! \todo Finish function documentation!!!
2453 * \par Function Description
2456 DEFINE_I_CALLBACK(add_bus
)
2458 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2460 exit_if_null(w_current
);
2462 o_redraw_cleanstates(w_current
);
2463 o_invalidate_rubber (w_current
);
2466 i_update_middle_button(w_current
, i_callback_add_bus
, _("Bus"));
2467 i_set_state(w_current
, STARTDRAWBUS
);
2468 i_update_toolbar(w_current
);
2470 /* somewhere you need to nearest point locking... */
2471 w_current
->inside_action
= 0;
2474 /*! \todo Finish function documentation!!!
2476 * \par Function Description
2479 DEFINE_I_CALLBACK(add_bus_hotkey
)
2481 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2484 exit_if_null(w_current
);
2486 if (!x_event_get_pointer_position(w_current
, TRUE
, &wx
, &wy
))
2489 o_redraw_cleanstates(w_current
);
2490 o_invalidate_rubber (w_current
);
2493 i_update_middle_button(w_current
, i_callback_add_bus_hotkey
, _("Bus"));
2494 i_set_state(w_current
, STARTDRAWBUS
);
2495 i_update_toolbar(w_current
);
2497 o_bus_start(w_current
, wx
, wy
);
2499 w_current
->event_state
=DRAWBUS
;
2500 w_current
->inside_action
= 1;
2503 /*! \todo Finish function documentation!!!
2505 * \par Function Description
2508 * don't use the widget parameter on this function, or do some checking...
2509 * since there is a call: widget = NULL, data = 0 (will be w_current hack)
2511 void i_callback_toolbar_add_bus(GtkWidget
* widget
, gpointer data
)
2513 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2514 exit_if_null(w_current
);
2515 if (!w_current
->window
) return;
2517 if (GTK_TOGGLE_BUTTON (widget
)->active
) {
2518 i_callback_add_bus(data
, 0, NULL
);
2522 /*! \todo Finish function documentation!!!
2524 * \par Function Description
2527 DEFINE_I_CALLBACK(add_text
)
2529 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2531 exit_if_null(w_current
);
2533 o_redraw_cleanstates(w_current
);
2534 o_invalidate_rubber (w_current
);
2536 w_current
->inside_action
= 0;
2537 i_set_state(w_current
, SELECT
);
2538 i_update_toolbar(w_current
);
2540 text_input_dialog(w_current
);
2543 /*! \todo Finish function documentation!!!
2545 * \par Function Description
2548 * don't use the widget parameter on this function, or do some checking...
2549 * since there is a call: widget = NULL, data = 0 (will be w_current hack)
2551 void i_callback_toolbar_add_text(GtkWidget
* widget
, gpointer data
)
2553 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2554 exit_if_null(w_current
);
2555 if (!w_current
->window
) return;
2557 i_callback_add_text(data
, 0, NULL
);
2560 /*! \todo Finish function documentation!!!
2562 * \par Function Description
2565 DEFINE_I_CALLBACK(add_line
)
2567 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2569 exit_if_null(w_current
);
2571 o_redraw_cleanstates(w_current
);
2572 o_invalidate_rubber (w_current
);
2574 i_update_middle_button(w_current
, i_callback_add_line
, _("Line"));
2575 i_set_state(w_current
, DRAWLINE
);
2576 w_current
->inside_action
= 0;
2579 /*! \todo Finish function documentation!!!
2581 * \par Function Description
2584 DEFINE_I_CALLBACK(add_line_hotkey
)
2586 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2589 exit_if_null(w_current
);
2591 if (!x_event_get_pointer_position(w_current
, TRUE
, &wx
, &wy
))
2594 o_redraw_cleanstates(w_current
);
2595 o_invalidate_rubber (w_current
);
2597 i_update_middle_button(w_current
, i_callback_add_line_hotkey
, _("Line"));
2599 o_line_start(w_current
, wx
, wy
);
2601 w_current
->inside_action
= 1;
2602 i_set_state(w_current
, ENDLINE
);
2605 /*! \todo Finish function documentation!!!
2607 * \par Function Description
2610 DEFINE_I_CALLBACK(add_box
)
2612 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2614 exit_if_null(w_current
);
2616 o_redraw_cleanstates(w_current
);
2617 o_invalidate_rubber (w_current
);
2619 i_update_middle_button(w_current
, i_callback_add_box
, _("Box"));
2620 w_current
->inside_action
= 0;
2621 i_set_state(w_current
, DRAWBOX
);
2624 /*! \todo Finish function documentation!!!
2626 * \par Function Description
2629 DEFINE_I_CALLBACK(add_box_hotkey
)
2631 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2634 exit_if_null(w_current
);
2636 if (!x_event_get_pointer_position(w_current
, TRUE
, &wx
, &wy
))
2639 o_redraw_cleanstates(w_current
);
2640 o_invalidate_rubber (w_current
);
2642 i_update_middle_button(w_current
, i_callback_add_box_hotkey
, _("Box"));
2644 o_box_start(w_current
, wx
, wy
);
2646 w_current
->inside_action
= 1;
2647 i_set_state(w_current
, ENDBOX
);
2650 /*! \todo Finish function documentation!!!
2652 * \par Function Description
2655 DEFINE_I_CALLBACK(add_picture
)
2657 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2659 exit_if_null(w_current
);
2661 o_redraw_cleanstates(w_current
);
2662 o_invalidate_rubber (w_current
);
2664 w_current
->inside_action
= 0;
2665 i_set_state(w_current
, SELECT
);
2666 i_update_toolbar(w_current
);
2668 picture_selection_dialog(w_current
);
2671 /*! \todo Finish function documentation!!!
2673 * \par Function Description
2676 DEFINE_I_CALLBACK(add_picture_hotkey
)
2678 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2680 /* If this function necessary? Yes, if you want the hotkey to work. */
2681 i_callback_add_picture(w_current
, 0, NULL
);
2684 /*! \todo Finish function documentation!!!
2686 * \par Function Description
2689 DEFINE_I_CALLBACK(add_circle
)
2691 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2693 exit_if_null(w_current
);
2695 o_redraw_cleanstates(w_current
);
2696 o_invalidate_rubber (w_current
);
2698 i_update_middle_button(w_current
, i_callback_add_circle
, _("Circle"));
2699 w_current
->inside_action
= 0;
2700 i_set_state(w_current
, DRAWCIRCLE
);
2703 /*! \todo Finish function documentation!!!
2705 * \par Function Description
2708 DEFINE_I_CALLBACK(add_circle_hotkey
)
2710 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2713 exit_if_null(w_current
);
2715 if (!x_event_get_pointer_position(w_current
, TRUE
, &wx
, &wy
))
2718 o_redraw_cleanstates(w_current
);
2719 o_invalidate_rubber (w_current
);
2721 i_update_middle_button(w_current
, i_callback_add_circle_hotkey
,
2724 o_circle_start(w_current
, wx
, wy
);
2726 w_current
->inside_action
= 1;
2727 i_set_state(w_current
, ENDCIRCLE
);
2730 /*! \todo Finish function documentation!!!
2732 * \par Function Description
2735 DEFINE_I_CALLBACK(add_arc
)
2737 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2739 exit_if_null(w_current
);
2741 o_redraw_cleanstates(w_current
);
2742 o_invalidate_rubber (w_current
);
2744 i_update_middle_button(w_current
, i_callback_add_arc
, _("Arc"));
2745 w_current
->inside_action
= 0;
2746 i_set_state(w_current
, DRAWARC
);
2749 /*! \todo Finish function documentation!!!
2751 * \par Function Description
2754 DEFINE_I_CALLBACK(add_arc_hotkey
)
2756 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2759 exit_if_null(w_current
);
2761 if (!x_event_get_pointer_position(w_current
, TRUE
, &wx
, &wy
))
2764 o_redraw_cleanstates(w_current
);
2765 o_invalidate_rubber (w_current
);
2767 i_update_middle_button(w_current
, i_callback_add_arc_hotkey
, _("Arc"));
2769 o_arc_start(w_current
, wx
, wy
);
2771 w_current
->inside_action
= 1;
2772 i_set_state(w_current
, ENDARC
);
2775 /*! \todo Finish function documentation!!!
2777 * \par Function Description
2780 DEFINE_I_CALLBACK(add_pin
)
2782 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2784 exit_if_null(w_current
);
2786 o_redraw_cleanstates(w_current
);
2787 o_invalidate_rubber (w_current
);
2789 i_update_middle_button(w_current
, i_callback_add_pin
, _("Pin"));
2790 w_current
->inside_action
= 0;
2791 i_set_state(w_current
, DRAWPIN
);
2794 /*! \todo Finish function documentation!!!
2796 * \par Function Description
2799 DEFINE_I_CALLBACK(add_pin_hotkey
)
2801 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2804 exit_if_null(w_current
);
2806 if (!x_event_get_pointer_position(w_current
, TRUE
, &wx
, &wy
))
2809 o_redraw_cleanstates(w_current
);
2810 o_invalidate_rubber (w_current
);
2812 i_update_middle_button(w_current
, i_callback_add_pin_hotkey
, _("Pin"));
2814 o_pin_start(w_current
, wx
, wy
);
2816 w_current
->inside_action
= 1;
2817 i_set_state(w_current
, ENDPIN
);
2820 /*! \section hierarchy-menu Hierarchy Menu Callback Functions */
2821 /*! \todo Finish function documentation!!!
2823 * \par Function Description
2826 DEFINE_I_CALLBACK(hierarchy_down_schematic
)
2828 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2830 char *current_filename
=NULL
;
2832 OBJECT
*object
=NULL
;
2833 PAGE
*save_first_page
=NULL
;
2835 int loaded_flag
=FALSE
;
2836 int page_control
= 0;
2837 int saved_page_control
= 0;
2839 int looking_inside
=FALSE
;
2841 exit_if_null(w_current
);
2843 object
= o_select_return_first_object(w_current
);
2845 /* only allow going into symbols */
2846 if (object
== NULL
|| object
->type
!= OBJ_COMPLEX
)
2849 parent
= w_current
->toplevel
->page_current
;
2850 attrib
= o_attrib_search_attached_attribs_by_name (object
, "source", count
);
2852 /* if above is null, then look inside symbol */
2853 if (attrib
== NULL
) {
2855 o_attrib_search_inherited_attribs_by_name (object
, "source", count
);
2856 looking_inside
= TRUE
;
2858 printf("going to look inside now\n");
2864 /* look for source=filename,filename, ... */
2866 current_filename
= u_basic_breakup_string(attrib
, ',', pcount
);
2868 /* loop over all filenames */
2869 while(current_filename
!= NULL
) {
2871 s_log_message(_("Searching for source [%s]\n"), current_filename
);
2872 saved_page_control
= page_control
;
2874 s_hierarchy_down_schematic_single(w_current
->toplevel
,
2878 HIERARCHY_NORMAL_LOAD
);
2880 /* s_hierarchy_down_schematic_single() will not zoom the loaded page */
2881 if (page_control
!= -1) {
2882 a_zoom_extents(w_current
,
2883 s_page_objects (w_current
->toplevel
->page_current
),
2885 o_undo_savestate(w_current
, UNDO_ALL
);
2888 /* save the first page */
2889 if ( !loaded_flag
&& page_control
> 0 ) {
2890 save_first_page
= w_current
->toplevel
->page_current
;
2893 /* now do some error fixing */
2894 if (page_control
== -1) {
2895 s_log_message(_("Cannot find source [%s]\n"), current_filename
);
2897 /* restore this for the next page */
2898 page_control
= saved_page_control
;
2900 /* this only signifies that we tried */
2904 g_free(current_filename
);
2906 current_filename
= u_basic_breakup_string(attrib
, ',', pcount
);
2910 g_free(current_filename
);
2914 /* continue looking outside first */
2915 if (!looking_inside
) {
2917 o_attrib_search_attached_attribs_by_name (object
, "source", count
);
2920 /* okay we were looking outside and didn't find anything,
2921 * so now we need to look inside the symbol */
2922 if (!looking_inside
&& attrib
== NULL
&& !loaded_flag
) {
2923 looking_inside
= TRUE
;
2925 printf("switching to go to look inside\n");
2929 if (looking_inside
) {
2931 printf("looking inside\n");
2934 o_attrib_search_inherited_attribs_by_name (object
, "source", count
);
2940 if (save_first_page
) {
2941 w_current
->toplevel
->page_current
= save_first_page
;
2943 x_window_set_current_page( w_current
, w_current
->toplevel
->page_current
);
2947 /*! \todo Finish function documentation!!!
2949 * \par Function Description
2950 * \bug may cause problems with non-directory symbols
2952 DEFINE_I_CALLBACK(hierarchy_down_symbol
)
2954 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2956 const CLibSymbol
*sym
;
2958 exit_if_null(w_current
);
2960 object
= o_select_return_first_object(w_current
);
2961 if (object
!= NULL
) {
2962 /* only allow going into symbols */
2963 if (object
->type
== OBJ_COMPLEX
) {
2964 s_log_message(_("Searching for symbol [%s]\n"),
2965 object
->complex_basename
);
2966 sym
= s_clib_get_symbol_by_name (object
->complex_basename
);
2969 if (s_clib_symbol_get_filename(sym
) == NULL
) {
2970 s_log_message(_("Symbol is not a real file."
2971 " Symbol cannot be loaded.\n"));
2974 s_hierarchy_down_symbol(w_current
->toplevel
, sym
,
2975 w_current
->toplevel
->page_current
);
2976 /* s_hierarchy_down_symbol() will not zoom the loaded page */
2977 a_zoom_extents(w_current
,
2978 s_page_objects (w_current
->toplevel
->page_current
),
2980 o_undo_savestate(w_current
, UNDO_ALL
);
2981 x_window_set_current_page(w_current
, w_current
->toplevel
->page_current
);
2986 /*! \todo Finish function documentation!!!
2988 * \par Function Description
2991 DEFINE_I_CALLBACK(hierarchy_up
)
2993 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2996 exit_if_null(w_current
);
2998 up_page
= s_hierarchy_find_up_page (w_current
->toplevel
->pages
,
2999 w_current
->toplevel
->page_current
);
3000 if (up_page
== NULL
) {
3001 s_log_message(_("Cannot find any schematics above the current one!\n"));
3003 x_window_set_current_page(w_current
, up_page
);
3007 /*! \todo Finish function documentation!!!
3009 * \par Function Description
3012 * Egil Kvaleberg <egil@kvaleberg.no> on October 7, 2002 -
3013 * Provide documentation for symbol (i.e. component)
3015 DEFINE_I_CALLBACK(hierarchy_documentation
)
3017 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3018 char *attrib_doc
= NULL
;
3019 char *attrib_device
= NULL
;
3020 char *attrib_value
= NULL
;
3021 OBJECT
*object
= NULL
;
3022 const gchar
*sourcename
= NULL
;
3023 const CLibSymbol
*sym
= NULL
;
3025 exit_if_null(w_current
);
3027 object
= o_select_return_first_object(w_current
);
3028 if (object
!= NULL
) {
3029 /* only allow going into symbols */
3030 if (object
->type
== OBJ_COMPLEX
) {
3032 /* look for "documentation" */
3033 attrib_doc
= o_attrib_search_object_attribs_by_name (object
, "documentation", 0);
3034 /* look for "device" */
3035 attrib_device
= o_attrib_search_object_attribs_by_name (object
, "device", 0);
3036 /* look for "value" */
3037 attrib_value
= o_attrib_search_object_attribs_by_name (object
, "value", 0);
3039 sym
= s_clib_get_symbol_by_name (object
->complex_basename
);
3041 sourcename
= s_clib_source_get_name (s_clib_symbol_get_source(sym
));
3044 initiate_gschemdoc(attrib_doc
,
3047 object
->complex_basename
,
3051 g_free(attrib_device
);
3052 g_free(attrib_value
);
3055 generic_msg_dialog(_("This command retrieves the component documentation from the web, but there is no component selected"));
3060 /*! \section attributes-menu Attributes Menu Callback Functions */
3061 /*! \todo Finish function documentation!!!
3063 * \par Function Description
3066 DEFINE_I_CALLBACK(attributes_attach
)
3068 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3069 OBJECT
*first_object
;
3072 exit_if_null(w_current
);
3074 /* This is a new addition 3/15 to prevent this from executing
3075 * inside an action */
3076 if (w_current
->inside_action
) {
3080 /* do we want to update the shortcut outside of the ifs? */
3081 /* probably, if this fails the user may want to try again */
3082 i_update_middle_button(w_current
, i_callback_attributes_attach
,
3085 /* skip over head */
3086 s_current
= geda_list_get_glist( w_current
->toplevel
->page_current
->selection_list
);
3091 first_object
= (OBJECT
*) s_current
->data
;
3092 if (!first_object
) {
3096 /* skip over first object */
3097 s_current
= g_list_next(s_current
);
3098 while (s_current
!= NULL
) {
3099 OBJECT
*object
= s_current
->data
;
3100 if (object
!= NULL
) {
3101 o_attrib_attach (w_current
->toplevel
, object
, first_object
, TRUE
);
3102 w_current
->toplevel
->page_current
->CHANGED
=1;
3104 s_current
= g_list_next(s_current
);
3106 o_undo_savestate(w_current
, UNDO_ALL
);
3109 /*! \todo Finish function documentation!!!
3111 * \par Function Description
3114 DEFINE_I_CALLBACK(attributes_detach
)
3116 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3120 exit_if_null(w_current
);
3122 /* This is a new addition 3/15 to prevent this from executing
3123 * inside an action */
3124 if (w_current
->inside_action
) {
3128 /* same note as above on i_update_middle_button */
3129 i_update_middle_button(w_current
, i_callback_attributes_detach
,
3132 s_current
= geda_list_get_glist( w_current
->toplevel
->page_current
->selection_list
);
3133 while (s_current
!= NULL
) {
3134 o_current
= (OBJECT
*) s_current
->data
;
3136 if (o_current
->attribs
) {
3137 o_attrib_detach_all (w_current
->toplevel
, o_current
);
3138 w_current
->toplevel
->page_current
->CHANGED
=1;
3141 s_current
= g_list_next(s_current
);
3143 o_undo_savestate(w_current
, UNDO_ALL
);
3146 /*! \todo Finish function documentation!!!
3148 * \par Function Description
3151 DEFINE_I_CALLBACK(attributes_show_name
)
3153 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3154 TOPLEVEL
*toplevel
= w_current
->toplevel
;
3156 exit_if_null(w_current
);
3158 /* This is a new addition 3/15 to prevent this from executing
3159 * inside an action */
3160 if (w_current
->inside_action
) {
3164 i_update_middle_button(w_current
, i_callback_attributes_show_name
,
3167 if (o_select_selected (w_current
)) {
3168 SELECTION
*selection
= toplevel
->page_current
->selection_list
;
3171 for (s_current
= geda_list_get_glist (selection
);
3173 s_current
= g_list_next (s_current
)) {
3174 OBJECT
*object
= (OBJECT
*)s_current
->data
;
3175 o_attrib_toggle_show_name_value (w_current
, object
, SHOW_NAME
);
3178 o_undo_savestate (w_current
, UNDO_ALL
);
3182 /*! \todo Finish function documentation!!!
3184 * \par Function Description
3187 DEFINE_I_CALLBACK(attributes_show_value
)
3189 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3190 TOPLEVEL
*toplevel
= w_current
->toplevel
;
3192 exit_if_null(w_current
);
3194 /* This is a new addition 3/15 to prevent this from executing
3195 * inside an action */
3196 if (w_current
->inside_action
) {
3200 i_update_middle_button(w_current
, i_callback_attributes_show_value
,
3203 if (o_select_selected (w_current
)) {
3204 SELECTION
*selection
= toplevel
->page_current
->selection_list
;
3207 for (s_current
= geda_list_get_glist (selection
);
3209 s_current
= g_list_next (s_current
)) {
3210 OBJECT
*object
= (OBJECT
*)s_current
->data
;
3211 o_attrib_toggle_show_name_value (w_current
, object
, SHOW_VALUE
);
3214 o_undo_savestate (w_current
, UNDO_ALL
);
3218 /*! \todo Finish function documentation!!!
3220 * \par Function Description
3223 DEFINE_I_CALLBACK(attributes_show_both
)
3225 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3226 TOPLEVEL
*toplevel
= w_current
->toplevel
;
3228 exit_if_null(w_current
);
3230 /* This is a new addition 3/15 to prevent this from executing
3231 * inside an action */
3232 if (w_current
->inside_action
) {
3236 i_update_middle_button(w_current
, i_callback_attributes_show_both
,
3239 if (o_select_selected (w_current
)) {
3240 SELECTION
*selection
= toplevel
->page_current
->selection_list
;
3243 for (s_current
= geda_list_get_glist (selection
);
3245 s_current
= g_list_next (s_current
)) {
3246 OBJECT
*object
= (OBJECT
*)s_current
->data
;
3247 o_attrib_toggle_show_name_value (w_current
, object
, SHOW_NAME_VALUE
);
3250 o_undo_savestate (w_current
, UNDO_ALL
);
3254 /*! \todo Finish function documentation!!!
3256 * \par Function Description
3259 DEFINE_I_CALLBACK(attributes_visibility_toggle
)
3261 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3262 TOPLEVEL
*toplevel
= w_current
->toplevel
;
3264 exit_if_null(w_current
);
3266 /* This is a new addition 3/15 to prevent this from executing
3267 * inside an action */
3268 if (w_current
->inside_action
) {
3272 i_update_middle_button(w_current
,
3273 i_callback_attributes_visibility_toggle
,
3276 if (o_select_selected (w_current
)) {
3277 SELECTION
*selection
= toplevel
->page_current
->selection_list
;
3280 for (s_current
= geda_list_get_glist (selection
);
3282 s_current
= g_list_next (s_current
)) {
3283 OBJECT
*object
= (OBJECT
*)s_current
->data
;
3284 o_attrib_toggle_visibility (w_current
, object
);
3287 o_undo_savestate (w_current
, UNDO_ALL
);
3291 /*! \section script-menu Script Menu Callback Functions */
3292 /*! \todo Finish function documentation!!!
3294 * \par Function Description
3297 * not currently implemented
3299 DEFINE_I_CALLBACK(script_console
)
3301 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3303 exit_if_null(w_current
);
3304 printf(_("Sorry but this is a non-functioning menu option\n"));
3307 /*! \section layers-menu Layers Menu Callback Functions */
3309 /*! \section options-menu Options Menu Callback Functions */
3310 /*! \todo Finish function documentation!!!
3312 * \par Function Description
3315 * repeat last command doesn't make sense on options either??? (does it?)
3317 DEFINE_I_CALLBACK(options_text_size
)
3319 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3321 exit_if_null(w_current
);
3322 text_size_dialog(w_current
);
3325 /*! \todo Finish function documentation!!!
3327 * \par Function Description
3330 DEFINE_I_CALLBACK(options_snap_size
)
3332 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3334 exit_if_null(w_current
);
3335 snap_size_dialog(w_current
);
3338 /*! \brief Multiply by two the snap grid size.
3339 * \par Function Description
3340 * Callback function for the scale-up snap grid size hotkey.
3341 * Multiply by two the snap grid size.
3343 DEFINE_I_CALLBACK(options_scale_up_snap_size
)
3345 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3347 exit_if_null(w_current
);
3349 w_current
->snap_size
*= 2;
3350 w_current
->toplevel
->page_current
->CHANGED
=1; /* maybe remove those two lines */
3351 o_undo_savestate(w_current
, UNDO_ALL
);
3353 i_update_grid_info (w_current
);
3354 o_invalidate_all (w_current
);
3357 /*! \brief Divide by two the snap grid size.
3358 * \par Function Description
3359 * Callback function for the scale-down snap grid size hotkey.
3360 * Divide by two the snap grid size (if it's and even number).
3362 DEFINE_I_CALLBACK(options_scale_down_snap_size
)
3364 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3366 exit_if_null(w_current
);
3368 if (w_current
->snap_size
% 2 == 0)
3369 w_current
->snap_size
/= 2;
3370 w_current
->toplevel
->page_current
->CHANGED
=1; /* maybe remove those two lines */
3371 o_undo_savestate(w_current
, UNDO_ALL
);
3373 i_update_grid_info (w_current
);
3374 o_invalidate_all (w_current
);
3378 /*! \todo Finish function documentation!!!
3380 * \par Function Description
3383 * repeat last command doesn't make sense on options either??? (does
3386 DEFINE_I_CALLBACK(options_afeedback
)
3388 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3390 exit_if_null(w_current
);
3392 if (w_current
->actionfeedback_mode
== BOUNDINGBOX
) {
3393 w_current
->actionfeedback_mode
= OUTLINE
;
3394 s_log_message(_("Action feedback mode set to OUTLINE\n"));
3396 w_current
->actionfeedback_mode
= BOUNDINGBOX
;
3397 s_log_message(_("Action feedback mode set to BOUNDINGBOX\n"));
3399 if (w_current
->inside_action
&&
3400 w_current
->toplevel
->page_current
->place_list
!= NULL
)
3401 o_place_invalidate_rubber (w_current
, FALSE
);
3404 /*! \todo Finish function documentation!!!
3406 * \par Function Description
3409 DEFINE_I_CALLBACK(options_grid
)
3411 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3413 exit_if_null(w_current
);
3415 switch (w_current
->grid
) {
3416 case GRID_NONE
: w_current
->grid
= GRID_DOTS
; break;
3417 case GRID_DOTS
: w_current
->grid
= GRID_MESH
; break;
3418 case GRID_MESH
: w_current
->grid
= GRID_NONE
; break;
3421 switch (w_current
->grid
) {
3422 case GRID_NONE
: s_log_message (_("Grid OFF\n")); break;
3423 case GRID_DOTS
: s_log_message (_("Dot grid selected\n")); break;
3424 case GRID_MESH
: s_log_message (_("Mesh grid selected\n")); break;
3427 i_update_grid_info (w_current
);
3428 o_invalidate_all (w_current
);
3431 /*! \todo Finish function documentation!!!
3433 * \par Function Description
3436 DEFINE_I_CALLBACK(options_snap
)
3438 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3440 /* toggle to the next snap state */
3441 w_current
->snap
= (w_current
->snap
+1) % SNAP_STATE_COUNT
;
3443 switch (w_current
->snap
) {
3445 s_log_message(_("Snap OFF (CAUTION!)\n"));
3448 s_log_message(_("Snap ON\n"));
3451 s_log_message(_("Snap back to the grid (CAUTION!)\n"));
3454 g_critical("options_snap: toplevel->snap out of range: %d\n",
3458 i_show_state(w_current
, NULL
); /* update status on screen */
3459 i_update_grid_info (w_current
);
3462 /*! \todo Finish function documentation!!!
3464 * \par Function Description
3467 * Rubber band is cool !
3468 * Added on/off option from the pull down menu
3469 * Chris Ellec - January 2001
3471 DEFINE_I_CALLBACK(options_rubberband
)
3473 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3475 if (w_current
->netconn_rubberband
) {
3476 w_current
->netconn_rubberband
= 0;
3477 s_log_message(_("Rubber band OFF \n"));
3479 w_current
->netconn_rubberband
= 1;
3480 s_log_message(_("Rubber band ON\n"));
3485 /*! \brief callback function for setting the magnetic net option
3486 * \par Function Description
3487 * This function just toggles a variable to switch the magnetic net
3490 DEFINE_I_CALLBACK(options_magneticnet
)
3492 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3494 if ((w_current
->magneticnet_mode
= !w_current
->magneticnet_mode
)) {
3495 s_log_message(_("magnetic net mode: ON\n"));
3498 s_log_message(_("magnetic net mode: OFF\n"));
3500 i_show_state(w_current
, NULL
);
3504 /*! \todo Finish function documentation!!!
3506 * \par Function Description
3509 DEFINE_I_CALLBACK(options_show_log_window
)
3511 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3513 exit_if_null(w_current
);
3517 /*! \todo Finish function documentation!!!
3519 * \par Function Description
3522 * this is Ales' catch all misc callback
3524 DEFINE_I_CALLBACK(misc
)
3528 /*! \todo Finish function documentation!!!
3530 * \par Function Description
3533 * this is Ales' second catch all misc callback
3535 DEFINE_I_CALLBACK(misc2
)
3539 /*! \todo Finish function documentation!!!
3541 * \par Function Description
3544 * this is Ales' third catch all misc callback
3546 DEFINE_I_CALLBACK(misc3
)
3550 /*! \todo Finish function documentation!!!
3552 * \par Function Description
3555 * HACK: be sure that you don't use the widget parameter in this one,
3556 * since it is being called with a null, I suppose we should call it
3557 * with the right param.
3559 DEFINE_I_CALLBACK(cancel
)
3561 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3562 TOPLEVEL
*toplevel
= w_current
->toplevel
;
3563 GValue value
= { 0, };
3565 exit_if_null(w_current
);
3567 if (w_current
->event_state
== ENDCOMP
&&
3568 w_current
->cswindow
) {
3569 /* user hit escape key when placing components */
3571 /* Undraw any outline of the place list */
3572 o_place_invalidate_rubber (w_current
, FALSE
);
3573 w_current
->rubber_visible
= 0;
3575 /* De-select the lists in the component selector */
3576 x_compselect_deselect (w_current
);
3578 /* Present the component selector again */
3579 g_value_init (&value
, G_TYPE_BOOLEAN
);
3580 g_value_set_boolean (&value
, FALSE
);
3581 g_object_set_property (G_OBJECT(w_current
->cswindow
), "hidden", &value
);
3584 if (w_current
->inside_action
) {
3585 /* If we're cancelling from a move action, re-wind the
3586 * page contents back to their state before we started */
3587 if (w_current
->event_state
== MOVE
||
3588 w_current
->event_state
== ENDMOVE
)
3589 o_move_cancel (w_current
);
3591 /* If we're cancelling from a grip action, call the specific cancel
3592 * routine to reset the visibility of the object being modified */
3593 if (w_current
->event_state
== GRIPS
)
3594 o_grips_cancel (w_current
);
3597 /* Free the place list and its contents. If we were in a move
3598 * action, the list (refering to objects on the page) would
3599 * already have been cleared in o_move_cancel(), so this is OK. */
3600 s_delete_object_glist(toplevel
, toplevel
->page_current
->place_list
);
3601 toplevel
->page_current
->place_list
= NULL
;
3603 /* leave this on for now... but it might have to change */
3604 /* this is problematic since we don't know what the right mode */
3605 /* (when you cancel inside an action) should be */
3606 i_set_state(w_current
, SELECT
);
3607 i_update_toolbar(w_current
);
3609 /* clear the key guile command-sequence */
3610 scm_c_eval_string ("(set! current-command-sequence '())");
3612 if (w_current
->inside_action
) {
3613 o_invalidate_all (w_current
);
3616 w_current
->inside_action
=0;
3619 /*! \section help-menu Help Menu Callback Functions */
3620 /*! \todo Finish function documentation!!!
3622 * \par Function Description
3625 DEFINE_I_CALLBACK(help_about
)
3627 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3629 exit_if_null(w_current
);
3630 about_dialog(w_current
);
3633 /*! \todo Finish function documentation!!!
3635 * \par Function Description
3638 DEFINE_I_CALLBACK(help_hotkeys
)
3640 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3642 exit_if_null(w_current
);
3643 x_dialog_hotkeys(w_current
);
3646 /*! \todo Finish function documentation!!!
3648 * \par Function Description
3651 DEFINE_I_CALLBACK(options_show_coord_window
)
3653 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3655 exit_if_null(w_current
);
3656 coord_dialog (w_current
, 0, 0);
3659 /* these is a special wrapper function which cannot use the above */
3660 /* DEFINE_I_CALLBACK macro */
3662 /*! \todo Finish function documentation!!!
3664 * \par Function Description
3667 * When invoked (via signal delete_event), closes the current window
3668 * if this is the last window, quit gschem
3669 * used when you click the close button on the window which sends a DELETE
3672 gboolean
i_callback_close_wm ( GtkWidget
*widget
, GdkEvent
*event
,
3676 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3677 exit_if_null(w_current
);
3679 x_window_close(w_current
);
3681 /* stop further propagation of the delete_event signal for window: */
3682 /* - if user has cancelled the close the window should obvioulsy */
3683 /* not be destroyed */
3684 /* - otherwise window has already been destroyed, nothing more to */