# HG changeset patch # User Richard M. Stallman # Date 804451404 0 # Node ID a46766b7288acc48c14a0158402070f8eef72d64 # Parent 80a5aedfb4c7b30f6b9cd2dd4e13bd04d86d945b (single_submenu): Handle commands appearing directly in the menu bar. diff -r 80a5aedfb4c7 -r a46766b7288a src/xmenu.c --- a/src/xmenu.c Thu Jun 29 17:32:59 1995 +0000 +++ b/src/xmenu.c Thu Jun 29 18:43:24 1995 +0000 @@ -1300,6 +1300,7 @@ widget_value **submenu_stack; int mapno; int previous_items = menu_items_used; + int top_level_items = 0; length = Flength (maps); len = XINT (length); @@ -1317,7 +1318,16 @@ /* Loop over the given keymaps, making a pane for each map. But don't make a pane that is empty--ignore that map instead. */ for (i = 0; i < len; i++) - single_keymap_panes (mapvec[i], item_name, item_key, 0); + { + if (SYMBOLP (mapvec[i])) + { + top_level_items = 1; + push_menu_pane (Qnil, Qnil); + push_menu_item (item_name, Qt, item_key, mapvec[i], Qnil); + } + else + single_keymap_panes (mapvec[i], item_name, item_key, 0); + } /* Create a tree of widget_value objects representing the panes and their items. */ @@ -1330,6 +1340,7 @@ wv->enabled = 1; first_wv = wv; save_wv = 0; + prev_wv = 0; /* Loop over all panes and items made during this call and construct a tree of widget_value objects. @@ -1405,8 +1416,9 @@ wv = malloc_widget_value (); if (prev_wv) prev_wv->next = wv; - else + else save_wv->contents = wv; + wv->name = (char *) XSTRING (item_name)->data; if (!NILP (descrip)) wv->key = (char *) XSTRING (descrip)->data; @@ -1421,6 +1433,15 @@ } } + /* If we have just one "menu item" + that was originally a button, return it by itself. */ + if (top_level_items && first_wv->contents && first_wv->contents->next == 0) + { + wv = first_wv->contents; + free_widget_value (first_wv); + return wv; + } + return first_wv; }