aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1994-03-19 10:31:57 +0000
committerRichard M. Stallman1994-03-19 10:31:57 +0000
commit80670155d2b3a50f0d7f587268e4590cb6936b23 (patch)
tree043e88fff2262f0f98c6886eab00b9363c8c16a4 /src
parent13162c0e6b8bd645f74de20a4e49203ed9afaba6 (diff)
downloademacs-80670155d2b3a50f0d7f587268e4590cb6936b23.tar.gz
emacs-80670155d2b3a50f0d7f587268e4590cb6936b23.zip
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
(xdialog_show): Call lw_modify_all_widgets properly. Generate dialog's name at run time to specify number of buttons. Report error if too many buttons to handle or if multiple panes.
Diffstat (limited to 'src')
-rw-r--r--src/xmenu.c69
1 files changed, 64 insertions, 5 deletions
diff --git a/src/xmenu.c b/src/xmenu.c
index c3de3ec9446..4a8fb70d221 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -854,11 +854,12 @@ You can also use a list of keymaps as MENU.\n\
854When MENU is a keymap or a list of keymaps, the return value\n\ 854When MENU is a keymap or a list of keymaps, the return value\n\
855is a list of events.\n\n\ 855is a list of events.\n\n\
856Alternatively, you can specify a menu of multiple panes\n\ 856Alternatively, you can specify a menu of multiple panes\n\
857 with a list of the form (TITLE PANE1 PANE2...),\n\ 857 with a list of the form (TITLE PANE),\n\
858where each pane is a list of form (TITLE ITEM1 ITEM2...).\n\ 858where PANE is a list of form (TITLE ITEM1 ITEM2...).\n\
859Each ITEM is normally a cons cell (STRING . VALUE);\n\ 859Each ITEM is normally a cons cell (STRING . VALUE);\n\
860but a string can appear as an item--that makes a nonselectable line\n\ 860but a string can appear as an item--that makes a nonselectable line\n\
861in the menu.\n\ 861in the menu.\n\
862Dialog boxes do not support multiple panes.\n\
862With this form of menu, the return value is VALUE from the chosen item.\n\ 863With this form of menu, the return value is VALUE from the chosen item.\n\
863\n\ 864\n\
864If POSITION is nil, don't display the menu at all, just precalculate the\n\ 865If POSITION is nil, don't display the menu at all, just precalculate the\n\
@@ -906,6 +907,31 @@ cached information about equivalent key sequences.")
906 XFASTINT (y) = 0; 907 XFASTINT (y) = 0;
907 } 908 }
908 } 909 }
910 else
911 {
912 tem = Fcar (position);
913 if (XTYPE (tem) == Lisp_Cons)
914 {
915 window = Fcar (Fcdr (position));
916 x = Fcar (tem);
917 y = Fcar (Fcdr (tem));
918 }
919 else
920 {
921 tem = Fcar (Fcdr (position)); /* EVENT_START (position) */
922 window = Fcar (tem); /* POSN_WINDOW (tem) */
923 tem = Fcar (Fcdr (Fcdr (tem))); /* POSN_WINDOW_POSN (tem) */
924 x = Fcar (tem);
925 y = Fcdr (tem);
926
927 /* Determine whether this menu is handling a menu bar click. */
928 tem = Fcar (Fcdr (Fcar (Fcdr (position))));
929 if (XTYPE (Fcar (position)) != Lisp_Cons
930 && CONSP (tem)
931 && EQ (Fcar (tem), Qmenu_bar))
932 menubarp = 1;
933 }
934 }
909 935
910 CHECK_NUMBER (x, 0); 936 CHECK_NUMBER (x, 0);
911 CHECK_NUMBER (y, 0); 937 CHECK_NUMBER (y, 0);
@@ -1740,6 +1766,7 @@ xdialog_show (f, x, y, menubarp, keymaps, title, error)
1740 int dialog_id; 1766 int dialog_id;
1741 Widget menu; 1767 Widget menu;
1742 XlwMenuWidget menubar = (XlwMenuWidget) f->display.x->menubar_widget; 1768 XlwMenuWidget menubar = (XlwMenuWidget) f->display.x->menubar_widget;
1769 char dialog_name[6];
1743 1770
1744 /* This is the menu bar item (if any) that led to this menu. */ 1771 /* This is the menu bar item (if any) that led to this menu. */
1745 widget_value *menubar_item = 0; 1772 widget_value *menubar_item = 0;
@@ -1759,6 +1786,12 @@ xdialog_show (f, x, y, menubarp, keymaps, title, error)
1759 1786
1760 *error = NULL; 1787 *error = NULL;
1761 1788
1789 if (menu_items_n_panes > 1)
1790 {
1791 *error = "Multiple panes in dialog box";
1792 return Qnil;
1793 }
1794
1762 /* Create a tree of widget_value objects 1795 /* Create a tree of widget_value objects
1763 representing the text label and buttons. */ 1796 representing the text label and buttons. */
1764 { 1797 {
@@ -1788,9 +1821,22 @@ xdialog_show (f, x, y, menubarp, keymaps, title, error)
1788 descrip 1821 descrip
1789 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY]; 1822 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY];
1790 1823
1824 if (NILP (item_name))
1825 {
1826 free_menubar_widget_value_tree (first_wv);
1827 *error = "Submenu in dialog items";
1828 return Qnil;
1829 }
1830 if (nb_buttons >= 10)
1831 {
1832 free_menubar_widget_value_tree (first_wv);
1833 *error = "Too many dialog items";
1834 return Qnil;
1835 }
1836
1791 wv = malloc_widget_value (); 1837 wv = malloc_widget_value ();
1792 prev_wv->next = wv; 1838 prev_wv->next = wv;
1793 wv->name = (char *) button_names [nb_buttons]; 1839 wv->name = (char *) button_names[nb_buttons];
1794 if (!NILP (descrip)) 1840 if (!NILP (descrip))
1795 wv->key = XSTRING (descrip)->data; 1841 wv->key = XSTRING (descrip)->data;
1796 wv->value = XSTRING (item_name)->data; 1842 wv->value = XSTRING (item_name)->data;
@@ -1803,7 +1849,18 @@ xdialog_show (f, x, y, menubarp, keymaps, title, error)
1803 } 1849 }
1804 1850
1805 wv = malloc_widget_value (); 1851 wv = malloc_widget_value ();
1806 wv->name = "Q2BR1"; 1852 wv->name = dialog_name;
1853
1854 /* Dialog boxes use a really stupid name encoding
1855 which specifies how many buttons to use
1856 and how many buttons are on the right.
1857 The Q means something also. */
1858 dialog_name[0] = 'Q';
1859 dialog_name[1] = '0' + nb_buttons;
1860 dialog_name[2] = 'B';
1861 dialog_name[3] = 'R';
1862 dialog_name[4] = '0' + nb_buttons / 2;
1863 dialog_name[5] = 0;
1807 wv->contents = first_wv; 1864 wv->contents = first_wv;
1808 first_wv = wv; 1865 first_wv = wv;
1809 1866
@@ -1814,8 +1871,10 @@ xdialog_show (f, x, y, menubarp, keymaps, title, error)
1814 menu = lw_create_widget (first_wv->name, "dialog", dialog_id, first_wv, 1871 menu = lw_create_widget (first_wv->name, "dialog", dialog_id, first_wv,
1815 f->display.x->widget, 1, 0, 1872 f->display.x->widget, 1, 0,
1816 dialog_selection_callback, 0); 1873 dialog_selection_callback, 0);
1874#if 0 /* This causes crashes, and seems to be redundant -- rms. */
1817 lw_modify_all_widgets (dialog_id, first_wv, True); 1875 lw_modify_all_widgets (dialog_id, first_wv, True);
1818 lw_modify_all_widgets (dialog_id, first_wv->contents, True); 1876#endif
1877 lw_modify_all_widgets (dialog_id, first_wv->contents->next, True);
1819 /* Free the widget_value objects we used to specify the contents. */ 1878 /* Free the widget_value objects we used to specify the contents. */
1820 free_menubar_widget_value_tree (first_wv); 1879 free_menubar_widget_value_tree (first_wv);
1821 1880