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