annotate src/menubar.c @ 428:3ecd8885ac67 r21-2-22

Import from CVS: tag r21-2-22
author cvs
date Mon, 13 Aug 2007 11:28:15 +0200
parents
children 84b14dcb0985
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* Implements an elisp-programmable menubar.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1993, 1994 Free Software Foundation, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 Copyright (C) 1995 Tinker Systems and INS Engineering Corp.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 along with XEmacs; see the file COPYING. If not, write to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 Boston, MA 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 /* Synched up with: Not in FSF. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 /* #### There ain't much here because menubars have not been
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 properly abstracted yet. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 #include "lisp.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 #include "buffer.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 #include "device.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 #include "frame.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 #include "gui.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 #include "menubar.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 #include "redisplay.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 #include "window.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 int menubar_show_keybindings;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 Lisp_Object Vmenubar_configuration;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 Lisp_Object Qcurrent_menubar;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 Lisp_Object Qactivate_menubar_hook, Vactivate_menubar_hook;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 Lisp_Object Vmenubar_visible_p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 static Lisp_Object Vcurrent_menubar; /* DO NOT ever reference this.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 Always go through Qcurrent_menubar.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 See below. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 Lisp_Object Vblank_menubar;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 int popup_menu_titles;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 Lisp_Object Vmenubar_pointer_glyph;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 menubar_variable_changed (Lisp_Object sym, Lisp_Object *val,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 Lisp_Object in_object, int flags)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 MARK_MENUBAR_CHANGED;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 update_frame_menubars (struct frame *f)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 if (f->menubar_changed || f->windows_changed)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 MAYBE_FRAMEMETH (f, update_frame_menubars, (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 f->menubar_changed = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 free_frame_menubars (struct frame *f)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 /* If we had directly allocated any memory for the menubars instead
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 of using all Lisp_Objects this is where we would now free it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 MAYBE_FRAMEMETH (f, free_frame_menubars, (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 menubar_visible_p_changed (Lisp_Object specifier, struct window *w,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 Lisp_Object oldval)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 MARK_MENUBAR_CHANGED;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 menubar_visible_p_changed_in_frame (Lisp_Object specifier, struct frame *f,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 Lisp_Object oldval)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 update_frame_menubars (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 current_frame_menubar (CONST struct frame* f)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 struct window *w = XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 return symbol_value_in_buffer (Qcurrent_menubar, w->buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 menu_parse_submenu_keywords (Lisp_Object desc, Lisp_Object gui_item)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 struct Lisp_Gui_Item* pgui_item = XGUI_ITEM (gui_item);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 /* Menu descriptor should be a list */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 CHECK_CONS (desc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 /* First element may be menu name, although can be omitted.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 Let's think that if stuff begins with anything than a keyword
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 or a list (submenu), this is a menu name, expected to be a string */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 if (!KEYWORDP (XCAR (desc)) && !CONSP (XCAR (desc)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 CHECK_STRING (XCAR (desc));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 pgui_item->name = XCAR (desc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 desc = XCDR (desc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 if (!NILP (desc))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 CHECK_CONS (desc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 /* Walk along all key-value pairs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 while (!NILP(desc) && KEYWORDP (XCAR (desc)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 Lisp_Object key, val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 key = XCAR (desc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 desc = XCDR (desc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 CHECK_CONS (desc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 val = XCAR (desc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 desc = XCDR (desc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 if (!NILP (desc))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 CHECK_CONS (desc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 gui_item_add_keyval_pair (gui_item, key, val, ERROR_ME);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 /* Return the rest - supposed to be a list of items */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 return desc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 DEFUN ("menu-find-real-submenu", Fmenu_find_real_submenu, 2, 2, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 Find a submenu descriptor within DESC by following PATH.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 This function finds a submenu descriptor, either from the description
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 DESC or generated by a filter within DESC. The function regards :config
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 and :included keywords in the DESC, and expands submenus along the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 PATH using :filter functions. Return value is a descriptor for the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 submenu, NOT expanded and NOT checked against :config and :included.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 Also, individual menu items are not looked for, only submenus.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 See also 'find-menu-item'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 (desc, path))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 Lisp_Object path_entry, submenu_desc, submenu;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 struct gcpro gcpro1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 Lisp_Object gui_item = allocate_gui_item ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 struct Lisp_Gui_Item* pgui_item = XGUI_ITEM (gui_item);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 GCPRO1 (gui_item);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 EXTERNAL_LIST_LOOP (path_entry, path)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 /* Verify that DESC describes a menu, not single item */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 if (!CONSP (desc))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 RETURN_UNGCPRO (Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 /* Parse this menu */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 desc = menu_parse_submenu_keywords (desc, gui_item);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 /* Check that this (sub)menu is active */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 if (!gui_item_active_p (gui_item))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 RETURN_UNGCPRO (Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 /* Apply :filter */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 if (!NILP (pgui_item->filter))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 desc = call1 (pgui_item->filter, desc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 /* Find the next menu on the path inside this one */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 EXTERNAL_LIST_LOOP (submenu_desc, desc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 submenu = XCAR (submenu_desc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 if (CONSP (submenu)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 && STRINGP (XCAR (submenu))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 && !NILP (Fstring_equal (XCAR (submenu), XCAR (path_entry))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 desc = submenu;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 goto descend;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 /* Submenu not found */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 RETURN_UNGCPRO (Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 descend:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 /* Prepare for the next iteration */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 gui_item_init (gui_item);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 /* We have successfully descended down the end of the path */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 return desc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 DEFUN ("popup-menu", Fpopup_menu, 1, 2, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 Pop up the given menu.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 A menu description is a list of menu items, strings, and submenus.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 The first element of a menu must be a string, which is the name of the menu.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 This is the string that will be displayed in the parent menu, if any. For
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 toplevel menus, it is ignored. This string is not displayed in the menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 itself.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 If an element of a menu is a string, then that string will be presented in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 the menu as unselectable text.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 If an element of a menu is a string consisting solely of hyphens, then that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 item will be presented as a solid horizontal line.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 If an element of a menu is a list, it is treated as a submenu. The name of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 that submenu (the first element in the list) will be used as the name of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 item representing this menu on the parent.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 Otherwise, the element must be a vector, which describes a menu item.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 A menu item can have any of the following forms:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 [ "name" callback <active-p> ]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 [ "name" callback <active-p> <suffix> ]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 [ "name" callback :<keyword> <value> :<keyword> <value> ... ]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 The name is the string to display on the menu; it is filtered through the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 resource database, so it is possible for resources to override what string
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 is actually displayed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 If the `callback' of a menu item is a symbol, then it must name a command.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 It will be invoked with `call-interactively'. If it is a list, then it is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 evaluated with `eval'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 The possible keywords are this:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 :active <form> Same as <active-p> in the first two forms: the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 expression is evaluated just before the menu is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 displayed, and the menu will be selectable only if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 the result is non-nil.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 :suffix <form> Same as <suffix> in the second form: the expression
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 is evaluated just before the menu is displayed and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 resulting string is appended to the displayed name,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 providing a convenient way of adding the name of a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 command's ``argument'' to the menu, like
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 ``Kill Buffer NAME''.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 :keys "string" Normally, the keyboard equivalents of commands in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 menus are displayed when the `callback' is a symbol.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 This can be used to specify keys for more complex menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 items. It is passed through `substitute-command-keys'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 first.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 :style <style> Specifies what kind of object this menu item is:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 nil A normal menu item.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 toggle A toggle button.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 radio A radio button.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 The only difference between toggle and radio buttons is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 how they are displayed. But for consistency, a toggle
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 button should be used when there is one option whose
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 value can be turned on or off, and radio buttons should
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 be used when there is a set of mutually exclusive
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 options. When using a group of radio buttons, you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 should arrange for no more than one to be marked as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 selected at a time.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 :selected <form> Meaningful only when STYLE is `toggle' or `radio'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 This specifies whether the button will be in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 selected or unselected state.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 For example:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 [ "Save As..." write-file t ]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 [ "Revert Buffer" revert-buffer (buffer-modified-p) ]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 [ "Read Only" toggle-read-only :style toggle :selected buffer-read-only ]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 See menubar.el for many more examples.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 (menu_desc, event))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 struct frame *f = decode_frame(Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 MAYBE_FRAMEMETH (f, popup_menu, (menu_desc,event));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 DEFUN ("normalize-menu-item-name", Fnormalize_menu_item_name, 1, 2, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 Convert a menu item name string into normal form, and return the new string.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 Menu item names should be converted to normal form before being compared.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 (name, buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 struct buffer *buf = decode_buffer (buffer, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 struct Lisp_String *n;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 Charcount end;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 Bufbyte *name_data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 Bufbyte *string_result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 Bufbyte *string_result_ptr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 Emchar elt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 int expecting_underscore = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 CHECK_STRING (name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 n = XSTRING (name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 end = string_char_length (n);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 name_data = string_data (n);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 string_result = (Bufbyte *) alloca (end * MAX_EMCHAR_LEN);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 string_result_ptr = string_result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 for (i = 0; i < end; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 elt = charptr_emchar (name_data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 elt = DOWNCASE (buf, elt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 if (expecting_underscore)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 expecting_underscore = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 switch (elt)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 case '%':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 /* Allow `%%' to mean `%'. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 string_result_ptr += set_charptr_emchar (string_result_ptr, '%');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 case '_':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 string_result_ptr += set_charptr_emchar (string_result_ptr, '%');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 string_result_ptr += set_charptr_emchar (string_result_ptr, elt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 else if (elt == '%')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 expecting_underscore = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 string_result_ptr += set_charptr_emchar (string_result_ptr, elt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 INC_CHARPTR (name_data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 return make_string (string_result, string_result_ptr - string_result);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 syms_of_menubar (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 defsymbol (&Qcurrent_menubar, "current-menubar");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 DEFSUBR (Fpopup_menu);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 DEFSUBR (Fnormalize_menu_item_name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 DEFSUBR (Fmenu_find_real_submenu);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 vars_of_menubar (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 /* put in Vblank_menubar a menubar value which has no visible
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 * items. This is a bit tricky due to various quirks. We
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 * could use '(["" nil nil]), but this is apparently equivalent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 * to '(nil), and a new frame created with this menubar will
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 * get a vertically-squished menubar. If we use " " as the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 * button title instead of "", we get an etched button border.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 * So we use
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 * '(("No active menubar" ["" nil nil]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 * which creates a menu whose title is "No active menubar",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 * and this works fine.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 Lisp_Object menu_item[3];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 static CONST char *blank_msg = "No active menubar";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 menu_item[0] = build_string ("");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 menu_item[1] = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 menu_item[2] = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 Vblank_menubar = Fcons (Fcons (build_string (blank_msg),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 Fcons (Fvector (3, &menu_item[0]),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 Qnil)),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 staticpro (&Vblank_menubar);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 DEFVAR_BOOL ("popup-menu-titles", &popup_menu_titles /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 If true, popup menus will have title bars at the top.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 popup_menu_titles = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 /* #### Replace current menubar with a specifier. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 /* All C code must access the menubar via Qcurrent_menubar
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 because it can be buffer-local. Note that Vcurrent_menubar
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 doesn't need to exist at all, except for the magic function. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 DEFVAR_LISP_MAGIC ("current-menubar", &Vcurrent_menubar /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 The current menubar. This may be buffer-local.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 When the menubar is changed, the function `set-menubar-dirty-flag' has to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 be called for the menubar to be updated on the frame. See `set-menubar'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 and `set-buffer-menubar'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 A menubar is a list of menus and menu-items.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 A menu is a list of menu items, keyword-value pairs, strings, and submenus.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 The first element of a menu must be a string, which is the name of the menu.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 This is the string that will be displayed in the parent menu, if any. For
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 toplevel menus, it is ignored. This string is not displayed in the menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 itself.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 Immediately following the name string of the menu, any of three
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 optional keyword-value pairs is permitted.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 If an element of a menu (or menubar) is a string, then that string will be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 presented as unselectable text.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 If an element of a menu is a string consisting solely of hyphens, then that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 item will be presented as a solid horizontal line.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 If an element of a menu is a list, it is treated as a submenu. The name of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 that submenu (the first element in the list) will be used as the name of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 item representing this menu on the parent.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 If an element of a menubar is `nil', then it is used to represent the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 division between the set of menubar-items which are flushleft and those
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 which are flushright.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 Otherwise, the element must be a vector, which describes a menu item.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 A menu item can have any of the following forms:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 [ "name" callback <active-p> ]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 [ "name" callback <active-p> <suffix> ]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 [ "name" callback :<keyword> <value> :<keyword> <value> ... ]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 The name is the string to display on the menu; it is filtered through the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 resource database, so it is possible for resources to override what string
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 is actually displayed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 If the `callback' of a menu item is a symbol, then it must name a command.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 It will be invoked with `call-interactively'. If it is a list, then it is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 evaluated with `eval'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 The possible keywords are this:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 :active <form> Same as <active-p> in the first two forms: the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 expression is evaluated just before the menu is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 displayed, and the menu will be selectable only if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 the result is non-nil.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 :suffix <form> Same as <suffix> in the second form: the expression
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 is evaluated just before the menu is displayed and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 resulting string is appended to the displayed name,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 providing a convenient way of adding the name of a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 command's ``argument'' to the menu, like
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 ``Kill Buffer NAME''.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 :keys "string" Normally, the keyboard equivalents of commands in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 menus are displayed when the `callback' is a symbol.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 This can be used to specify keys for more complex menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 items. It is passed through `substitute-command-keys'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 first.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 :style <style> Specifies what kind of object this menu item is:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 nil A normal menu item.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 toggle A toggle button.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 radio A radio button.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 button A menubar button.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 The only difference between toggle and radio buttons is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 how they are displayed. But for consistency, a toggle
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 button should be used when there is one option whose
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 value can be turned on or off, and radio buttons should
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 be used when there is a set of mutually exclusive
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 options. When using a group of radio buttons, you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 should arrange for no more than one to be marked as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 selected at a time.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 :selected <form> Meaningful only when STYLE is `toggle', `radio' or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 `button'. This specifies whether the button will be in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480 the selected or unselected state.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 :included <form> This can be used to control the visibility of a menu or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 menu item. The form is evaluated and the menu or menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 item is only displayed if the result is non-nil.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 :config <symbol> This is an efficient shorthand for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 :included (memq symbol menubar-configuration)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 See the variable `menubar-configuration'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 :filter <function> A menu filter can only be used in a menu item list.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 (i.e.: not in a menu item itself). It is used to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 sensitize or incrementally create a submenu only when
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 it is selected by the user and not every time the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 menubar is activated. The filter function is passed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 the list of menu items in the submenu and must return a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 list of menu items to be used for the menu. It is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 called only when the menu is about to be displayed, so
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 other menus may already be displayed. Vile and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 terrible things will happen if a menu filter function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 changes the current buffer, window, or frame. It
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 also should not raise, lower, or iconify any frames.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 Basically, the filter function should have no
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 side-effects.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 :key-sequence keys Used in FSF Emacs as an hint to an equivalent keybinding.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 Ignored by XEnacs for easymenu.el compatability.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 :label <form> (unimplemented!) Like :suffix, but replaces label
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 completely.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 (might be added in 21.2).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 For example:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 ("File"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 :filter file-menu-filter ; file-menu-filter is a function that takes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 ; one argument (a list of menu items) and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 ; returns a list of menu items
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 [ "Save As..." write-file t ]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 [ "Revert Buffer" revert-buffer (buffer-modified-p) ]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 [ "Read Only" toggle-read-only :style toggle
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 :selected buffer-read-only ]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 See x-menubar.el for many more examples.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 After the menubar is clicked upon, but before any menus are popped up,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 the functions on the `activate-menubar-hook' are invoked to make top-level
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 changes to the menus and menubar. Note, however, that the use of menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 filters (using the :filter keyword) is usually a more efficient way to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 dynamically alter or sensitize menus.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 */, menubar_variable_changed);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 Vcurrent_menubar = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 DEFVAR_LISP ("activate-menubar-hook", &Vactivate_menubar_hook /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 Function or functions called before a menubar menu is pulled down.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 These functions are called with no arguments, and should interrogate and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 modify the value of `current-menubar' as desired.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 The functions on this hook are invoked after the mouse goes down, but before
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 the menu is mapped, and may be used to activate, deactivate, add, or delete
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 items from the menus. However, it is probably the case that using a :filter
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 keyword in a submenu would be a more efficient way of updating menus. See
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544 the documentation of `current-menubar'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 These functions may return the symbol `t' to assert that they have made
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 no changes to the menubar. If any other value is returned, the menubar is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 recomputed. If `t' is returned but the menubar has been changed, then the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 changes may not show up right away. Returning `nil' when the menubar has
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 not changed is not so bad; more computation will be done, but redisplay of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 the menubar will still be performed optimally.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 Vactivate_menubar_hook = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 defsymbol (&Qactivate_menubar_hook, "activate-menubar-hook");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 DEFVAR_BOOL ("menubar-show-keybindings", &menubar_show_keybindings /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 If true, the menubar will display keyboard equivalents.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 If false, only the command names will be displayed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 menubar_show_keybindings = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 DEFVAR_LISP_MAGIC ("menubar-configuration", &Vmenubar_configuration /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 A list of symbols, against which the value of the :config tag for each
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 menubar item will be compared. If a menubar item has a :config tag, then
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 it is omitted from the menubar if that tag is not a member of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 `menubar-configuration' list.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 */ , menubar_variable_changed);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 Vmenubar_configuration = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 DEFVAR_LISP ("menubar-pointer-glyph", &Vmenubar_pointer_glyph /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 *The shape of the mouse-pointer when over the menubar.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572 This is a glyph; use `set-glyph-image' to change it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
573 If unspecified in a particular domain, the window-system-provided
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 default pointer is used.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 Fprovide (intern ("menubar"));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 specifier_vars_of_menubar (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 DEFVAR_SPECIFIER ("menubar-visible-p", &Vmenubar_visible_p /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 *Whether the menubar is visible.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 This is a specifier; use `set-specifier' to change it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 Vmenubar_visible_p = Fmake_specifier (Qboolean);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 set_specifier_fallback (Vmenubar_visible_p, list1 (Fcons (Qnil, Qt)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 set_specifier_caching (Vmenubar_visible_p,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 slot_offset (struct window,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 menubar_visible_p),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 menubar_visible_p_changed,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 slot_offset (struct frame,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 menubar_visible_p),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 menubar_visible_p_changed_in_frame);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 complex_vars_of_menubar (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 Vmenubar_pointer_glyph = Fmake_glyph_internal (Qpointer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 }