comparison src/menubar.c @ 398:74fd4e045ea6 r21-2-29

Import from CVS: tag r21-2-29
author cvs
date Mon, 13 Aug 2007 11:13:30 +0200
parents aabb7f5b1c81
children 2f8bb876ab1d
comparison
equal deleted inserted replaced
397:f4aeb21a5bad 398:74fd4e045ea6
93 { 93 {
94 update_frame_menubars (f); 94 update_frame_menubars (f);
95 } 95 }
96 96
97 Lisp_Object 97 Lisp_Object
98 current_frame_menubar (CONST struct frame* f) 98 current_frame_menubar (const struct frame* f)
99 { 99 {
100 struct window *w = XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f)); 100 struct window *w = XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f));
101 return symbol_value_in_buffer (Qcurrent_menubar, w->buffer); 101 return symbol_value_in_buffer (Qcurrent_menubar, w->buffer);
102 } 102 }
103 103
104 Lisp_Object 104 Lisp_Object
105 menu_parse_submenu_keywords (Lisp_Object desc, struct gui_item* pgui_item) 105 menu_parse_submenu_keywords (Lisp_Object desc, Lisp_Object gui_item)
106 { 106 {
107 Lisp_Gui_Item* pgui_item = XGUI_ITEM (gui_item);
108
107 /* Menu descriptor should be a list */ 109 /* Menu descriptor should be a list */
108 CHECK_CONS (desc); 110 CHECK_CONS (desc);
109 111
110 /* First element may be menu name, although can be omitted. 112 /* First element may be menu name, although can be omitted.
111 Let's think that if stuff begins with anything than a keyword 113 Let's think that if stuff begins with anything than a keyword
128 CHECK_CONS (desc); 130 CHECK_CONS (desc);
129 val = XCAR (desc); 131 val = XCAR (desc);
130 desc = XCDR (desc); 132 desc = XCDR (desc);
131 if (!NILP (desc)) 133 if (!NILP (desc))
132 CHECK_CONS (desc); 134 CHECK_CONS (desc);
133 gui_item_add_keyval_pair (pgui_item, key, val, ERROR_ME); 135 gui_item_add_keyval_pair (gui_item, key, val, ERROR_ME);
134 } 136 }
135 137
136 /* Return the rest - supposed to be a list of items */ 138 /* Return the rest - supposed to be a list of items */
137 return desc; 139 return desc;
138 } 140 }
150 */ 152 */
151 (desc, path)) 153 (desc, path))
152 { 154 {
153 Lisp_Object path_entry, submenu_desc, submenu; 155 Lisp_Object path_entry, submenu_desc, submenu;
154 struct gcpro gcpro1; 156 struct gcpro gcpro1;
155 struct gui_item gui_item; 157 Lisp_Object gui_item = allocate_gui_item ();
156 158 Lisp_Gui_Item* pgui_item = XGUI_ITEM (gui_item);
157 gui_item_init (&gui_item); 159
158 GCPRO_GUI_ITEM (&gui_item); 160 GCPRO1 (gui_item);
159 161
160 EXTERNAL_LIST_LOOP (path_entry, path) 162 EXTERNAL_LIST_LOOP (path_entry, path)
161 { 163 {
162 /* Verify that DESC describes a menu, not single item */ 164 /* Verify that DESC describes a menu, not single item */
163 if (!CONSP (desc)) 165 if (!CONSP (desc))
164 RETURN_UNGCPRO (Qnil); 166 RETURN_UNGCPRO (Qnil);
165 167
166 /* Parse this menu */ 168 /* Parse this menu */
167 desc = menu_parse_submenu_keywords (desc, &gui_item); 169 desc = menu_parse_submenu_keywords (desc, gui_item);
168 170
169 /* Check that this (sub)menu is active */ 171 /* Check that this (sub)menu is active */
170 if (!gui_item_active_p (&gui_item)) 172 if (!gui_item_active_p (gui_item))
171 RETURN_UNGCPRO (Qnil); 173 RETURN_UNGCPRO (Qnil);
172 174
173 /* Apply :filter */ 175 /* Apply :filter */
174 if (!NILP (gui_item.filter)) 176 if (!NILP (pgui_item->filter))
175 desc = call1 (gui_item.filter, desc); 177 desc = call1 (pgui_item->filter, desc);
176 178
177 /* Find the next menu on the path inside this one */ 179 /* Find the next menu on the path inside this one */
178 EXTERNAL_LIST_LOOP (submenu_desc, desc) 180 EXTERNAL_LIST_LOOP (submenu_desc, desc)
179 { 181 {
180 submenu = XCAR (submenu_desc); 182 submenu = XCAR (submenu_desc);
189 /* Submenu not found */ 191 /* Submenu not found */
190 RETURN_UNGCPRO (Qnil); 192 RETURN_UNGCPRO (Qnil);
191 193
192 descend: 194 descend:
193 /* Prepare for the next iteration */ 195 /* Prepare for the next iteration */
194 gui_item_init (&gui_item); 196 gui_item_init (gui_item);
195 } 197 }
196 198
197 /* We have successfully descended down the end of the path */ 199 /* We have successfully descended down the end of the path */
198 UNGCPRO; 200 UNGCPRO;
199 return desc; 201 return desc;
292 Menu item names should be converted to normal form before being compared. 294 Menu item names should be converted to normal form before being compared.
293 */ 295 */
294 (name, buffer)) 296 (name, buffer))
295 { 297 {
296 struct buffer *buf = decode_buffer (buffer, 0); 298 struct buffer *buf = decode_buffer (buffer, 0);
297 struct Lisp_String *n; 299 Lisp_String *n;
298 Charcount end; 300 Charcount end;
299 int i; 301 int i;
300 Bufbyte *name_data; 302 Bufbyte *name_data;
301 Bufbyte *string_result; 303 Bufbyte *string_result;
302 Bufbyte *string_result_ptr; 304 Bufbyte *string_result_ptr;
351 } 353 }
352 354
353 void 355 void
354 vars_of_menubar (void) 356 vars_of_menubar (void)
355 { 357 {
356 { 358 /* put in Vblank_menubar a menubar value which has no visible
357 /* put in Vblank_menubar a menubar value which has no visible 359 * items. This is a bit tricky due to various quirks. We
358 * items. This is a bit tricky due to various quirks. We 360 * could use '(["" nil nil]), but this is apparently equivalent
359 * could use '(["" nil nil]), but this is apparently equivalent 361 * to '(nil), and a new frame created with this menubar will
360 * to '(nil), and a new frame created with this menubar will 362 * get a vertically-squished menubar. If we use " " as the
361 * get a vertically-squished menubar. If we use " " as the 363 * button title instead of "", we get an etched button border.
362 * button title instead of "", we get an etched button border. 364 * So we use
363 * So we use 365 * '(("No active menubar" ["" nil nil]))
364 * '(("No active menubar" ["" nil nil])) 366 * which creates a menu whose title is "No active menubar",
365 * which creates a menu whose title is "No active menubar", 367 * and this works fine.
366 * and this works fine. 368 */
367 */ 369
368 370 Vblank_menubar = list1 (list2 (build_string ("No active menubar"),
369 Lisp_Object menu_item[3]; 371 vector3 (build_string (""), Qnil, Qnil)));
370 static CONST char *blank_msg = "No active menubar"; 372 staticpro (&Vblank_menubar);
371
372 menu_item[0] = build_string ("");
373 menu_item[1] = Qnil;
374 menu_item[2] = Qnil;
375 Vblank_menubar = Fcons (Fcons (build_string (blank_msg),
376 Fcons (Fvector (3, &menu_item[0]),
377 Qnil)),
378 Qnil);
379 Vblank_menubar = Fpurecopy (Vblank_menubar);
380 staticpro (&Vblank_menubar);
381 }
382 373
383 DEFVAR_BOOL ("popup-menu-titles", &popup_menu_titles /* 374 DEFVAR_BOOL ("popup-menu-titles", &popup_menu_titles /*
384 If true, popup menus will have title bars at the top. 375 If true, popup menus will have title bars at the top.
385 */ ); 376 */ );
386 popup_menu_titles = 1; 377 popup_menu_titles = 1;
500 also should not raise, lower, or iconify any frames. 491 also should not raise, lower, or iconify any frames.
501 Basically, the filter function should have no 492 Basically, the filter function should have no
502 side-effects. 493 side-effects.
503 494
504 :key-sequence keys Used in FSF Emacs as an hint to an equivalent keybinding. 495 :key-sequence keys Used in FSF Emacs as an hint to an equivalent keybinding.
505 Ignored by XEnacs for easymenu.el compatability. 496 Ignored by XEnacs for easymenu.el compatibility.
506 497
507 :label <form> (unimplemented!) Like :suffix, but replaces label 498 :label <form> (unimplemented!) Like :suffix, but replaces label
508 completely. 499 completely.
509 (might be added in 21.2). 500 (might be added in 21.2).
510 501
585 */ ); 576 */ );
586 Vmenubar_visible_p = Fmake_specifier (Qboolean); 577 Vmenubar_visible_p = Fmake_specifier (Qboolean);
587 578
588 set_specifier_fallback (Vmenubar_visible_p, list1 (Fcons (Qnil, Qt))); 579 set_specifier_fallback (Vmenubar_visible_p, list1 (Fcons (Qnil, Qt)));
589 set_specifier_caching (Vmenubar_visible_p, 580 set_specifier_caching (Vmenubar_visible_p,
590 slot_offset (struct window, 581 offsetof (struct window, menubar_visible_p),
591 menubar_visible_p),
592 menubar_visible_p_changed, 582 menubar_visible_p_changed,
593 slot_offset (struct frame, 583 offsetof (struct frame, menubar_visible_p),
594 menubar_visible_p),
595 menubar_visible_p_changed_in_frame); 584 menubar_visible_p_changed_in_frame);
596 } 585 }
597 586
598 void 587 void
599 complex_vars_of_menubar (void) 588 complex_vars_of_menubar (void)