diff options
author | Dmitry Antipov <dmantipov@yandex.ru> | 2014-06-02 22:01:21 +0400 |
---|---|---|
committer | Dmitry Antipov <dmantipov@yandex.ru> | 2014-06-02 22:01:21 +0400 |
commit | 5668fb88bf3731d39c4e958c8e79a549f789ce1e (patch) | |
tree | b0d3fd3555fca3b34c47b803a633da2f36d31165 /src/xmenu.c | |
parent | da11196a248b530c3b3a8329497d71332f8c71a3 (diff) | |
download | emacs-5668fb88bf3731d39c4e958c8e79a549f789ce1e.tar.gz |
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/xmenu.c')
-rw-r--r-- | src/xmenu.c | 74 |
1 files changed, 16 insertions, 58 deletions
diff --git a/src/xmenu.c b/src/xmenu.c index 683e9c6cd90..c167eaa8159 100644 --- a/src/xmenu.c +++ b/src/xmenu.c @@ -882,12 +882,8 @@ set_frame_menubar (struct frame *f, bool first_time, bool deep_p) /* Convert menu_items into widget_value trees to display the menu. This cannot evaluate Lisp code. */ - wv = xmalloc_widget_value (); - wv->name = "menubar"; - wv->value = 0; - wv->enabled = 1; + wv = make_widget_value ("menubar", NULL, true, Qnil); wv->button_type = BUTTON_TYPE_NONE; - wv->help = Qnil; first_wv = wv; for (i = 0; submenu_start[i] >= 0; i++) @@ -952,12 +948,8 @@ set_frame_menubar (struct frame *f, bool first_time, bool deep_p) /* Make a widget-value tree containing just the top level menu bar strings. */ - wv = xmalloc_widget_value (); - wv->name = "menubar"; - wv->value = 0; - wv->enabled = 1; + wv = make_widget_value ("menubar", NULL, true, Qnil); wv->button_type = BUTTON_TYPE_NONE; - wv->help = Qnil; first_wv = wv; items = FRAME_MENU_BAR_ITEMS (f); @@ -969,12 +961,8 @@ set_frame_menubar (struct frame *f, bool first_time, bool deep_p) if (NILP (string)) break; - wv = xmalloc_widget_value (); - wv->name = SSDATA (string); - wv->value = 0; - wv->enabled = 1; + wv = make_widget_value (SSDATA (string), NULL, true, Qnil); wv->button_type = BUTTON_TYPE_NONE; - wv->help = Qnil; /* This prevents lwlib from assuming this menu item is really supposed to be empty. */ /* The intptr_t cast avoids a warning. @@ -1474,12 +1462,8 @@ xmenu_show (struct frame *f, int x, int y, bool for_click, bool keymaps, /* Create a tree of widget_value objects representing the panes and their items. */ - wv = xmalloc_widget_value (); - wv->name = "menu"; - wv->value = 0; - wv->enabled = 1; + wv = make_widget_value ("menu", NULL, true, Qnil); wv->button_type = BUTTON_TYPE_NONE; - wv->help =Qnil; first_wv = wv; first_pane = 1; @@ -1537,18 +1521,14 @@ xmenu_show (struct frame *f, int x, int y, bool for_click, bool keymaps, with its items as a submenu beneath it. */ if (!keymaps && strcmp (pane_string, "")) { - wv = xmalloc_widget_value (); + wv = make_widget_value (pane_string, NULL, true, Qnil); if (save_wv) save_wv->next = wv; else first_wv->contents = wv; - wv->name = (char *) pane_string; if (keymaps && !NILP (prefix)) wv->name++; - wv->value = 0; - wv->enabled = 1; wv->button_type = BUTTON_TYPE_NONE; - wv->help = Qnil; save_wv = wv; prev_wv = 0; } @@ -1586,20 +1566,18 @@ xmenu_show (struct frame *f, int x, int y, bool for_click, bool keymaps, } #endif /* not HAVE_MULTILINGUAL_MENU */ - wv = xmalloc_widget_value (); + wv = make_widget_value (SSDATA (item_name), NULL, !NILP (enable), + STRINGP (help) ? help : Qnil); if (prev_wv) prev_wv->next = wv; else save_wv->contents = wv; - wv->name = SSDATA (item_name); if (!NILP (descrip)) wv->key = SSDATA (descrip); - wv->value = 0; /* If this item has a null value, make the call_data null so that it won't display a box when the mouse is on it. */ wv->call_data = !NILP (def) ? aref_addr (menu_items, i) : 0; - wv->enabled = !NILP (enable); if (NILP (type)) wv->button_type = BUTTON_TYPE_NONE; @@ -1612,11 +1590,6 @@ xmenu_show (struct frame *f, int x, int y, bool for_click, bool keymaps, wv->selected = !NILP (selected); - if (! STRINGP (help)) - help = Qnil; - - wv->help = help; - prev_wv = wv; i += MENU_ITEMS_ITEM_LENGTH; @@ -1626,27 +1599,20 @@ xmenu_show (struct frame *f, int x, int y, bool for_click, bool keymaps, /* Deal with the title, if it is non-nil. */ if (!NILP (title)) { - widget_value *wv_title = xmalloc_widget_value (); - widget_value *wv_sep1 = xmalloc_widget_value (); - widget_value *wv_sep2 = xmalloc_widget_value (); + widget_value *wv_title; + widget_value *wv_sep1 = make_widget_value ("--", NULL, false, Qnil); + widget_value *wv_sep2 = make_widget_value ("--", NULL, false, Qnil); - wv_sep2->name = "--"; wv_sep2->next = first_wv->contents; - wv_sep2->help = Qnil; - - wv_sep1->name = "--"; wv_sep1->next = wv_sep2; - wv_sep1->help = Qnil; #ifndef HAVE_MULTILINGUAL_MENU if (STRING_MULTIBYTE (title)) title = ENCODE_MENU_STRING (title); #endif - wv_title->name = SSDATA (title); - wv_title->enabled = true; + wv_title = make_widget_value (SSDATA (title), NULL, true, Qnil); wv_title->button_type = BUTTON_TYPE_NONE; - wv_title->help = Qnil; wv_title->next = wv_sep1; first_wv->contents = wv_title; } @@ -1867,11 +1833,7 @@ x_dialog_show (struct frame *f, Lisp_Object title, pane_name = AREF (menu_items, MENU_ITEMS_PANE_NAME); pane_string = (NILP (pane_name) ? "" : SSDATA (pane_name)); - prev_wv = xmalloc_widget_value (); - prev_wv->value = (char *) pane_string; - prev_wv->enabled = 1; - prev_wv->name = "message"; - prev_wv->help = Qnil; + prev_wv = make_widget_value ("message", (char *) pane_string, true, Qnil); first_wv = prev_wv; /* Loop over all panes and items, filling in the tree. */ @@ -1907,15 +1869,13 @@ x_dialog_show (struct frame *f, Lisp_Object title, return Qnil; } - wv = xmalloc_widget_value (); + wv = make_widget_value (button_names[nb_buttons], + SSDATA (item_name), + !NILP (enable), Qnil); prev_wv->next = wv; - wv->name = (char *) button_names[nb_buttons]; if (!NILP (descrip)) wv->key = SSDATA (descrip); - wv->value = SSDATA (item_name); wv->call_data = aref_addr (menu_items, i); - wv->enabled = !NILP (enable); - wv->help = Qnil; prev_wv = wv; if (! boundary_seen) @@ -1930,9 +1890,7 @@ x_dialog_show (struct frame *f, Lisp_Object title, if (! boundary_seen) left_count = nb_buttons - nb_buttons / 2; - wv = xmalloc_widget_value (); - wv->name = dialog_name; - wv->help = Qnil; + wv = make_widget_value (dialog_name, NULL, false, Qnil); /* Frame title: 'Q' = Question, 'I' = Information. Can also have 'E' = Error if, one day, we want |