aboutsummaryrefslogtreecommitdiffstats
path: root/src/nsmenu.m
diff options
context:
space:
mode:
authorDmitry Antipov2014-06-02 22:01:21 +0400
committerDmitry Antipov2014-06-02 22:01:21 +0400
commit5668fb88bf3731d39c4e958c8e79a549f789ce1e (patch)
treeb0d3fd3555fca3b34c47b803a633da2f36d31165 /src/nsmenu.m
parentda11196a248b530c3b3a8329497d71332f8c71a3 (diff)
downloademacs-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/nsmenu.m')
-rw-r--r--src/nsmenu.m52
1 files changed, 10 insertions, 42 deletions
diff --git a/src/nsmenu.m b/src/nsmenu.m
index 24842241f37..e5f0b7668bc 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -266,12 +266,8 @@ ns_update_menubar (struct frame *f, bool deep_p, EmacsMenu *submenu)
266 266
267 /* parse stage 2: insert into lucid 'widget_value' structures 267 /* parse stage 2: insert into lucid 'widget_value' structures
268 [comments in other terms say not to evaluate lisp code here] */ 268 [comments in other terms say not to evaluate lisp code here] */
269 wv = xmalloc_widget_value (); 269 wv = make_widget_value ("menubar", NULL, true, Qnil);
270 wv->name = "menubar";
271 wv->value = 0;
272 wv->enabled = 1;
273 wv->button_type = BUTTON_TYPE_NONE; 270 wv->button_type = BUTTON_TYPE_NONE;
274 wv->help = Qnil;
275 first_wv = wv; 271 first_wv = wv;
276 272
277 for (i = 0; i < 4*n; i += 4) 273 for (i = 0; i < 4*n; i += 4)
@@ -378,12 +374,8 @@ ns_update_menubar (struct frame *f, bool deep_p, EmacsMenu *submenu)
378 int n; 374 int n;
379 Lisp_Object string; 375 Lisp_Object string;
380 376
381 wv = xmalloc_widget_value (); 377 wv = make_widget_value ("menubar", NULL, true, Qnil);
382 wv->name = "menubar";
383 wv->value = 0;
384 wv->enabled = 1;
385 wv->button_type = BUTTON_TYPE_NONE; 378 wv->button_type = BUTTON_TYPE_NONE;
386 wv->help = Qnil;
387 first_wv = wv; 379 first_wv = wv;
388 380
389 /* Make widget-value tree w/ just the top level menu bar strings */ 381 /* Make widget-value tree w/ just the top level menu bar strings */
@@ -439,12 +431,8 @@ ns_update_menubar (struct frame *f, bool deep_p, EmacsMenu *submenu)
439 memcpy (previous_strings[i/4], SDATA (string), 431 memcpy (previous_strings[i/4], SDATA (string),
440 min (10, SBYTES (string) + 1)); 432 min (10, SBYTES (string) + 1));
441 433
442 wv = xmalloc_widget_value (); 434 wv = make_widget_value (SSDATA (string), NULL, true, Qnil);
443 wv->name = SSDATA (string);
444 wv->value = 0;
445 wv->enabled = 1;
446 wv->button_type = BUTTON_TYPE_NONE; 435 wv->button_type = BUTTON_TYPE_NONE;
447 wv->help = Qnil;
448 wv->call_data = (void *) (intptr_t) (-1); 436 wv->call_data = (void *) (intptr_t) (-1);
449 437
450#ifdef NS_IMPL_COCOA 438#ifdef NS_IMPL_COCOA
@@ -838,12 +826,8 @@ ns_menu_show (struct frame *f, int x, int y, bool for_click, bool keymaps,
838 p.x = x; p.y = y; 826 p.x = x; p.y = y;
839 827
840 /* now parse stage 2 as in ns_update_menubar */ 828 /* now parse stage 2 as in ns_update_menubar */
841 wv = xmalloc_widget_value (); 829 wv = make_widget_value ("contextmenu", NULL, true, Qnil);
842 wv->name = "contextmenu";
843 wv->value = 0;
844 wv->enabled = 1;
845 wv->button_type = BUTTON_TYPE_NONE; 830 wv->button_type = BUTTON_TYPE_NONE;
846 wv->help = Qnil;
847 first_wv = wv; 831 first_wv = wv;
848 832
849#if 0 833#if 0
@@ -914,18 +898,14 @@ ns_menu_show (struct frame *f, int x, int y, bool for_click, bool keymaps,
914 with its items as a submenu beneath it. */ 898 with its items as a submenu beneath it. */
915 if (!keymaps && strcmp (pane_string, "")) 899 if (!keymaps && strcmp (pane_string, ""))
916 { 900 {
917 wv = xmalloc_widget_value (); 901 wv = make_widget_value (pane_string, NULL, true, Qnil);
918 if (save_wv) 902 if (save_wv)
919 save_wv->next = wv; 903 save_wv->next = wv;
920 else 904 else
921 first_wv->contents = wv; 905 first_wv->contents = wv;
922 wv->name = pane_string;
923 if (keymaps && !NILP (prefix)) 906 if (keymaps && !NILP (prefix))
924 wv->name++; 907 wv->name++;
925 wv->value = 0;
926 wv->enabled = 1;
927 wv->button_type = BUTTON_TYPE_NONE; 908 wv->button_type = BUTTON_TYPE_NONE;
928 wv->help = Qnil;
929 save_wv = wv; 909 save_wv = wv;
930 prev_wv = 0; 910 prev_wv = 0;
931 } 911 }
@@ -963,20 +943,18 @@ ns_menu_show (struct frame *f, int x, int y, bool for_click, bool keymaps,
963 } 943 }
964#endif /* not HAVE_MULTILINGUAL_MENU */ 944#endif /* not HAVE_MULTILINGUAL_MENU */
965 945
966 wv = xmalloc_widget_value (); 946 wv = make_widget_value (SSDATA (item_name), NULL, !NILP (enabled),
947 STRINGP (help) ? help : Qnil);
967 if (prev_wv) 948 if (prev_wv)
968 prev_wv->next = wv; 949 prev_wv->next = wv;
969 else 950 else
970 save_wv->contents = wv; 951 save_wv->contents = wv;
971 wv->name = SSDATA (item_name);
972 if (!NILP (descrip)) 952 if (!NILP (descrip))
973 wv->key = SSDATA (descrip); 953 wv->key = SSDATA (descrip);
974 wv->value = 0;
975 /* If this item has a null value, 954 /* If this item has a null value,
976 make the call_data null so that it won't display a box 955 make the call_data null so that it won't display a box
977 when the mouse is on it. */ 956 when the mouse is on it. */
978 wv->call_data = !NILP (def) ? aref_addr (menu_items, i) : 0; 957 wv->call_data = !NILP (def) ? aref_addr (menu_items, i) : 0;
979 wv->enabled = !NILP (enable);
980 958
981 if (NILP (type)) 959 if (NILP (type))
982 wv->button_type = BUTTON_TYPE_NONE; 960 wv->button_type = BUTTON_TYPE_NONE;
@@ -989,11 +967,6 @@ ns_menu_show (struct frame *f, int x, int y, bool for_click, bool keymaps,
989 967
990 wv->selected = !NILP (selected); 968 wv->selected = !NILP (selected);
991 969
992 if (! STRINGP (help))
993 help = Qnil;
994
995 wv->help = help;
996
997 prev_wv = wv; 970 prev_wv = wv;
998 971
999 i += MENU_ITEMS_ITEM_LENGTH; 972 i += MENU_ITEMS_ITEM_LENGTH;
@@ -1004,24 +977,19 @@ ns_menu_show (struct frame *f, int x, int y, bool for_click, bool keymaps,
1004 977
1005 if (!NILP (title)) 978 if (!NILP (title))
1006 { 979 {
1007 widget_value *wv_title = xmalloc_widget_value (); 980 widget_value *wv_title;
1008 widget_value *wv_sep = xmalloc_widget_value (); 981 widget_value *wv_sep = make_widget_value ("--", NULL, false, Qnil);
1009 982
1010 /* Maybe replace this separator with a bitmap or owner-draw item 983 /* Maybe replace this separator with a bitmap or owner-draw item
1011 so that it looks better. Having two separators looks odd. */ 984 so that it looks better. Having two separators looks odd. */
1012 wv_sep->name = "--";
1013 wv_sep->next = first_wv->contents; 985 wv_sep->next = first_wv->contents;
1014 wv_sep->help = Qnil;
1015 986
1016#ifndef HAVE_MULTILINGUAL_MENU 987#ifndef HAVE_MULTILINGUAL_MENU
1017 if (STRING_MULTIBYTE (title)) 988 if (STRING_MULTIBYTE (title))
1018 title = ENCODE_MENU_STRING (title); 989 title = ENCODE_MENU_STRING (title);
1019#endif 990#endif
1020 991 wv_title = make_widget_value (SSDATA (title), NULL, false, Qnil);
1021 wv_title->name = SSDATA (title);
1022 wv_title->enabled = NO;
1023 wv_title->button_type = BUTTON_TYPE_NONE; 992 wv_title->button_type = BUTTON_TYPE_NONE;
1024 wv_title->help = Qnil;
1025 wv_title->next = wv_sep; 993 wv_title->next = wv_sep;
1026 first_wv->contents = wv_title; 994 first_wv->contents = wv_title;
1027 } 995 }