Index: trunk/src/conf_act.c =================================================================== --- trunk/src/conf_act.c (revision 17797) +++ trunk/src/conf_act.c (revision 17798) @@ -236,43 +236,17 @@ static const char pcb_acth_ChkMode[] = "Return 1 if the currently selected mode is the expected_mode"; static fgw_error_t pcb_act_ChkMode(fgw_arg_t *res, int argc, fgw_arg_t *argv) { -#warning cleanup TODO: convert this to a compile-time hash; or make the toolbar configurable from the menu file - struct { - const char *name; - int mode; - } *m, modes[] = { - {"none", PCB_MODE_NO}, - {"arc", PCB_MODE_ARC}, - {"arrow", PCB_MODE_ARROW}, - {"copy", PCB_MODE_COPY}, - {"insertpoint", PCB_MODE_INSERT_POINT}, - {"line", PCB_MODE_LINE}, - {"lock", PCB_MODE_LOCK}, - {"move", PCB_MODE_MOVE}, - {"pastebuffer", PCB_MODE_PASTE_BUFFER}, - {"polygon", PCB_MODE_POLYGON}, - {"polygonhole", PCB_MODE_POLYGON_HOLE}, - {"rectangle", PCB_MODE_RECTANGLE}, - {"remove", PCB_MODE_REMOVE}, - {"rotate", PCB_MODE_ROTATE}, - {"rubberbandmove", PCB_MODE_RUBBERBAND_MOVE}, - {"text", PCB_MODE_TEXT}, - {"thermal", PCB_MODE_THERMAL}, - {"via", PCB_MODE_VIA}, - {NULL, 0} - }; char *dst; + pcb_toolid_t id; PCB_ACT_CONVARG(1, FGW_STR, ChkMode, dst = argv[1].val.str); - for(m = modes; m->name != NULL; m++) { - if (strcmp(m->name, dst) == 0) { - PCB_ACT_IRES(conf_core.editor.mode == m->mode); - return 0; - } + id = pcb_tool_lookup(dst); + if (id >= 0) { + PCB_ACT_IRES(conf_core.editor.mode == id); + return 0; } - pcb_message(PCB_MSG_ERROR, "Unknown mode in ChkMode(): %s\n", argv[1]); - abort(); + PCB_ACT_IRES(-1); } Index: trunk/src/pcb-menu-default.lht =================================================================== --- trunk/src/pcb-menu-default.lht (revision 17797) +++ trunk/src/pcb-menu-default.lht (revision 17798) @@ -348,14 +348,14 @@ ha:Arc = { checked=ChkMode(arc); li:a={{t;a};{F3};}; action=Mode(Arc); update_on={editor/mode} } ha:Text = { checked=ChkMode(text); li:a={{t;t};{F4};}; action=Mode(Text); update_on={editor/mode} } ha:Rectangle = { checked=ChkMode(rectangle); li:a={{t;r};{F5};}; action=Mode(Rectangle); update_on={editor/mode} } - ha:Polygon = { checked=ChkMode(polygon); li:a={{t;p};{F6};}; action=Mode(Polygon); update_on={editor/mode} } - ha:Polygon Hole = { checked=ChkMode(polygonhole); a={t;h}; action=Mode(PolygonHole); update_on={editor/mode} } - ha:Buffer = { checked=ChkMode(pastebuffer); li:a={{t;b};{F7};}; action=Mode(PasteBuffer); update_on={editor/mode} } + ha:Polygon = { checked=ChkMode(poly); li:a={{t;p};{F6};}; action=Mode(Polygon); update_on={editor/mode} } + ha:Polygon Hole = { checked=ChkMode(polyhole); a={t;h}; action=Mode(PolygonHole); update_on={editor/mode} } + ha:Buffer = { checked=ChkMode(buffer); li:a={{t;b};{F7};}; action=Mode(PasteBuffer); update_on={editor/mode} } ha:Del/Remove = { checked=ChkMode(remove); li:a={{t;d};{F8};}; action=Mode(Remove); update_on={editor/mode} } ha:Rotate = { checked=ChkMode(rotate); li:a={{t;o};{F9};}; action=Mode(Rotate); update_on={editor/mode} } ha:Thermal = { checked=ChkMode(thermal); li:a={{t;e};{F10};}; action=Mode(Thermal); update_on={editor/mode} } ha:Arrow = { checked=ChkMode(arrow); li:a={{t;n};{F11};{space};}; action=Mode(Arrow); update_on={editor/mode} } - ha:Insert Point = { checked=ChkMode(insertpoint); li:a={{t;i};{Insert};}; action=Mode(InsertPoint); update_on={editor/mode} } + ha:Insert Point = { checked=ChkMode(insert); li:a={{t;i};{Insert};}; action=Mode(InsertPoint); update_on={editor/mode} } ha:Move = { checked=ChkMode(move); a={t;m}; action=Mode(Move); update_on={editor/mode} } ha:Copy = { checked=ChkMode(copy); a={t;c}; action=Mode(Copy); update_on={editor/mode} } ha:Lock = { checked=ChkMode(lock); li:a={{t;k};{F12};}; action=Mode(Lock); update_on={editor/mode} }