comparison src/xmenu.c @ 14546:bc0388a7c282

(xmalloc_widget_value): New function. Use it instead of malloc_widget_value.
author Richard M. Stallman <rms@gnu.org>
date Sun, 11 Feb 1996 20:31:53 +0000
parents 6448a36ceaad
children b94ba0bf8b7c
comparison
equal deleted inserted replaced
14545:bd43252760b4 14546:bc0388a7c282
113 static Lisp_Object xmenu_show (); 113 static Lisp_Object xmenu_show ();
114 static void keymap_panes (); 114 static void keymap_panes ();
115 static void single_keymap_panes (); 115 static void single_keymap_panes ();
116 static void list_of_panes (); 116 static void list_of_panes ();
117 static void list_of_items (); 117 static void list_of_items ();
118
119 /* Allocate a widget_value, blocking input. */
120
121 widget_value
122 xmalloc_widget_value ()
123 {
124 widget_value value;
125
126 BLOCK_INPUT;
127 value = malloc_widget_value ();
128 UNBLOCK_INPUT;
129
130 return value;
131 }
118 132
119 /* This holds a Lisp vector that holds the results of decoding 133 /* This holds a Lisp vector that holds the results of decoding
120 the keymaps or alist-of-alists that specify a menu. 134 the keymaps or alist-of-alists that specify a menu.
121 135
122 It describes the panes and items within the panes. 136 It describes the panes and items within the panes.
1371 /* Create a tree of widget_value objects 1385 /* Create a tree of widget_value objects
1372 representing the panes and their items. */ 1386 representing the panes and their items. */
1373 1387
1374 submenu_stack 1388 submenu_stack
1375 = (widget_value **) alloca (menu_items_used * sizeof (widget_value *)); 1389 = (widget_value **) alloca (menu_items_used * sizeof (widget_value *));
1376 wv = malloc_widget_value (); 1390 wv = xmalloc_widget_value ();
1377 wv->name = "menu"; 1391 wv->name = "menu";
1378 wv->value = 0; 1392 wv->value = 0;
1379 wv->enabled = 1; 1393 wv->enabled = 1;
1380 first_wv = wv; 1394 first_wv = wv;
1381 save_wv = 0; 1395 save_wv = 0;
1425 /* If the pane has a meaningful name, 1439 /* If the pane has a meaningful name,
1426 make the pane a top-level menu item 1440 make the pane a top-level menu item
1427 with its items as a submenu beneath it. */ 1441 with its items as a submenu beneath it. */
1428 if (strcmp (pane_string, "")) 1442 if (strcmp (pane_string, ""))
1429 { 1443 {
1430 wv = malloc_widget_value (); 1444 wv = xmalloc_widget_value ();
1431 if (save_wv) 1445 if (save_wv)
1432 save_wv->next = wv; 1446 save_wv->next = wv;
1433 else 1447 else
1434 first_wv->contents = wv; 1448 first_wv->contents = wv;
1435 wv->name = pane_string; 1449 wv->name = pane_string;
1452 enable = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_ENABLE]; 1466 enable = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_ENABLE];
1453 descrip 1467 descrip
1454 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY]; 1468 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY];
1455 def = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_DEFINITION]; 1469 def = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_DEFINITION];
1456 1470
1457 wv = malloc_widget_value (); 1471 wv = xmalloc_widget_value ();
1458 if (prev_wv) 1472 if (prev_wv)
1459 prev_wv->next = wv; 1473 prev_wv->next = wv;
1460 else 1474 else
1461 save_wv->contents = wv; 1475 save_wv->contents = wv;
1462 1476
1568 id = f->output_data.x->id; 1582 id = f->output_data.x->id;
1569 1583
1570 if (! menubar_widget) 1584 if (! menubar_widget)
1571 deep_p = 1; 1585 deep_p = 1;
1572 1586
1573 wv = malloc_widget_value (); 1587 wv = xmalloc_widget_value ();
1574 wv->name = "menubar"; 1588 wv->name = "menubar";
1575 wv->value = 0; 1589 wv->value = 0;
1576 wv->enabled = 1; 1590 wv->enabled = 1;
1577 first_wv = wv; 1591 first_wv = wv;
1578 1592
1693 1707
1694 string = XVECTOR (items)->contents[i + 1]; 1708 string = XVECTOR (items)->contents[i + 1];
1695 if (NILP (string)) 1709 if (NILP (string))
1696 break; 1710 break;
1697 1711
1698 wv = malloc_widget_value (); 1712 wv = xmalloc_widget_value ();
1699 wv->name = (char *) XSTRING (string)->data; 1713 wv->name = (char *) XSTRING (string)->data;
1700 wv->value = 0; 1714 wv->value = 0;
1701 wv->enabled = 1; 1715 wv->enabled = 1;
1702 1716
1703 if (prev_wv) 1717 if (prev_wv)
1881 return Qnil; 1895 return Qnil;
1882 } 1896 }
1883 1897
1884 /* Create a tree of widget_value objects 1898 /* Create a tree of widget_value objects
1885 representing the panes and their items. */ 1899 representing the panes and their items. */
1886 wv = malloc_widget_value (); 1900 wv = xmalloc_widget_value ();
1887 wv->name = "menu"; 1901 wv->name = "menu";
1888 wv->value = 0; 1902 wv->value = 0;
1889 wv->enabled = 1; 1903 wv->enabled = 1;
1890 first_wv = wv; 1904 first_wv = wv;
1891 first_pane = 1; 1905 first_pane = 1;
1933 /* If the pane has a meaningful name, 1947 /* If the pane has a meaningful name,
1934 make the pane a top-level menu item 1948 make the pane a top-level menu item
1935 with its items as a submenu beneath it. */ 1949 with its items as a submenu beneath it. */
1936 if (!keymaps && strcmp (pane_string, "")) 1950 if (!keymaps && strcmp (pane_string, ""))
1937 { 1951 {
1938 wv = malloc_widget_value (); 1952 wv = xmalloc_widget_value ();
1939 if (save_wv) 1953 if (save_wv)
1940 save_wv->next = wv; 1954 save_wv->next = wv;
1941 else 1955 else
1942 first_wv->contents = wv; 1956 first_wv->contents = wv;
1943 wv->name = pane_string; 1957 wv->name = pane_string;
1964 enable = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_ENABLE]; 1978 enable = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_ENABLE];
1965 descrip 1979 descrip
1966 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY]; 1980 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY];
1967 def = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_DEFINITION]; 1981 def = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_DEFINITION];
1968 1982
1969 wv = malloc_widget_value (); 1983 wv = xmalloc_widget_value ();
1970 if (prev_wv) 1984 if (prev_wv)
1971 prev_wv->next = wv; 1985 prev_wv->next = wv;
1972 else 1986 else
1973 save_wv->contents = wv; 1987 save_wv->contents = wv;
1974 wv->name = (char *) XSTRING (item_name)->data; 1988 wv->name = (char *) XSTRING (item_name)->data;
1988 } 2002 }
1989 2003
1990 /* Deal with the title, if it is non-nil. */ 2004 /* Deal with the title, if it is non-nil. */
1991 if (!NILP (title)) 2005 if (!NILP (title))
1992 { 2006 {
1993 widget_value *wv_title = malloc_widget_value (); 2007 widget_value *wv_title = xmalloc_widget_value ();
1994 widget_value *wv_sep1 = malloc_widget_value (); 2008 widget_value *wv_sep1 = xmalloc_widget_value ();
1995 widget_value *wv_sep2 = malloc_widget_value (); 2009 widget_value *wv_sep2 = xmalloc_widget_value ();
1996 2010
1997 wv_sep2->name = "--"; 2011 wv_sep2->name = "--";
1998 wv_sep2->next = first_wv->contents; 2012 wv_sep2->next = first_wv->contents;
1999 2013
2000 wv_sep1->name = "--"; 2014 wv_sep1->name = "--";
2193 char *pane_string; 2207 char *pane_string;
2194 pane_name = XVECTOR (menu_items)->contents[MENU_ITEMS_PANE_NAME]; 2208 pane_name = XVECTOR (menu_items)->contents[MENU_ITEMS_PANE_NAME];
2195 prefix = XVECTOR (menu_items)->contents[MENU_ITEMS_PANE_PREFIX]; 2209 prefix = XVECTOR (menu_items)->contents[MENU_ITEMS_PANE_PREFIX];
2196 pane_string = (NILP (pane_name) 2210 pane_string = (NILP (pane_name)
2197 ? "" : (char *) XSTRING (pane_name)->data); 2211 ? "" : (char *) XSTRING (pane_name)->data);
2198 prev_wv = malloc_widget_value (); 2212 prev_wv = xmalloc_widget_value ();
2199 prev_wv->value = pane_string; 2213 prev_wv->value = pane_string;
2200 if (keymaps && !NILP (prefix)) 2214 if (keymaps && !NILP (prefix))
2201 prev_wv->name++; 2215 prev_wv->name++;
2202 prev_wv->enabled = 1; 2216 prev_wv->enabled = 1;
2203 prev_wv->name = "message"; 2217 prev_wv->name = "message";
2234 free_menubar_widget_value_tree (first_wv); 2248 free_menubar_widget_value_tree (first_wv);
2235 *error = "Too many dialog items"; 2249 *error = "Too many dialog items";
2236 return Qnil; 2250 return Qnil;
2237 } 2251 }
2238 2252
2239 wv = malloc_widget_value (); 2253 wv = xmalloc_widget_value ();
2240 prev_wv->next = wv; 2254 prev_wv->next = wv;
2241 wv->name = (char *) button_names[nb_buttons]; 2255 wv->name = (char *) button_names[nb_buttons];
2242 if (!NILP (descrip)) 2256 if (!NILP (descrip))
2243 wv->key = (char *) XSTRING (descrip)->data; 2257 wv->key = (char *) XSTRING (descrip)->data;
2244 wv->value = (char *) XSTRING (item_name)->data; 2258 wv->value = (char *) XSTRING (item_name)->data;
2256 /* If the boundary was not specified, 2270 /* If the boundary was not specified,
2257 by default put half on the left and half on the right. */ 2271 by default put half on the left and half on the right. */
2258 if (! boundary_seen) 2272 if (! boundary_seen)
2259 left_count = nb_buttons - nb_buttons / 2; 2273 left_count = nb_buttons - nb_buttons / 2;
2260 2274
2261 wv = malloc_widget_value (); 2275 wv = xmalloc_widget_value ();
2262 wv->name = dialog_name; 2276 wv->name = dialog_name;
2263 2277
2264 /* Dialog boxes use a really stupid name encoding 2278 /* Dialog boxes use a really stupid name encoding
2265 which specifies how many buttons to use 2279 which specifies how many buttons to use
2266 and how many buttons are on the right. 2280 and how many buttons are on the right.