diff options
| author | Gerd Moellmann | 2000-01-27 15:32:21 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2000-01-27 15:32:21 +0000 |
| commit | 3e703b25fb6c3fc017f806da130bef4c093f5f17 (patch) | |
| tree | 97c09ce3979e1877a0c79281906c872ca1111482 /src | |
| parent | f9a70a31718a329d98272bbba17184c295994023 (diff) | |
| download | emacs-3e703b25fb6c3fc017f806da130bef4c093f5f17.tar.gz emacs-3e703b25fb6c3fc017f806da130bef4c093f5f17.zip | |
(xmenu_show) [!USE_X_TOOLKIT]: Pass help to
XMenuAddSelection. Pass help callback to XMenuActivate.
(menu_help_callback) [!USE_X_TOOLKIT]: New function.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xmenu.c | 51 |
1 files changed, 47 insertions, 4 deletions
diff --git a/src/xmenu.c b/src/xmenu.c index ed48e79e1ed..f0030006fa8 100644 --- a/src/xmenu.c +++ b/src/xmenu.c | |||
| @@ -2478,6 +2478,41 @@ xdialog_show (f, keymaps, title, error) | |||
| 2478 | } | 2478 | } |
| 2479 | #else /* not USE_X_TOOLKIT */ | 2479 | #else /* not USE_X_TOOLKIT */ |
| 2480 | 2480 | ||
| 2481 | /* The frame of the last activated non-toolkit menu bar. | ||
| 2482 | Used to generate menu help events. */ | ||
| 2483 | |||
| 2484 | static struct frame *menu_help_frame; | ||
| 2485 | |||
| 2486 | |||
| 2487 | /* Show help HELP_STRING, or clear help if HELP_STRING is null. This | ||
| 2488 | cannot be done with generating a HELP_EVENT because XMenuActivate | ||
| 2489 | contains a loop that doesn't let Emacs process keyboard events. */ | ||
| 2490 | |||
| 2491 | static void | ||
| 2492 | menu_help_callback (help_string) | ||
| 2493 | char *help_string; | ||
| 2494 | { | ||
| 2495 | Lisp_Object msg; | ||
| 2496 | extern Lisp_Object Vshow_help_function; | ||
| 2497 | struct gcpro gcpro1; | ||
| 2498 | |||
| 2499 | msg = help_string ? build_string (help_string) : Qnil; | ||
| 2500 | GCPRO1 (msg); | ||
| 2501 | |||
| 2502 | if (!NILP (Vshow_help_function)) | ||
| 2503 | call1 (Vshow_help_function, msg); | ||
| 2504 | else if (!MINI_WINDOW_P (XWINDOW (selected_window))) | ||
| 2505 | { | ||
| 2506 | if (STRINGP (msg)) | ||
| 2507 | message3_nolog (msg, XSTRING (msg)->size, STRING_MULTIBYTE (msg)); | ||
| 2508 | else | ||
| 2509 | message (0); | ||
| 2510 | } | ||
| 2511 | |||
| 2512 | UNGCPRO; | ||
| 2513 | } | ||
| 2514 | |||
| 2515 | |||
| 2481 | static Lisp_Object | 2516 | static Lisp_Object |
| 2482 | xmenu_show (f, x, y, for_click, keymaps, title, error) | 2517 | xmenu_show (f, x, y, for_click, keymaps, title, error) |
| 2483 | FRAME_PTR f; | 2518 | FRAME_PTR f; |
| @@ -2609,13 +2644,17 @@ xmenu_show (f, x, y, for_click, keymaps, title, error) | |||
| 2609 | else | 2644 | else |
| 2610 | { | 2645 | { |
| 2611 | /* Create a new item within current pane. */ | 2646 | /* Create a new item within current pane. */ |
| 2612 | Lisp_Object item_name, enable, descrip; | 2647 | Lisp_Object item_name, enable, descrip, help; |
| 2613 | unsigned char *item_data; | 2648 | unsigned char *item_data; |
| 2649 | char *help_string; | ||
| 2614 | 2650 | ||
| 2615 | item_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_NAME]; | 2651 | item_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_NAME]; |
| 2616 | enable = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_ENABLE]; | 2652 | enable = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_ENABLE]; |
| 2617 | descrip | 2653 | descrip |
| 2618 | = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY]; | 2654 | = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY]; |
| 2655 | help = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_HELP]; | ||
| 2656 | help_string = STRINGP (help) ? XSTRING (help)->data : NULL; | ||
| 2657 | |||
| 2619 | if (!NILP (descrip)) | 2658 | if (!NILP (descrip)) |
| 2620 | { | 2659 | { |
| 2621 | int gap = maxwidth - STRING_BYTES (XSTRING (item_name)); | 2660 | int gap = maxwidth - STRING_BYTES (XSTRING (item_name)); |
| @@ -2645,7 +2684,7 @@ xmenu_show (f, x, y, for_click, keymaps, title, error) | |||
| 2645 | 2684 | ||
| 2646 | if (XMenuAddSelection (FRAME_X_DISPLAY (f), | 2685 | if (XMenuAddSelection (FRAME_X_DISPLAY (f), |
| 2647 | menu, lpane, 0, item_data, | 2686 | menu, lpane, 0, item_data, |
| 2648 | !NILP (enable)) | 2687 | !NILP (enable), help_string) |
| 2649 | == XM_FAILURE) | 2688 | == XM_FAILURE) |
| 2650 | { | 2689 | { |
| 2651 | XMenuDestroy (FRAME_X_DISPLAY (f), menu); | 2690 | XMenuDestroy (FRAME_X_DISPLAY (f), menu); |
| @@ -2684,9 +2723,13 @@ xmenu_show (f, x, y, for_click, keymaps, title, error) | |||
| 2684 | XMenuSetAEQ (menu, TRUE); | 2723 | XMenuSetAEQ (menu, TRUE); |
| 2685 | XMenuSetFreeze (menu, TRUE); | 2724 | XMenuSetFreeze (menu, TRUE); |
| 2686 | pane = selidx = 0; | 2725 | pane = selidx = 0; |
| 2687 | 2726 | ||
| 2727 | /* Help display under X won't work because XMenuActivate contains | ||
| 2728 | a loop that doesn't give Emacs a chance to process it. */ | ||
| 2729 | menu_help_frame = f; | ||
| 2688 | status = XMenuActivate (FRAME_X_DISPLAY (f), menu, &pane, &selidx, | 2730 | status = XMenuActivate (FRAME_X_DISPLAY (f), menu, &pane, &selidx, |
| 2689 | x, y, ButtonReleaseMask, &datap); | 2731 | x, y, ButtonReleaseMask, &datap, |
| 2732 | menu_help_callback); | ||
| 2690 | 2733 | ||
| 2691 | 2734 | ||
| 2692 | #ifdef HAVE_X_WINDOWS | 2735 | #ifdef HAVE_X_WINDOWS |