Index: trunk/src/board.c =================================================================== --- trunk/src/board.c (revision 5450) +++ trunk/src/board.c (revision 5451) @@ -34,6 +34,7 @@ #include "rtree.h" #include "undo.h" #include "draw.h" +#include "event.h" pcb_board_t *PCB; @@ -222,8 +223,7 @@ { free(PCB->Name); PCB->Name = Name; - if (pcb_gui != NULL) - pcb_hid_action("PCBChanged"); + pcb_board_changed(0); return (pcb_true); } @@ -244,8 +244,7 @@ else pcb_crosshair_set_range(0, 0, Width, Height); - if (pcb_gui != NULL) - pcb_hid_action("PCBChanged"); + pcb_board_changed(0); } void pcb_board_remove(pcb_board_t *Ptr) @@ -318,3 +317,8 @@ PCB->Changed = New; } + +void pcb_board_changed(int reverted) +{ + pcb_event(PCB_EVENT_BOARD_CHANGED, "i", reverted); +} Index: trunk/src/board.h =================================================================== --- trunk/src/board.h (revision 5450) +++ trunk/src/board.h (revision 5451) @@ -173,5 +173,6 @@ /* sets or resets changed flag and redraws status */ void pcb_board_set_changed_flag(pcb_bool New); +void pcb_board_changed(int reverted); #endif Index: trunk/src/event.h =================================================================== --- trunk/src/event.h (revision 5450) +++ trunk/src/event.h (revision 5451) @@ -33,6 +33,8 @@ PCB_EVENT_LOAD_PRE, /* called before loading a new design */ PCB_EVENT_LOAD_POST, /* called after loading a new design, whether it was successful or not */ + PCB_EVENT_BOARD_CHANGED, /* called after the board being edited got replaced (used to be the PCBChanged action) */ + PCB_EVENT_RUBBER_RESET, /* rubber band: reset attached */ PCB_EVENT_RUBBER_REMOVE_ELEMENT, /* rubber band: removed an element with rubber bands attached */ PCB_EVENT_RUBBER_MOVE, /* rubber band: object moved */ Index: trunk/src/file_act.c =================================================================== --- trunk/src/file_act.c (revision 5450) +++ trunk/src/file_act.c (revision 5451) @@ -200,9 +200,7 @@ pcb_crosshair_set_range(0, 0, PCB->MaxWidth, PCB->MaxHeight); pcb_center_display(PCB->MaxWidth / 2, PCB->MaxHeight / 2); pcb_redraw(); - - if (pcb_gui != NULL) - pcb_hid_action("PCBChanged"); + pcb_board_changed(0); pcb_notify_crosshair_change(pcb_true); return 0; } Index: trunk/src/gui_act.c =================================================================== --- trunk/src/gui_act.c (revision 5450) +++ trunk/src/gui_act.c (revision 5451) @@ -1258,8 +1258,18 @@ return 0; } +static const char pcb_acts_PCBChanged[] = "PCBChanged([revert])"; +static const char pcb_acth_PCBChanged[] = + "Tells the GUI that the whole PCB has changed. The optional \"revert\"" + "parameter can be used as a hint to the GUI that the same design is being" + "reloaded, and that it might keep some viewport settings"; +static int pcb_act_PCBChanged(int argc, const char **argv, pcb_coord_t x, pcb_coord_t y) +{ + const char *rv = argv == NULL ? NULL : argv[0]; + pcb_board_changed((rv != NULL) && (strcasecmp(rv, "revert") == 0)); + return 0; +} - pcb_hid_action_t gui_action_list[] = { {"Display", 0, pcb_act_Display, pcb_acth_Display, pcb_acts_Display} @@ -1267,7 +1277,8 @@ {"CycleDrag", 0, pcb_act_CycleDrag, pcb_acth_CycleDrag, pcb_acts_CycleDrag} , - {"pcb_act_FullScreen", 0, pcb_act_FullScreen, pcb_acth_FullScreen, pcb_acts_FullScreen} + {"FullScreen", 0, pcb_act_FullScreen, + pcb_acth_FullScreen, pcb_acts_FullScreen} , {"MarkCrosshair", 0, pcb_act_MarkCrosshair, pcb_acth_MarkCrosshair, pcb_acts_MarkCrosshair} @@ -1295,6 +1306,9 @@ , {"SwitchHID", 0, pcb_act_SwitchHID, pcb_acth_SwitchHID, pcb_acts_SwitchHID} + , + {"PCBChanged", 0, pcb_act_PCBChanged, + pcb_acth_PCBChanged, pcb_acts_PCBChanged} }; PCB_REGISTER_ACTIONS(gui_action_list, NULL) Index: trunk/src/hid.h =================================================================== --- trunk/src/hid.h (revision 5450) +++ trunk/src/hid.h (revision 5451) @@ -95,7 +95,6 @@ /* Note that PCB expects the gui to provide the following actions: - PCBChanged(); RouteStylesChanged() NetlistChanged() (but core should call "void NetlistChanged(int);" in netlist.c) LayersChanged() Index: trunk/src/hid_actions.c =================================================================== --- trunk/src/hid_actions.c (revision 5450) +++ trunk/src/hid_actions.c (revision 5451) @@ -463,19 +463,6 @@ %end-doc */ - -static const char pcbchanged_syntax[] = "PCBChanged([revert])"; -static const char pcbchanged_help[] = - "Tells the GUI that the whole PCB has changed. The optional \"revert\"" - "parameter can be used as a hint to the GUI that the same design is being" - "reloaded, and that it might keep some viewport settings"; - -/* %start-doc actions PCBChanged - -@hidaction - -%end-doc */ - static const char routestyleschanged_syntax[] = "RouteStylesChanged()"; static const char routestyleschanged_help[] = "Tells the GUI that the routing styles have changed."; Index: trunk/src/plug_io.c =================================================================== --- trunk/src/plug_io.c (revision 5450) +++ trunk/src/plug_io.c (revision 5451) @@ -282,7 +282,7 @@ * if successful, update some other stuff * * If revert is pcb_true, we pass "revert" as a parameter - * to the HID's PCBChanged action. + * to the pcb changed event. */ static int real_load_pcb(const char *Filename, const char *fmt, pcb_bool revert, pcb_bool require_font, int how) { @@ -358,12 +358,8 @@ if (pcb_hid_get_flag("GetStyle()") < 0) pcb_use_route_style_idx(&PCB->RouteStyle, 0); - if (((how == 0) || (revert)) && (pcb_gui != NULL)) { - if (revert) - pcb_hid_actionl("PCBChanged", "revert", NULL); - else - pcb_hid_action("PCBChanged"); - } + if ((how == 0) || (revert)) + pcb_board_changed(revert); #ifdef DEBUG end = clock(); @@ -384,8 +380,7 @@ } } - if (pcb_gui != NULL) - pcb_hid_action("PCBChanged"); + pcb_board_changed(0); /* release unused memory */ pcb_board_remove(newPCB); Index: trunk/src_plugins/hid_batch/batch.c =================================================================== --- trunk/src_plugins/hid_batch/batch.c (revision 5450) +++ trunk/src_plugins/hid_batch/batch.c (revision 5451) @@ -12,6 +12,7 @@ #include "pcb-printf.h" #include "plugins.h" #include "compat_misc.h" +#include "event.h" #include "hid_draw_helpers.h" #include "hid_nogui.h" @@ -42,8 +43,11 @@ static void hid_batch_uninit(void) { pcb_hid_remove_actions_by_cookie(batch_cookie); - if (prompt != NULL) + pcb_event_unbind_allcookie(batch_cookie); + if (prompt != NULL) { free(prompt); + prompt = NULL; + } } static int nop(int argc, const char **argv, pcb_coord_t x, pcb_coord_t y) @@ -51,7 +55,7 @@ return 0; } -static int PCBChanged(int argc, const char **argv, pcb_coord_t x, pcb_coord_t y) +static void ev_pcb_changed(void *user_data, int argc, pcb_event_arg_t argv[]) { if (prompt != NULL) free(prompt); @@ -66,7 +70,6 @@ } else prompt = pcb_strdup("no-board"); - return 0; } static int help(int argc, const char **argv, pcb_coord_t x, pcb_coord_t y) @@ -98,8 +101,6 @@ } pcb_hid_action_t batch_action_list[] = { - {"PCBChanged", 0, PCBChanged} - , {"RouteStylesChanged", 0, nop} , {"NetlistChanged", 0, nop} @@ -339,6 +340,7 @@ static pcb_hid_t batch_hid; + pcb_uninit_t hid_hid_batch_init() { memset(&batch_hid, 0, sizeof(pcb_hid_t)); @@ -393,9 +395,10 @@ batch_hid.propedit_add_value = batch_propedit_add_value; batch_hid.propedit_add_stat = batch_propedit_add_stat; + pcb_event_bind(PCB_EVENT_BOARD_CHANGED, ev_pcb_changed, NULL, batch_cookie); pcb_hid_register_hid(&batch_hid); - return NULL; + return hid_batch_uninit; } static void batch_begin(void) Index: trunk/src_plugins/hid_gtk/gtkhid-main.c =================================================================== --- trunk/src_plugins/hid_gtk/gtkhid-main.c (revision 5450) +++ trunk/src_plugins/hid_gtk/gtkhid-main.c (revision 5451) @@ -1079,16 +1079,16 @@ /* ---------------------------------------------------------------------- */ -int PCBChanged(int argc, const char **argv, pcb_coord_t x, pcb_coord_t y) +static void ev_pcb_changed(void *user_data, int argc, pcb_event_arg_t argv[]) { - if (!ghidgui) - return 0; + if ((!ghidgui) || (!gtkhid_active)) + return; if (PCB != NULL) ghid_window_set_name_label(PCB->Name); if (!gport->pixmap) - return 0; + return; if (ghidgui->route_style_selector) { ghid_route_style_selector_empty(GHID_ROUTE_STYLE_SELECTOR(ghidgui->route_style_selector)); @@ -1099,7 +1099,6 @@ ghid_port_ranges_scale(); ghid_zoom_view_fit(); ghid_sync_with_new_layout(); - return 0; } /* ---------------------------------------------------------------------- */ @@ -1971,8 +1970,6 @@ , {"Pan", 0, PanAction, pan_help, pan_syntax} , - {"PCBChanged", 0, PCBChanged} - , {"PointCursor", 0, PointCursor} , {"Popup", 0, Popup, popup_help, popup_syntax} @@ -2159,6 +2156,7 @@ pcb_event_bind(PCB_EVENT_SAVE_PRE, ghid_conf_save_pre_wgeo, NULL, ghid_cookie); pcb_event_bind(PCB_EVENT_LOAD_POST, ghid_conf_load_post_wgeo, NULL, ghid_cookie); + pcb_event_bind(PCB_EVENT_BOARD_CHANGED, ev_pcb_changed, NULL, ghid_cookie); return hid_hid_gtk_uninit; } Index: trunk/src_plugins/hid_gtk/gui-output-events.c =================================================================== --- trunk/src_plugins/hid_gtk/gui-output-events.c (revision 5450) +++ trunk/src_plugins/hid_gtk/gui-output-events.c (revision 5451) @@ -278,7 +278,7 @@ gdk_color_white(gport->colormap, &gport->offlimits_color); first_time_done = TRUE; ghid_drawing_area_configure_hook(out); - PCBChanged(0, NULL, 0, 0); + pcb_board_changed(0); } else { ghid_drawing_area_configure_hook(out); Index: trunk/src_plugins/hid_gtk/gui.h =================================================================== --- trunk/src_plugins/hid_gtk/gui.h (revision 5450) +++ trunk/src_plugins/hid_gtk/gui.h (revision 5451) @@ -446,11 +446,8 @@ /* gtkhid-main.c */ void ghid_pan_view_rel(pcb_coord_t dx, pcb_coord_t dy); void ghid_get_coords(const char *msg, pcb_coord_t * x, pcb_coord_t * y); -gint PCBChanged(int argc, const char **argv, pcb_coord_t x, pcb_coord_t y); - - extern GdkPixmap *XC_hand_source, *XC_hand_mask; extern GdkPixmap *XC_lock_source, *XC_lock_mask; extern GdkPixmap *XC_clock_source, *XC_clock_mask; Index: trunk/src_plugins/hid_lesstif/main.c =================================================================== --- trunk/src_plugins/hid_lesstif/main.c (revision 5450) +++ trunk/src_plugins/hid_lesstif/main.c (revision 5451) @@ -334,10 +334,10 @@ return 0; } -static int PCBChanged(int argc, const char **argv, pcb_coord_t x, pcb_coord_t y) +static void ev_pcb_changed(void *user_data, int argc, pcb_event_arg_t argv[]) { if (work_area == 0) - return 0; + return; /*pcb_printf("PCB Changed! %$mD\n", PCB->MaxWidth, PCB->MaxHeight); */ stdarg_n = 0; stdarg(XmNminimum, 0); @@ -366,7 +366,7 @@ stdarg(XmNtitle, cp ? cp + 1 : PCB->Filename); XtSetValues(appwidget, stdarg_args, stdarg_n); } - return 0; + return; } @@ -870,9 +870,6 @@ } pcb_hid_action_t lesstif_main_action_list[] = { - {"PCBChanged", 0, PCBChanged, - pcbchanged_help, pcbchanged_syntax} - , {"SetUnits", 0, SetUnits, setunits_help, setunits_syntax} , @@ -1850,7 +1847,7 @@ XtDispatchEvent(&e); } - PCBChanged(0, 0, 0, 0); + pcb_board_changed(0); lesstif_menubar = menu; pcb_event(PCB_EVENT_GUI_INIT, NULL); @@ -3760,6 +3757,11 @@ void lesstif_create_menu(const char *menu, const char *action, const char *mnemonic, const char *accel, const char *tip, const char *cookie); +static void hid_lesstif_uninit(void) +{ + pcb_event_unbind_allcookie(lesstif_cookie); +} + pcb_uninit_t hid_hid_lesstif_init() { memset(&lesstif_hid, 0, sizeof(pcb_hid_t)); @@ -3831,9 +3833,11 @@ lesstif_hid.create_menu = lesstif_create_menu; lesstif_hid.usage = lesstif_usage; + pcb_event_bind(PCB_EVENT_BOARD_CHANGED, ev_pcb_changed, NULL, lesstif_cookie); + pcb_hid_register_hid(&lesstif_hid); - return NULL; + return hid_lesstif_uninit; } static void lesstif_begin(void) Index: trunk/src_plugins/hid_remote/remote.c =================================================================== --- trunk/src_plugins/hid_remote/remote.c (revision 5450) +++ trunk/src_plugins/hid_remote/remote.c (revision 5451) @@ -40,9 +40,8 @@ return 0; } -static int PCBChanged(int argc, const char **argv, pcb_coord_t x, pcb_coord_t y) +static void ev_pcb_changed(void *user_data, int argc, pcb_event_arg_t argv[]) { - return 0; } static int help(int argc, const char **argv, pcb_coord_t x, pcb_coord_t y) @@ -388,6 +387,7 @@ static void hid_hid_remote_uninit() { pcb_hid_remove_actions_by_cookie(remote_cookie); + pcb_event_unbind_allcookie(batch_cookie); } pcb_uninit_t hid_hid_remote_init() @@ -448,6 +448,7 @@ pcb_hid_register_hid(&remote_hid); + pcb_event_bind(PCB_EVENT_BOARD_CHANGED, ev_pcb_changed, NULL, remote_cookie); return hid_hid_remote_uninit; }