You should have received a copy of the GNU General Public License
along with GNU Emacs; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
/* X pop-up deck-of-cards menu facility for gnuemacs.
*
Lisp_Object Qdebug_on_next_call;
+Lisp_Object Qmenu_alias;
+
extern Lisp_Object Qmenu_enable;
extern Lisp_Object Qmenu_bar;
extern Lisp_Object Qmouse_click, Qevent_kind;
/* If the command is an alias for another
(such as easymenu.el and lmenu.el set it up),
see if the original command name has equivalent keys. */
- if (SYMBOLP (def) && SYMBOLP (XSYMBOL (def)->function))
+ if (SYMBOLP (def) && SYMBOLP (XSYMBOL (def)->function)
+ && ! NILP (Fget (def, Qmenu_alias)))
savedkey = Fwhere_is_internal (XSYMBOL (def)->function,
Qnil, Qt, Qnil);
else
int for_click = 0;
struct gcpro gcpro1;
+#ifdef HAVE_MENUS
if (! NILP (position))
{
check_x ();
xpos += XINT (x);
ypos += XINT (y);
}
+#endif /* HAVE_MENUS */
title = Qnil;
GCPRO1 (title);
return Qnil;
}
+#ifdef HAVE_MENUS
/* Display them in a menu. */
BLOCK_INPUT;
discard_menu_items ();
UNGCPRO;
+#endif /* HAVE_MENUS */
if (error_name) error (error_name);
return selection;
}
+#ifdef HAVE_MENUS
+
DEFUN ("x-popup-dialog", Fx_popup_dialog, Sx_popup_dialog, 2, 2, 0,
"Pop up a dialog box and return user's selection.\n\
POSITION specifies which frame to use.\n\
popup_activated_flag = 0;
}
+/* Allocate a widget_value, blocking input. */
+
+widget_value *
+xmalloc_widget_value ()
+{
+ widget_value *value;
+
+ BLOCK_INPUT;
+ value = malloc_widget_value ();
+ UNBLOCK_INPUT;
+
+ return value;
+}
/* This recursively calls free_widget_value on the tree of widgets.
It must free all data that was malloc'ed for these widget_values.
But don't make a pane that is empty--ignore that map instead. */
for (i = 0; i < len; i++)
{
- if (SYMBOLP (mapvec[i]))
+ if (SYMBOLP (mapvec[i])
+ || (CONSP (mapvec[i])
+ && NILP (Fkeymapp (mapvec[i]))))
{
+ /* Here we have a command at top level in the menu bar
+ as opposed to a submenu. */
top_level_items = 1;
push_menu_pane (Qnil, Qnil);
push_menu_item (item_name, Qt, item_key, mapvec[i], Qnil);
submenu_stack
= (widget_value **) alloca (menu_items_used * sizeof (widget_value *));
- wv = malloc_widget_value ();
+ wv = xmalloc_widget_value ();
wv->name = "menu";
wv->value = 0;
wv->enabled = 1;
with its items as a submenu beneath it. */
if (strcmp (pane_string, ""))
{
- wv = malloc_widget_value ();
+ wv = xmalloc_widget_value ();
if (save_wv)
save_wv->next = wv;
else
= XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY];
def = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_DEFINITION];
- wv = malloc_widget_value ();
+ wv = xmalloc_widget_value ();
if (prev_wv)
prev_wv->next = wv;
else
if (! menubar_widget)
deep_p = 1;
- wv = malloc_widget_value ();
+ wv = xmalloc_widget_value ();
wv->name = "menubar";
wv->value = 0;
wv->enabled = 1;
really recompute the menubar from the value. */
if (! NILP (Vlucid_menu_bar_dirty_flag))
call0 (Qrecompute_lucid_menubar);
- call1 (Vrun_hooks, Qmenu_bar_update_hook);
+ safe_run_hooks (Qmenu_bar_update_hook);
FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f));
items = FRAME_MENU_BAR_ITEMS (f);
menu_items = f->menu_bar_vector;
menu_items_allocated = XVECTOR (menu_items)->size;
init_menu_items ();
- for (i = 0; i < XVECTOR (items)->size; i += 3)
+ for (i = 0; i < XVECTOR (items)->size; i += 4)
{
Lisp_Object key, string, maps;
/* Now GC cannot happen during the lifetime of the widget_value,
so it's safe to store data from a Lisp_String. */
wv = first_wv->contents;
- for (i = 0; i < XVECTOR (items)->size; i += 3)
+ for (i = 0; i < XVECTOR (items)->size; i += 4)
{
Lisp_Object string;
string = XVECTOR (items)->contents[i + 1];
just the top level menu bar strings. */
items = FRAME_MENU_BAR_ITEMS (f);
- for (i = 0; i < XVECTOR (items)->size; i += 3)
+ for (i = 0; i < XVECTOR (items)->size; i += 4)
{
Lisp_Object string;
if (NILP (string))
break;
- wv = malloc_widget_value ();
+ wv = xmalloc_widget_value ();
wv->name = (char *) XSTRING (string)->data;
wv->value = 0;
wv->enabled = 1;
/* Create a tree of widget_value objects
representing the panes and their items. */
- wv = malloc_widget_value ();
+ wv = xmalloc_widget_value ();
wv->name = "menu";
wv->value = 0;
wv->enabled = 1;
with its items as a submenu beneath it. */
if (!keymaps && strcmp (pane_string, ""))
{
- wv = malloc_widget_value ();
+ wv = xmalloc_widget_value ();
if (save_wv)
save_wv->next = wv;
else
= XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY];
def = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_DEFINITION];
- wv = malloc_widget_value ();
+ wv = xmalloc_widget_value ();
if (prev_wv)
prev_wv->next = wv;
else
/* Deal with the title, if it is non-nil. */
if (!NILP (title))
{
- widget_value *wv_title = malloc_widget_value ();
- widget_value *wv_sep1 = malloc_widget_value ();
- widget_value *wv_sep2 = malloc_widget_value ();
+ widget_value *wv_title = xmalloc_widget_value ();
+ widget_value *wv_sep1 = xmalloc_widget_value ();
+ widget_value *wv_sep2 = xmalloc_widget_value ();
wv_sep2->name = "--";
wv_sep2->next = first_wv->contents;
prefix = XVECTOR (menu_items)->contents[MENU_ITEMS_PANE_PREFIX];
pane_string = (NILP (pane_name)
? "" : (char *) XSTRING (pane_name)->data);
- prev_wv = malloc_widget_value ();
+ prev_wv = xmalloc_widget_value ();
prev_wv->value = pane_string;
if (keymaps && !NILP (prefix))
prev_wv->name++;
return Qnil;
}
- wv = malloc_widget_value ();
+ wv = xmalloc_widget_value ();
prev_wv->next = wv;
wv->name = (char *) button_names[nb_buttons];
if (!NILP (descrip))
if (! boundary_seen)
left_count = nb_buttons - nb_buttons / 2;
- wv = malloc_widget_value ();
+ wv = xmalloc_widget_value ();
wv->name = dialog_name;
/* Dialog boxes use a really stupid name encoding
}
#endif /* not USE_X_TOOLKIT */
+
+#endif /* HAVE_MENUS */
\f
syms_of_xmenu ()
{
staticpro (&menu_items);
menu_items = Qnil;
+ Qmenu_alias = intern ("menu-alias");
+ staticpro (&Qmenu_alias);
+
Qdebug_on_next_call = intern ("debug-on-next-call");
staticpro (&Qdebug_on_next_call);
#endif
defsubr (&Sx_popup_menu);
+#ifdef HAVE_MENUS
defsubr (&Sx_popup_dialog);
+#endif
}