gschem

i_callbacks.c

Go to the documentation of this file.
00001 /* gEDA - GPL Electronic Design Automation
00002  * gschem - gEDA Schematic Capture
00003  * Copyright (C) 1998-2010 Ales Hvezda
00004  * Copyright (C) 1998-2011 gEDA Contributors (see ChangeLog for details)
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00019  */
00020 #include <config.h>
00021 
00022 #include <stdio.h>
00023 #ifdef HAVE_STRING_H
00024 #include <string.h>
00025 #endif
00026 #ifdef HAVE_UNISTD_H
00027 #include <unistd.h>
00028 #endif
00029 
00030 #include "gschem.h"
00031 
00032 #ifdef HAVE_LIBDMALLOC
00033 #include <dmalloc.h>
00034 #endif
00035 
00037 #define DELIMITERS ", "
00038 
00044 /* every i_callback functions have the same footprint */
00045 #define DEFINE_I_CALLBACK(name)             \
00046     void i_callback_ ## name(gpointer data,     \
00047                      guint callback_action, \
00048                      GtkWidget *widget)
00049 
00066 DEFINE_I_CALLBACK(file_new)
00067 {
00068   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*)data;
00069   PAGE *page;
00070 
00071   g_return_if_fail (w_current != NULL);
00072 
00073   /* create a new page */
00074   page = x_window_open_page (w_current, NULL);
00075   x_window_set_current_page (w_current, page);
00076   s_log_message (_("New page created [%s]\n"), page->page_filename);
00077 }
00078 
00087 void i_callback_toolbar_file_new(GtkWidget* widget, gpointer data)
00088 {
00089   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
00090   g_return_if_fail (w_current != NULL);
00091   if (!w_current->window) return;
00092     
00093   i_callback_file_new(data, 0, NULL);
00094 }
00095 
00101 DEFINE_I_CALLBACK(file_new_window)
00102 {
00103   GSCHEM_TOPLEVEL *w_current;
00104   PAGE *page;
00105 
00106   w_current = gschem_toplevel_new ();
00107   gschem_toplevel_alloc_libgeda_toplevel (w_current);
00108 
00109   w_current->toplevel->load_newer_backup_func = x_fileselect_load_backup;
00110   w_current->toplevel->load_newer_backup_data = w_current;
00111 
00112   o_text_set_rendered_bounds_func (w_current->toplevel,
00113                                    o_text_get_rendered_bounds, w_current);
00114 
00115   /* Damage notifications should invalidate the object on screen */
00116   o_add_change_notify (w_current->toplevel,
00117                        (ChangeNotifyFunc) o_invalidate,
00118                        (ChangeNotifyFunc) o_invalidate, w_current);
00119 
00120   x_window_setup (w_current);
00121 
00122   page = x_window_open_page (w_current, NULL);
00123   x_window_set_current_page (w_current, page);
00124   s_log_message (_("New Window created [%s]\n"), page->page_filename);
00125 }
00126 
00137 DEFINE_I_CALLBACK(file_open)
00138 {
00139   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
00140 
00141   g_return_if_fail (w_current != NULL);
00142 
00143   x_fileselect_open (w_current);
00144 }
00145 
00156 void i_callback_toolbar_file_open(GtkWidget* widget, gpointer data)
00157 {
00158   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
00159   g_return_if_fail (w_current != NULL);
00160   if (!w_current->window) return;
00161 
00162   i_callback_file_open(data, 0, NULL);
00163 }
00164 
00170 DEFINE_I_CALLBACK(file_script)
00171 {
00172   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
00173 
00174   g_return_if_fail (w_current != NULL);
00175   setup_script_selector(w_current);
00176 }
00177 
00187 DEFINE_I_CALLBACK(file_save)
00188 {
00189   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
00190 
00191   g_return_if_fail (w_current != NULL);
00192 
00198   if (strstr(w_current->toplevel->page_current->page_filename,
00199              w_current->toplevel->untitled_name)) {
00200     x_fileselect_save (w_current);
00201   } else {
00202     x_window_save_page (w_current,
00203                         w_current->toplevel->page_current,
00204                         w_current->toplevel->page_current->page_filename);
00205   }
00206 }
00207 
00218 void i_callback_toolbar_file_save(GtkWidget* widget, gpointer data)
00219 {
00220   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
00221   g_return_if_fail (w_current != NULL);
00222   if (!w_current->window) return;
00223 
00224   i_callback_file_save(data, 0, NULL);
00225 }
00226 
00235 DEFINE_I_CALLBACK(file_save_all)
00236 {
00237   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
00238 
00239   g_return_if_fail (w_current != NULL);
00240 
00241   if (s_page_save_all(w_current->toplevel)) {
00242      i_set_state_msg(w_current, SELECT, _("Failed to Save All"));
00243   } else {
00244      i_set_state_msg(w_current, SELECT, _("Saved All"));
00245   }
00246 
00247   i_update_toolbar(w_current);
00248   x_pagesel_update (w_current);
00249   i_update_menus(w_current);
00250 }
00251 
00257 DEFINE_I_CALLBACK(file_save_as)
00258 {
00259   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
00260 
00261   g_return_if_fail (w_current != NULL);
00262   x_fileselect_save (w_current);
00263 }
00264 
00270 DEFINE_I_CALLBACK(file_print)
00271 {
00272   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
00273   char *base=NULL, *filename;
00274   char *ps_filename=NULL;
00275   
00276   g_return_if_fail (w_current != NULL);
00277   g_return_if_fail (w_current->toplevel->page_current->page_filename != NULL);
00278 
00279   /* shortcut */
00280   filename = w_current->toplevel->page_current->page_filename;
00281 
00282   /* get the base file name */
00283   if (g_str_has_suffix(filename, ".sch")) {
00284     /* the filename ends with ".sch", remove it */
00285     base = g_strndup(filename, strlen(filename) - strlen(".sch"));
00286   } else {
00287     /* the filename does not end with .sch */
00288     base = g_strdup (filename);
00289   }
00290 
00291   /* add ".ps" tp the base filename */
00292   ps_filename = g_strconcat (base, ".ps", NULL);
00293   g_free(base);
00294 
00295   if (output_filename) {
00296     x_print_setup(w_current, output_filename);
00297   } else {
00298     x_print_setup(w_current, ps_filename);
00299   }
00300 
00301   g_free(ps_filename);
00302 }
00303 
00309 DEFINE_I_CALLBACK(file_write_png)
00310 {
00311   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
00312 
00313   g_return_if_fail (w_current != NULL);
00314 
00315   x_image_setup(w_current);
00316 }
00317 
00328 DEFINE_I_CALLBACK(file_close)
00329 {
00330   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
00331 
00332   g_return_if_fail (w_current != NULL);
00333 
00334   s_log_message(_("Closing Window\n"));
00335   x_window_close(w_current);
00336 }
00337 
00348 int i_callback_close(gpointer data, guint callback_action, GtkWidget *widget)
00349 {
00350   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
00351 
00352   g_return_val_if_fail ((w_current != NULL), FALSE);
00353   i_callback_file_close(w_current, 0, widget);
00354   return(FALSE);
00355 }
00356 
00362 DEFINE_I_CALLBACK(file_quit)
00363 {
00364   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
00365 
00366   g_return_if_fail (w_current != NULL);
00367   x_window_close_all(w_current);
00368 }
00369 
00376 DEFINE_I_CALLBACK(edit_undo)
00377 {
00378   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
00379 
00380   /* If we're cancelling from a move action, re-wind the
00381    * page contents back to their state before we started.
00382    *
00383    * It "might" be nice to sub-undo rotates / zoom changes
00384    * made whilst moving components, but when the undo code
00385    * hits s_page_delete(), the place list objects are free'd.
00386    * Since they are also contained in the schematic page, a
00387    * crash occurs when the page objects are free'd.
00388    * */
00389   if (w_current->inside_action &&
00390       (w_current->event_state == MOVE ||
00391        w_current->event_state == ENDMOVE)) {
00392     i_callback_cancel (w_current, 0, NULL);
00393   } else {
00394     o_undo_callback(w_current, UNDO_ACTION);
00395   }
00396 }
00397 
00406 void i_callback_toolbar_edit_undo(GtkWidget* widget, gpointer data)
00407 {
00408   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
00409   g_return_if_fail (w_current != NULL);
00410   if (!w_current->window) return;
00411 
00412   i_callback_edit_undo(data, 0, NULL);
00413 }
00414 
00420 DEFINE_I_CALLBACK(edit_redo)
00421 {
00422   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
00423 
00424   o_undo_callback(w_current, REDO_ACTION);
00425 }
00426 
00435 void i_callback_toolbar_edit_redo(GtkWidget* widget, gpointer data)
00436 {
00437   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
00438   g_return_if_fail (w_current != NULL);
00439   if (!w_current->window) return;
00440 
00441   i_callback_edit_redo(data, 0, NULL);
00442 }
00443 
00451 DEFINE_I_CALLBACK(edit_select)
00452 {
00453   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
00454   o_redraw_cleanstates(w_current);  
00455 
00456   /* this is probably the only place this should be */
00457   i_set_state(w_current, SELECT);
00458   i_update_toolbar(w_current);
00459   w_current->inside_action = 0;
00460 }
00461 
00470 void i_callback_toolbar_edit_select(GtkWidget* widget, gpointer data)
00471 {
00472   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
00473   g_return_if_fail (w_current != NULL);
00474   if (!w_current->window) return;
00475 
00476   if (GTK_TOGGLE_BUTTON (widget)->active) {
00477     if (!o_invalidate_rubber (w_current)) {
00478       i_callback_cancel(w_current, 0, NULL);
00479     }
00480     i_callback_edit_select(data, 0, NULL);
00481   }
00482 }
00483 
00488 DEFINE_I_CALLBACK (edit_select_all)
00489 {
00490   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL *) data;
00491   o_redraw_cleanstates (w_current);
00492 
00493   o_select_visible_unlocked (w_current);
00494 
00495   i_set_state (w_current, SELECT);
00496   w_current->inside_action = 0;
00497   i_update_toolbar (w_current);
00498   i_update_menus (w_current);
00499 }
00500 
00505 DEFINE_I_CALLBACK (edit_deselect)
00506 {
00507   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL *) data;
00508   o_redraw_cleanstates (w_current);
00509 
00510   o_select_unselect_all (w_current);
00511 
00512   i_set_state (w_current, SELECT);
00513   w_current->inside_action = 0;
00514   i_update_toolbar (w_current);
00515   i_update_menus (w_current);
00516 }
00517 
00523 DEFINE_I_CALLBACK(edit_copy)
00524 {
00525   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
00526 
00527   g_return_if_fail (w_current != NULL);
00528 
00529   i_update_middle_button(w_current, i_callback_edit_copy, _("Copy"));
00530   if (o_select_return_first_object(w_current)) {
00531     o_redraw_cleanstates(w_current);
00532     i_set_state(w_current, STARTCOPY);
00533   } else {
00534     i_set_state_msg(w_current, SELECT, _("Select objs first"));
00535   }
00536 }
00537 
00543 DEFINE_I_CALLBACK(edit_copy_hotkey)
00544 {
00545   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
00546   gint wx, wy; 
00547 
00548   g_return_if_fail (w_current != NULL);
00549 
00550   if (!x_event_get_pointer_position(w_current, TRUE, &wx, &wy))
00551     return;
00552 
00553   i_update_middle_button(w_current, i_callback_edit_copy_hotkey, _("Copy"));
00554   if (o_select_return_first_object(w_current)) {
00555     o_redraw_cleanstates(w_current);
00556     w_current->event_state = COPY;
00557     o_copy_start(w_current, wx, wy);
00558     w_current->event_state = ENDCOPY;
00559     w_current->inside_action = 1;
00560   }
00561 }
00562 
00568 DEFINE_I_CALLBACK(edit_mcopy)
00569 {
00570   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
00571 
00572   g_return_if_fail (w_current != NULL);
00573 
00574   i_update_middle_button(w_current, i_callback_edit_copy, _("Multiple Copy"));
00575   if (o_select_return_first_object(w_current)) {
00576     o_redraw_cleanstates(w_current);
00577     i_set_state(w_current, STARTMCOPY);
00578   } else {
00579     i_set_state_msg(w_current, SELECT, _("Select objs first"));
00580   }
00581 }
00582 
00588 DEFINE_I_CALLBACK(edit_mcopy_hotkey)
00589 {
00590   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
00591   gint wx, wy; 
00592 
00593   g_return_if_fail (w_current != NULL);
00594 
00595   if (!x_event_get_pointer_position(w_current, TRUE, &wx, &wy))
00596     return;
00597 
00598   i_update_middle_button(w_current, i_callback_edit_mcopy_hotkey, _("Multiple Copy"));
00599   if (o_select_return_first_object(w_current)) {
00600     o_redraw_cleanstates(w_current);    
00601     w_current->event_state = MCOPY; 
00602     o_copy_start(w_current, wx, wy);
00603     w_current->event_state = ENDMCOPY;
00604     w_current->inside_action = 1;
00605   }
00606 }
00607 
00613 DEFINE_I_CALLBACK(edit_move)
00614 {
00615   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
00616 
00617   g_return_if_fail (w_current != NULL);
00618 
00619   i_update_middle_button(w_current, i_callback_edit_move, _("Move"));
00620   if (o_select_return_first_object(w_current)) {
00621     o_redraw_cleanstates(w_current);
00622     i_set_state(w_current, STARTMOVE);
00623   } else {
00624     i_set_state_msg(w_current, SELECT, _("Select objs first"));
00625   }
00626 }
00627 
00633 DEFINE_I_CALLBACK(edit_move_hotkey)
00634 {
00635   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
00636   gint wx, wy; 
00637 
00638   g_return_if_fail (w_current != NULL);
00639 
00640   if (!x_event_get_pointer_position(w_current, TRUE, &wx, &wy))
00641     return;
00642 
00643   i_update_middle_button(w_current, i_callback_edit_move_hotkey, _("Move"));
00644   if (o_select_return_first_object(w_current)) {
00645     o_redraw_cleanstates(w_current);
00646     o_move_start(w_current, wx, wy);
00647     w_current->event_state = ENDMOVE;
00648     w_current->inside_action = 1;
00649   }
00650 }
00651 
00657 DEFINE_I_CALLBACK(edit_delete)
00658 {
00659   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
00660 
00661   g_return_if_fail (w_current != NULL);
00662 
00663   i_update_middle_button(w_current, i_callback_edit_delete, _("Delete"));
00664 
00665   if (o_select_return_first_object(w_current)) {
00666     o_redraw_cleanstates(w_current);    
00667     o_delete_selected(w_current);
00668     /* if you delete the objects you must go into select
00669      * mode after the delete */
00670     w_current->inside_action = 0;
00671     i_set_state(w_current, SELECT);
00672     i_update_toolbar(w_current);
00673     i_update_menus(w_current);
00674   }
00675 }
00676 
00682 DEFINE_I_CALLBACK(edit_edit)
00683 {
00684   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
00685 
00686   g_return_if_fail (w_current != NULL);
00687 
00688   i_update_middle_button(w_current, i_callback_edit_edit, _("Edit"));
00689   o_edit(w_current, geda_list_get_glist( w_current->toplevel->page_current->selection_list ) );
00690 }
00691 
00697 DEFINE_I_CALLBACK(edit_pin_type)
00698 {
00699   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
00700 
00701   g_return_if_fail (w_current != NULL);
00702 
00703   i_update_middle_button (w_current, i_callback_edit_pin_type, _("Edit pin type"));
00704 
00705   x_dialog_edit_pin_type (w_current,
00706                           geda_list_get_glist (w_current->toplevel->
00707                                                  page_current->selection_list));
00708 }
00709 
00715 DEFINE_I_CALLBACK(edit_text)
00716 {
00717   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
00718   OBJECT *object;
00719 
00720   g_return_if_fail (w_current != NULL);
00721 
00722   i_update_middle_button(w_current, i_callback_edit_text, _("Edit Text"));
00723   object = o_select_return_first_object(w_current);
00724   if (object) {
00725     if (object->type == OBJ_TEXT) {
00726       o_text_edit(w_current, object);
00727     }
00728   }
00729 }
00730 
00736 DEFINE_I_CALLBACK(edit_slot)
00737 {
00738   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
00739   OBJECT *object;
00740 
00741   g_return_if_fail (w_current != NULL);
00742 
00743   object = o_select_return_first_object(w_current);
00744 
00745   i_update_middle_button(w_current, i_callback_edit_slot, _("Slot"));
00746   if (object) {
00747     o_slot_start(w_current, object);
00748   }
00749 }
00750 
00756 DEFINE_I_CALLBACK(edit_color)
00757 {
00758   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
00759 
00760   g_return_if_fail (w_current != NULL);
00761 
00762   i_update_middle_button(w_current, i_callback_edit_color, _("Color"));
00763 
00764   color_edit_dialog(w_current);
00765 }
00766 
00773 DEFINE_I_CALLBACK(edit_rotate_90)
00774 {
00775   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
00776 
00777   g_return_if_fail (w_current != NULL);
00778 
00779   /* If inside an appropriate action, send a button 2 released,
00780    * so rotating will be handled by x_event.c */
00781   if ( w_current->inside_action &&
00782        (w_current->event_state == ENDCOMP ||
00783         w_current->event_state == ENDTEXT ||
00784         w_current->event_state == ENDMOVE ||
00785         w_current->event_state == ENDCOPY ||
00786         w_current->event_state == ENDMCOPY ||
00787         w_current->event_state == ENDPASTE )) {
00788       GdkEvent* event;
00789 
00790       event = gdk_event_new(GDK_BUTTON_RELEASE);
00791       ((GdkEventButton*) event)->button = 2;
00792       x_event_button_released (NULL, (GdkEventButton *) event, w_current);
00793       gdk_event_free(event);
00794 
00795       return;
00796     }
00797 
00798   i_set_state(w_current, ENDROTATEP);
00799   i_update_middle_button(w_current, i_callback_edit_rotate_90, _("Rotate"));
00800 }
00801 
00808 DEFINE_I_CALLBACK(edit_rotate_90_hotkey)
00809 {
00810   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
00811   GList *object_list;
00812   gint wx, wy; 
00813 
00814   g_return_if_fail (w_current != NULL);
00815 
00816   if (!x_event_get_pointer_position(w_current, TRUE, &wx, &wy))
00817     return;
00818 
00819   /* If inside an appropriate action, send a button 2 released,
00820    * so rotating will be handled by x_event.c */
00821   if ( w_current->inside_action &&
00822        (w_current->event_state == ENDCOMP ||
00823         w_current->event_state == ENDTEXT ||
00824         w_current->event_state == ENDMOVE ||
00825         w_current->event_state == ENDCOPY ||
00826         w_current->event_state == ENDMCOPY ||
00827         w_current->event_state == ENDPASTE )) {
00828       GdkEvent* event;
00829 
00830       event = gdk_event_new(GDK_BUTTON_RELEASE);
00831       ((GdkEventButton*) event)->button = 2;
00832       x_event_button_released (NULL, (GdkEventButton *) event, w_current);
00833       gdk_event_free(event);
00834 
00835       return;
00836     }
00837 
00838   o_redraw_cleanstates(w_current);
00839 
00840   object_list = geda_list_get_glist( w_current->toplevel->page_current->selection_list );
00841 
00842   if (object_list) {
00843     i_update_middle_button(w_current,
00844                            i_callback_edit_rotate_90_hotkey, _("Rotate"));
00845     /* Allow o_rotate_world_update to redraw the objects */
00846     o_rotate_world_update(w_current, wx, wy, 90, object_list);
00847   }
00848 
00849   w_current->event_state = SELECT;
00850   w_current->inside_action = 0;
00851   i_update_toolbar(w_current);
00852 }
00853 
00859 DEFINE_I_CALLBACK(edit_mirror)
00860 {
00861   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
00862 
00863   g_return_if_fail (w_current != NULL);
00864 
00865   i_set_state(w_current, ENDMIRROR);
00866   i_update_middle_button(w_current, i_callback_edit_mirror, _("Mirror"));
00867 }
00868 
00874 DEFINE_I_CALLBACK(edit_mirror_hotkey)
00875 {
00876   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
00877   GList *object_list;
00878   gint wx, wy; 
00879 
00880   g_return_if_fail (w_current != NULL);
00881 
00882   if (!x_event_get_pointer_position(w_current, TRUE, &wx, &wy))
00883     return;
00884 
00885   o_redraw_cleanstates(w_current);  
00886 
00887   object_list = geda_list_get_glist( w_current->toplevel->page_current->selection_list );
00888 
00889   if (object_list) {
00890     i_update_middle_button(w_current,
00891                            i_callback_edit_mirror_hotkey, _("Mirror"));
00892     o_mirror_world_update(w_current, wx, wy, object_list);
00893   }
00894 
00895   w_current->event_state = SELECT;
00896   w_current->inside_action = 0;
00897   i_update_toolbar(w_current);
00898 }
00899 
00906 DEFINE_I_CALLBACK(edit_lock)
00907 {
00908   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
00909 
00910   g_return_if_fail (w_current != NULL);
00911 
00912   i_update_middle_button(w_current, i_callback_edit_lock, _("Lock"));
00913 
00914   if (o_select_return_first_object(w_current)) {
00915     o_lock(w_current);
00916   }
00917 }
00918 
00924 DEFINE_I_CALLBACK(edit_unlock)
00925 {
00926   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
00927 
00928   g_return_if_fail (w_current != NULL);
00929 
00930   i_update_middle_button(w_current, i_callback_edit_unlock, _("Unlock"));
00931   if (o_select_return_first_object(w_current)) {
00932     o_unlock(w_current);
00933   }
00934 }
00935 
00941 DEFINE_I_CALLBACK(edit_translate)
00942 {
00943   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
00944 
00945   g_return_if_fail (w_current != NULL);
00946 
00947   i_update_middle_button(w_current,
00948                          i_callback_edit_translate, _("Translate"));
00949 
00950   if (w_current->snap == SNAP_OFF) {
00951     s_log_message(_("WARNING: Do not translate with snap off!\n"));
00952     s_log_message(_("WARNING: Turning snap on and continuing "
00953                   "with translate.\n"));
00954     w_current->snap = SNAP_GRID;
00955     i_show_state(w_current, NULL); /* update status on screen */
00956   }
00957 
00958   if (w_current->snap_size != 100) {
00959     s_log_message(_("WARNING: Snap grid size is "
00960                   "not equal to 100!\n"));
00961     s_log_message(_("WARNING: If you are translating a symbol "
00962                   "to the origin, the snap grid size should be "
00963                   "set to 100\n"));
00964   }
00965 
00966   translate_dialog(w_current);
00967 }
00968 
00969 DEFINE_I_CALLBACK(edit_invoke_macro)
00970 {
00971   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
00972 
00973   g_return_if_fail (w_current != NULL);
00974 
00975   gtk_widget_show(w_current->macro_box);
00976   gtk_widget_grab_focus(w_current->macro_entry);
00977 }
00978 
00985 DEFINE_I_CALLBACK(edit_embed)
00986 {
00987   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
00988   OBJECT *o_current;
00989 
00990   g_return_if_fail (w_current != NULL);
00991 
00992   i_update_middle_button(w_current, i_callback_edit_embed, _("Embed"));
00993   /* anything selected ? */
00994   if (o_select_selected(w_current)) {
00995     /* yes, embed each selected component */
00996     GList *s_current =
00997       geda_list_get_glist( w_current->toplevel->page_current->selection_list );
00998 
00999     while (s_current != NULL) {
01000       o_current = (OBJECT *) s_current->data;
01001       g_assert (o_current != NULL);
01002       if ( (o_current->type == OBJ_COMPLEX) ||
01003        (o_current->type == OBJ_PICTURE) ) {
01004         o_embed (w_current->toplevel, o_current);
01005       }
01006       s_current = g_list_next(s_current);
01007     }
01008     o_undo_savestate(w_current, UNDO_ALL);
01009   } else {
01010     /* nothing selected, go back to select state */
01011     o_redraw_cleanstates(w_current);    
01012     w_current->inside_action = 0;
01013     i_set_state(w_current, SELECT);
01014   }
01015   
01016 }
01017 
01024 DEFINE_I_CALLBACK(edit_unembed)
01025 {
01026   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
01027   OBJECT *o_current;
01028 
01029   g_return_if_fail (w_current != NULL);
01030 
01031   i_update_middle_button(w_current, i_callback_edit_unembed, _("Unembed"));
01032   /* anything selected ? */
01033   if (o_select_selected(w_current)) {
01034     /* yes, unembed each selected component */
01035     GList *s_current =
01036       geda_list_get_glist( w_current->toplevel->page_current->selection_list );
01037 
01038     while (s_current != NULL) {
01039       o_current = (OBJECT *) s_current->data;
01040       g_assert (o_current != NULL);
01041       if ( (o_current->type == OBJ_COMPLEX) ||
01042            (o_current->type == OBJ_PICTURE) ) {
01043         o_unembed (w_current->toplevel, o_current);
01044       }
01045       s_current = g_list_next(s_current);
01046     }
01047     o_undo_savestate(w_current, UNDO_ALL);
01048   } else {
01049     /* nothing selected, go back to select state */
01050     o_redraw_cleanstates(w_current);    
01051     w_current->inside_action = 0;
01052     i_set_state(w_current, SELECT);
01053   }
01054 
01055 }
01056 
01063 DEFINE_I_CALLBACK(edit_update)
01064 {
01065   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
01066   TOPLEVEL *toplevel = w_current->toplevel;
01067   GList *selection;
01068   GList *selected_components = NULL;
01069   GList *iter;
01070 
01071   g_return_if_fail (w_current != NULL);
01072 
01073   i_update_middle_button(w_current, i_callback_edit_update, _("Update"));
01074   if (o_select_selected(w_current)) {
01075 
01076     /* Updating components modifies the selection. Therefore, create a
01077      * new list of only the OBJECTs we want to update from the current
01078      * selection, then iterate over that new list to perform the
01079      * update. */
01080     selection = geda_list_get_glist (toplevel->page_current->selection_list);
01081     for (iter = selection; iter != NULL; iter = g_list_next (iter)) {
01082       OBJECT *o_current = (OBJECT *) iter->data;
01083       if (o_current != NULL && o_current->type == OBJ_COMPLEX) {
01084         selected_components = g_list_prepend (selected_components, o_current);
01085       }
01086     }
01087     for (iter = selected_components; iter != NULL; iter = g_list_next (iter)) {
01088       OBJECT *o_current = (OBJECT *) iter->data;
01089       iter->data = o_update_component (w_current, o_current);
01090     }
01091     g_list_free (selected_components);
01092 
01093   } else {
01094     /* nothing selected, go back to select state */
01095     o_redraw_cleanstates(w_current);    
01096     w_current->inside_action = 0;
01097     i_set_state(w_current, SELECT);
01098   }
01099 
01100 }
01101 
01107 DEFINE_I_CALLBACK(edit_show_hidden)
01108 {
01109   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
01110 
01111   g_return_if_fail (w_current != NULL);
01112 
01113   /* This is a new addition 3/15 to prevent this from executing
01114    * inside an action */
01115   if (w_current->inside_action)
01116     return;
01117 
01118   i_update_middle_button(w_current,
01119                          i_callback_edit_show_hidden,
01120                          _("ShowHidden"));
01121 
01122   o_edit_show_hidden (w_current,
01123                       s_page_objects (w_current->toplevel->page_current));
01124 }
01125 
01131 DEFINE_I_CALLBACK(edit_find)
01132 {
01133   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
01134 
01135   g_return_if_fail (w_current != NULL);
01136 
01137   /* This is a new addition 3/15 to prevent this from executing
01138    * inside an action */
01139   if (w_current->inside_action)
01140     return;
01141 
01142   find_text_dialog(w_current);
01143 }
01144 
01150 DEFINE_I_CALLBACK(edit_hide_text)
01151 {
01152   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
01153 
01154   g_return_if_fail (w_current != NULL);
01155 
01156   /* This is a new addition 3/15 to prevent this from executing
01157    * inside an action */
01158   if (w_current->inside_action)
01159     return;
01160 
01161   hide_text_dialog(w_current);
01162 }
01163 
01169 DEFINE_I_CALLBACK(edit_show_text)
01170 {
01171   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
01172 
01173   g_return_if_fail (w_current != NULL);
01174 
01175   /* This is a new addition 3/15 to prevent this from executing
01176    * inside an action */
01177   if (w_current->inside_action)
01178     return;
01179 
01180   show_text_dialog(w_current);
01181 }
01182 
01188 DEFINE_I_CALLBACK(edit_autonumber_text)
01189 {
01190   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
01191 
01192   g_return_if_fail (w_current != NULL);
01193 
01194   /* This is a new addition 3/15 to prevent this from executing
01195    * inside an action */
01196   if (w_current->inside_action)
01197     return;
01198 
01199   autonumber_text_dialog(w_current);
01200 }
01201 
01207 DEFINE_I_CALLBACK(edit_linetype)
01208 {
01209   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
01210 
01211   g_return_if_fail (w_current != NULL);
01212 
01213   line_type_dialog(w_current);
01214 }
01215 
01221 DEFINE_I_CALLBACK(edit_filltype)
01222 {
01223   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
01224 
01225   g_return_if_fail (w_current != NULL);
01226 
01227   fill_type_dialog(w_current);
01228 }
01229 
01239 DEFINE_I_CALLBACK(view_redraw)
01240 {
01241   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
01242 
01243   g_return_if_fail (w_current != NULL);
01244   o_invalidate_all (w_current);
01245 }
01246 
01254 DEFINE_I_CALLBACK(view_zoom_full)
01255 {
01256   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
01257 
01258   g_return_if_fail (w_current != NULL);
01259 
01260   /* scroll bar stuff */
01261   a_zoom(w_current, ZOOM_FULL, DONTCARE, 0);
01262 
01263   if (w_current->undo_panzoom) {
01264     o_undo_savestate(w_current, UNDO_VIEWPORT_ONLY); 
01265   }
01266 }
01267 
01275 DEFINE_I_CALLBACK(view_zoom_extents)
01276 {
01277   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
01278 
01279   g_return_if_fail (w_current != NULL);
01280 
01281   /* scroll bar stuff */
01282   a_zoom_extents (w_current,
01283                   s_page_objects (w_current->toplevel->page_current), 0);
01284   if (w_current->undo_panzoom) {
01285     o_undo_savestate(w_current, UNDO_VIEWPORT_ONLY);
01286   }
01287 }
01288 
01296 DEFINE_I_CALLBACK(view_zoom_box)
01297 {
01298   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
01299 
01300   g_return_if_fail (w_current != NULL);
01301 
01302   o_redraw_cleanstates(w_current);  
01303   w_current->inside_action = 0;
01304   i_set_state(w_current, ZOOMBOXSTART);
01305 }
01306 
01312 DEFINE_I_CALLBACK(view_zoom_box_hotkey)
01313 {
01314   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
01315   gint wx, wy; 
01316 
01317   g_return_if_fail (w_current != NULL);
01318 
01319   if (!x_event_get_pointer_position(w_current, FALSE, &wx, &wy))
01320     return;
01321 
01322   o_redraw_cleanstates(w_current);
01323   a_zoom_box_start(w_current, wx, wy);
01324 
01325   w_current->inside_action = 1;
01326   i_set_state(w_current, ZOOMBOXEND);
01327 }
01328 
01336 DEFINE_I_CALLBACK(view_zoom_in)
01337 {
01338   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
01339 
01340   g_return_if_fail (w_current != NULL);
01341 
01342   a_zoom(w_current, ZOOM_IN, MENU, 0);
01343 
01344   if (w_current->undo_panzoom) {
01345     o_undo_savestate(w_current, UNDO_VIEWPORT_ONLY); 
01346   }
01347 }
01348 
01356 DEFINE_I_CALLBACK(view_zoom_out)
01357 {
01358   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
01359 
01360   g_return_if_fail (w_current != NULL);
01361 
01362   a_zoom(w_current, ZOOM_OUT, MENU, 0);
01363  
01364   if (w_current->undo_panzoom) {
01365     o_undo_savestate(w_current, UNDO_VIEWPORT_ONLY); 
01366   }
01367 }
01368 
01377 DEFINE_I_CALLBACK(view_zoom_in_hotkey)
01378 {
01379   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
01380 
01381   g_return_if_fail (w_current != NULL);
01382 
01383   a_zoom(w_current, ZOOM_IN, HOTKEY, 0);
01384 
01385   if (w_current->undo_panzoom) {
01386     o_undo_savestate(w_current, UNDO_VIEWPORT_ONLY); 
01387   }
01388 }
01389 
01397 DEFINE_I_CALLBACK(view_zoom_out_hotkey)
01398 {
01399   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
01400 
01401   g_return_if_fail (w_current != NULL);
01402 
01403   a_zoom(w_current, ZOOM_OUT, HOTKEY, 0);
01404 
01405   if (w_current->undo_panzoom) {
01406     o_undo_savestate(w_current, UNDO_VIEWPORT_ONLY); 
01407   }
01408 }
01409 
01415 DEFINE_I_CALLBACK(view_pan)
01416 {
01417   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
01418 
01419   g_return_if_fail (w_current != NULL);
01420 
01421   o_redraw_cleanstates(w_current);  
01422   w_current->inside_action = 0;
01423   i_set_state(w_current, STARTPAN);
01424 
01425   /* I don't know if this would get in the way */
01426   i_update_middle_button(w_current, i_callback_view_pan, _("Pan"));
01427 }
01428 
01433 DEFINE_I_CALLBACK(view_pan_left)
01434 {
01435   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
01436 
01437   g_return_if_fail (w_current != NULL);
01438 
01439   a_pan_mouse(w_current, w_current->keyboardpan_gain, 0);
01440 }
01441 
01446 DEFINE_I_CALLBACK(view_pan_right)
01447 {
01448   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
01449 
01450   g_return_if_fail (w_current != NULL);
01451 
01452   /* yes, that's a negative sign there */
01453   a_pan_mouse(w_current, -w_current->keyboardpan_gain, 0);
01454 }
01455 
01460 DEFINE_I_CALLBACK(view_pan_up)
01461 {
01462   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
01463 
01464   g_return_if_fail (w_current != NULL);
01465 
01466   a_pan_mouse(w_current, 0, w_current->keyboardpan_gain);
01467 }
01468 
01473 DEFINE_I_CALLBACK(view_pan_down)
01474 {
01475   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
01476 
01477   g_return_if_fail (w_current != NULL);
01478 
01479   /* yes, that's a negative sign there */
01480   a_pan_mouse(w_current, 0, -w_current->keyboardpan_gain);
01481 }
01482 
01488 DEFINE_I_CALLBACK(view_pan_hotkey)
01489 {
01490   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
01491   gint wx, wy; 
01492 
01493   g_return_if_fail (w_current != NULL);
01494 
01495   if (!x_event_get_pointer_position(w_current, FALSE, &wx, &wy))
01496     return;
01497 
01498   i_update_middle_button(w_current, i_callback_view_pan_hotkey, _("Pan"));
01499 
01500   a_pan(w_current, wx, wy);
01501 
01502   if (w_current->undo_panzoom) {
01503     o_undo_savestate(w_current, UNDO_VIEWPORT_ONLY); 
01504   }
01505 }
01506 
01512 DEFINE_I_CALLBACK (view_dark_colors)
01513 {
01514   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
01515 
01516   x_color_free ();
01517   /* Change the scheme here */
01518   g_scm_c_eval_string_protected ("(load (build-path geda-rc-path \"gschem-colormap-darkbg\"))");
01519   x_color_allocate ();
01520 
01521   o_invalidate_all (w_current);
01522 }
01523 
01529 DEFINE_I_CALLBACK (view_light_colors)
01530 {
01531   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
01532 
01533   x_color_free ();
01534   /* Change the scheme here */
01535   g_scm_c_eval_string_protected ("(load (build-path geda-rc-path \"gschem-colormap-lightbg\"))");
01536   x_color_allocate ();
01537 
01538   o_invalidate_all (w_current);
01539 }
01540 
01546 DEFINE_I_CALLBACK (view_bw_colors)
01547 {
01548   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
01549 
01550   x_color_free ();
01551   /* Change the scheme here */
01552   g_scm_c_eval_string_protected ("(load (build-path geda-rc-path \"gschem-colormap-bw\"))");
01553   x_color_allocate ();
01554 
01555   o_invalidate_all (w_current);
01556 }
01557 
01564 DEFINE_I_CALLBACK(page_manager)
01565 {
01566   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
01567 
01568   g_return_if_fail (w_current != NULL);
01569 
01570   x_pagesel_open (w_current);
01571 }
01572 
01578 DEFINE_I_CALLBACK(page_next)
01579 {
01580   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*)data;
01581   TOPLEVEL *toplevel = w_current->toplevel;
01582   PAGE *p_current = toplevel->page_current;
01583   PAGE *p_new;
01584   GList *iter;
01585 
01586   g_return_if_fail (w_current != NULL);
01587 
01588   iter = g_list_find( geda_list_get_glist( toplevel->pages ), p_current );
01589   iter = g_list_next( iter );
01590 
01591   if (iter == NULL) {
01592     return;
01593   }
01594 
01595   if (w_current->enforce_hierarchy) {
01596     p_new = s_hierarchy_find_next_page(toplevel->pages, p_current);
01597   } else {
01598     p_new = (PAGE *)iter->data;
01599   }
01600 
01601   if (p_new == NULL || p_new == p_current) {
01602     return;
01603   }
01604 
01605   x_window_set_current_page (w_current, p_new);
01606 }
01607 
01613 DEFINE_I_CALLBACK(page_prev)
01614 {
01615   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*)data;
01616   TOPLEVEL *toplevel = w_current->toplevel;
01617   PAGE *p_current = toplevel->page_current;
01618   PAGE *p_new;
01619   GList *iter;
01620 
01621   g_return_if_fail (w_current != NULL);
01622 
01623   iter = g_list_find( geda_list_get_glist( toplevel->pages ), p_current );
01624   iter = g_list_previous( iter );
01625 
01626   if ( iter == NULL  )
01627     return;
01628 
01629   p_new = (PAGE *)iter->data;
01630 
01631   if (w_current->enforce_hierarchy) {
01632     p_new = s_hierarchy_find_prev_page(toplevel->pages, p_current);
01633   } else {
01634     p_new = (PAGE *)iter->data;
01635   }
01636 
01637   if (p_new == NULL || p_new == p_current) {
01638     return;
01639   }
01640 
01641   x_window_set_current_page (w_current, p_new);
01642 }
01643 
01649 DEFINE_I_CALLBACK(page_new)
01650 {
01651   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*)data;
01652   PAGE *page;
01653 
01654   g_return_if_fail (w_current != NULL);
01655 
01656   /* create a new page */
01657   page = x_window_open_page (w_current, NULL);
01658   x_window_set_current_page (w_current, page);
01659   s_log_message (_("New page created [%s]\n"), page->page_filename);
01660 }
01661 
01667 DEFINE_I_CALLBACK(page_close)
01668 {
01669   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
01670 
01671   g_return_if_fail (w_current != NULL);
01672 
01673   if (w_current->toplevel->page_current->CHANGED) {
01674     x_dialog_close_changed_page (w_current, w_current->toplevel->page_current);
01675   } else {
01676     x_window_close_page (w_current, w_current->toplevel->page_current);
01677   }
01678 
01679 }
01680 
01687 DEFINE_I_CALLBACK(page_revert)
01688 {
01689   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
01690   PAGE *page;
01691   gchar *filename;
01692   int page_control;
01693   int up;
01694   int response;
01695   GtkWidget* dialog;
01696 
01697   g_return_if_fail (w_current != NULL);
01698 
01699   dialog = gtk_message_dialog_new ((GtkWindow*) w_current->main_window,
01700                                    GTK_DIALOG_DESTROY_WITH_PARENT,
01701                                    GTK_MESSAGE_QUESTION,
01702                                    GTK_BUTTONS_YES_NO,
01703                                    _("Really revert page?"));
01704 
01705   /* Set the alternative button order (ok, cancel, help) for other systems */
01706   gtk_dialog_set_alternative_button_order(GTK_DIALOG(dialog),
01707                       GTK_RESPONSE_YES,
01708                       GTK_RESPONSE_NO,
01709                       -1);
01710 
01711   response = gtk_dialog_run (GTK_DIALOG (dialog));
01712   gtk_widget_destroy (dialog);
01713 
01714   if (response != GTK_RESPONSE_YES )
01715     return;
01716 
01717   /* save this for later */
01718   filename = g_strdup (w_current->toplevel->page_current->page_filename);
01719   page_control = w_current->toplevel->page_current->page_control;
01720   up = w_current->toplevel->page_current->up;
01721 
01722   /* delete the page, then re-open the file as a new page */
01723   s_page_delete (w_current->toplevel, w_current->toplevel->page_current);
01724 
01725   page = x_window_open_page (w_current, filename);
01726 
01727   /* make sure we maintain the hierarchy info */
01728   page->page_control = page_control;
01729   page->up = up;
01730 
01731   x_window_set_current_page (w_current, page);
01732 }
01733 
01739 DEFINE_I_CALLBACK(page_discard)
01740 {
01741   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*)data;
01742 
01743   g_return_if_fail (w_current != NULL);
01744 
01745   x_window_close_page (w_current, w_current->toplevel->page_current);
01746 }
01747 
01753 DEFINE_I_CALLBACK(page_print)
01754 {
01755   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
01756 
01757   s_page_print_all(w_current->toplevel);
01758 }
01759 
01765 DEFINE_I_CALLBACK(clipboard_copy)
01766 {
01767   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
01768 
01769   g_return_if_fail (w_current != NULL);
01770   if (!o_select_selected (w_current)) return;
01771 
01772   i_update_middle_button (w_current, i_callback_clipboard_copy,
01773                           _("Copy to clipboard"));
01774 
01775   o_buffer_copy (w_current, 0);
01776   x_clipboard_set (w_current, object_buffer[0]);
01777 }
01778 
01783 DEFINE_I_CALLBACK(clipboard_cut)
01784 {
01785   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
01786 
01787   g_return_if_fail (w_current != NULL);
01788   if (!o_select_selected (w_current)) return;
01789 
01790   i_update_middle_button (w_current, i_callback_clipboard_cut,
01791                           _("Cut to clipboard"));
01792 
01793   o_buffer_cut (w_current, 0);
01794   x_clipboard_set (w_current, object_buffer[0]);
01795 }
01796 
01801 DEFINE_I_CALLBACK(clipboard_paste)
01802 {
01803   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL *) data;
01804   TOPLEVEL *toplevel = w_current->toplevel;
01805   GList *object_list = NULL;
01806 
01807   g_return_if_fail (w_current != NULL);
01808 
01809   i_update_middle_button (w_current, i_callback_buffer_paste1, _("Paste from clipboard"));
01810 
01811   object_list = x_clipboard_get (w_current);
01812 
01813   if (object_list != NULL) {
01814     s_delete_object_glist (toplevel, object_buffer[0]);
01815     object_buffer[0] = object_list;
01816     o_redraw_cleanstates (w_current);
01817     w_current->buffer_number = 0;
01818     w_current->inside_action = 1;
01819     i_set_state (w_current, STARTPASTE);
01820   } else {
01821     i_set_state_msg (w_current, SELECT, _("Empty buffer"));
01822   }
01823 }
01824 
01830 DEFINE_I_CALLBACK(clipboard_paste_hotkey)
01831 {
01832   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL *) data;
01833   TOPLEVEL *toplevel = w_current->toplevel;
01834   GList *object_list = NULL;
01835   gint wx, wy;
01836 
01837   g_return_if_fail (w_current != NULL);
01838 
01839   if (!x_event_get_pointer_position (w_current, TRUE, &wx, &wy))
01840     return;
01841 
01842   object_list = x_clipboard_get (w_current);
01843 
01844   if (object_list == NULL) return;
01845   s_delete_object_glist (toplevel, object_buffer[0]);
01846   object_buffer[0] = object_list;
01847 
01848   o_buffer_paste_start (w_current, wx, wy, 0);
01849 }
01850 
01857 DEFINE_I_CALLBACK(buffer_copy1)
01858 {
01859   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
01860 
01861   g_return_if_fail (w_current != NULL);
01862 
01863   if (!o_select_selected (w_current))
01864     return;
01865 
01866   i_update_middle_button(w_current, i_callback_buffer_copy1, _("Copy 1"));
01867   o_buffer_copy(w_current, 0);
01868   i_update_menus(w_current);
01869 }
01870 
01876 DEFINE_I_CALLBACK(buffer_copy2)
01877 {
01878   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
01879 
01880   g_return_if_fail (w_current != NULL);
01881 
01882   if (!o_select_selected (w_current))
01883     return;
01884 
01885   i_update_middle_button(w_current, i_callback_buffer_copy2, _("Copy 2"));
01886   o_buffer_copy(w_current, 1);
01887   i_update_menus(w_current);
01888 }
01889 
01895 DEFINE_I_CALLBACK(buffer_copy3)
01896 {
01897   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
01898 
01899   g_return_if_fail (w_current != NULL);
01900 
01901   if (!o_select_selected (w_current))
01902     return;
01903 
01904   i_update_middle_button(w_current, i_callback_buffer_copy3, _("Copy 3"));
01905   o_buffer_copy(w_current, 2);
01906   i_update_menus(w_current);
01907 }
01908 
01914 DEFINE_I_CALLBACK(buffer_copy4)
01915 {
01916   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
01917 
01918   g_return_if_fail (w_current != NULL);
01919 
01920   if (!o_select_selected (w_current))
01921     return;
01922 
01923   i_update_middle_button(w_current, i_callback_buffer_copy4, _("Copy 4"));
01924   o_buffer_copy(w_current, 3);
01925   i_update_menus(w_current);
01926 }
01927 
01933 DEFINE_I_CALLBACK(buffer_copy5)
01934 {
01935   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
01936 
01937   g_return_if_fail (w_current != NULL);
01938 
01939   if (!o_select_selected (w_current))
01940     return;
01941 
01942   i_update_middle_button(w_current, i_callback_buffer_copy5, _("Copy 5"));
01943   o_buffer_copy(w_current, 4);
01944   i_update_menus(w_current);
01945 }
01946 
01952 DEFINE_I_CALLBACK(buffer_cut1)
01953 {
01954   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
01955 
01956   g_return_if_fail (w_current != NULL);
01957 
01958   if (!o_select_selected (w_current))
01959     return;
01960 
01961   i_update_middle_button(w_current, i_callback_buffer_cut1, _("Cut 1"));
01962   o_buffer_cut(w_current, 0);
01963   i_update_menus(w_current);
01964 }
01965 
01971 DEFINE_I_CALLBACK(buffer_cut2)
01972 {
01973   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
01974 
01975   g_return_if_fail (w_current != NULL);
01976 
01977   if (!o_select_selected (w_current))
01978     return;
01979 
01980   i_update_middle_button(w_current, i_callback_buffer_cut2, _("Cut 2"));
01981   o_buffer_cut(w_current, 1);
01982   i_update_menus(w_current);
01983 }
01984 
01990 DEFINE_I_CALLBACK(buffer_cut3)
01991 {
01992   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
01993 
01994   g_return_if_fail (w_current != NULL);
01995 
01996   if (!o_select_selected (w_current))
01997     return;
01998 
01999   i_update_middle_button(w_current, i_callback_buffer_cut3, _("Cut 3"));
02000   o_buffer_cut(w_current, 2);
02001   i_update_menus(w_current);
02002 }
02003 
02009 DEFINE_I_CALLBACK(buffer_cut4)
02010 {
02011   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
02012 
02013   g_return_if_fail (w_current != NULL);
02014 
02015   if (!o_select_selected (w_current))
02016     return;
02017 
02018   i_update_middle_button(w_current, i_callback_buffer_cut4, _("Cut 4"));
02019   o_buffer_cut(w_current, 3);
02020   i_update_menus(w_current);
02021 }
02022 
02028 DEFINE_I_CALLBACK(buffer_cut5)
02029 {
02030   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
02031 
02032   g_return_if_fail (w_current != NULL);
02033 
02034   if (!o_select_selected (w_current))
02035     return;
02036 
02037   i_update_middle_button(w_current, i_callback_buffer_cut5, _("Cut 5"));
02038   o_buffer_cut(w_current, 4);
02039   i_update_menus(w_current);
02040 }
02041 
02047 DEFINE_I_CALLBACK(buffer_paste1)
02048 {
02049   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
02050 
02051   g_return_if_fail (w_current != NULL);
02052 
02053   i_update_middle_button(w_current, i_callback_buffer_paste1, _("Paste 1"));
02054   if (object_buffer[0] != NULL) {
02055     o_redraw_cleanstates(w_current);
02056     w_current->buffer_number = 0;
02057     w_current->inside_action = 1;
02058     i_set_state(w_current, STARTPASTE);
02059   } else {
02060     i_set_state_msg(w_current, SELECT, _("Empty buffer"));
02061   }
02062 }
02063 
02069 DEFINE_I_CALLBACK(buffer_paste2)
02070 {
02071   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
02072 
02073   g_return_if_fail (w_current != NULL);
02074 
02075   i_update_middle_button(w_current, i_callback_buffer_paste2, _("Paste 2"));
02076   if (object_buffer[1] != NULL) {
02077     o_redraw_cleanstates(w_current);
02078     w_current->buffer_number = 1;
02079     w_current->inside_action = 1;
02080     i_set_state(w_current, STARTPASTE);
02081   } else {
02082     i_set_state_msg(w_current, SELECT, _("Empty buffer"));
02083   }
02084 }
02085 
02091 DEFINE_I_CALLBACK(buffer_paste3)
02092 {
02093   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
02094 
02095   g_return_if_fail (w_current != NULL);
02096 
02097   i_update_middle_button(w_current, i_callback_buffer_paste3, _("Paste 3"));
02098   if (object_buffer[2] != NULL) {
02099     o_redraw_cleanstates(w_current);
02100     w_current->buffer_number = 2;
02101     w_current->inside_action = 1;
02102     i_set_state(w_current, STARTPASTE);
02103   } else {
02104     i_set_state_msg(w_current, SELECT, _("Empty buffer"));
02105   }
02106 }
02107 
02113 DEFINE_I_CALLBACK(buffer_paste4)
02114 {
02115   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
02116 
02117   g_return_if_fail (w_current != NULL);
02118 
02119   i_update_middle_button(w_current, i_callback_buffer_paste4, _("Paste 4"));
02120   if (object_buffer[3] != NULL) {
02121     o_redraw_cleanstates(w_current);
02122     w_current->buffer_number = 3;
02123     w_current->inside_action = 1;
02124     i_set_state(w_current, STARTPASTE);
02125   } else {
02126     i_set_state_msg(w_current, SELECT, _("Empty buffer"));
02127   }
02128 }
02129 
02135 DEFINE_I_CALLBACK(buffer_paste5)
02136 {
02137   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
02138 
02139   g_return_if_fail (w_current != NULL);
02140 
02141   i_update_middle_button(w_current, i_callback_buffer_paste5, _("Paste 5"));
02142   if (object_buffer[4] != NULL) {
02143     o_redraw_cleanstates(w_current);
02144     w_current->buffer_number = 4;
02145     w_current->inside_action = 1;
02146     i_set_state(w_current, STARTPASTE);
02147   } else {
02148     i_set_state_msg(w_current, SELECT, _("Empty buffer"));
02149   }
02150 }
02151 
02157 DEFINE_I_CALLBACK(buffer_paste1_hotkey)
02158 {
02159   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
02160   gint wx, wy; 
02161 
02162   g_return_if_fail (w_current != NULL);
02163 
02164   if (object_buffer[0] == NULL) {
02165     return;
02166   }
02167 
02168   if (!x_event_get_pointer_position(w_current, TRUE, &wx, &wy))
02169     return;
02170 
02171   o_buffer_paste_start(w_current, wx, wy, 0);
02172 }
02173 
02179 DEFINE_I_CALLBACK(buffer_paste2_hotkey)
02180 {
02181   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
02182   gint wx, wy; 
02183 
02184   g_return_if_fail (w_current != NULL);
02185 
02186   if (object_buffer[1] == NULL) {
02187     return;
02188   }
02189 
02190   if (!x_event_get_pointer_position(w_current, TRUE, &wx, &wy))
02191     return;
02192 
02193   o_buffer_paste_start(w_current, wx, wy, 1);
02194 }
02195 
02201 DEFINE_I_CALLBACK(buffer_paste3_hotkey)
02202 {
02203   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
02204   gint wx, wy; 
02205 
02206   g_return_if_fail (w_current != NULL);
02207 
02208   if (object_buffer[2] == NULL) {
02209     return;
02210   }
02211 
02212   if (!x_event_get_pointer_position(w_current, TRUE, &wx, &wy))
02213     return;
02214 
02215   o_buffer_paste_start(w_current, wx, wy, 2);
02216 }
02217 
02223 DEFINE_I_CALLBACK(buffer_paste4_hotkey)
02224 {
02225   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
02226   gint wx, wy; 
02227 
02228   g_return_if_fail (w_current != NULL);
02229 
02230   if (object_buffer[3] == NULL) {
02231     return;
02232   }
02233 
02234   if (!x_event_get_pointer_position(w_current, TRUE, &wx, &wy))
02235     return;
02236 
02237   o_buffer_paste_start(w_current, wx, wy, 3);
02238 }
02239 
02245 DEFINE_I_CALLBACK(buffer_paste5_hotkey)
02246 {
02247   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
02248   gint wx, wy; 
02249 
02250   g_return_if_fail (w_current != NULL);
02251 
02252   if (object_buffer[4] == NULL) {
02253     return;
02254   }
02255 
02256   if (!x_event_get_pointer_position(w_current, TRUE, &wx, &wy))
02257     return;
02258 
02259   o_buffer_paste_start(w_current, wx, wy, 4);
02260 }
02261 
02268 DEFINE_I_CALLBACK(add_component)
02269 {
02270   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
02271 
02272   g_return_if_fail (w_current != NULL);
02273 
02274   o_redraw_cleanstates (w_current);
02275   x_compselect_open (w_current);
02276 
02277   i_update_middle_button(w_current,
02278                          i_callback_add_component, _("Component"));
02279 
02280   i_set_state(w_current, SELECT);
02281   i_update_toolbar(w_current);
02282 }
02283 
02292 void i_callback_toolbar_add_component(GtkWidget* widget, gpointer data)
02293 {
02294   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
02295   g_return_if_fail (w_current != NULL);
02296   if (!w_current->window) return;
02297 
02298   i_callback_add_component(data, 0, NULL);
02299 }
02300 
02306 DEFINE_I_CALLBACK(add_attribute)
02307 {
02308   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
02309 
02310   g_return_if_fail (w_current != NULL);
02311 
02312   attrib_edit_dialog(w_current, NULL, FROM_MENU);
02313   i_update_middle_button(w_current, i_callback_add_attribute,
02314                          _("Attribute"));
02315 
02316   i_set_state(w_current, SELECT);
02317   i_update_toolbar(w_current);
02318 }
02319 
02325 DEFINE_I_CALLBACK(add_attribute_hotkey)
02326 {
02327   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
02328 
02329   g_return_if_fail (w_current != NULL);
02330 
02331   attrib_edit_dialog(w_current, NULL, FROM_HOTKEY);
02332   i_update_middle_button(w_current, i_callback_add_attribute_hotkey,
02333                          _("Attribute"));
02334 
02335   i_set_state(w_current, SELECT);
02336   i_update_toolbar(w_current);
02337 }
02338 
02344 DEFINE_I_CALLBACK(add_net)
02345 {
02346   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
02347 
02348   g_return_if_fail (w_current != NULL);
02349 
02350   o_redraw_cleanstates(w_current);  
02351   o_invalidate_rubber (w_current);
02352   o_net_reset(w_current);
02353 
02354   /* need to click */
02355   i_update_middle_button(w_current, i_callback_add_net, _("Net"));
02356   i_set_state(w_current, STARTDRAWNET);
02357   i_update_toolbar(w_current);
02358   /* somewhere you need to nearest point locking... */
02359   w_current->inside_action = 0;
02360 }
02361 
02367 DEFINE_I_CALLBACK(add_net_hotkey)
02368 {
02369   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
02370   gint wx, wy;
02371 
02372   g_return_if_fail (w_current != NULL);
02373 
02374   if (!x_event_get_pointer_position(w_current, TRUE, &wx, &wy))
02375     return;
02376 
02377   o_redraw_cleanstates(w_current);  
02378   o_invalidate_rubber (w_current);
02379   o_net_reset(w_current);
02380 
02381   /* need to click */
02382   i_update_middle_button(w_current, i_callback_add_net_hotkey, _("Net"));
02383   i_set_state(w_current, STARTDRAWNET);
02384   i_update_toolbar(w_current);
02385 
02386   o_net_start(w_current, wx, wy);
02387 
02388   w_current->event_state=DRAWNET;
02389   w_current->inside_action = 1;
02390 }
02391 
02400 void i_callback_toolbar_add_net(GtkWidget* widget, gpointer data)
02401 {
02402   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
02403   g_return_if_fail (w_current != NULL);
02404   if (!w_current->window) return;
02405 
02406   if (GTK_TOGGLE_BUTTON (widget)->active) {
02407     i_callback_add_net(data, 0, NULL);
02408   }
02409 }
02410 
02416 DEFINE_I_CALLBACK(add_bus)
02417 {
02418   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
02419 
02420   g_return_if_fail (w_current != NULL);
02421 
02422   o_redraw_cleanstates(w_current);  
02423   o_invalidate_rubber (w_current);
02424 
02425   /* need to click */
02426   i_update_middle_button(w_current, i_callback_add_bus, _("Bus"));
02427   i_set_state(w_current, STARTDRAWBUS);
02428   i_update_toolbar(w_current);
02429 
02430   /* somewhere you need to nearest point locking... */
02431   w_current->inside_action = 0;
02432 }
02433 
02439 DEFINE_I_CALLBACK(add_bus_hotkey)
02440 {
02441   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
02442   gint wx, wy;
02443 
02444   g_return_if_fail (w_current != NULL);
02445 
02446   if (!x_event_get_pointer_position(w_current, TRUE, &wx, &wy))
02447     return;
02448 
02449   o_redraw_cleanstates(w_current);  
02450   o_invalidate_rubber (w_current);
02451 
02452   /* need to click */
02453   i_update_middle_button(w_current, i_callback_add_bus_hotkey, _("Bus"));
02454   i_set_state(w_current, STARTDRAWBUS);
02455   i_update_toolbar(w_current);
02456 
02457   o_bus_start(w_current, wx, wy);
02458 
02459   w_current->event_state=DRAWBUS;
02460   w_current->inside_action = 1;
02461 }
02462 
02471 void i_callback_toolbar_add_bus(GtkWidget* widget, gpointer data)
02472 {
02473   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
02474   g_return_if_fail (w_current != NULL);
02475   if (!w_current->window) return;
02476 
02477   if (GTK_TOGGLE_BUTTON (widget)->active) {
02478      i_callback_add_bus(data, 0, NULL);
02479   }
02480 }
02481 
02487 DEFINE_I_CALLBACK(add_text)
02488 {
02489   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
02490 
02491   g_return_if_fail (w_current != NULL);
02492   
02493   o_redraw_cleanstates(w_current);  
02494   o_invalidate_rubber (w_current);
02495 
02496   w_current->inside_action = 0;
02497   i_set_state(w_current, SELECT);
02498   i_update_toolbar(w_current);
02499 
02500   text_input_dialog(w_current);
02501 }
02502 
02511 void i_callback_toolbar_add_text(GtkWidget* widget, gpointer data)
02512 {
02513   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
02514   g_return_if_fail (w_current != NULL);
02515   if (!w_current->window) return;
02516 
02517   i_callback_add_text(data, 0, NULL);
02518 }
02519 
02525 DEFINE_I_CALLBACK(add_line)
02526 {
02527   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
02528 
02529   g_return_if_fail (w_current != NULL);
02530 
02531   o_redraw_cleanstates(w_current);  
02532   o_invalidate_rubber (w_current);
02533 
02534   i_update_middle_button(w_current, i_callback_add_line, _("Line"));
02535   i_set_state(w_current, DRAWLINE);
02536   w_current->inside_action = 0;
02537 }
02538 
02544 DEFINE_I_CALLBACK(add_line_hotkey)
02545 {
02546   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
02547   gint wx, wy;
02548   
02549   g_return_if_fail (w_current != NULL);
02550 
02551   if (!x_event_get_pointer_position(w_current, TRUE, &wx, &wy))
02552     return;
02553 
02554   o_redraw_cleanstates(w_current);  
02555   o_invalidate_rubber (w_current);
02556 
02557   i_update_middle_button(w_current, i_callback_add_line_hotkey, _("Line"));
02558 
02559   o_line_start(w_current, wx, wy);
02560 
02561   w_current->inside_action = 1;
02562   i_set_state(w_current, ENDLINE);
02563 }
02564 
02570 DEFINE_I_CALLBACK(add_box)
02571 {
02572   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
02573 
02574   g_return_if_fail (w_current != NULL);
02575 
02576   o_redraw_cleanstates(w_current);  
02577   o_invalidate_rubber (w_current);
02578 
02579   i_update_middle_button(w_current, i_callback_add_box, _("Box"));
02580   w_current->inside_action = 0;
02581   i_set_state(w_current, DRAWBOX);
02582 }
02583 
02589 DEFINE_I_CALLBACK(add_box_hotkey)
02590 {
02591   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
02592   gint wx, wy; 
02593 
02594   g_return_if_fail (w_current != NULL);
02595 
02596   if (!x_event_get_pointer_position(w_current, TRUE, &wx, &wy))
02597     return;
02598 
02599   o_redraw_cleanstates(w_current);  
02600   o_invalidate_rubber (w_current);
02601 
02602   i_update_middle_button(w_current, i_callback_add_box_hotkey, _("Box"));
02603 
02604   o_box_start(w_current, wx, wy);
02605 
02606   w_current->inside_action = 1;
02607   i_set_state(w_current, ENDBOX);
02608 }
02609 
02615 DEFINE_I_CALLBACK(add_picture)
02616 {
02617   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
02618 
02619   g_return_if_fail (w_current != NULL);
02620 
02621   o_redraw_cleanstates(w_current);  
02622   o_invalidate_rubber (w_current);
02623 
02624   w_current->inside_action = 0;
02625   i_set_state(w_current, SELECT);
02626   i_update_toolbar(w_current);
02627 
02628   picture_selection_dialog(w_current);
02629 }
02630 
02636 DEFINE_I_CALLBACK(add_picture_hotkey)
02637 {
02638   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
02639 
02640   /* If this function necessary? Yes, if you want the hotkey to work. */
02641   i_callback_add_picture(w_current, 0, NULL);
02642 }
02643 
02649 DEFINE_I_CALLBACK(add_circle)
02650 {
02651   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
02652 
02653   g_return_if_fail (w_current != NULL);
02654 
02655   o_redraw_cleanstates(w_current);  
02656   o_invalidate_rubber (w_current);
02657 
02658   i_update_middle_button(w_current, i_callback_add_circle, _("Circle"));
02659   w_current->inside_action = 0;
02660   i_set_state(w_current, DRAWCIRCLE);
02661 }
02662 
02668 DEFINE_I_CALLBACK(add_circle_hotkey)
02669 {
02670   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
02671   gint wx, wy; 
02672 
02673   g_return_if_fail (w_current != NULL);
02674 
02675   if (!x_event_get_pointer_position(w_current, TRUE, &wx, &wy))
02676     return;
02677 
02678   o_redraw_cleanstates(w_current);  
02679   o_invalidate_rubber (w_current);
02680 
02681   i_update_middle_button(w_current, i_callback_add_circle_hotkey,
02682                          _("Circle"));
02683 
02684   o_circle_start(w_current, wx, wy);
02685 
02686   w_current->inside_action = 1;
02687   i_set_state(w_current, ENDCIRCLE);
02688 }
02689 
02695 DEFINE_I_CALLBACK(add_arc)
02696 {
02697   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
02698 
02699   g_return_if_fail (w_current != NULL);
02700   
02701   o_redraw_cleanstates(w_current);  
02702   o_invalidate_rubber (w_current);
02703 
02704   i_update_middle_button(w_current, i_callback_add_arc, _("Arc"));
02705   w_current->inside_action = 0;
02706   i_set_state(w_current, DRAWARC);
02707 }
02708 
02714 DEFINE_I_CALLBACK(add_arc_hotkey)
02715 {
02716   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
02717   gint wx, wy; 
02718 
02719   g_return_if_fail (w_current != NULL);
02720 
02721   if (!x_event_get_pointer_position(w_current, TRUE, &wx, &wy))
02722     return;
02723 
02724   o_redraw_cleanstates(w_current);  
02725   o_invalidate_rubber (w_current);
02726 
02727   i_update_middle_button(w_current, i_callback_add_arc_hotkey, _("Arc"));
02728 
02729   o_arc_start(w_current, wx, wy);
02730 
02731   w_current->inside_action = 1;
02732   i_set_state(w_current, ENDARC);
02733 }
02734 
02740 DEFINE_I_CALLBACK(add_pin)
02741 {
02742   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
02743 
02744   g_return_if_fail (w_current != NULL);
02745 
02746   o_redraw_cleanstates(w_current);  
02747   o_invalidate_rubber (w_current);
02748 
02749   i_update_middle_button(w_current, i_callback_add_pin, _("Pin"));
02750   w_current->inside_action = 0;
02751   i_set_state(w_current, DRAWPIN);
02752 }
02753 
02759 DEFINE_I_CALLBACK(add_pin_hotkey)
02760 {
02761   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
02762   gint wx, wy; 
02763 
02764   g_return_if_fail (w_current != NULL);
02765 
02766   if (!x_event_get_pointer_position(w_current, TRUE, &wx, &wy))
02767     return;
02768 
02769   o_redraw_cleanstates(w_current);  
02770   o_invalidate_rubber (w_current);
02771 
02772   i_update_middle_button(w_current, i_callback_add_pin_hotkey, _("Pin"));
02773 
02774   o_pin_start(w_current, wx, wy);
02775 
02776   w_current->inside_action = 1;
02777   i_set_state(w_current, ENDPIN);
02778 }
02779 
02786 DEFINE_I_CALLBACK(hierarchy_down_schematic)
02787 {
02788   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
02789   char *attrib=NULL;
02790   char *current_filename=NULL;
02791   int count=0;
02792   OBJECT *object=NULL;
02793   PAGE *save_first_page=NULL;
02794   PAGE *parent=NULL;
02795   PAGE *child = NULL;
02796   int loaded_flag=FALSE;
02797   int page_control = 0;
02798   int pcount = 0;
02799   int looking_inside=FALSE;
02800 
02801   g_return_if_fail (w_current != NULL);
02802 
02803   object = o_select_return_first_object(w_current);
02804 
02805   /* only allow going into symbols */
02806   if (object == NULL || object->type != OBJ_COMPLEX)
02807     return;
02808 
02809   parent = w_current->toplevel->page_current;
02810   attrib = o_attrib_search_attached_attribs_by_name (object, "source", count);
02811 
02812   /* if above is null, then look inside symbol */
02813   if (attrib == NULL) {
02814     attrib =
02815       o_attrib_search_inherited_attribs_by_name (object, "source", count);
02816     looking_inside = TRUE;
02817 #if DEBUG
02818     printf("going to look inside now\n");
02819 #endif
02820   }
02821 
02822   while (attrib) {
02823 
02824     /* look for source=filename,filename, ... */
02825     pcount = 0;
02826     current_filename = u_basic_breakup_string(attrib, ',', pcount);
02827 
02828     /* loop over all filenames */
02829     while(current_filename != NULL) {
02830 
02831       s_log_message(_("Searching for source [%s]\n"), current_filename);
02832       child = s_hierarchy_down_schematic_single(w_current->toplevel,
02833                                                 current_filename,
02834                                                 parent,
02835                                                 page_control,
02836                                                 HIERARCHY_NORMAL_LOAD);
02837 
02838       /* s_hierarchy_down_schematic_single() will not zoom the loaded page */
02839       if (child != NULL) {
02840         s_page_goto (w_current->toplevel, child);
02841         a_zoom_extents(w_current,
02842                        s_page_objects (w_current->toplevel->page_current),
02843                        A_PAN_DONT_REDRAW);
02844         o_undo_savestate(w_current, UNDO_ALL);
02845         s_page_goto (w_current->toplevel, parent);
02846       }
02847 
02848       /* save the first page */
02849       if ( !loaded_flag && (child != NULL)) {
02850         save_first_page = child;
02851       }
02852 
02853       /* now do some error fixing */
02854       if (child == NULL) {
02855         s_log_message(_("Cannot find source [%s]\n"), current_filename);
02856       } else {
02857         /* this only signifies that we tried */
02858         loaded_flag = TRUE;
02859         page_control = child->page_control;
02860       }
02861 
02862       g_free(current_filename);
02863       pcount++;
02864       current_filename = u_basic_breakup_string(attrib, ',', pcount);
02865     }
02866 
02867     g_free(attrib);
02868     g_free(current_filename);
02869 
02870     count++;
02871 
02872     /* continue looking outside first */
02873     if (!looking_inside) {
02874       attrib =
02875         o_attrib_search_attached_attribs_by_name (object, "source", count);
02876     }
02877 
02878     /* okay we were looking outside and didn't find anything,
02879      * so now we need to look inside the symbol */
02880     if (!looking_inside && attrib == NULL && !loaded_flag ) {
02881       looking_inside = TRUE;
02882 #if DEBUG
02883       printf("switching to go to look inside\n");
02884 #endif
02885     }
02886 
02887     if (looking_inside) {
02888 #if DEBUG
02889       printf("looking inside\n");
02890 #endif
02891       attrib =
02892         o_attrib_search_inherited_attribs_by_name (object, "source", count);
02893     }
02894   }
02895 
02896   if (loaded_flag && (save_first_page != NULL)) {
02897     x_window_set_current_page (w_current, save_first_page);
02898   }
02899 }
02900 
02906 DEFINE_I_CALLBACK(hierarchy_down_symbol)
02907 {
02908   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
02909   OBJECT *object;
02910   const CLibSymbol *sym;
02911 
02912   g_return_if_fail (w_current != NULL);
02913 
02914   object = o_select_return_first_object(w_current);
02915   if (object != NULL) {
02916     /* only allow going into symbols */
02917     if (object->type == OBJ_COMPLEX) {
02918       s_log_message(_("Searching for symbol [%s]\n"), 
02919             object->complex_basename);
02920       sym = s_clib_get_symbol_by_name (object->complex_basename);
02921       if (sym == NULL)
02922     return;
02923       if (s_clib_symbol_get_filename(sym) == NULL) {
02924     s_log_message(_("Symbol is not a real file."
02925             " Symbol cannot be loaded.\n"));
02926     return;
02927       }
02928       s_hierarchy_down_symbol(w_current->toplevel, sym,
02929                   w_current->toplevel->page_current);
02930       /* s_hierarchy_down_symbol() will not zoom the loaded page */
02931       a_zoom_extents(w_current,
02932                      s_page_objects (w_current->toplevel->page_current),
02933                      A_PAN_DONT_REDRAW);
02934       o_undo_savestate(w_current, UNDO_ALL);
02935       x_window_set_current_page(w_current, w_current->toplevel->page_current);
02936     }
02937   }
02938 }
02939 
02945 DEFINE_I_CALLBACK(hierarchy_up)
02946 {
02947   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
02948   PAGE *up_page;
02949 
02950   g_return_if_fail (w_current != NULL);
02951 
02952   up_page = s_hierarchy_find_up_page (w_current->toplevel->pages,
02953                                       w_current->toplevel->page_current);
02954   if (up_page == NULL) {
02955     s_log_message(_("Cannot find any schematics above the current one!\n"));
02956   } else {
02957     x_window_set_current_page(w_current, up_page);
02958   }
02959 }
02960 
02967 DEFINE_I_CALLBACK(attributes_attach)
02968 {
02969   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
02970   OBJECT *first_object;
02971   GList *s_current;
02972   GList *attached_objects = NULL;
02973 
02974   g_return_if_fail (w_current != NULL);
02975 
02976   /* This is a new addition 3/15 to prevent this from executing
02977    * inside an action */
02978   if (w_current->inside_action) {
02979     return;
02980   }
02981 
02982   /* do we want to update the shortcut outside of the ifs? */
02983   /* probably, if this fails the user may want to try again */
02984   i_update_middle_button(w_current, i_callback_attributes_attach,
02985                          _("Attach"));
02986 
02987   /* skip over head */
02988   s_current = geda_list_get_glist( w_current->toplevel->page_current->selection_list );
02989   if (!s_current) {
02990     return;
02991   }
02992 
02993   first_object = (OBJECT *) s_current->data; 
02994   if (!first_object) {
02995     return; 
02996   }
02997 
02998   /* skip over first object */
02999   s_current = g_list_next(s_current);
03000   while (s_current != NULL) {
03001     OBJECT *object = s_current->data;
03002     if (object != NULL) {
03003       o_attrib_attach (w_current->toplevel, object, first_object, TRUE);
03004       attached_objects = g_list_prepend (attached_objects, object);
03005       w_current->toplevel->page_current->CHANGED=1;
03006     }
03007     s_current = g_list_next(s_current);
03008   }
03009 
03010   if (attached_objects != NULL) {
03011     g_run_hook_object_list (w_current, "%attach-attribs-hook",
03012                             attached_objects);
03013     g_list_free (attached_objects);
03014   }
03015 
03016   o_undo_savestate(w_current, UNDO_ALL);
03017 }
03018 
03024 DEFINE_I_CALLBACK(attributes_detach)
03025 {
03026   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
03027   GList *s_current;
03028   OBJECT *o_current;
03029   GList *detached_attribs = NULL;
03030 
03031   g_return_if_fail (w_current != NULL);
03032 
03033   /* This is a new addition 3/15 to prevent this from executing
03034    * inside an action */
03035   if (w_current->inside_action) {
03036     return;
03037   }
03038 
03039   /* same note as above on i_update_middle_button */
03040   i_update_middle_button(w_current, i_callback_attributes_detach,
03041                          _("Detach"));
03042 
03043   s_current = geda_list_get_glist( w_current->toplevel->page_current->selection_list );
03044   while (s_current != NULL) {
03045     o_current = (OBJECT *) s_current->data;
03046     if (o_current) {
03047       if (o_current->attribs) {
03048         detached_attribs = g_list_concat (g_list_copy (o_current->attribs),
03049                                           detached_attribs);
03050         o_attrib_detach_all (w_current->toplevel, o_current);
03051         w_current->toplevel->page_current->CHANGED=1;
03052       }
03053     }
03054     s_current = g_list_next(s_current);
03055   }
03056 
03057   if (detached_attribs != NULL) {
03058     g_run_hook_object_list (w_current, "%detach-attribs-hook",
03059                             detached_attribs);
03060     g_list_free (detached_attribs);
03061   }
03062 
03063   o_undo_savestate(w_current, UNDO_ALL);
03064 }
03065 
03071 DEFINE_I_CALLBACK(attributes_show_name)
03072 {
03073   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
03074   TOPLEVEL *toplevel = w_current->toplevel;
03075 
03076   g_return_if_fail (w_current != NULL);
03077 
03078   /* This is a new addition 3/15 to prevent this from executing
03079    * inside an action */
03080   if (w_current->inside_action) {
03081     return;
03082   }
03083 
03084   i_update_middle_button(w_current, i_callback_attributes_show_name,
03085                          _("ShowN"));
03086 
03087   if (o_select_selected (w_current)) {
03088     SELECTION *selection = toplevel->page_current->selection_list;
03089     GList *s_current;
03090 
03091     for (s_current = geda_list_get_glist (selection);
03092          s_current != NULL;
03093          s_current = g_list_next (s_current)) {
03094       OBJECT *object = (OBJECT*)s_current->data;
03095       if (object->type == OBJ_TEXT)
03096         o_attrib_toggle_show_name_value (w_current, object, SHOW_NAME);
03097     }
03098 
03099     o_undo_savestate (w_current, UNDO_ALL);
03100   }
03101 }
03102 
03108 DEFINE_I_CALLBACK(attributes_show_value)
03109 {
03110   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
03111   TOPLEVEL *toplevel = w_current->toplevel;
03112 
03113   g_return_if_fail (w_current != NULL);
03114 
03115   /* This is a new addition 3/15 to prevent this from executing
03116    * inside an action */
03117   if (w_current->inside_action) {
03118     return;
03119   }
03120 
03121   i_update_middle_button(w_current, i_callback_attributes_show_value,
03122                          _("ShowV"));
03123 
03124   if (o_select_selected (w_current)) {
03125     SELECTION *selection = toplevel->page_current->selection_list;
03126     GList *s_current;
03127 
03128     for (s_current = geda_list_get_glist (selection);
03129          s_current != NULL;
03130          s_current = g_list_next (s_current)) {
03131       OBJECT *object = (OBJECT*)s_current->data;
03132       if (object->type == OBJ_TEXT)
03133         o_attrib_toggle_show_name_value (w_current, object, SHOW_VALUE);
03134     }
03135 
03136     o_undo_savestate (w_current, UNDO_ALL);
03137   }
03138 }
03139 
03145 DEFINE_I_CALLBACK(attributes_show_both)
03146 {
03147   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
03148   TOPLEVEL *toplevel = w_current->toplevel;
03149 
03150   g_return_if_fail (w_current != NULL);
03151 
03152   /* This is a new addition 3/15 to prevent this from executing
03153    * inside an action */
03154   if (w_current->inside_action) {
03155     return;
03156   }
03157 
03158   i_update_middle_button(w_current, i_callback_attributes_show_both,
03159                          _("ShowB"));
03160 
03161   if (o_select_selected (w_current)) {
03162     SELECTION *selection = toplevel->page_current->selection_list;
03163     GList *s_current;
03164 
03165     for (s_current = geda_list_get_glist (selection);
03166          s_current != NULL;
03167          s_current = g_list_next (s_current)) {
03168       OBJECT *object = (OBJECT*)s_current->data;
03169       if (object->type == OBJ_TEXT)
03170         o_attrib_toggle_show_name_value (w_current, object, SHOW_NAME_VALUE);
03171     }
03172 
03173     o_undo_savestate (w_current, UNDO_ALL);
03174   }
03175 }
03176 
03182 DEFINE_I_CALLBACK(attributes_visibility_toggle)
03183 {
03184   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
03185   TOPLEVEL *toplevel = w_current->toplevel;
03186 
03187   g_return_if_fail (w_current != NULL);
03188 
03189   /* This is a new addition 3/15 to prevent this from executing
03190    * inside an action */
03191   if (w_current->inside_action) {
03192     return;
03193   }
03194 
03195   i_update_middle_button(w_current,
03196                          i_callback_attributes_visibility_toggle,
03197                          _("VisToggle"));
03198 
03199   if (o_select_selected (w_current)) {
03200     SELECTION *selection = toplevel->page_current->selection_list;
03201     GList *s_current;
03202 
03203     for (s_current = geda_list_get_glist (selection);
03204          s_current != NULL;
03205          s_current = g_list_next (s_current)) {
03206       OBJECT *object = (OBJECT*)s_current->data;
03207       if (object->type == OBJ_TEXT)
03208         o_attrib_toggle_visibility (w_current, object);
03209     }
03210 
03211     o_undo_savestate (w_current, UNDO_ALL);
03212   }
03213 }
03214 
03223 DEFINE_I_CALLBACK(script_console)
03224 {
03225   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
03226 
03227   g_return_if_fail (w_current != NULL);
03228   printf(_("Sorry but this is a non-functioning menu option\n"));
03229 }
03230 
03241 DEFINE_I_CALLBACK(options_text_size)
03242 {
03243   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
03244 
03245   g_return_if_fail (w_current != NULL);
03246   text_size_dialog(w_current);
03247 }
03248 
03254 DEFINE_I_CALLBACK(options_snap_size)
03255 {
03256   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
03257 
03258   g_return_if_fail (w_current != NULL);
03259   snap_size_dialog(w_current);
03260 }
03261 
03267 DEFINE_I_CALLBACK(options_scale_up_snap_size)
03268 {
03269   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
03270 
03271   g_return_if_fail (w_current != NULL);
03272 
03273   w_current->snap_size *= 2;
03274   w_current->toplevel->page_current->CHANGED=1;  /* maybe remove those two lines */
03275   o_undo_savestate(w_current, UNDO_ALL);
03276 
03277   i_update_grid_info (w_current);
03278   o_invalidate_all (w_current);
03279 }
03280 
03286 DEFINE_I_CALLBACK(options_scale_down_snap_size)
03287 {
03288   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
03289 
03290   g_return_if_fail (w_current != NULL);
03291 
03292   if (w_current->snap_size % 2 == 0)
03293     w_current->snap_size /= 2;
03294   w_current->toplevel->page_current->CHANGED=1;  /* maybe remove those two lines */
03295   o_undo_savestate(w_current, UNDO_ALL);
03296 
03297   i_update_grid_info (w_current);
03298   o_invalidate_all (w_current);
03299 
03300 }
03301 
03310 DEFINE_I_CALLBACK(options_afeedback)
03311 {
03312   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
03313 
03314   g_return_if_fail (w_current != NULL);
03315 
03316   if (w_current->actionfeedback_mode == BOUNDINGBOX) {
03317     w_current->actionfeedback_mode = OUTLINE;
03318     s_log_message(_("Action feedback mode set to OUTLINE\n"));
03319   } else {
03320     w_current->actionfeedback_mode = BOUNDINGBOX;
03321     s_log_message(_("Action feedback mode set to BOUNDINGBOX\n"));
03322   }
03323   if (w_current->inside_action &&
03324       w_current->toplevel->page_current->place_list != NULL)
03325     o_place_invalidate_rubber (w_current, FALSE);
03326 }
03327 
03333 DEFINE_I_CALLBACK(options_grid)
03334 {
03335   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
03336 
03337   g_return_if_fail (w_current != NULL);
03338 
03339   switch (w_current->grid) {
03340     case GRID_NONE: w_current->grid = GRID_DOTS; break;
03341     case GRID_DOTS: w_current->grid = GRID_MESH; break;
03342     case GRID_MESH: w_current->grid = GRID_NONE; break;
03343   }
03344 
03345   switch (w_current->grid) {
03346     case GRID_NONE: s_log_message (_("Grid OFF\n"));           break;
03347     case GRID_DOTS: s_log_message (_("Dot grid selected\n"));  break;
03348     case GRID_MESH: s_log_message (_("Mesh grid selected\n")); break;
03349   }
03350 
03351   i_update_grid_info (w_current);
03352   o_invalidate_all (w_current);
03353 }
03354 
03360 DEFINE_I_CALLBACK(options_snap)
03361 {
03362   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
03363 
03364   /* toggle to the next snap state */
03365   w_current->snap = (w_current->snap+1) % SNAP_STATE_COUNT;
03366 
03367   switch (w_current->snap) {
03368   case SNAP_OFF:
03369     s_log_message(_("Snap OFF (CAUTION!)\n"));
03370     break;
03371   case SNAP_GRID:
03372     s_log_message(_("Snap ON\n"));
03373     break;
03374   case SNAP_RESNAP:
03375     s_log_message(_("Snap back to the grid (CAUTION!)\n"));
03376     break;
03377   default:
03378     g_critical("options_snap: toplevel->snap out of range: %d\n",
03379                w_current->snap);
03380   }
03381 
03382   i_show_state(w_current, NULL); /* update status on screen */
03383   i_update_grid_info (w_current);
03384 }
03385 
03395 DEFINE_I_CALLBACK(options_rubberband)
03396 {
03397   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
03398 
03399   if (w_current->netconn_rubberband) {
03400     w_current->netconn_rubberband = 0;
03401     s_log_message(_("Rubber band OFF \n"));
03402   } else {
03403     w_current->netconn_rubberband = 1;
03404     s_log_message(_("Rubber band ON\n"));
03405   }
03406 }
03407 
03408 
03414 DEFINE_I_CALLBACK(options_magneticnet)
03415 {
03416   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
03417 
03418   if ((w_current->magneticnet_mode = !w_current->magneticnet_mode)) {
03419     s_log_message(_("magnetic net mode: ON\n"));
03420   }
03421   else {
03422     s_log_message(_("magnetic net mode: OFF\n"));
03423   }
03424   i_show_state(w_current, NULL);
03425 }
03426 
03427 
03433 DEFINE_I_CALLBACK(options_show_log_window)
03434 {
03435   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
03436 
03437   g_return_if_fail (w_current != NULL);
03438   x_log_open ();
03439 }
03440 
03448 DEFINE_I_CALLBACK(misc)
03449 {
03450 }
03451 
03459 DEFINE_I_CALLBACK(misc2)
03460 {
03461 }
03462 
03470 DEFINE_I_CALLBACK(misc3)
03471 {
03472 }
03473 
03483 DEFINE_I_CALLBACK(cancel)
03484 {
03485   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
03486   TOPLEVEL *toplevel = w_current->toplevel;
03487   GValue value = { 0, };
03488 
03489   g_return_if_fail (w_current != NULL);
03490 
03491   if (w_current->event_state == ENDCOMP &&
03492       w_current->cswindow) {
03493     /* user hit escape key when placing components */
03494 
03495     /* Undraw any outline of the place list */
03496     o_place_invalidate_rubber (w_current, FALSE);
03497     w_current->rubber_visible = 0;
03498 
03499     /* De-select the lists in the component selector */
03500     x_compselect_deselect (w_current);
03501 
03502     /* Present the component selector again */
03503     g_value_init (&value, G_TYPE_BOOLEAN);
03504     g_value_set_boolean (&value, FALSE);
03505     g_object_set_property (G_OBJECT(w_current->cswindow), "hidden", &value);
03506   }
03507 
03508   if (w_current->inside_action) {
03509     /* If we're cancelling from a move action, re-wind the
03510      * page contents back to their state before we started */
03511     if (w_current->event_state == MOVE ||
03512         w_current->event_state == ENDMOVE)
03513       o_move_cancel (w_current);
03514 
03515     /* If we're cancelling from a grip action, call the specific cancel
03516      * routine to reset the visibility of the object being modified */
03517     if (w_current->event_state == GRIPS)
03518       o_grips_cancel (w_current);
03519   }
03520 
03521   /* Free the place list and its contents. If we were in a move
03522    * action, the list (refering to objects on the page) would
03523    * already have been cleared in o_move_cancel(), so this is OK. */
03524   s_delete_object_glist(toplevel, toplevel->page_current->place_list);
03525   toplevel->page_current->place_list = NULL;
03526 
03527   /* leave this on for now... but it might have to change */
03528   /* this is problematic since we don't know what the right mode */
03529   /* (when you cancel inside an action) should be */
03530   i_set_state(w_current, SELECT);
03531   i_update_toolbar(w_current);
03532 
03533   /* clear the key guile command-sequence */
03534   g_keys_reset (w_current);
03535 
03536   if (w_current->inside_action) { 
03537      o_invalidate_all (w_current);
03538   }
03539 
03540   w_current->inside_action=0;
03541 }
03542 
03549 DEFINE_I_CALLBACK(help_about)
03550 {
03551   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
03552 
03553   g_return_if_fail (w_current != NULL);
03554   about_dialog(w_current);
03555 }
03556 
03562 DEFINE_I_CALLBACK(help_hotkeys)
03563 {
03564   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
03565 
03566   g_return_if_fail (w_current != NULL);
03567   x_dialog_hotkeys(w_current);
03568 }
03569 
03575 DEFINE_I_CALLBACK(options_show_coord_window)
03576 {
03577   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
03578 
03579   g_return_if_fail (w_current != NULL);
03580   coord_dialog (w_current, 0, 0);
03581 }
03582 
03583 /* these is a special wrapper function which cannot use the above */
03584 /* DEFINE_I_CALLBACK macro */
03585 
03596 gboolean i_callback_close_wm ( GtkWidget *widget, GdkEvent *event, 
03597                        gpointer data ) 
03598 {
03599 
03600   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
03601   g_return_val_if_fail ((w_current != NULL), TRUE);
03602 
03603   x_window_close(w_current);
03604 
03605   /* stop further propagation of the delete_event signal for window: */
03606   /*   - if user has cancelled the close the window should obvioulsy */
03607   /*   not be destroyed */
03608   /*   - otherwise window has already been destroyed, nothing more to */
03609   /*   do */
03610   return TRUE;
03611 }
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines