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
);
161 x_window_setup (w_current
);
163 page
= x_window_open_page (w_current
, NULL
);
164 x_window_set_current_page (w_current
, page
);
165 s_log_message (_("New Window created [%s]\n"), page
->page_filename
);
168 /*! \todo Finish function documentation!!!
170 * \par Function Description
173 * don't use the widget parameter on this function, or do some
175 * since there is a call: widget = NULL, data = 0 (will be w_current)
176 * \todo This should be renamed to page_open perhaps...
178 DEFINE_I_CALLBACK(file_open
)
180 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
182 exit_if_null(w_current
);
184 x_fileselect_open (w_current
);
187 /*! \todo Finish function documentation!!!
189 * \par Function Description
192 * don't use the widget parameter on this function, or do some
194 * since there is a call: widget = NULL, data = 0 (will be w_current)
195 * \todo This should be renamed to page_open perhaps...
197 void i_callback_toolbar_file_open(GtkWidget
* widget
, gpointer data
)
199 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
200 exit_if_null(w_current
);
201 if (!w_current
->window
) return;
203 i_callback_file_open(data
, 0, NULL
);
206 /*! \todo Finish function documentation!!!
208 * \par Function Description
211 DEFINE_I_CALLBACK(file_script
)
213 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
215 exit_if_null(w_current
);
216 setup_script_selector(w_current
);
219 /*! \todo Finish function documentation!!!
221 * \par Function Description
224 * don't use the widget parameter on this function, or do some
226 * since there is a call: widget = NULL, data = 0 (will be w_current)
228 DEFINE_I_CALLBACK(file_save
)
230 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
232 exit_if_null(w_current
);
234 /*! \todo probably there should be a flag that says whether
235 * page_filename is derived from untitled_name or specified by
236 * a user. Some twisted people might name their files like
239 if (strstr(w_current
->toplevel
->page_current
->page_filename
,
240 w_current
->toplevel
->untitled_name
)) {
241 x_fileselect_save (w_current
);
243 x_window_save_page (w_current
,
244 w_current
->toplevel
->page_current
,
245 w_current
->toplevel
->page_current
->page_filename
);
249 /*! \todo Finish function documentation!!!
251 * \par Function Description
254 * don't use the widget parameter on this function, or do some
256 * since there is a call: widget = NULL, data = 0 (will be w_current)
257 * \todo This should be renamed to page_open perhaps...
259 void i_callback_toolbar_file_save(GtkWidget
* widget
, gpointer data
)
261 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
262 exit_if_null(w_current
);
263 if (!w_current
->window
) return;
265 i_callback_file_save(data
, 0, NULL
);
268 /*! \todo Finish function documentation!!!
270 * \par Function Description
273 * don't use the widget parameter on this function, or do some checking...
274 * since there is a call: widget = NULL, data = 0 (will be w_current)
276 DEFINE_I_CALLBACK(file_save_all
)
278 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
280 exit_if_null(w_current
);
282 if (s_page_save_all(w_current
->toplevel
)) {
283 i_set_state_msg(w_current
, SELECT
, _("Failed to Save All"));
285 i_set_state_msg(w_current
, SELECT
, _("Saved All"));
288 i_update_toolbar(w_current
);
289 x_pagesel_update (w_current
);
290 i_update_menus(w_current
);
293 /*! \todo Finish function documentation!!!
295 * \par Function Description
298 DEFINE_I_CALLBACK(file_save_as
)
300 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
302 exit_if_null(w_current
);
303 x_fileselect_save (w_current
);
306 /*! \todo Finish function documentation!!!
308 * \par Function Description
311 DEFINE_I_CALLBACK(file_print
)
313 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
314 char *base
=NULL
, *filename
;
315 char *ps_filename
=NULL
;
317 exit_if_null(w_current
);
318 exit_if_null(w_current
->toplevel
->page_current
->page_filename
);
321 filename
= w_current
->toplevel
->page_current
->page_filename
;
323 /* get the base file name */
324 if (g_str_has_suffix(filename
, ".sch")) {
325 /* the filename ends with ".sch", remove it */
326 base
= g_strndup(filename
, strlen(filename
) - strlen(".sch"));
328 /* the filename does not end with .sch */
329 base
= g_strdup (filename
);
332 /* add ".ps" tp the base filename */
333 ps_filename
= g_strconcat (base
, ".ps", NULL
);
336 if (output_filename
) {
337 x_print_setup(w_current
, output_filename
);
339 x_print_setup(w_current
, ps_filename
);
345 /*! \todo Finish function documentation!!!
347 * \par Function Description
350 DEFINE_I_CALLBACK(file_write_png
)
352 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
354 exit_if_null(w_current
);
356 x_image_setup(w_current
);
359 /*! \todo Finish function documentation!!!
361 * \par Function Description
364 * don't use the widget parameter on this function, or do some
366 * since there is a call: widget = NULL, data = 0 (will be w_current)
367 * this function closes a window
369 DEFINE_I_CALLBACK(file_close
)
371 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
373 exit_if_null(w_current
);
375 s_log_message(_("Closing Window\n"));
376 x_window_close(w_current
);
379 /*! \todo Finish function documentation!!!
381 * \par Function Description
382 * This function is called when you send a delete event to gschem
385 * Also DON'T ref the widget parameter since they can be null
386 * \todo Need a cleaner way of doing this. This routine is used by the
387 * delete event signals
389 int i_callback_close(gpointer data
, guint callback_action
, GtkWidget
*widget
)
391 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
393 exit_if_null(w_current
);
394 i_callback_file_close(w_current
, 0, widget
);
398 /*! \todo Finish function documentation!!!
400 * \par Function Description
403 DEFINE_I_CALLBACK(file_quit
)
405 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
407 exit_if_null(w_current
);
408 x_window_close_all(w_current
);
411 /*! \section edit-menu Edit Menu Callback Functions */
412 /*! \todo Finish function documentation!!!
414 * \par Function Description
417 DEFINE_I_CALLBACK(edit_undo
)
419 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
421 /* If we're cancelling from a move action, re-wind the
422 * page contents back to their state before we started.
424 * It "might" be nice to sub-undo rotates / zoom changes
425 * made whilst moving components, but when the undo code
426 * hits s_page_delete(), the place list objects are free'd.
427 * Since they are also contained in the schematic page, a
428 * crash occurs when the page objects are free'd.
430 if (w_current
->inside_action
&&
431 (w_current
->event_state
== MOVE
||
432 w_current
->event_state
== ENDMOVE
)) {
433 i_callback_cancel (w_current
, 0, NULL
);
435 w_current
->toplevel
->DONT_REDRAW
= 0;
436 o_undo_callback(w_current
, UNDO_ACTION
);
440 /*! \todo Finish function documentation!!!
442 * \par Function Description
445 * don't use the widget parameter on this function, or do some checking...
446 * since there is a call: widget = NULL, data = 0 (will be w_current hack)
448 void i_callback_toolbar_edit_undo(GtkWidget
* widget
, gpointer data
)
450 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
451 exit_if_null(w_current
);
452 if (!w_current
->window
) return;
454 i_callback_edit_undo(data
, 0, NULL
);
457 /*! \todo Finish function documentation!!!
459 * \par Function Description
462 DEFINE_I_CALLBACK(edit_redo
)
464 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
466 w_current
->toplevel
->DONT_REDRAW
= 0;
467 o_undo_callback(w_current
, REDO_ACTION
);
470 /*! \todo Finish function documentation!!!
472 * \par Function Description
475 * don't use the widget parameter on this function, or do some checking...
476 * since there is a call: widget = NULL, data = 0 (will be w_current hack)
478 void i_callback_toolbar_edit_redo(GtkWidget
* widget
, gpointer data
)
480 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
481 exit_if_null(w_current
);
482 if (!w_current
->window
) return;
484 i_callback_edit_redo(data
, 0, NULL
);
487 /*! \todo Finish function documentation!!!
489 * \par Function Description
492 * Select also does not update the middle button shortcut.
494 DEFINE_I_CALLBACK(edit_select
)
496 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
497 o_redraw_cleanstates(w_current
);
499 /* this is probably the only place this should be */
500 i_set_state(w_current
, SELECT
);
501 i_update_toolbar(w_current
);
502 w_current
->inside_action
= 0;
505 /*! \todo Finish function documentation!!!
507 * \par Function Description
510 * don't use the widget parameter on this function, or do some checking...
511 * since there is a call: widget = NULL, data = 0 (will be w_current hack)
513 void i_callback_toolbar_edit_select(GtkWidget
* widget
, gpointer data
)
515 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
516 exit_if_null(w_current
);
517 if (!w_current
->window
) return;
519 if (GTK_TOGGLE_BUTTON (widget
)->active
) {
520 if (!o_invalidate_rubber (w_current
)) {
521 i_callback_cancel(w_current
, 0, NULL
);
523 i_callback_edit_select(data
, 0, NULL
);
527 /*! \todo Finish function documentation!!!
529 * \par Function Description
532 DEFINE_I_CALLBACK(edit_copy
)
534 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
536 exit_if_null(w_current
);
538 i_update_middle_button(w_current
, i_callback_edit_copy
, _("Copy"));
539 if (o_select_return_first_object(w_current
)) {
540 o_redraw_cleanstates(w_current
);
541 i_set_state(w_current
, STARTCOPY
);
543 i_set_state_msg(w_current
, SELECT
, _("Select objs first"));
547 /*! \todo Finish function documentation!!!
549 * \par Function Description
552 DEFINE_I_CALLBACK(edit_copy_hotkey
)
554 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
557 exit_if_null(w_current
);
559 if (!x_event_get_pointer_position(w_current
, TRUE
, &wx
, &wy
))
562 i_update_middle_button(w_current
, i_callback_edit_copy_hotkey
, _("Copy"));
563 if (o_select_return_first_object(w_current
)) {
564 o_redraw_cleanstates(w_current
);
565 w_current
->event_state
= COPY
;
566 o_copy_start(w_current
, wx
, wy
);
567 w_current
->event_state
= ENDCOPY
;
568 w_current
->inside_action
= 1;
572 /*! \todo Finish function documentation!!!
574 * \par Function Description
577 DEFINE_I_CALLBACK(edit_mcopy
)
579 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
581 exit_if_null(w_current
);
583 i_update_middle_button(w_current
, i_callback_edit_copy
, _("Multiple Copy"));
584 if (o_select_return_first_object(w_current
)) {
585 o_redraw_cleanstates(w_current
);
586 i_set_state(w_current
, STARTMCOPY
);
588 i_set_state_msg(w_current
, SELECT
, _("Select objs first"));
592 /*! \todo Finish function documentation!!!
594 * \par Function Description
597 DEFINE_I_CALLBACK(edit_mcopy_hotkey
)
599 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
602 exit_if_null(w_current
);
604 if (!x_event_get_pointer_position(w_current
, TRUE
, &wx
, &wy
))
607 i_update_middle_button(w_current
, i_callback_edit_mcopy_hotkey
, _("Multiple Copy"));
608 if (o_select_return_first_object(w_current
)) {
609 o_redraw_cleanstates(w_current
);
610 w_current
->event_state
= MCOPY
;
611 o_copy_start(w_current
, wx
, wy
);
612 w_current
->event_state
= ENDMCOPY
;
613 w_current
->inside_action
= 1;
617 /*! \todo Finish function documentation!!!
619 * \par Function Description
622 DEFINE_I_CALLBACK(edit_move
)
624 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
626 exit_if_null(w_current
);
628 i_update_middle_button(w_current
, i_callback_edit_move
, _("Move"));
629 if (o_select_return_first_object(w_current
)) {
630 o_redraw_cleanstates(w_current
);
631 i_set_state(w_current
, STARTMOVE
);
633 i_set_state_msg(w_current
, SELECT
, _("Select objs first"));
637 /*! \todo Finish function documentation!!!
639 * \par Function Description
642 DEFINE_I_CALLBACK(edit_move_hotkey
)
644 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
647 exit_if_null(w_current
);
649 if (!x_event_get_pointer_position(w_current
, TRUE
, &wx
, &wy
))
652 i_update_middle_button(w_current
, i_callback_edit_move_hotkey
, _("Move"));
653 if (o_select_return_first_object(w_current
)) {
654 o_redraw_cleanstates(w_current
);
655 o_move_start(w_current
, wx
, wy
);
656 w_current
->event_state
= ENDMOVE
;
657 w_current
->inside_action
= 1;
661 /*! \todo Finish function documentation!!!
663 * \par Function Description
666 DEFINE_I_CALLBACK(edit_delete
)
668 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
670 exit_if_null(w_current
);
672 i_update_middle_button(w_current
, i_callback_edit_delete
, _("Delete"));
674 if (o_select_return_first_object(w_current
)) {
675 o_redraw_cleanstates(w_current
);
676 o_delete_selected(w_current
);
677 /* if you delete the objects you must go into select
678 * mode after the delete */
679 w_current
->inside_action
= 0;
680 i_set_state(w_current
, SELECT
);
681 i_update_toolbar(w_current
);
682 i_update_menus(w_current
);
686 /*! \todo Finish function documentation!!!
688 * \par Function Description
691 DEFINE_I_CALLBACK(edit_edit
)
693 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
695 exit_if_null(w_current
);
697 i_update_middle_button(w_current
, i_callback_edit_edit
, _("Edit"));
698 o_edit(w_current
, geda_list_get_glist( w_current
->toplevel
->page_current
->selection_list
) );
701 /*! \todo Finish function documentation!!!
703 * \par Function Description
706 DEFINE_I_CALLBACK(edit_pin_type
)
708 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
710 exit_if_null(w_current
);
712 i_update_middle_button (w_current
, i_callback_edit_pin_type
, _("Edit pin type"));
714 x_dialog_edit_pin_type (w_current
,
715 geda_list_get_glist (w_current
->toplevel
->
716 page_current
->selection_list
));
719 /*! \todo Finish function documentation!!!
721 * \par Function Description
724 DEFINE_I_CALLBACK(edit_text
)
726 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
729 exit_if_null(w_current
);
731 i_update_middle_button(w_current
, i_callback_edit_text
, _("Edit Text"));
732 object
= o_select_return_first_object(w_current
);
734 if (object
->type
== OBJ_TEXT
) {
735 o_text_edit(w_current
, object
);
740 /*! \todo Finish function documentation!!!
742 * \par Function Description
745 DEFINE_I_CALLBACK(edit_slot
)
747 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
750 exit_if_null(w_current
);
752 object
= o_select_return_first_object(w_current
);
754 i_update_middle_button(w_current
, i_callback_edit_slot
, _("Slot"));
756 o_slot_start(w_current
, object
);
760 /*! \todo Finish function documentation!!!
762 * \par Function Description
765 DEFINE_I_CALLBACK(edit_color
)
767 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
769 exit_if_null(w_current
);
771 i_update_middle_button(w_current
, i_callback_edit_color
, _("Color"));
773 color_edit_dialog(w_current
);
776 /*! \todo Finish function documentation!!!
778 * \par Function Description
779 * This function rotate all objects in the selection list by 90 degrees.
782 DEFINE_I_CALLBACK(edit_rotate_90
)
784 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
786 exit_if_null(w_current
);
788 /* If inside an appropriate action, send a button 2 released,
789 * so rotating will be handled by x_event.c */
790 if ( w_current
->inside_action
&&
791 (w_current
->event_state
== ENDCOMP
||
792 w_current
->event_state
== ENDTEXT
||
793 w_current
->event_state
== ENDMOVE
||
794 w_current
->event_state
== ENDCOPY
||
795 w_current
->event_state
== ENDMCOPY
||
796 w_current
->event_state
== ENDPASTE
)) {
799 event
= gdk_event_new(GDK_BUTTON_RELEASE
);
800 ((GdkEventButton
*) event
)->button
= 2;
801 x_event_button_released (NULL
, (GdkEventButton
*) event
, w_current
);
802 gdk_event_free(event
);
807 i_set_state(w_current
, ENDROTATEP
);
808 i_update_middle_button(w_current
, i_callback_edit_rotate_90
, _("Rotate"));
811 /*! \todo Finish function documentation!!!
813 * \par Function Description
814 * This function rotate all objects in the selection list by 90 degrees.
817 DEFINE_I_CALLBACK(edit_rotate_90_hotkey
)
819 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
823 exit_if_null(w_current
);
825 if (!x_event_get_pointer_position(w_current
, TRUE
, &wx
, &wy
))
828 /* If inside an appropriate action, send a button 2 released,
829 * so rotating will be handled by x_event.c */
830 if ( w_current
->inside_action
&&
831 (w_current
->event_state
== ENDCOMP
||
832 w_current
->event_state
== ENDTEXT
||
833 w_current
->event_state
== ENDMOVE
||
834 w_current
->event_state
== ENDCOPY
||
835 w_current
->event_state
== ENDMCOPY
||
836 w_current
->event_state
== ENDPASTE
)) {
839 event
= gdk_event_new(GDK_BUTTON_RELEASE
);
840 ((GdkEventButton
*) event
)->button
= 2;
841 x_event_button_released (NULL
, (GdkEventButton
*) event
, w_current
);
842 gdk_event_free(event
);
847 o_redraw_cleanstates(w_current
);
849 object_list
= geda_list_get_glist( w_current
->toplevel
->page_current
->selection_list
);
852 i_update_middle_button(w_current
,
853 i_callback_edit_rotate_90_hotkey
, _("Rotate"));
854 /* Allow o_rotate_world_update to redraw the objects */
855 w_current
->toplevel
->DONT_REDRAW
= 0;
856 o_rotate_world_update(w_current
, wx
, wy
, 90, object_list
);
859 w_current
->event_state
= SELECT
;
860 w_current
->inside_action
= 0;
861 i_update_toolbar(w_current
);
864 /*! \todo Finish function documentation!!!
866 * \par Function Description
869 DEFINE_I_CALLBACK(edit_mirror
)
871 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
873 exit_if_null(w_current
);
875 i_set_state(w_current
, ENDMIRROR
);
876 i_update_middle_button(w_current
, i_callback_edit_mirror
, _("Mirror"));
879 /*! \todo Finish function documentation!!!
881 * \par Function Description
884 DEFINE_I_CALLBACK(edit_mirror_hotkey
)
886 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
890 exit_if_null(w_current
);
892 if (!x_event_get_pointer_position(w_current
, TRUE
, &wx
, &wy
))
895 o_redraw_cleanstates(w_current
);
897 object_list
= geda_list_get_glist( w_current
->toplevel
->page_current
->selection_list
);
900 i_update_middle_button(w_current
,
901 i_callback_edit_mirror_hotkey
, _("Mirror"));
902 o_mirror_world_update(w_current
, wx
, wy
, object_list
);
905 w_current
->event_state
= SELECT
;
906 w_current
->inside_action
= 0;
907 i_update_toolbar(w_current
);
910 /*! \todo Finish function documentation!!!
912 * \par Function Description
913 * This function locks all objects in selection list.
916 DEFINE_I_CALLBACK(edit_lock
)
918 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
920 exit_if_null(w_current
);
922 i_update_middle_button(w_current
, i_callback_edit_lock
, _("Lock"));
924 if (o_select_return_first_object(w_current
)) {
929 /*! \todo Finish function documentation!!!
931 * \par Function Description
932 * Thus function unlocks all objects in selection list.
934 DEFINE_I_CALLBACK(edit_unlock
)
936 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
938 exit_if_null(w_current
);
940 i_update_middle_button(w_current
, i_callback_edit_unlock
, _("Unlock"));
941 if (o_select_return_first_object(w_current
)) {
946 /*! \todo Finish function documentation!!!
948 * \par Function Description
951 DEFINE_I_CALLBACK(edit_translate
)
953 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
955 exit_if_null(w_current
);
957 i_update_middle_button(w_current
,
958 i_callback_edit_translate
, _("Translate"));
960 if (w_current
->snap
== SNAP_OFF
) {
961 s_log_message(_("WARNING: Do not translate with snap off!\n"));
962 s_log_message(_("WARNING: Turning snap on and continuing "
963 "with translate.\n"));
964 w_current
->snap
= SNAP_GRID
;
965 i_show_state(w_current
, NULL
); /* update status on screen */
968 if (w_current
->snap_size
!= 100) {
969 s_log_message(_("WARNING: Snap grid size is "
970 "not equal to 100!\n"));
971 s_log_message(_("WARNING: If you are translating a symbol "
972 "to the origin, the snap grid size should be "
976 translate_dialog(w_current
);
979 DEFINE_I_CALLBACK(edit_invoke_macro
)
981 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
983 exit_if_null(w_current
);
985 gtk_widget_show(w_current
->macro_box
);
986 gtk_widget_grab_focus(w_current
->macro_entry
);
989 /*! \todo Finish function documentation!!!
991 * \par Function Description
992 * This function embedds all objects in selection list
995 DEFINE_I_CALLBACK(edit_embed
)
997 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1000 exit_if_null(w_current
);
1002 i_update_middle_button(w_current
, i_callback_edit_embed
, _("Embed"));
1003 /* anything selected ? */
1004 if (o_select_selected(w_current
)) {
1005 /* yes, embed each selected component */
1007 geda_list_get_glist( w_current
->toplevel
->page_current
->selection_list
);
1009 while (s_current
!= NULL
) {
1010 o_current
= (OBJECT
*) s_current
->data
;
1011 g_assert (o_current
!= NULL
);
1012 if ( (o_current
->type
== OBJ_COMPLEX
) ||
1013 (o_current
->type
== OBJ_PICTURE
) ) {
1014 o_embed (w_current
->toplevel
, o_current
);
1016 s_current
= g_list_next(s_current
);
1018 o_invalidate_glist (w_current
, geda_list_get_glist (
1019 w_current
->toplevel
->page_current
->selection_list
));
1020 o_undo_savestate(w_current
, UNDO_ALL
);
1022 /* nothing selected, go back to select state */
1023 o_redraw_cleanstates(w_current
);
1024 w_current
->inside_action
= 0;
1025 i_set_state(w_current
, SELECT
);
1030 /*! \todo Finish function documentation!!!
1032 * \par Function Description
1033 * This function unembedds all objects in selection list.
1036 DEFINE_I_CALLBACK(edit_unembed
)
1038 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1041 exit_if_null(w_current
);
1043 i_update_middle_button(w_current
, i_callback_edit_unembed
, _("Unembed"));
1044 /* anything selected ? */
1045 if (o_select_selected(w_current
)) {
1046 /* yes, unembed each selected component */
1048 geda_list_get_glist( w_current
->toplevel
->page_current
->selection_list
);
1050 while (s_current
!= NULL
) {
1051 o_current
= (OBJECT
*) s_current
->data
;
1052 g_assert (o_current
!= NULL
);
1053 if ( (o_current
->type
== OBJ_COMPLEX
) ||
1054 (o_current
->type
== OBJ_PICTURE
) ) {
1055 o_unembed (w_current
->toplevel
, o_current
);
1057 s_current
= g_list_next(s_current
);
1059 o_invalidate_glist (w_current
, geda_list_get_glist (
1060 w_current
->toplevel
->page_current
->selection_list
));
1061 o_undo_savestate(w_current
, UNDO_ALL
);
1063 /* nothing selected, go back to select state */
1064 o_redraw_cleanstates(w_current
);
1065 w_current
->inside_action
= 0;
1066 i_set_state(w_current
, SELECT
);
1071 /*! \todo Finish function documentation!!!
1073 * \par Function Description
1074 * This function updates components
1077 DEFINE_I_CALLBACK(edit_update
)
1079 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1080 TOPLEVEL
*toplevel
= w_current
->toplevel
;
1082 GList
* selection_copy
;
1085 exit_if_null(w_current
);
1087 i_update_middle_button(w_current
, i_callback_edit_update
, _("Update"));
1088 /* anything selected ? */
1089 if (o_select_selected(w_current
)) {
1091 /* yes, update each selected component, but operate from a copy of the */
1092 /* selection list, since o_update_component will modify the selection */
1094 /* After the following code executes, only OBJ_COMPLEX object will be */
1095 /* left selected. */
1097 /* g_list_copy does a shallow copy which is exactly what we need here */
1098 selection_copy
= g_list_copy (
1099 geda_list_get_glist (toplevel
->page_current
->selection_list
));
1100 s_current
= selection_copy
;
1101 while (s_current
!= NULL
) {
1102 o_current
= (OBJECT
*) s_current
->data
;
1103 g_assert (o_current
!= NULL
);
1104 if (o_current
->type
== OBJ_COMPLEX
) {
1105 o_update_component (w_current
, o_current
);
1109 /* object was not a OBJ_COMPLEX, so unselect it. */
1110 o_selection_remove (toplevel
,
1111 toplevel
->page_current
->selection_list
, o_current
);
1113 s_current
= g_list_next(s_current
);
1115 g_list_free(selection_copy
);
1117 /* Make sure the display is up to date */
1118 o_invalidate_all (w_current
);
1120 /* nothing selected, go back to select state */
1121 o_redraw_cleanstates(w_current
);
1122 w_current
->inside_action
= 0;
1123 i_set_state(w_current
, SELECT
);
1128 /*! \todo Finish function documentation!!!
1130 * \par Function Description
1133 DEFINE_I_CALLBACK(edit_show_hidden
)
1135 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1137 exit_if_null(w_current
);
1139 /* This is a new addition 3/15 to prevent this from executing
1140 * inside an action */
1141 if (w_current
->inside_action
)
1144 i_update_middle_button(w_current
,
1145 i_callback_edit_show_hidden
,
1148 o_edit_show_hidden (w_current
,
1149 s_page_objects (w_current
->toplevel
->page_current
));
1152 /*! \todo Finish function documentation!!!
1154 * \par Function Description
1157 DEFINE_I_CALLBACK(edit_make_visible
)
1159 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1161 exit_if_null(w_current
);
1163 /* This is a new addition 3/15 to prevent this from executing
1164 * inside an action */
1165 if (w_current
->inside_action
)
1168 i_update_middle_button(w_current
,
1169 i_callback_edit_make_visible
,
1172 o_edit_make_visible (w_current
,
1173 s_page_objects (w_current
->toplevel
->page_current
));
1176 /*! \todo Finish function documentation!!!
1178 * \par Function Description
1181 DEFINE_I_CALLBACK(edit_find
)
1183 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1185 exit_if_null(w_current
);
1187 /* This is a new addition 3/15 to prevent this from executing
1188 * inside an action */
1189 if (w_current
->inside_action
)
1192 find_text_dialog(w_current
);
1195 /*! \todo Finish function documentation!!!
1197 * \par Function Description
1200 DEFINE_I_CALLBACK(edit_hide_text
)
1202 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1204 exit_if_null(w_current
);
1206 /* This is a new addition 3/15 to prevent this from executing
1207 * inside an action */
1208 if (w_current
->inside_action
)
1211 hide_text_dialog(w_current
);
1214 /*! \todo Finish function documentation!!!
1216 * \par Function Description
1219 DEFINE_I_CALLBACK(edit_show_text
)
1221 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1223 exit_if_null(w_current
);
1225 /* This is a new addition 3/15 to prevent this from executing
1226 * inside an action */
1227 if (w_current
->inside_action
)
1230 show_text_dialog(w_current
);
1233 /*! \todo Finish function documentation!!!
1235 * \par Function Description
1238 DEFINE_I_CALLBACK(edit_autonumber_text
)
1240 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1242 exit_if_null(w_current
);
1244 /* This is a new addition 3/15 to prevent this from executing
1245 * inside an action */
1246 if (w_current
->inside_action
)
1249 autonumber_text_dialog(w_current
);
1252 /*! \todo Finish function documentation!!!
1254 * \par Function Description
1257 DEFINE_I_CALLBACK(edit_linetype
)
1259 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1261 exit_if_null(w_current
);
1263 line_type_dialog(w_current
);
1266 /*! \todo Finish function documentation!!!
1268 * \par Function Description
1271 DEFINE_I_CALLBACK(edit_filltype
)
1273 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1275 exit_if_null(w_current
);
1277 fill_type_dialog(w_current
);
1280 /*! \section view-menu View Menu Callback Functions */
1281 /*! \todo Finish function documentation!!!
1283 * \par Function Description
1286 * repeat middle shortcut doesn't make sense on redraw, just hit right
1289 DEFINE_I_CALLBACK(view_redraw
)
1291 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1293 exit_if_null(w_current
);
1294 o_invalidate_all (w_current
);
1297 /*! \todo Finish function documentation!!!
1299 * \par Function Description
1302 * repeat middle shortcut would get into the way of what user is try to do
1304 DEFINE_I_CALLBACK(view_zoom_full
)
1306 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1308 exit_if_null(w_current
);
1310 /* scroll bar stuff */
1311 a_zoom(w_current
, ZOOM_FULL
, DONTCARE
, 0);
1313 if (w_current
->undo_panzoom
) {
1314 o_undo_savestate(w_current
, UNDO_VIEWPORT_ONLY
);
1318 /*! \todo Finish function documentation!!!
1320 * \par Function Description
1323 * repeat middle shortcut would get into the way of what user is try to do
1325 DEFINE_I_CALLBACK(view_zoom_extents
)
1327 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1329 exit_if_null(w_current
);
1331 /* scroll bar stuff */
1332 a_zoom_extents (w_current
,
1333 s_page_objects (w_current
->toplevel
->page_current
), 0);
1334 if (w_current
->undo_panzoom
) {
1335 o_undo_savestate(w_current
, UNDO_VIEWPORT_ONLY
);
1339 /*! \todo Finish function documentation!!!
1341 * \par Function Description
1344 * repeat middle shortcut would get into the way of what user is try to do
1346 DEFINE_I_CALLBACK(view_zoom_box
)
1348 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1350 exit_if_null(w_current
);
1352 o_redraw_cleanstates(w_current
);
1353 w_current
->inside_action
= 0;
1354 i_set_state(w_current
, ZOOMBOXSTART
);
1357 /*! \todo Finish function documentation!!!
1359 * \par Function Description
1362 DEFINE_I_CALLBACK(view_zoom_box_hotkey
)
1364 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1367 exit_if_null(w_current
);
1369 if (!x_event_get_pointer_position(w_current
, FALSE
, &wx
, &wy
))
1372 o_redraw_cleanstates(w_current
);
1373 a_zoom_box_start(w_current
, wx
, wy
);
1375 w_current
->inside_action
= 1;
1376 i_set_state(w_current
, ZOOMBOXEND
);
1379 /*! \todo Finish function documentation!!!
1381 * \par Function Description
1384 * repeat middle shortcut would get into the way of what user is try to do
1386 DEFINE_I_CALLBACK(view_zoom_in
)
1388 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1390 exit_if_null(w_current
);
1392 a_zoom(w_current
, ZOOM_IN
, MENU
, 0);
1394 if (w_current
->undo_panzoom
) {
1395 o_undo_savestate(w_current
, UNDO_VIEWPORT_ONLY
);
1399 /*! \todo Finish function documentation!!!
1401 * \par Function Description
1404 * repeat middle shortcut would get into the way of what user is try to do
1406 DEFINE_I_CALLBACK(view_zoom_out
)
1408 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1410 exit_if_null(w_current
);
1412 a_zoom(w_current
, ZOOM_OUT
, MENU
, 0);
1414 if (w_current
->undo_panzoom
) {
1415 o_undo_savestate(w_current
, UNDO_VIEWPORT_ONLY
);
1419 /*! \todo Finish function documentation!!!
1421 * \par Function Description
1424 * repeat middle shortcut would get into the way of what user is try
1427 DEFINE_I_CALLBACK(view_zoom_in_hotkey
)
1429 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1431 exit_if_null(w_current
);
1433 a_zoom(w_current
, ZOOM_IN
, HOTKEY
, 0);
1435 if (w_current
->undo_panzoom
) {
1436 o_undo_savestate(w_current
, UNDO_VIEWPORT_ONLY
);
1440 /*! \todo Finish function documentation!!!
1442 * \par Function Description
1445 * repeat middle shortcut would get into the way of what user is try to do
1447 DEFINE_I_CALLBACK(view_zoom_out_hotkey
)
1449 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1451 exit_if_null(w_current
);
1453 a_zoom(w_current
, ZOOM_OUT
, HOTKEY
, 0);
1455 if (w_current
->undo_panzoom
) {
1456 o_undo_savestate(w_current
, UNDO_VIEWPORT_ONLY
);
1460 /*! \todo Finish function documentation!!!
1462 * \par Function Description
1465 DEFINE_I_CALLBACK(view_pan
)
1467 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1469 exit_if_null(w_current
);
1471 o_redraw_cleanstates(w_current
);
1472 w_current
->inside_action
= 0;
1473 i_set_state(w_current
, STARTPAN
);
1475 /* I don't know if this would get in the way */
1476 i_update_middle_button(w_current
, i_callback_view_pan
, _("Pan"));
1479 /*! \brief Scheme callback function that moves the viewport to the left.
1481 * The distance can be set with "keyboardpan-gain" scheme callback.
1483 DEFINE_I_CALLBACK(view_pan_left
)
1485 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1487 exit_if_null(w_current
);
1489 a_pan_mouse(w_current
, w_current
->keyboardpan_gain
, 0);
1492 /*! \brief Scheme callback function that moves the viewport to the right.
1494 * The distance can be set with "keyboardpan-gain" scheme callback.
1496 DEFINE_I_CALLBACK(view_pan_right
)
1498 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1500 exit_if_null(w_current
);
1502 /* yes, that's a negative sign there */
1503 a_pan_mouse(w_current
, -w_current
->keyboardpan_gain
, 0);
1506 /*! \brief Scheme callback function that moves the viewport up.
1508 * The distance can be set with "keyboardpan-gain" scheme callback.
1510 DEFINE_I_CALLBACK(view_pan_up
)
1512 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1514 exit_if_null(w_current
);
1516 a_pan_mouse(w_current
, 0, w_current
->keyboardpan_gain
);
1519 /*! \brief Scheme callback function that moves the viewport down.
1521 * The distance can be set with "keyboardpan-gain" scheme callback.
1523 DEFINE_I_CALLBACK(view_pan_down
)
1525 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1527 exit_if_null(w_current
);
1529 /* yes, that's a negative sign there */
1530 a_pan_mouse(w_current
, 0, -w_current
->keyboardpan_gain
);
1533 /*! \todo Finish function documentation!!!
1535 * \par Function Description
1538 DEFINE_I_CALLBACK(view_pan_hotkey
)
1540 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1543 exit_if_null(w_current
);
1545 if (!x_event_get_pointer_position(w_current
, FALSE
, &wx
, &wy
))
1548 i_update_middle_button(w_current
, i_callback_view_pan_hotkey
, _("Pan"));
1550 a_pan(w_current
, wx
, wy
);
1552 if (w_current
->undo_panzoom
) {
1553 o_undo_savestate(w_current
, UNDO_VIEWPORT_ONLY
);
1557 /*! \todo Finish function documentation!!!
1559 * \par Function Description
1562 DEFINE_I_CALLBACK(view_update_cues
)
1564 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1566 i_update_middle_button(w_current
,
1567 i_callback_view_update_cues
, _("Update Cues"));
1569 o_invalidate_all (w_current
);
1572 /*! \todo Finish function documentation!!!
1574 * \par Function Description
1577 DEFINE_I_CALLBACK (view_dark_colors
)
1579 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1582 /* Change the scheme here */
1583 g_scm_c_eval_string_protected ("(load (build-path geda-rc-path \"gschem-colormap-darkbg\"))");
1584 x_color_allocate ();
1586 o_invalidate_all (w_current
);
1589 /*! \todo Finish function documentation!!!
1591 * \par Function Description
1594 DEFINE_I_CALLBACK (view_light_colors
)
1596 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1599 /* Change the scheme here */
1600 g_scm_c_eval_string_protected ("(load (build-path geda-rc-path \"gschem-colormap-lightbg\"))");
1601 x_color_allocate ();
1603 o_invalidate_all (w_current
);
1606 /*! \section page-menu Page Menu Callback Functions */
1607 /*! \todo Finish function documentation!!!
1609 * \par Function Description
1612 DEFINE_I_CALLBACK(page_manager
)
1614 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1616 exit_if_null(w_current
);
1618 x_pagesel_open (w_current
);
1621 /*! \todo Finish function documentation!!!
1623 * \par Function Description
1626 DEFINE_I_CALLBACK(page_next
)
1628 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*)data
;
1629 TOPLEVEL
*toplevel
= w_current
->toplevel
;
1630 PAGE
*p_current
= toplevel
->page_current
;
1634 exit_if_null(w_current
);
1636 iter
= g_list_find( geda_list_get_glist( toplevel
->pages
), p_current
);
1637 iter
= g_list_next( iter
);
1643 if (w_current
->enforce_hierarchy
) {
1644 p_new
= s_hierarchy_find_next_page(toplevel
->pages
, p_current
);
1646 p_new
= (PAGE
*)iter
->data
;
1649 if (p_new
== NULL
|| p_new
== p_current
) {
1653 x_window_set_current_page (w_current
, p_new
);
1656 /*! \todo Finish function documentation!!!
1658 * \par Function Description
1661 DEFINE_I_CALLBACK(page_prev
)
1663 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*)data
;
1664 TOPLEVEL
*toplevel
= w_current
->toplevel
;
1665 PAGE
*p_current
= toplevel
->page_current
;
1669 exit_if_null(w_current
);
1671 iter
= g_list_find( geda_list_get_glist( toplevel
->pages
), p_current
);
1672 iter
= g_list_previous( iter
);
1677 p_new
= (PAGE
*)iter
->data
;
1679 if (w_current
->enforce_hierarchy
) {
1680 p_new
= s_hierarchy_find_prev_page(toplevel
->pages
, p_current
);
1682 p_new
= (PAGE
*)iter
->data
;
1685 if (p_new
== NULL
|| p_new
== p_current
) {
1689 x_window_set_current_page (w_current
, p_new
);
1692 /*! \todo Finish function documentation!!!
1694 * \par Function Description
1697 DEFINE_I_CALLBACK(page_new
)
1699 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*)data
;
1702 exit_if_null(w_current
);
1704 /* create a new page */
1705 page
= x_window_open_page (w_current
, NULL
);
1706 x_window_set_current_page (w_current
, page
);
1707 s_log_message (_("New page created [%s]\n"), page
->page_filename
);
1710 /*! \todo Finish function documentation!!!
1712 * \par Function Description
1715 DEFINE_I_CALLBACK(page_close
)
1717 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1719 exit_if_null(w_current
);
1721 if (w_current
->toplevel
->page_current
->CHANGED
) {
1722 x_dialog_close_changed_page (w_current
, w_current
->toplevel
->page_current
);
1724 x_window_close_page (w_current
, w_current
->toplevel
->page_current
);
1729 /*! \todo Finish function documentation!!!
1731 * \par Function Description
1733 * \bug may have memory leak?
1735 DEFINE_I_CALLBACK(page_revert
)
1737 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1745 exit_if_null(w_current
);
1747 dialog
= gtk_message_dialog_new ((GtkWindow
*) w_current
->main_window
,
1748 GTK_DIALOG_DESTROY_WITH_PARENT
,
1749 GTK_MESSAGE_QUESTION
,
1751 _("Really revert page?"));
1753 /* Set the alternative button order (ok, cancel, help) for other systems */
1754 gtk_dialog_set_alternative_button_order(GTK_DIALOG(dialog
),
1759 response
= gtk_dialog_run (GTK_DIALOG (dialog
));
1760 gtk_widget_destroy (dialog
);
1762 if (response
!= GTK_RESPONSE_YES
)
1765 /* save this for later */
1766 filename
= g_strdup (w_current
->toplevel
->page_current
->page_filename
);
1767 page_control
= w_current
->toplevel
->page_current
->page_control
;
1768 up
= w_current
->toplevel
->page_current
->up
;
1770 /* delete the page, then re-open the file as a new page */
1771 s_page_delete (w_current
->toplevel
, w_current
->toplevel
->page_current
);
1773 page
= x_window_open_page (w_current
, filename
);
1775 /* make sure we maintain the hierarchy info */
1776 page
->page_control
= page_control
;
1779 x_window_set_current_page (w_current
, page
);
1782 /*! \todo Finish function documentation!!!
1784 * \par Function Description
1787 DEFINE_I_CALLBACK(page_discard
)
1789 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*)data
;
1791 exit_if_null(w_current
);
1793 x_window_close_page (w_current
, w_current
->toplevel
->page_current
);
1796 /*! \todo Finish function documentation!!!
1798 * \par Function Description
1801 DEFINE_I_CALLBACK(page_print
)
1803 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1805 s_page_print_all(w_current
->toplevel
);
1808 /*! \section clipboard-menu Clipboard Menu Callback Functions */
1809 /*! \brief Copy selection to clipboard.
1810 * \par Function Description
1811 * Copies the current selection to the clipboard, via buffer 0.
1813 DEFINE_I_CALLBACK(clipboard_copy
)
1815 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1817 exit_if_null (w_current
);
1818 if (!o_select_selected (w_current
)) return;
1820 i_update_middle_button (w_current
, i_callback_clipboard_copy
,
1821 _("Copy to clipboard"));
1823 o_buffer_copy (w_current
, 0);
1824 x_clipboard_set (w_current
, object_buffer
[0]);
1827 /*! \brief Cut selection to clipboard.
1828 * \par Function Description
1829 * Cut the current selection to the clipboard, via buffer 0.
1831 DEFINE_I_CALLBACK(clipboard_cut
)
1833 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1835 exit_if_null (w_current
);
1836 if (!o_select_selected (w_current
)) return;
1838 i_update_middle_button (w_current
, i_callback_clipboard_cut
,
1839 _("Cut to clipboard"));
1841 o_buffer_cut (w_current
, 0);
1842 x_clipboard_set (w_current
, object_buffer
[0]);
1845 /*! \brief Start pasting clipboard contents.
1846 * \par Function Description
1847 * Cut the current selection to the clipboard, via buffer 0.
1849 DEFINE_I_CALLBACK(clipboard_paste
)
1851 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1852 TOPLEVEL
*toplevel
= w_current
->toplevel
;
1853 GList
*object_list
= NULL
;
1855 exit_if_null(w_current
);
1857 i_update_middle_button (w_current
, i_callback_buffer_paste1
, _("Paste from clipboard"));
1859 object_list
= x_clipboard_get (w_current
);
1861 if (object_list
!= NULL
) {
1862 s_delete_object_glist (toplevel
, object_buffer
[0]);
1863 object_buffer
[0] = object_list
;
1864 o_redraw_cleanstates (w_current
);
1865 w_current
->buffer_number
= 0;
1866 w_current
->inside_action
= 1;
1867 i_set_state (w_current
, STARTPASTE
);
1869 i_set_state_msg (w_current
, SELECT
, _("Empty buffer"));
1873 /*! \brief Start pasting clipboard contents (hotkey version)
1874 * \par Function Description
1875 * It's not entirely clear what the difference is between this and
1876 * i_callback_clipboard_paste()...
1878 DEFINE_I_CALLBACK(clipboard_paste_hotkey
)
1880 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1881 TOPLEVEL
*toplevel
= w_current
->toplevel
;
1882 GList
*object_list
= NULL
;
1885 exit_if_null (w_current
);
1887 if (!x_event_get_pointer_position (w_current
, TRUE
, &wx
, &wy
))
1890 object_list
= x_clipboard_get (w_current
);
1892 if (object_list
== NULL
) return;
1893 s_delete_object_glist (toplevel
, object_buffer
[0]);
1894 object_buffer
[0] = object_list
;
1896 o_buffer_paste_start (w_current
, wx
, wy
, 0);
1899 /*! \section buffer-menu Buffer Menu Callback Functions */
1900 /*! \todo Finish function documentation!!!
1902 * \par Function Description
1905 DEFINE_I_CALLBACK(buffer_copy1
)
1907 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1909 exit_if_null(w_current
);
1911 if (!o_select_selected (w_current
))
1914 i_update_middle_button(w_current
, i_callback_buffer_copy1
, _("Copy 1"));
1915 o_buffer_copy(w_current
, 0);
1916 i_update_menus(w_current
);
1919 /*! \todo Finish function documentation!!!
1921 * \par Function Description
1924 DEFINE_I_CALLBACK(buffer_copy2
)
1926 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1928 exit_if_null(w_current
);
1930 if (!o_select_selected (w_current
))
1933 i_update_middle_button(w_current
, i_callback_buffer_copy2
, _("Copy 2"));
1934 o_buffer_copy(w_current
, 1);
1935 i_update_menus(w_current
);
1938 /*! \todo Finish function documentation!!!
1940 * \par Function Description
1943 DEFINE_I_CALLBACK(buffer_copy3
)
1945 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1947 exit_if_null(w_current
);
1949 if (!o_select_selected (w_current
))
1952 i_update_middle_button(w_current
, i_callback_buffer_copy3
, _("Copy 3"));
1953 o_buffer_copy(w_current
, 2);
1954 i_update_menus(w_current
);
1957 /*! \todo Finish function documentation!!!
1959 * \par Function Description
1962 DEFINE_I_CALLBACK(buffer_copy4
)
1964 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1966 exit_if_null(w_current
);
1968 if (!o_select_selected (w_current
))
1971 i_update_middle_button(w_current
, i_callback_buffer_copy4
, _("Copy 4"));
1972 o_buffer_copy(w_current
, 3);
1973 i_update_menus(w_current
);
1976 /*! \todo Finish function documentation!!!
1978 * \par Function Description
1981 DEFINE_I_CALLBACK(buffer_copy5
)
1983 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
1985 exit_if_null(w_current
);
1987 if (!o_select_selected (w_current
))
1990 i_update_middle_button(w_current
, i_callback_buffer_copy5
, _("Copy 5"));
1991 o_buffer_copy(w_current
, 4);
1992 i_update_menus(w_current
);
1995 /*! \todo Finish function documentation!!!
1997 * \par Function Description
2000 DEFINE_I_CALLBACK(buffer_cut1
)
2002 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2004 exit_if_null(w_current
);
2006 if (!o_select_selected (w_current
))
2009 i_update_middle_button(w_current
, i_callback_buffer_cut1
, _("Cut 1"));
2010 o_buffer_cut(w_current
, 0);
2011 i_update_menus(w_current
);
2014 /*! \todo Finish function documentation!!!
2016 * \par Function Description
2019 DEFINE_I_CALLBACK(buffer_cut2
)
2021 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2023 exit_if_null(w_current
);
2025 if (!o_select_selected (w_current
))
2028 i_update_middle_button(w_current
, i_callback_buffer_cut2
, _("Cut 2"));
2029 o_buffer_cut(w_current
, 1);
2030 i_update_menus(w_current
);
2033 /*! \todo Finish function documentation!!!
2035 * \par Function Description
2038 DEFINE_I_CALLBACK(buffer_cut3
)
2040 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2042 exit_if_null(w_current
);
2044 if (!o_select_selected (w_current
))
2047 i_update_middle_button(w_current
, i_callback_buffer_cut3
, _("Cut 3"));
2048 o_buffer_cut(w_current
, 2);
2049 i_update_menus(w_current
);
2052 /*! \todo Finish function documentation!!!
2054 * \par Function Description
2057 DEFINE_I_CALLBACK(buffer_cut4
)
2059 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2061 exit_if_null(w_current
);
2063 if (!o_select_selected (w_current
))
2066 i_update_middle_button(w_current
, i_callback_buffer_cut4
, _("Cut 4"));
2067 o_buffer_cut(w_current
, 3);
2068 i_update_menus(w_current
);
2071 /*! \todo Finish function documentation!!!
2073 * \par Function Description
2076 DEFINE_I_CALLBACK(buffer_cut5
)
2078 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2080 exit_if_null(w_current
);
2082 if (!o_select_selected (w_current
))
2085 i_update_middle_button(w_current
, i_callback_buffer_cut5
, _("Cut 5"));
2086 o_buffer_cut(w_current
, 4);
2087 i_update_menus(w_current
);
2090 /*! \todo Finish function documentation!!!
2092 * \par Function Description
2095 DEFINE_I_CALLBACK(buffer_paste1
)
2097 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2099 exit_if_null(w_current
);
2101 i_update_middle_button(w_current
, i_callback_buffer_paste1
, _("Paste 1"));
2102 if (object_buffer
[0] != NULL
) {
2103 o_redraw_cleanstates(w_current
);
2104 w_current
->buffer_number
= 0;
2105 w_current
->inside_action
= 1;
2106 i_set_state(w_current
, STARTPASTE
);
2108 i_set_state_msg(w_current
, SELECT
, _("Empty buffer"));
2112 /*! \todo Finish function documentation!!!
2114 * \par Function Description
2117 DEFINE_I_CALLBACK(buffer_paste2
)
2119 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2121 exit_if_null(w_current
);
2123 i_update_middle_button(w_current
, i_callback_buffer_paste2
, _("Paste 2"));
2124 if (object_buffer
[1] != NULL
) {
2125 o_redraw_cleanstates(w_current
);
2126 w_current
->buffer_number
= 1;
2127 w_current
->inside_action
= 1;
2128 i_set_state(w_current
, STARTPASTE
);
2130 i_set_state_msg(w_current
, SELECT
, _("Empty buffer"));
2134 /*! \todo Finish function documentation!!!
2136 * \par Function Description
2139 DEFINE_I_CALLBACK(buffer_paste3
)
2141 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2143 exit_if_null(w_current
);
2145 i_update_middle_button(w_current
, i_callback_buffer_paste3
, _("Paste 3"));
2146 if (object_buffer
[2] != NULL
) {
2147 o_redraw_cleanstates(w_current
);
2148 w_current
->buffer_number
= 2;
2149 w_current
->inside_action
= 1;
2150 i_set_state(w_current
, STARTPASTE
);
2152 i_set_state_msg(w_current
, SELECT
, _("Empty buffer"));
2156 /*! \todo Finish function documentation!!!
2158 * \par Function Description
2161 DEFINE_I_CALLBACK(buffer_paste4
)
2163 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2165 exit_if_null(w_current
);
2167 i_update_middle_button(w_current
, i_callback_buffer_paste4
, _("Paste 4"));
2168 if (object_buffer
[3] != NULL
) {
2169 o_redraw_cleanstates(w_current
);
2170 w_current
->buffer_number
= 3;
2171 w_current
->inside_action
= 1;
2172 i_set_state(w_current
, STARTPASTE
);
2174 i_set_state_msg(w_current
, SELECT
, _("Empty buffer"));
2178 /*! \todo Finish function documentation!!!
2180 * \par Function Description
2183 DEFINE_I_CALLBACK(buffer_paste5
)
2185 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2187 exit_if_null(w_current
);
2189 i_update_middle_button(w_current
, i_callback_buffer_paste5
, _("Paste 5"));
2190 if (object_buffer
[4] != NULL
) {
2191 o_redraw_cleanstates(w_current
);
2192 w_current
->buffer_number
= 4;
2193 w_current
->inside_action
= 1;
2194 i_set_state(w_current
, STARTPASTE
);
2196 i_set_state_msg(w_current
, SELECT
, _("Empty buffer"));
2200 /*! \todo Finish function documentation!!!
2202 * \par Function Description
2205 DEFINE_I_CALLBACK(buffer_paste1_hotkey
)
2207 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2210 exit_if_null(w_current
);
2212 if (object_buffer
[0] == NULL
) {
2216 if (!x_event_get_pointer_position(w_current
, TRUE
, &wx
, &wy
))
2219 o_buffer_paste_start(w_current
, wx
, wy
, 0);
2222 /*! \todo Finish function documentation!!!
2224 * \par Function Description
2227 DEFINE_I_CALLBACK(buffer_paste2_hotkey
)
2229 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2232 exit_if_null(w_current
);
2234 if (object_buffer
[1] == NULL
) {
2238 if (!x_event_get_pointer_position(w_current
, TRUE
, &wx
, &wy
))
2241 o_buffer_paste_start(w_current
, wx
, wy
, 1);
2244 /*! \todo Finish function documentation!!!
2246 * \par Function Description
2249 DEFINE_I_CALLBACK(buffer_paste3_hotkey
)
2251 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2254 exit_if_null(w_current
);
2256 if (object_buffer
[2] == NULL
) {
2260 if (!x_event_get_pointer_position(w_current
, TRUE
, &wx
, &wy
))
2263 o_buffer_paste_start(w_current
, wx
, wy
, 2);
2266 /*! \todo Finish function documentation!!!
2268 * \par Function Description
2271 DEFINE_I_CALLBACK(buffer_paste4_hotkey
)
2273 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2276 exit_if_null(w_current
);
2278 if (object_buffer
[3] == NULL
) {
2282 if (!x_event_get_pointer_position(w_current
, TRUE
, &wx
, &wy
))
2285 o_buffer_paste_start(w_current
, wx
, wy
, 3);
2288 /*! \todo Finish function documentation!!!
2290 * \par Function Description
2293 DEFINE_I_CALLBACK(buffer_paste5_hotkey
)
2295 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2298 exit_if_null(w_current
);
2300 if (object_buffer
[4] == NULL
) {
2304 if (!x_event_get_pointer_position(w_current
, TRUE
, &wx
, &wy
))
2307 o_buffer_paste_start(w_current
, wx
, wy
, 4);
2310 /*! \section add-menu Add Menu Callback Functions */
2311 /*! \todo Finish function documentation!!!
2313 * \par Function Description
2316 DEFINE_I_CALLBACK(add_component
)
2318 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2320 exit_if_null(w_current
);
2322 o_redraw_cleanstates (w_current
);
2323 x_compselect_open (w_current
);
2325 i_update_middle_button(w_current
,
2326 i_callback_add_component
, _("Component"));
2328 i_set_state(w_current
, SELECT
);
2329 i_update_toolbar(w_current
);
2332 /*! \todo Finish function documentation!!!
2334 * \par Function Description
2337 * don't use the widget parameter on this function, or do some checking...
2338 * since there is a call: widget = NULL, data = 0 (will be w_current hack)
2340 void i_callback_toolbar_add_component(GtkWidget
* widget
, gpointer data
)
2342 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2343 exit_if_null(w_current
);
2344 if (!w_current
->window
) return;
2346 i_callback_add_component(data
, 0, NULL
);
2349 /*! \todo Finish function documentation!!!
2351 * \par Function Description
2354 DEFINE_I_CALLBACK(add_attribute
)
2356 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2358 exit_if_null(w_current
);
2360 attrib_edit_dialog(w_current
, NULL
, FROM_MENU
);
2361 i_update_middle_button(w_current
, i_callback_add_attribute
,
2364 i_set_state(w_current
, SELECT
);
2365 i_update_toolbar(w_current
);
2368 /*! \todo Finish function documentation!!!
2370 * \par Function Description
2373 DEFINE_I_CALLBACK(add_attribute_hotkey
)
2375 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2377 exit_if_null(w_current
);
2379 attrib_edit_dialog(w_current
, NULL
, FROM_HOTKEY
);
2380 i_update_middle_button(w_current
, i_callback_add_attribute_hotkey
,
2383 i_set_state(w_current
, SELECT
);
2384 i_update_toolbar(w_current
);
2387 /*! \todo Finish function documentation!!!
2389 * \par Function Description
2392 DEFINE_I_CALLBACK(add_net
)
2394 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2396 exit_if_null(w_current
);
2398 o_redraw_cleanstates(w_current
);
2399 o_invalidate_rubber (w_current
);
2400 o_net_reset(w_current
);
2403 i_update_middle_button(w_current
, i_callback_add_net
, _("Net"));
2404 i_set_state(w_current
, STARTDRAWNET
);
2405 i_update_toolbar(w_current
);
2406 /* somewhere you need to nearest point locking... */
2407 w_current
->inside_action
= 0;
2410 /*! \todo Finish function documentation!!!
2412 * \par Function Description
2415 DEFINE_I_CALLBACK(add_net_hotkey
)
2417 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2420 exit_if_null(w_current
);
2422 if (!x_event_get_pointer_position(w_current
, TRUE
, &wx
, &wy
))
2425 o_redraw_cleanstates(w_current
);
2426 o_invalidate_rubber (w_current
);
2427 o_net_reset(w_current
);
2430 i_update_middle_button(w_current
, i_callback_add_net_hotkey
, _("Net"));
2431 i_set_state(w_current
, STARTDRAWNET
);
2432 i_update_toolbar(w_current
);
2434 o_net_start(w_current
, wx
, wy
);
2436 w_current
->event_state
=DRAWNET
;
2437 w_current
->inside_action
= 1;
2440 /*! \todo Finish function documentation!!!
2442 * \par Function Description
2445 * don't use the widget parameter on this function, or do some checking...
2446 * since there is a call: widget = NULL, data = 0 (will be w_current hack)
2448 void i_callback_toolbar_add_net(GtkWidget
* widget
, gpointer data
)
2450 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2451 exit_if_null(w_current
);
2452 if (!w_current
->window
) return;
2454 if (GTK_TOGGLE_BUTTON (widget
)->active
) {
2455 i_callback_add_net(data
, 0, NULL
);
2459 /*! \todo Finish function documentation!!!
2461 * \par Function Description
2464 DEFINE_I_CALLBACK(add_bus
)
2466 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2468 exit_if_null(w_current
);
2470 o_redraw_cleanstates(w_current
);
2471 o_invalidate_rubber (w_current
);
2474 i_update_middle_button(w_current
, i_callback_add_bus
, _("Bus"));
2475 i_set_state(w_current
, STARTDRAWBUS
);
2476 i_update_toolbar(w_current
);
2478 /* somewhere you need to nearest point locking... */
2479 w_current
->inside_action
= 0;
2482 /*! \todo Finish function documentation!!!
2484 * \par Function Description
2487 DEFINE_I_CALLBACK(add_bus_hotkey
)
2489 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2492 exit_if_null(w_current
);
2494 if (!x_event_get_pointer_position(w_current
, TRUE
, &wx
, &wy
))
2497 o_redraw_cleanstates(w_current
);
2498 o_invalidate_rubber (w_current
);
2501 i_update_middle_button(w_current
, i_callback_add_bus_hotkey
, _("Bus"));
2502 i_set_state(w_current
, STARTDRAWBUS
);
2503 i_update_toolbar(w_current
);
2505 o_bus_start(w_current
, wx
, wy
);
2507 w_current
->event_state
=DRAWBUS
;
2508 w_current
->inside_action
= 1;
2511 /*! \todo Finish function documentation!!!
2513 * \par Function Description
2516 * don't use the widget parameter on this function, or do some checking...
2517 * since there is a call: widget = NULL, data = 0 (will be w_current hack)
2519 void i_callback_toolbar_add_bus(GtkWidget
* widget
, gpointer data
)
2521 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2522 exit_if_null(w_current
);
2523 if (!w_current
->window
) return;
2525 if (GTK_TOGGLE_BUTTON (widget
)->active
) {
2526 i_callback_add_bus(data
, 0, NULL
);
2530 /*! \todo Finish function documentation!!!
2532 * \par Function Description
2535 DEFINE_I_CALLBACK(add_text
)
2537 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2539 exit_if_null(w_current
);
2541 o_redraw_cleanstates(w_current
);
2542 o_invalidate_rubber (w_current
);
2544 w_current
->inside_action
= 0;
2545 i_set_state(w_current
, SELECT
);
2546 i_update_toolbar(w_current
);
2548 text_input_dialog(w_current
);
2551 /*! \todo Finish function documentation!!!
2553 * \par Function Description
2556 * don't use the widget parameter on this function, or do some checking...
2557 * since there is a call: widget = NULL, data = 0 (will be w_current hack)
2559 void i_callback_toolbar_add_text(GtkWidget
* widget
, gpointer data
)
2561 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2562 exit_if_null(w_current
);
2563 if (!w_current
->window
) return;
2565 i_callback_add_text(data
, 0, NULL
);
2568 /*! \todo Finish function documentation!!!
2570 * \par Function Description
2573 DEFINE_I_CALLBACK(add_line
)
2575 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2577 exit_if_null(w_current
);
2579 o_redraw_cleanstates(w_current
);
2580 o_invalidate_rubber (w_current
);
2582 i_update_middle_button(w_current
, i_callback_add_line
, _("Line"));
2583 i_set_state(w_current
, DRAWLINE
);
2584 w_current
->inside_action
= 0;
2587 /*! \todo Finish function documentation!!!
2589 * \par Function Description
2592 DEFINE_I_CALLBACK(add_line_hotkey
)
2594 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2597 exit_if_null(w_current
);
2599 if (!x_event_get_pointer_position(w_current
, TRUE
, &wx
, &wy
))
2602 o_redraw_cleanstates(w_current
);
2603 o_invalidate_rubber (w_current
);
2605 i_update_middle_button(w_current
, i_callback_add_line_hotkey
, _("Line"));
2607 o_line_start(w_current
, wx
, wy
);
2609 w_current
->inside_action
= 1;
2610 i_set_state(w_current
, ENDLINE
);
2613 /*! \todo Finish function documentation!!!
2615 * \par Function Description
2618 DEFINE_I_CALLBACK(add_box
)
2620 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2622 exit_if_null(w_current
);
2624 o_redraw_cleanstates(w_current
);
2625 o_invalidate_rubber (w_current
);
2627 i_update_middle_button(w_current
, i_callback_add_box
, _("Box"));
2628 w_current
->inside_action
= 0;
2629 i_set_state(w_current
, DRAWBOX
);
2632 /*! \todo Finish function documentation!!!
2634 * \par Function Description
2637 DEFINE_I_CALLBACK(add_box_hotkey
)
2639 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2642 exit_if_null(w_current
);
2644 if (!x_event_get_pointer_position(w_current
, TRUE
, &wx
, &wy
))
2647 o_redraw_cleanstates(w_current
);
2648 o_invalidate_rubber (w_current
);
2650 i_update_middle_button(w_current
, i_callback_add_box_hotkey
, _("Box"));
2652 o_box_start(w_current
, wx
, wy
);
2654 w_current
->inside_action
= 1;
2655 i_set_state(w_current
, ENDBOX
);
2658 /*! \todo Finish function documentation!!!
2660 * \par Function Description
2663 DEFINE_I_CALLBACK(add_picture
)
2665 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2667 exit_if_null(w_current
);
2669 o_redraw_cleanstates(w_current
);
2670 o_invalidate_rubber (w_current
);
2672 w_current
->inside_action
= 0;
2673 i_set_state(w_current
, SELECT
);
2674 i_update_toolbar(w_current
);
2676 picture_selection_dialog(w_current
);
2679 /*! \todo Finish function documentation!!!
2681 * \par Function Description
2684 DEFINE_I_CALLBACK(add_picture_hotkey
)
2686 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2688 /* If this function necessary? Yes, if you want the hotkey to work. */
2689 i_callback_add_picture(w_current
, 0, NULL
);
2692 /*! \todo Finish function documentation!!!
2694 * \par Function Description
2697 DEFINE_I_CALLBACK(add_circle
)
2699 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2701 exit_if_null(w_current
);
2703 o_redraw_cleanstates(w_current
);
2704 o_invalidate_rubber (w_current
);
2706 i_update_middle_button(w_current
, i_callback_add_circle
, _("Circle"));
2707 w_current
->inside_action
= 0;
2708 i_set_state(w_current
, DRAWCIRCLE
);
2711 /*! \todo Finish function documentation!!!
2713 * \par Function Description
2716 DEFINE_I_CALLBACK(add_circle_hotkey
)
2718 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2721 exit_if_null(w_current
);
2723 if (!x_event_get_pointer_position(w_current
, TRUE
, &wx
, &wy
))
2726 o_redraw_cleanstates(w_current
);
2727 o_invalidate_rubber (w_current
);
2729 i_update_middle_button(w_current
, i_callback_add_circle_hotkey
,
2732 o_circle_start(w_current
, wx
, wy
);
2734 w_current
->inside_action
= 1;
2735 i_set_state(w_current
, ENDCIRCLE
);
2738 /*! \todo Finish function documentation!!!
2740 * \par Function Description
2743 DEFINE_I_CALLBACK(add_arc
)
2745 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2747 exit_if_null(w_current
);
2749 o_redraw_cleanstates(w_current
);
2750 o_invalidate_rubber (w_current
);
2752 i_update_middle_button(w_current
, i_callback_add_arc
, _("Arc"));
2753 w_current
->inside_action
= 0;
2754 i_set_state(w_current
, DRAWARC
);
2757 /*! \todo Finish function documentation!!!
2759 * \par Function Description
2762 DEFINE_I_CALLBACK(add_arc_hotkey
)
2764 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2767 exit_if_null(w_current
);
2769 if (!x_event_get_pointer_position(w_current
, TRUE
, &wx
, &wy
))
2772 o_redraw_cleanstates(w_current
);
2773 o_invalidate_rubber (w_current
);
2775 i_update_middle_button(w_current
, i_callback_add_arc_hotkey
, _("Arc"));
2777 o_arc_start(w_current
, wx
, wy
);
2779 w_current
->inside_action
= 1;
2780 i_set_state(w_current
, ENDARC
);
2783 /*! \todo Finish function documentation!!!
2785 * \par Function Description
2788 DEFINE_I_CALLBACK(add_pin
)
2790 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2792 exit_if_null(w_current
);
2794 o_redraw_cleanstates(w_current
);
2795 o_invalidate_rubber (w_current
);
2797 i_update_middle_button(w_current
, i_callback_add_pin
, _("Pin"));
2798 w_current
->inside_action
= 0;
2799 i_set_state(w_current
, DRAWPIN
);
2802 /*! \todo Finish function documentation!!!
2804 * \par Function Description
2807 DEFINE_I_CALLBACK(add_pin_hotkey
)
2809 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2812 exit_if_null(w_current
);
2814 if (!x_event_get_pointer_position(w_current
, TRUE
, &wx
, &wy
))
2817 o_redraw_cleanstates(w_current
);
2818 o_invalidate_rubber (w_current
);
2820 i_update_middle_button(w_current
, i_callback_add_pin_hotkey
, _("Pin"));
2822 o_pin_start(w_current
, wx
, wy
);
2824 w_current
->inside_action
= 1;
2825 i_set_state(w_current
, ENDPIN
);
2828 /*! \section hierarchy-menu Hierarchy Menu Callback Functions */
2829 /*! \todo Finish function documentation!!!
2831 * \par Function Description
2834 DEFINE_I_CALLBACK(hierarchy_down_schematic
)
2836 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2838 char *current_filename
=NULL
;
2840 OBJECT
*object
=NULL
;
2841 PAGE
*save_first_page
=NULL
;
2843 int loaded_flag
=FALSE
;
2844 int page_control
= 0;
2845 int saved_page_control
= 0;
2847 int looking_inside
=FALSE
;
2849 exit_if_null(w_current
);
2851 object
= o_select_return_first_object(w_current
);
2853 /* only allow going into symbols */
2854 if (object
== NULL
|| object
->type
!= OBJ_COMPLEX
)
2857 parent
= w_current
->toplevel
->page_current
;
2858 attrib
= o_attrib_search_attached_attribs_by_name (object
, "source", count
);
2860 /* if above is null, then look inside symbol */
2861 if (attrib
== NULL
) {
2863 o_attrib_search_inherited_attribs_by_name (object
, "source", count
);
2864 looking_inside
= TRUE
;
2866 printf("going to look inside now\n");
2872 /* look for source=filename,filename, ... */
2874 current_filename
= u_basic_breakup_string(attrib
, ',', pcount
);
2876 /* loop over all filenames */
2877 while(current_filename
!= NULL
) {
2879 s_log_message(_("Searching for source [%s]\n"), current_filename
);
2880 saved_page_control
= page_control
;
2882 s_hierarchy_down_schematic_single(w_current
->toplevel
,
2886 HIERARCHY_NORMAL_LOAD
);
2888 /* s_hierarchy_down_schematic_single() will not zoom the loaded page */
2889 if (page_control
!= -1) {
2890 a_zoom_extents(w_current
,
2891 s_page_objects (w_current
->toplevel
->page_current
),
2893 o_undo_savestate(w_current
, UNDO_ALL
);
2896 /* save the first page */
2897 if ( !loaded_flag
&& page_control
> 0 ) {
2898 save_first_page
= w_current
->toplevel
->page_current
;
2901 /* now do some error fixing */
2902 if (page_control
== -1) {
2903 s_log_message(_("Cannot find source [%s]\n"), current_filename
);
2905 /* restore this for the next page */
2906 page_control
= saved_page_control
;
2908 /* this only signifies that we tried */
2912 g_free(current_filename
);
2914 current_filename
= u_basic_breakup_string(attrib
, ',', pcount
);
2918 g_free(current_filename
);
2922 /* continue looking outside first */
2923 if (!looking_inside
) {
2925 o_attrib_search_attached_attribs_by_name (object
, "source", count
);
2928 /* okay we were looking outside and didn't find anything,
2929 * so now we need to look inside the symbol */
2930 if (!looking_inside
&& attrib
== NULL
&& !loaded_flag
) {
2931 looking_inside
= TRUE
;
2933 printf("switching to go to look inside\n");
2937 if (looking_inside
) {
2939 printf("looking inside\n");
2942 o_attrib_search_inherited_attribs_by_name (object
, "source", count
);
2948 if (save_first_page
) {
2949 w_current
->toplevel
->page_current
= save_first_page
;
2951 x_window_set_current_page( w_current
, w_current
->toplevel
->page_current
);
2955 /*! \todo Finish function documentation!!!
2957 * \par Function Description
2958 * \bug may cause problems with non-directory symbols
2960 DEFINE_I_CALLBACK(hierarchy_down_symbol
)
2962 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
2964 const CLibSymbol
*sym
;
2966 exit_if_null(w_current
);
2968 object
= o_select_return_first_object(w_current
);
2969 if (object
!= NULL
) {
2970 /* only allow going into symbols */
2971 if (object
->type
== OBJ_COMPLEX
) {
2972 s_log_message(_("Searching for symbol [%s]\n"),
2973 object
->complex_basename
);
2974 sym
= s_clib_get_symbol_by_name (object
->complex_basename
);
2977 if (s_clib_symbol_get_filename(sym
) == NULL
) {
2978 s_log_message(_("Symbol is not a real file."
2979 " Symbol cannot be loaded.\n"));
2982 s_hierarchy_down_symbol(w_current
->toplevel
, sym
,
2983 w_current
->toplevel
->page_current
);
2984 /* s_hierarchy_down_symbol() will not zoom the loaded page */
2985 a_zoom_extents(w_current
,
2986 s_page_objects (w_current
->toplevel
->page_current
),
2988 o_undo_savestate(w_current
, UNDO_ALL
);
2989 x_window_set_current_page(w_current
, w_current
->toplevel
->page_current
);
2994 /*! \todo Finish function documentation!!!
2996 * \par Function Description
2999 DEFINE_I_CALLBACK(hierarchy_up
)
3001 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3004 exit_if_null(w_current
);
3006 up_page
= s_hierarchy_find_up_page (w_current
->toplevel
->pages
,
3007 w_current
->toplevel
->page_current
);
3008 if (up_page
== NULL
) {
3009 s_log_message(_("Cannot find any schematics above the current one!\n"));
3011 x_window_set_current_page(w_current
, up_page
);
3015 /*! \todo Finish function documentation!!!
3017 * \par Function Description
3020 * Egil Kvaleberg <egil@kvaleberg.no> on October 7, 2002 -
3021 * Provide documentation for symbol (i.e. component)
3023 DEFINE_I_CALLBACK(hierarchy_documentation
)
3025 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3026 char *attrib_doc
= NULL
;
3027 char *attrib_device
= NULL
;
3028 char *attrib_value
= NULL
;
3029 OBJECT
*object
= NULL
;
3030 const gchar
*sourcename
= NULL
;
3031 const CLibSymbol
*sym
= NULL
;
3033 exit_if_null(w_current
);
3035 object
= o_select_return_first_object(w_current
);
3036 if (object
!= NULL
) {
3037 /* only allow going into symbols */
3038 if (object
->type
== OBJ_COMPLEX
) {
3040 /* look for "documentation" */
3041 attrib_doc
= o_attrib_search_object_attribs_by_name (object
, "documentation", 0);
3042 /* look for "device" */
3043 attrib_device
= o_attrib_search_object_attribs_by_name (object
, "device", 0);
3044 /* look for "value" */
3045 attrib_value
= o_attrib_search_object_attribs_by_name (object
, "value", 0);
3047 sym
= s_clib_get_symbol_by_name (object
->complex_basename
);
3049 sourcename
= s_clib_source_get_name (s_clib_symbol_get_source(sym
));
3052 initiate_gschemdoc(attrib_doc
,
3055 object
->complex_basename
,
3059 g_free(attrib_device
);
3060 g_free(attrib_value
);
3063 generic_msg_dialog(_("This command retrieves the component documentation from the web, but there is no component selected"));
3068 /*! \section attributes-menu Attributes Menu Callback Functions */
3069 /*! \todo Finish function documentation!!!
3071 * \par Function Description
3074 DEFINE_I_CALLBACK(attributes_attach
)
3076 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3077 OBJECT
*first_object
;
3080 exit_if_null(w_current
);
3082 /* This is a new addition 3/15 to prevent this from executing
3083 * inside an action */
3084 if (w_current
->inside_action
) {
3088 /* do we want to update the shortcut outside of the ifs? */
3089 /* probably, if this fails the user may want to try again */
3090 i_update_middle_button(w_current
, i_callback_attributes_attach
,
3093 /* skip over head */
3094 s_current
= geda_list_get_glist( w_current
->toplevel
->page_current
->selection_list
);
3099 first_object
= (OBJECT
*) s_current
->data
;
3100 if (!first_object
) {
3104 /* skip over first object */
3105 s_current
= g_list_next(s_current
);
3106 while (s_current
!= NULL
) {
3107 OBJECT
*object
= s_current
->data
;
3108 if (object
!= NULL
) {
3109 o_attrib_attach (w_current
->toplevel
, object
, first_object
, TRUE
);
3110 w_current
->toplevel
->page_current
->CHANGED
=1;
3112 s_current
= g_list_next(s_current
);
3114 o_undo_savestate(w_current
, UNDO_ALL
);
3117 /*! \todo Finish function documentation!!!
3119 * \par Function Description
3122 DEFINE_I_CALLBACK(attributes_detach
)
3124 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3128 exit_if_null(w_current
);
3130 /* This is a new addition 3/15 to prevent this from executing
3131 * inside an action */
3132 if (w_current
->inside_action
) {
3136 /* same note as above on i_update_middle_button */
3137 i_update_middle_button(w_current
, i_callback_attributes_detach
,
3140 s_current
= geda_list_get_glist( w_current
->toplevel
->page_current
->selection_list
);
3141 while (s_current
!= NULL
) {
3142 o_current
= (OBJECT
*) s_current
->data
;
3144 if (o_current
->attribs
) {
3145 o_attrib_detach_all (w_current
->toplevel
, o_current
);
3146 w_current
->toplevel
->page_current
->CHANGED
=1;
3149 s_current
= g_list_next(s_current
);
3151 o_undo_savestate(w_current
, UNDO_ALL
);
3154 /*! \todo Finish function documentation!!!
3156 * \par Function Description
3159 DEFINE_I_CALLBACK(attributes_show_name
)
3161 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3162 TOPLEVEL
*toplevel
= w_current
->toplevel
;
3164 exit_if_null(w_current
);
3166 /* This is a new addition 3/15 to prevent this from executing
3167 * inside an action */
3168 if (w_current
->inside_action
) {
3172 i_update_middle_button(w_current
, i_callback_attributes_show_name
,
3175 if (o_select_selected (w_current
)) {
3176 SELECTION
*selection
= toplevel
->page_current
->selection_list
;
3179 for (s_current
= geda_list_get_glist (selection
);
3181 s_current
= g_list_next (s_current
)) {
3182 OBJECT
*object
= (OBJECT
*)s_current
->data
;
3183 o_attrib_toggle_show_name_value (w_current
, object
, SHOW_NAME
);
3186 o_undo_savestate (w_current
, UNDO_ALL
);
3190 /*! \todo Finish function documentation!!!
3192 * \par Function Description
3195 DEFINE_I_CALLBACK(attributes_show_value
)
3197 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3198 TOPLEVEL
*toplevel
= w_current
->toplevel
;
3200 exit_if_null(w_current
);
3202 /* This is a new addition 3/15 to prevent this from executing
3203 * inside an action */
3204 if (w_current
->inside_action
) {
3208 i_update_middle_button(w_current
, i_callback_attributes_show_value
,
3211 if (o_select_selected (w_current
)) {
3212 SELECTION
*selection
= toplevel
->page_current
->selection_list
;
3215 for (s_current
= geda_list_get_glist (selection
);
3217 s_current
= g_list_next (s_current
)) {
3218 OBJECT
*object
= (OBJECT
*)s_current
->data
;
3219 o_attrib_toggle_show_name_value (w_current
, object
, SHOW_VALUE
);
3222 o_undo_savestate (w_current
, UNDO_ALL
);
3226 /*! \todo Finish function documentation!!!
3228 * \par Function Description
3231 DEFINE_I_CALLBACK(attributes_show_both
)
3233 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3234 TOPLEVEL
*toplevel
= w_current
->toplevel
;
3236 exit_if_null(w_current
);
3238 /* This is a new addition 3/15 to prevent this from executing
3239 * inside an action */
3240 if (w_current
->inside_action
) {
3244 i_update_middle_button(w_current
, i_callback_attributes_show_both
,
3247 if (o_select_selected (w_current
)) {
3248 SELECTION
*selection
= toplevel
->page_current
->selection_list
;
3251 for (s_current
= geda_list_get_glist (selection
);
3253 s_current
= g_list_next (s_current
)) {
3254 OBJECT
*object
= (OBJECT
*)s_current
->data
;
3255 o_attrib_toggle_show_name_value (w_current
, object
, SHOW_NAME_VALUE
);
3258 o_undo_savestate (w_current
, UNDO_ALL
);
3262 /*! \todo Finish function documentation!!!
3264 * \par Function Description
3267 DEFINE_I_CALLBACK(attributes_visibility_toggle
)
3269 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3270 TOPLEVEL
*toplevel
= w_current
->toplevel
;
3272 exit_if_null(w_current
);
3274 /* This is a new addition 3/15 to prevent this from executing
3275 * inside an action */
3276 if (w_current
->inside_action
) {
3280 i_update_middle_button(w_current
,
3281 i_callback_attributes_visibility_toggle
,
3284 if (o_select_selected (w_current
)) {
3285 SELECTION
*selection
= toplevel
->page_current
->selection_list
;
3288 for (s_current
= geda_list_get_glist (selection
);
3290 s_current
= g_list_next (s_current
)) {
3291 OBJECT
*object
= (OBJECT
*)s_current
->data
;
3292 o_attrib_toggle_visibility (w_current
, object
);
3295 o_undo_savestate (w_current
, UNDO_ALL
);
3299 /*! \section script-menu Script Menu Callback Functions */
3300 /*! \todo Finish function documentation!!!
3302 * \par Function Description
3305 * not currently implemented
3307 DEFINE_I_CALLBACK(script_console
)
3309 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3311 exit_if_null(w_current
);
3312 printf(_("Sorry but this is a non-functioning menu option\n"));
3315 /*! \section layers-menu Layers Menu Callback Functions */
3317 /*! \section options-menu Options Menu Callback Functions */
3318 /*! \todo Finish function documentation!!!
3320 * \par Function Description
3323 * repeat last command doesn't make sense on options either??? (does it?)
3325 DEFINE_I_CALLBACK(options_text_size
)
3327 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3329 exit_if_null(w_current
);
3330 text_size_dialog(w_current
);
3333 /*! \todo Finish function documentation!!!
3335 * \par Function Description
3338 DEFINE_I_CALLBACK(options_snap_size
)
3340 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3342 exit_if_null(w_current
);
3343 snap_size_dialog(w_current
);
3346 /*! \brief Multiply by two the snap grid size.
3347 * \par Function Description
3348 * Callback function for the scale-up snap grid size hotkey.
3349 * Multiply by two the snap grid size.
3351 DEFINE_I_CALLBACK(options_scale_up_snap_size
)
3353 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3355 exit_if_null(w_current
);
3357 w_current
->snap_size
*= 2;
3358 w_current
->toplevel
->page_current
->CHANGED
=1; /* maybe remove those two lines */
3359 o_undo_savestate(w_current
, UNDO_ALL
);
3361 i_update_grid_info (w_current
);
3362 o_invalidate_all (w_current
);
3365 /*! \brief Divide by two the snap grid size.
3366 * \par Function Description
3367 * Callback function for the scale-down snap grid size hotkey.
3368 * Divide by two the snap grid size (if it's and even number).
3370 DEFINE_I_CALLBACK(options_scale_down_snap_size
)
3372 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3374 exit_if_null(w_current
);
3376 if (w_current
->snap_size
% 2 == 0)
3377 w_current
->snap_size
/= 2;
3378 w_current
->toplevel
->page_current
->CHANGED
=1; /* maybe remove those two lines */
3379 o_undo_savestate(w_current
, UNDO_ALL
);
3381 i_update_grid_info (w_current
);
3382 o_invalidate_all (w_current
);
3386 /*! \todo Finish function documentation!!!
3388 * \par Function Description
3391 * repeat last command doesn't make sense on options either??? (does
3394 DEFINE_I_CALLBACK(options_afeedback
)
3396 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3398 exit_if_null(w_current
);
3400 if (w_current
->actionfeedback_mode
== BOUNDINGBOX
) {
3401 w_current
->actionfeedback_mode
= OUTLINE
;
3402 s_log_message(_("Action feedback mode set to OUTLINE\n"));
3404 w_current
->actionfeedback_mode
= BOUNDINGBOX
;
3405 s_log_message(_("Action feedback mode set to BOUNDINGBOX\n"));
3407 if (w_current
->inside_action
&&
3408 w_current
->toplevel
->page_current
->place_list
!= NULL
)
3409 o_place_invalidate_rubber (w_current
, FALSE
);
3412 /*! \todo Finish function documentation!!!
3414 * \par Function Description
3417 DEFINE_I_CALLBACK(options_grid
)
3419 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3421 exit_if_null(w_current
);
3423 switch (w_current
->grid
) {
3424 case GRID_NONE
: w_current
->grid
= GRID_DOTS
; break;
3425 case GRID_DOTS
: w_current
->grid
= GRID_MESH
; break;
3426 case GRID_MESH
: w_current
->grid
= GRID_NONE
; break;
3429 switch (w_current
->grid
) {
3430 case GRID_NONE
: s_log_message (_("Grid OFF\n")); break;
3431 case GRID_DOTS
: s_log_message (_("Dot grid selected\n")); break;
3432 case GRID_MESH
: s_log_message (_("Mesh grid selected\n")); break;
3435 i_update_grid_info (w_current
);
3436 o_invalidate_all (w_current
);
3439 /*! \todo Finish function documentation!!!
3441 * \par Function Description
3444 DEFINE_I_CALLBACK(options_snap
)
3446 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3448 /* toggle to the next snap state */
3449 w_current
->snap
= (w_current
->snap
+1) % SNAP_STATE_COUNT
;
3451 switch (w_current
->snap
) {
3453 s_log_message(_("Snap OFF (CAUTION!)\n"));
3456 s_log_message(_("Snap ON\n"));
3459 s_log_message(_("Snap back to the grid (CAUTION!)\n"));
3462 g_critical("options_snap: toplevel->snap out of range: %d\n",
3466 i_show_state(w_current
, NULL
); /* update status on screen */
3467 i_update_grid_info (w_current
);
3470 /*! \todo Finish function documentation!!!
3472 * \par Function Description
3475 * Rubber band is cool !
3476 * Added on/off option from the pull down menu
3477 * Chris Ellec - January 2001
3479 DEFINE_I_CALLBACK(options_rubberband
)
3481 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3483 if (w_current
->netconn_rubberband
) {
3484 w_current
->netconn_rubberband
= 0;
3485 s_log_message(_("Rubber band OFF \n"));
3487 w_current
->netconn_rubberband
= 1;
3488 s_log_message(_("Rubber band ON\n"));
3493 /*! \brief callback function for setting the magnetic net option
3494 * \par Function Description
3495 * This function just toggles a variable to switch the magnetic net
3498 DEFINE_I_CALLBACK(options_magneticnet
)
3500 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3502 if ((w_current
->magneticnet_mode
= !w_current
->magneticnet_mode
)) {
3503 s_log_message(_("magnetic net mode: ON\n"));
3506 s_log_message(_("magnetic net mode: OFF\n"));
3508 i_show_state(w_current
, NULL
);
3512 /*! \todo Finish function documentation!!!
3514 * \par Function Description
3517 DEFINE_I_CALLBACK(options_show_log_window
)
3519 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3521 exit_if_null(w_current
);
3525 /*! \todo Finish function documentation!!!
3527 * \par Function Description
3530 * this is Ales' catch all misc callback
3532 DEFINE_I_CALLBACK(misc
)
3536 /*! \todo Finish function documentation!!!
3538 * \par Function Description
3541 * this is Ales' second catch all misc callback
3543 DEFINE_I_CALLBACK(misc2
)
3547 /*! \todo Finish function documentation!!!
3549 * \par Function Description
3552 * this is Ales' third catch all misc callback
3554 DEFINE_I_CALLBACK(misc3
)
3558 /*! \todo Finish function documentation!!!
3560 * \par Function Description
3563 * HACK: be sure that you don't use the widget parameter in this one,
3564 * since it is being called with a null, I suppose we should call it
3565 * with the right param.
3567 DEFINE_I_CALLBACK(cancel
)
3569 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3570 TOPLEVEL
*toplevel
= w_current
->toplevel
;
3571 GValue value
= { 0, };
3573 exit_if_null(w_current
);
3575 if (w_current
->event_state
== ENDCOMP
&&
3576 w_current
->cswindow
) {
3577 /* user hit escape key when placing components */
3579 /* Undraw any outline of the place list */
3580 o_place_invalidate_rubber (w_current
, FALSE
);
3581 w_current
->rubber_visible
= 0;
3583 /* De-select the lists in the component selector */
3584 x_compselect_deselect (w_current
);
3586 /* Present the component selector again */
3587 g_value_init (&value
, G_TYPE_BOOLEAN
);
3588 g_value_set_boolean (&value
, FALSE
);
3589 g_object_set_property (G_OBJECT(w_current
->cswindow
), "hidden", &value
);
3592 if (w_current
->inside_action
) {
3593 /* If we're cancelling from a move action, re-wind the
3594 * page contents back to their state before we started */
3595 if (w_current
->event_state
== MOVE
||
3596 w_current
->event_state
== ENDMOVE
)
3597 o_move_cancel (w_current
);
3599 /* If we're cancelling from a grip action, call the specific cancel
3600 * routine to reset the visibility of the object being modified */
3601 if (w_current
->event_state
== GRIPS
)
3602 o_grips_cancel (w_current
);
3605 /* Free the place list and its contents. If we were in a move
3606 * action, the list (refering to objects on the page) would
3607 * already have been cleared in o_move_cancel(), so this is OK. */
3608 s_delete_object_glist(toplevel
, toplevel
->page_current
->place_list
);
3609 toplevel
->page_current
->place_list
= NULL
;
3611 /* leave this on for now... but it might have to change */
3612 /* this is problematic since we don't know what the right mode */
3613 /* (when you cancel inside an action) should be */
3614 i_set_state(w_current
, SELECT
);
3615 i_update_toolbar(w_current
);
3617 /* clear the key guile command-sequence */
3618 scm_c_eval_string ("(set! current-command-sequence '())");
3620 if (w_current
->inside_action
) {
3621 o_invalidate_all (w_current
);
3624 w_current
->inside_action
=0;
3627 /*! \section help-menu Help Menu Callback Functions */
3628 /*! \todo Finish function documentation!!!
3630 * \par Function Description
3633 DEFINE_I_CALLBACK(help_about
)
3635 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3637 exit_if_null(w_current
);
3638 about_dialog(w_current
);
3641 /*! \todo Finish function documentation!!!
3643 * \par Function Description
3646 DEFINE_I_CALLBACK(help_hotkeys
)
3648 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3650 exit_if_null(w_current
);
3651 x_dialog_hotkeys(w_current
);
3654 /*! \todo Finish function documentation!!!
3656 * \par Function Description
3659 DEFINE_I_CALLBACK(options_show_coord_window
)
3661 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3663 exit_if_null(w_current
);
3664 coord_dialog (w_current
, 0, 0);
3667 /* these is a special wrapper function which cannot use the above */
3668 /* DEFINE_I_CALLBACK macro */
3670 /*! \todo Finish function documentation!!!
3672 * \par Function Description
3675 * When invoked (via signal delete_event), closes the current window
3676 * if this is the last window, quit gschem
3677 * used when you click the close button on the window which sends a DELETE
3680 gboolean
i_callback_close_wm ( GtkWidget
*widget
, GdkEvent
*event
,
3684 GSCHEM_TOPLEVEL
*w_current
= (GSCHEM_TOPLEVEL
*) data
;
3685 exit_if_null(w_current
);
3687 x_window_close(w_current
);
3689 /* stop further propagation of the delete_event signal for window: */
3690 /* - if user has cancelled the close the window should obvioulsy */
3691 /* not be destroyed */
3692 /* - otherwise window has already been destroyed, nothing more to */