Index: src/gui_act.c =================================================================== --- src/gui_act.c (revision 1544) +++ src/gui_act.c (revision 1545) @@ -1017,7 +1017,7 @@ /* --------------------------------------------------------------------------- */ -static const char createmenu_syntax[] = "CreateMenu(path | path, action, mnemonic, accel, tooltip)"; +static const char createmenu_syntax[] = "CreateMenu(path | path, action, mnemonic, accel, tooltip, cookie)"; static const char createmenu_help[] = "Creates a new menu, popup (only path specified) or submenu (at least path and action are specified)"; /* %start-doc actions RouteStyle @@ -1032,7 +1032,7 @@ } if (argc > 0) { - gui->create_menu(argv[0], (argc > 1) ? argv[1] : NULL, (argc > 2) ? argv[2] : NULL, (argc > 3) ? argv[3] : NULL, (argc > 4) ? argv[4] : NULL); + gui->create_menu(argv[0], (argc > 1) ? argv[1] : NULL, (argc > 2) ? argv[2] : NULL, (argc > 3) ? argv[3] : NULL, (argc > 4) ? argv[4] : NULL, (argc > 5) ? argv[5] : NULL); return 0; } Index: src/hid.h =================================================================== --- src/hid.h (revision 1544) +++ src/hid.h (revision 1545) @@ -489,9 +489,11 @@ * menu is a / separated path to the new menu (parents are silently created). * The last non-NULL item is the new menu item. * action, mnemonic, accel and tip affect the new menu item. + * Cookie is strdup()'d into the lihata tree and can be used later to search + * and remove menu items that are no longer needed. * If action is NULL, the menu may get submenus. */ - void (*create_menu) (const char *menu, const char *action, const char *mnemonic, const char *accel, const char *tip); + void (*create_menu) (const char *menu, const char *action, const char *mnemonic, const char *accel, const char *tip, const char *cookie); }; /* This function (in the common code) will be called whenever the GUI Index: src/hid_cfg.c =================================================================== --- src/hid_cfg.c (revision 1544) +++ src/hid_cfg.c (revision 1545) @@ -45,6 +45,7 @@ const char *mnemonic; const char *accel; const char *tip; + const char *cookie; int target_level; int err; } create_menu_ctx_t; @@ -76,12 +77,12 @@ psub = hid_cfg_menu_field(cmc->parent, MF_SUBMENU, NULL); if (rel_level == cmc->target_level) { - node = hid_cfg_create_hash_node(psub, name, "dyn", "1", "m", cmc->mnemonic, "a", cmc->accel, "tip", cmc->tip, ((cmc->action != NULL) ? "action": NULL), cmc->action, NULL); + node = hid_cfg_create_hash_node(psub, name, "dyn", "1", "m", "cookie", cmc->cookie, cmc->mnemonic, "a", cmc->accel, "tip", cmc->tip, ((cmc->action != NULL) ? "action": NULL), cmc->action, NULL); if (node != NULL) cmc->err = 0; } else - node = hid_cfg_create_hash_node(psub, name, "dyn", "1", NULL); + node = hid_cfg_create_hash_node(psub, name, "dyn", "1", "cookie", cmc->cookie, NULL); if (node == NULL) return NULL; @@ -100,7 +101,7 @@ return node; } -int hid_cfg_create_menu(hid_cfg_t *hr, const char *path, const char *action, const char *mnemonic, const char *accel, const char *tip, create_menu_widget_t cb, void *cb_ctx) +int hid_cfg_create_menu(hid_cfg_t *hr, const char *path, const char *action, const char *mnemonic, const char *accel, const char *tip, const char *cookie, create_menu_widget_t cb, void *cb_ctx) { const char *name; create_menu_ctx_t cmc; @@ -113,6 +114,7 @@ cmc.mnemonic = mnemonic; cmc.accel = accel; cmc.tip = tip; + cmc.cookie = cookie; cmc.err = -1; /* Allow creating new nodes only under certain main paths that correspond to menus */ Index: src/hid_cfg.h =================================================================== --- src/hid_cfg.h (revision 1544) +++ src/hid_cfg.h (revision 1545) @@ -34,9 +34,10 @@ /* Create a set of resources representing a single menu item If action is NULL, it's a drop-down item that has submenus. The callback is called after the new lihata node is created. + NOTE: unlike other cookies, this cookie is strdup()'d. */ typedef int (*create_menu_widget_t)(void *ctx, const char *path, const char *name, int is_main, lht_node_t *parent, lht_node_t *menu_item); -int hid_cfg_create_menu(hid_cfg_t *hr, const char *path, const char *action, const char *mnemonic, const char *accel, const char *tip, create_menu_widget_t cb, void *cb_ctx); +int hid_cfg_create_menu(hid_cfg_t *hr, const char *path, const char *action, const char *mnemonic, const char *accel, const char *tip, const char *cookie, create_menu_widget_t cb, void *cb_ctx); /* Search and load the menu res for hidname; if not found, and embedded_fallback is not NULL, parse that string instead. Returns NULL on error */ Index: src_plugins/gpmi/pcb-gpmi/gpmi_plugin/gpmi_pkg/actions/actions.c =================================================================== --- src_plugins/gpmi/pcb-gpmi/gpmi_plugin/gpmi_pkg/actions/actions.c (revision 1544) +++ src_plugins/gpmi/pcb-gpmi/gpmi_plugin/gpmi_pkg/actions/actions.c (revision 1545) @@ -97,5 +97,5 @@ void create_menu(const char *path, const char *action, const char *mnemonic, const char *hotkey, const char *tooltip) { - gui->create_menu(path, action, mnemonic, hotkey, tooltip); + gui->create_menu(path, action, mnemonic, hotkey, tooltip, "TODO#2"); } Index: src_plugins/gpmi/pcb-gpmi/gpmi_plugin/gpmi_plugin.c =================================================================== --- src_plugins/gpmi/pcb-gpmi/gpmi_plugin/gpmi_plugin.c (revision 1544) +++ src_plugins/gpmi/pcb-gpmi/gpmi_plugin/gpmi_plugin.c (revision 1545) @@ -31,7 +31,7 @@ hid_gpmi_script_info_t *i; const char *menu = "/main_menu/Plugins/GPMI scripting/Scripts"; - gui->create_menu(menu, "gpmi_scripts()", "S", "Altg", "Manage GPMI scripts"); + gui->create_menu(menu, "gpmi_scripts()", "S", "Altg", "Manage GPMI scripts", gpmi_cookie); ev = gpmi_event_find("ACTE_gui_init", &ev_args); if (ev >= 0) { Index: src_plugins/hid_batch/batch.c =================================================================== --- src_plugins/hid_batch/batch.c (revision 1544) +++ src_plugins/hid_batch/batch.c (revision 1545) @@ -308,7 +308,7 @@ { } -static void batch_create_menu(const char *menu[], const char *action, const char *mnemonic, const char *accel, const char *tip) +static void batch_create_menu(const char *menu[], const char *action, const char *mnemonic, const char *accel, const char *tip, const char *cookie) { } Index: src_plugins/hid_gtk/ghid-main-menu.c =================================================================== --- src_plugins/hid_gtk/ghid-main-menu.c (revision 1544) +++ src_plugins/hid_gtk/ghid-main-menu.c (revision 1545) @@ -440,7 +440,7 @@ } /* Create a new menu by path */ -void ghid_create_menu(const char *menu_path, const char *action, const char *mnemonic, const char *accel, const char *tip) +void ghid_create_menu(const char *menu_path, const char *action, const char *mnemonic, const char *accel, const char *tip, const char *cookie) { - hid_cfg_create_menu(ghid_cfg, menu_path, action, mnemonic, accel, tip, ghid_create_menu_widget, NULL); + hid_cfg_create_menu(ghid_cfg, menu_path, action, mnemonic, accel, tip, cookie, ghid_create_menu_widget, NULL); } Index: src_plugins/hid_gtk/ghid-main-menu.h =================================================================== --- src_plugins/hid_gtk/ghid-main-menu.h (revision 1544) +++ src_plugins/hid_gtk/ghid-main-menu.h (revision 1545) @@ -31,7 +31,7 @@ void ghid_main_menu_install_layer_selector(GHidMainMenu * mm, GHidLayerSelector * ls); void ghid_main_menu_install_route_style_selector(GHidMainMenu * mm, GHidRouteStyleSelector * rss); -void ghid_create_menu(const char *menu, const char *action, const char *mnemonic, const char *accel, const char *tip); +void ghid_create_menu(const char *menu, const char *action, const char *mnemonic, const char *accel, const char *tip, const char *cookie); extern hid_cfg_t *ghid_cfg; Index: src_plugins/hid_lesstif/main.c =================================================================== --- src_plugins/hid_lesstif/main.c (revision 1544) +++ src_plugins/hid_lesstif/main.c (revision 1545) @@ -3757,7 +3757,7 @@ #include "dolists.h" -void lesstif_create_menu(const char *menu, const char *action, const char *mnemonic, const char *accel, const char *tip); +void lesstif_create_menu(const char *menu, const char *action, const char *mnemonic, const char *accel, const char *tip, const char *cookie); pcb_uninit_t hid_hid_lesstif_init() { Index: src_plugins/hid_lesstif/menu.c =================================================================== --- src_plugins/hid_lesstif/menu.c (revision 1544) +++ src_plugins/hid_lesstif/menu.c (revision 1545) @@ -1004,9 +1004,9 @@ } -void lesstif_create_menu(const char *menu_path, const char *action, const char *mnemonic, const char *accel, const char *tip) +void lesstif_create_menu(const char *menu_path, const char *action, const char *mnemonic, const char *accel, const char *tip, const char *cookie) { - hid_cfg_create_menu(lesstif_cfg, menu_path, action, mnemonic, accel, tip, lesstif_create_menu_widget, NULL); + hid_cfg_create_menu(lesstif_cfg, menu_path, action, mnemonic, accel, tip, cookie, lesstif_create_menu_widget, NULL); }