Index: trunk/src/Makefile.dep =================================================================== --- trunk/src/Makefile.dep (revision 705) +++ trunk/src/Makefile.dep (revision 706) @@ -6,7 +6,7 @@ copy.h create.h crosshair.h data.h draw.h error.h file.h find.h insert.h \ line.h mymem.h misc.h ds.h mirror.h move.h polygon.h rats.h remove.h \ report.h rotate.h rubberband.h search.h select.h set.h thermal.h undo.h \ - rtree.h pcb-printf.h + rtree.h pcb-printf.h plugins.h autoplace.o: autoplace.c ../config.h ../config.manual.h ../config.auto.h \ global.h const.h ../globalconst.h ../config.h macro.h hid.h polyarea.h \ libpcb_fp.h autoplace.h box.h misc.h ds.h mymem.h compat.h data.h draw.h \ @@ -131,6 +131,7 @@ pcb-printf.o: pcb-printf.c ../config.h ../config.manual.h \ ../config.auto.h global.h const.h ../globalconst.h ../config.h macro.h \ hid.h polyarea.h libpcb_fp.h pcb-printf.h +plugins.o: plugins.c plugins.h polygon.o: polygon.c ../config.h ../config.manual.h ../config.auto.h \ global.h const.h ../globalconst.h ../config.h macro.h hid.h polyarea.h \ libpcb_fp.h box.h misc.h ds.h mymem.h create.h crosshair.h data.h draw.h \ @@ -221,7 +222,7 @@ ../config.auto.h global.h const.h ../globalconst.h ../config.h macro.h \ hid.h polyarea.h libpcb_fp.h hid.h hid/common/hidnogui.h \ hid/common/../hidint.h compat.h error.h misc.h global.h ds.h mymem.h \ - portability.h pcb-printf.h hid/common/hidlist.h + portability.h pcb-printf.h plugins.h hid/common/hidlist.h hidnogui.o: hid/common/hidnogui.c ../config.h ../config.manual.h \ ../config.auto.h global.h const.h ../globalconst.h ../config.h macro.h \ hid.h polyarea.h libpcb_fp.h hid.h @@ -262,7 +263,7 @@ global.h const.h ../globalconst.h ../config.h macro.h hid.h polyarea.h \ libpcb_fp.h crosshair.h data.h error.h file.h mymem.h misc.h ds.h \ strflags.h parse_l.h parse_y.h create.h -buildin.o: buildin.c buildin.h +buildin.o: buildin.c plugins.h buildin.h hash.o: 3rd/genht/hash.c htsp.o: 3rd/genht/htsp.c 3rd/genht/htsp.h 3rd/genht/ht.h \ 3rd/genht/ht_inlines.h 3rd/genht/ht.c Index: trunk/src/Makefile.in =================================================================== --- trunk/src/Makefile.in (revision 705) +++ trunk/src/Makefile.in (revision 706) @@ -43,6 +43,7 @@ mymem.o netlist.o pcb-printf.o + plugins.o polygon.o polygon1.o puller.o Index: trunk/src/Makefile.in.mod/gpmi_plugin =================================================================== --- trunk/src/Makefile.in.mod/gpmi_plugin (revision 705) +++ trunk/src/Makefile.in.mod/gpmi_plugin (revision 706) @@ -14,7 +14,7 @@ append /local/pcb/EXEDEPS {pcb-gpmi/gpmi_plugin/gpmi_buildin.a} append /local/pcb/LDFLAGS /target/libs/script/gpmi/ldflags -append /local/pcb/buildin_init {hid_gpmi_init();} +append /local/pcb/buildin_init {hid_gpmi_init(); plugin_register("gpmi", "", NULL, 0); } #append /local/pcb/CFLAGS /target/libs/script/gpmi/cflags #append /local/pcb/LDFLAGS /target/libs/script/gpmi/ldflags Index: trunk/src/action.c =================================================================== --- trunk/src/action.c (revision 705) +++ trunk/src/action.c (revision 706) @@ -70,6 +70,7 @@ #include "rtree.h" #include "macro.h" #include "pcb-printf.h" +#include "plugins.h" #include #include /* rand() */ @@ -8062,6 +8063,61 @@ return 0; } +/* ---------------------------------------------------------------- */ +static const char manageplugins_syntax[] = + "ManagePlugins()\n"; + +static const char manageplugins_help[] = "Manage plugins dialog."; + +static int +ManagePlugins (int argc, char **argv, Coord x, Coord y) +{ + plugin_info_t *i; + int nump = 0, numb = 0; + DynamicStringType str; + + memset(&str, 0, sizeof(str)); + + for(i = plugins; i != NULL; i = i->next) + if (i->dynamic) + nump++; + else + numb++; + + DSAddString(&str, "Plugins loaded:\n"); + if (nump > 0) { + for(i = plugins; i != NULL; i = i->next) { + if (i->dynamic) { + DSAddCharacter(&str, ' '); + DSAddString(&str, i->name); + DSAddCharacter(&str, ' '); + DSAddString(&str, i->path); + DSAddCharacter(&str, '\n'); + } + } + } + else + DSAddString (&str, " (none)\n"); + + DSAddString (&str, "\n\nBuildins:\n"); + if (numb > 0) { + for(i = plugins; i != NULL; i = i->next) { + if (!i->dynamic) { + DSAddCharacter(&str, ' '); + DSAddString(&str, i->name); + DSAddCharacter(&str, '\n'); + } + } + } + else + DSAddString (&str, " (none)\n"); + + DSAddString (&str, "\n\nNOTE: this is the alpha version, can only list plugins/buildins\n"); + gui->report_dialog("Manage plugins", str.Data); + free(str.Data); +} + + /* --------------------------------------------------------------------------- */ HID_Action action_action_list[] = { @@ -8256,6 +8312,9 @@ {"Import", 0, ActionImport, import_help, import_syntax} , + {"ManagePlugins", 0, ManagePlugins, + manageplugins_help, manageplugins_syntax} + , }; REGISTER_ACTIONS (action_action_list) Index: trunk/src/buildin.c.in =================================================================== --- trunk/src/buildin.c.in (revision 705) +++ trunk/src/buildin.c.in (revision 706) @@ -1,5 +1,7 @@ print [@ /**** This file autogenerated by scconfig, do not edit ****/ +#include +#include "plugins.h" #include "buildin.h" void buildin_init(void) { Index: trunk/src/hid/common/hidinit.c =================================================================== --- trunk/src/hid/common/hidinit.c (revision 705) +++ trunk/src/hid/common/hidinit.c (revision 706) @@ -32,6 +32,7 @@ #include "misc.h" #include "portability.h" /* MKDIR() */ #include "pcb-printf.h" +#include "plugins.h" #ifdef HAVE_LIBDMALLOC #include @@ -109,6 +110,7 @@ symv = (void (*)()) sym; symv(); } + plugin_register(basename, path, so, 1); free (symname); } } Index: trunk/src/pcb-gpmi/gpmi_plugin/gpmi_pkg/actions/actions.h =================================================================== --- trunk/src/pcb-gpmi/gpmi_plugin/gpmi_pkg/actions/actions.h (revision 705) +++ trunk/src/pcb-gpmi/gpmi_plugin/gpmi_pkg/actions/actions.h (revision 706) @@ -1,17 +1,52 @@ #include +/* Generated when an action registered by the script is executed. + Arguments: + name: name of the action (as registed using function action_register()) + argc: number of arguments. Arguments can be accessed using function action_arg + x, y: optional coords, if need_xy was not empty at action_register */ gpmi_define_event(ACTE_action)(const char *name, int argc, int x, int y); + +/* Generated right after gui initialization, before the gui main loop. + Arguments: + argc: number of arguments the gui was initialized with. + argv[]: arguments the gui was initialized with - unaccessible for the scripts. */ gpmi_define_event(ACTE_gui_init)(int argc, char **argv); + + +/* Generated right before unloading a script to give the script a chance + to clean up. + Arguments: + conffile: the name of the config file that originally triggered laoding the script, or empty if the script was loaded from the gui. */ gpmi_define_event(ACTE_unload)(const char *conffile); -/* register an action in PCB - will generate event ACTE_action */ +/* Register an action in PCB - when the action is executed, event + ACTE_action is generated with the action name. + Multiple actions can be registered. Any action registered by the script + will trigger an ACTE_event sent to the script. + Arguments: + name: name of the action + need_xy: the question the user is asked when he needs to choose a coordinate; if empty, no coordinate is asked + description: description of the action (for the help) + syntax: syntax of the action (for the help) + Returns 0 on success. + */ int action_register(const char *name, const char *need_xy, const char *description, const char *syntax); -/* extract argument argn for the current action (makes sense only in an ACTE_action event handler */ +/* extract the (argn)th event argument for the current action (makes sense only in an ACTE_action event handler */ const char *action_arg(int argn); -/* call an existing action */ +/* call an existing action using PCB syntax (e.g. foo(1, 2, 3)) + Returns non-zero on error; generally returns value of the action + (which is also non-zero on error). */ int action(const char *cmdline); -/* Create a new menu at the given path in the menu system */ +/* Create a new menu or submenu at path. Missing parents are created + automatically with empty action, mnemonic, hotkey and tooltip. + Arguments: + path: the full path of the new menu + action: this action is executed when the user clicks on the menu + mnemonic: which letter to underline in the menu text (will be the fast-jump-there key once the menu is open) + hotkey: when this key is pressed in the main gui, the action is also triggered; the format is modifiers<Key>letter, where modifiers is Alt, Shift or Ctrl. This is the same syntax that is used in the .res files. + tooltip: short help text */ void create_menu(const char *path, const char *action, const char *mnemonic, const char *hotkey, const char *tooltip);