diff options
| author | Dmitry Antipov | 2014-06-02 22:01:21 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2014-06-02 22:01:21 +0400 |
| commit | 5668fb88bf3731d39c4e958c8e79a549f789ce1e (patch) | |
| tree | b0d3fd3555fca3b34c47b803a633da2f36d31165 /src/w32menu.c | |
| parent | da11196a248b530c3b3a8329497d71332f8c71a3 (diff) | |
| download | emacs-5668fb88bf3731d39c4e958c8e79a549f789ce1e.tar.gz emacs-5668fb88bf3731d39c4e958c8e79a549f789ce1e.zip | |
Use common memory management functions for lwlib and refactor users.
* lwlib/lwlib.h (widget_value): Do not maintain a free list any more.
(malloc_widget_value, free_widget_value): Remove prototypes.
* lwlib/lwlib.c (malloc_widget_value, free_widget_value):
(widget_value_free_list, malloc_cpt): Remove.
(free_widget_value_tree, copy_widget_value_tree): Adjust users.
* src/menu.h (xmalloc_widget_value): Replaced by ...
(make_widget_value): ... new prototype.
* src/menu.c (xmalloc_widget_value): Replaced by ...
(make_widget_value): ... new function.
(free_menubar_widget_value_tree, digest_single_submenu): Adjust users.
* src/gtkutil.c (malloc_widget_value, free_widget_value):
(widget_value_free_list, malloc_cpt): Remove old lwlib-compatible code.
* src/keyboard.h (enum button_type, struct _widget_value):
* src/gtkutil.h, src/nsgui.h, src/w32gui.h (malloc_widget_value):
(free_widget_value): Likewise.
* src/nsmenu.m (ns_update_menubar, ns_menu_show):
* src/w32menu.c (set_frame_menubar, w32_menu_show, w32_dialog_show):
* src/xmenu.c (set_frame_menubar, xmenu_show, x_dialog_show): Adjust users.
* src/xterm.h (XtParent) [USE_GTK]: Remove unused macro.
Diffstat (limited to 'src/w32menu.c')
| -rw-r--r-- | src/w32menu.c | 69 |
1 files changed, 15 insertions, 54 deletions
diff --git a/src/w32menu.c b/src/w32menu.c index 2c69fc78053..36b06bafad2 100644 --- a/src/w32menu.c +++ b/src/w32menu.c | |||
| @@ -376,12 +376,8 @@ set_frame_menubar (struct frame *f, bool first_time, bool deep_p) | |||
| 376 | /* Convert menu_items into widget_value trees | 376 | /* Convert menu_items into widget_value trees |
| 377 | to display the menu. This cannot evaluate Lisp code. */ | 377 | to display the menu. This cannot evaluate Lisp code. */ |
| 378 | 378 | ||
| 379 | wv = xmalloc_widget_value (); | 379 | wv = make_widget_value ("menubar", NULL, true, Qnil); |
| 380 | wv->name = "menubar"; | ||
| 381 | wv->value = 0; | ||
| 382 | wv->enabled = 1; | ||
| 383 | wv->button_type = BUTTON_TYPE_NONE; | 380 | wv->button_type = BUTTON_TYPE_NONE; |
| 384 | wv->help = Qnil; | ||
| 385 | first_wv = wv; | 381 | first_wv = wv; |
| 386 | 382 | ||
| 387 | for (i = 0; i < last_i; i += 4) | 383 | for (i = 0; i < last_i; i += 4) |
| @@ -444,12 +440,8 @@ set_frame_menubar (struct frame *f, bool first_time, bool deep_p) | |||
| 444 | /* Make a widget-value tree containing | 440 | /* Make a widget-value tree containing |
| 445 | just the top level menu bar strings. */ | 441 | just the top level menu bar strings. */ |
| 446 | 442 | ||
| 447 | wv = xmalloc_widget_value (); | 443 | wv = make_widget_value ("menubar", NULL, true, Qnil); |
| 448 | wv->name = "menubar"; | ||
| 449 | wv->value = 0; | ||
| 450 | wv->enabled = 1; | ||
| 451 | wv->button_type = BUTTON_TYPE_NONE; | 444 | wv->button_type = BUTTON_TYPE_NONE; |
| 452 | wv->help = Qnil; | ||
| 453 | first_wv = wv; | 445 | first_wv = wv; |
| 454 | 446 | ||
| 455 | items = FRAME_MENU_BAR_ITEMS (f); | 447 | items = FRAME_MENU_BAR_ITEMS (f); |
| @@ -461,12 +453,8 @@ set_frame_menubar (struct frame *f, bool first_time, bool deep_p) | |||
| 461 | if (NILP (string)) | 453 | if (NILP (string)) |
| 462 | break; | 454 | break; |
| 463 | 455 | ||
| 464 | wv = xmalloc_widget_value (); | 456 | wv = make_widget_value (SSDATA (string), NULL, true, Qnil); |
| 465 | wv->name = SSDATA (string); | ||
| 466 | wv->value = 0; | ||
| 467 | wv->enabled = 1; | ||
| 468 | wv->button_type = BUTTON_TYPE_NONE; | 457 | wv->button_type = BUTTON_TYPE_NONE; |
| 469 | wv->help = Qnil; | ||
| 470 | /* This prevents lwlib from assuming this | 458 | /* This prevents lwlib from assuming this |
| 471 | menu item is really supposed to be empty. */ | 459 | menu item is really supposed to be empty. */ |
| 472 | /* The EMACS_INT cast avoids a warning. | 460 | /* The EMACS_INT cast avoids a warning. |
| @@ -600,12 +588,8 @@ w32_menu_show (struct frame *f, int x, int y, int for_click, int keymaps, | |||
| 600 | 588 | ||
| 601 | /* Create a tree of widget_value objects | 589 | /* Create a tree of widget_value objects |
| 602 | representing the panes and their items. */ | 590 | representing the panes and their items. */ |
| 603 | wv = xmalloc_widget_value (); | 591 | wv = make_widget_value ("menu", NULL, true, Qnil); |
| 604 | wv->name = "menu"; | ||
| 605 | wv->value = 0; | ||
| 606 | wv->enabled = 1; | ||
| 607 | wv->button_type = BUTTON_TYPE_NONE; | 592 | wv->button_type = BUTTON_TYPE_NONE; |
| 608 | wv->help = Qnil; | ||
| 609 | first_wv = wv; | 593 | first_wv = wv; |
| 610 | first_pane = 1; | 594 | first_pane = 1; |
| 611 | 595 | ||
| @@ -665,18 +649,14 @@ w32_menu_show (struct frame *f, int x, int y, int for_click, int keymaps, | |||
| 665 | with its items as a submenu beneath it. */ | 649 | with its items as a submenu beneath it. */ |
| 666 | if (!keymaps && strcmp (pane_string, "")) | 650 | if (!keymaps && strcmp (pane_string, "")) |
| 667 | { | 651 | { |
| 668 | wv = xmalloc_widget_value (); | 652 | wv = make_widget_value (pane_string, NULL, true, Qnil); |
| 669 | if (save_wv) | 653 | if (save_wv) |
| 670 | save_wv->next = wv; | 654 | save_wv->next = wv; |
| 671 | else | 655 | else |
| 672 | first_wv->contents = wv; | 656 | first_wv->contents = wv; |
| 673 | wv->name = pane_string; | ||
| 674 | if (keymaps && !NILP (prefix)) | 657 | if (keymaps && !NILP (prefix)) |
| 675 | wv->name++; | 658 | wv->name++; |
| 676 | wv->value = 0; | ||
| 677 | wv->enabled = 1; | ||
| 678 | wv->button_type = BUTTON_TYPE_NONE; | 659 | wv->button_type = BUTTON_TYPE_NONE; |
| 679 | wv->help = Qnil; | ||
| 680 | save_wv = wv; | 660 | save_wv = wv; |
| 681 | prev_wv = 0; | 661 | prev_wv = 0; |
| 682 | } | 662 | } |
| @@ -717,19 +697,17 @@ w32_menu_show (struct frame *f, int x, int y, int for_click, int keymaps, | |||
| 717 | ASET (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY, descrip); | 697 | ASET (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY, descrip); |
| 718 | } | 698 | } |
| 719 | 699 | ||
| 720 | wv = xmalloc_widget_value (); | 700 | wv = make_widget_value (SSDATA (item_name), NULL, !NILP (enabled), |
| 701 | STRINGP (help) ? help : Qnil); | ||
| 721 | if (prev_wv) | 702 | if (prev_wv) |
| 722 | prev_wv->next = wv; | 703 | prev_wv->next = wv; |
| 723 | else | 704 | else |
| 724 | save_wv->contents = wv; | 705 | save_wv->contents = wv; |
| 725 | wv->name = SSDATA (item_name); | ||
| 726 | if (!NILP (descrip)) | 706 | if (!NILP (descrip)) |
| 727 | wv->key = SSDATA (descrip); | 707 | wv->key = SSDATA (descrip); |
| 728 | wv->value = 0; | ||
| 729 | /* Use the contents index as call_data, since we are | 708 | /* Use the contents index as call_data, since we are |
| 730 | restricted to 16-bits. */ | 709 | restricted to 16-bits. */ |
| 731 | wv->call_data = !NILP (def) ? (void *) (EMACS_INT) i : 0; | 710 | wv->call_data = !NILP (def) ? (void *) (EMACS_INT) i : 0; |
| 732 | wv->enabled = !NILP (enable); | ||
| 733 | 711 | ||
| 734 | if (NILP (type)) | 712 | if (NILP (type)) |
| 735 | wv->button_type = BUTTON_TYPE_NONE; | 713 | wv->button_type = BUTTON_TYPE_NONE; |
| @@ -742,11 +720,6 @@ w32_menu_show (struct frame *f, int x, int y, int for_click, int keymaps, | |||
| 742 | 720 | ||
| 743 | wv->selected = !NILP (selected); | 721 | wv->selected = !NILP (selected); |
| 744 | 722 | ||
| 745 | if (!STRINGP (help)) | ||
| 746 | help = Qnil; | ||
| 747 | |||
| 748 | wv->help = help; | ||
| 749 | |||
| 750 | prev_wv = wv; | 723 | prev_wv = wv; |
| 751 | 724 | ||
| 752 | i += MENU_ITEMS_ITEM_LENGTH; | 725 | i += MENU_ITEMS_ITEM_LENGTH; |
| @@ -756,25 +729,21 @@ w32_menu_show (struct frame *f, int x, int y, int for_click, int keymaps, | |||
| 756 | /* Deal with the title, if it is non-nil. */ | 729 | /* Deal with the title, if it is non-nil. */ |
| 757 | if (!NILP (title)) | 730 | if (!NILP (title)) |
| 758 | { | 731 | { |
| 759 | widget_value *wv_title = xmalloc_widget_value (); | 732 | widget_value *wv_title; |
| 760 | widget_value *wv_sep = xmalloc_widget_value (); | 733 | widget_value *wv_sep = make_widget_value ("--", NULL, false, Qnil); |
| 761 | 734 | ||
| 762 | /* Maybe replace this separator with a bitmap or owner-draw item | 735 | /* Maybe replace this separator with a bitmap or owner-draw item |
| 763 | so that it looks better. Having two separators looks odd. */ | 736 | so that it looks better. Having two separators looks odd. */ |
| 764 | wv_sep->name = "--"; | ||
| 765 | wv_sep->next = first_wv->contents; | 737 | wv_sep->next = first_wv->contents; |
| 766 | wv_sep->help = Qnil; | ||
| 767 | 738 | ||
| 768 | if (unicode_append_menu) | 739 | if (unicode_append_menu) |
| 769 | title = ENCODE_UTF_8 (title); | 740 | title = ENCODE_UTF_8 (title); |
| 770 | else if (STRING_MULTIBYTE (title)) | 741 | else if (STRING_MULTIBYTE (title)) |
| 771 | title = ENCODE_SYSTEM (title); | 742 | title = ENCODE_SYSTEM (title); |
| 772 | 743 | ||
| 773 | wv_title->name = SSDATA (title); | 744 | wv_title = make_widget_value (SSDATA (title), NULL, true, Qnil); |
| 774 | wv_title->enabled = TRUE; | ||
| 775 | wv_title->title = TRUE; | 745 | wv_title->title = TRUE; |
| 776 | wv_title->button_type = BUTTON_TYPE_NONE; | 746 | wv_title->button_type = BUTTON_TYPE_NONE; |
| 777 | wv_title->help = Qnil; | ||
| 778 | wv_title->next = wv_sep; | 747 | wv_title->next = wv_sep; |
| 779 | first_wv->contents = wv_title; | 748 | first_wv->contents = wv_title; |
| 780 | } | 749 | } |
| @@ -934,11 +903,7 @@ w32_dialog_show (struct frame *f, Lisp_Object title, | |||
| 934 | pane_name = AREF (menu_items, MENU_ITEMS_PANE_NAME); | 903 | pane_name = AREF (menu_items, MENU_ITEMS_PANE_NAME); |
| 935 | pane_string = (NILP (pane_name) | 904 | pane_string = (NILP (pane_name) |
| 936 | ? "" : SSDATA (pane_name)); | 905 | ? "" : SSDATA (pane_name)); |
| 937 | prev_wv = xmalloc_widget_value (); | 906 | prev_wv = make_widget_value ("message", pane_string, true, Qnil); |
| 938 | prev_wv->value = pane_string; | ||
| 939 | prev_wv->enabled = 1; | ||
| 940 | prev_wv->name = "message"; | ||
| 941 | prev_wv->help = Qnil; | ||
| 942 | first_wv = prev_wv; | 907 | first_wv = prev_wv; |
| 943 | 908 | ||
| 944 | /* Loop over all panes and items, filling in the tree. */ | 909 | /* Loop over all panes and items, filling in the tree. */ |
| @@ -975,15 +940,13 @@ w32_dialog_show (struct frame *f, Lisp_Object title, | |||
| 975 | return Qnil; | 940 | return Qnil; |
| 976 | } | 941 | } |
| 977 | 942 | ||
| 978 | wv = xmalloc_widget_value (); | 943 | wv = make_widget_value (button_names[nb_buttons], |
| 944 | SSDATA (item_name), | ||
| 945 | !NILP (enable), Qnil); | ||
| 979 | prev_wv->next = wv; | 946 | prev_wv->next = wv; |
| 980 | wv->name = (char *) button_names[nb_buttons]; | ||
| 981 | if (!NILP (descrip)) | 947 | if (!NILP (descrip)) |
| 982 | wv->key = SSDATA (descrip); | 948 | wv->key = SSDATA (descrip); |
| 983 | wv->value = SSDATA (item_name); | ||
| 984 | wv->call_data = aref_addr (menu_items, i); | 949 | wv->call_data = aref_addr (menu_items, i); |
| 985 | wv->enabled = !NILP (enable); | ||
| 986 | wv->help = Qnil; | ||
| 987 | prev_wv = wv; | 950 | prev_wv = wv; |
| 988 | 951 | ||
| 989 | if (! boundary_seen) | 952 | if (! boundary_seen) |
| @@ -998,9 +961,7 @@ w32_dialog_show (struct frame *f, Lisp_Object title, | |||
| 998 | if (! boundary_seen) | 961 | if (! boundary_seen) |
| 999 | left_count = nb_buttons - nb_buttons / 2; | 962 | left_count = nb_buttons - nb_buttons / 2; |
| 1000 | 963 | ||
| 1001 | wv = xmalloc_widget_value (); | 964 | wv = make_widget_value (dialog_name, NULL, false, Qnil); |
| 1002 | wv->name = dialog_name; | ||
| 1003 | wv->help = Qnil; | ||
| 1004 | 965 | ||
| 1005 | /* Frame title: 'Q' = Question, 'I' = Information. | 966 | /* Frame title: 'Q' = Question, 'I' = Information. |
| 1006 | Can also have 'E' = Error if, one day, we want | 967 | Can also have 'E' = Error if, one day, we want |