comparison src/menubar.c @ 185:3d6bfa290dbd r20-3b19

Import from CVS: tag r20-3b19
author cvs
date Mon, 13 Aug 2007 09:55:28 +0200
parents 6075d714658b
children a2f645c6b9f8
comparison
equal deleted inserted replaced
184:bcd2674570bf 185:3d6bfa290dbd
112 item representing this menu on the parent. 112 item representing this menu on the parent.
113 113
114 Otherwise, the element must be a vector, which describes a menu item. 114 Otherwise, the element must be a vector, which describes a menu item.
115 A menu item can have any of the following forms: 115 A menu item can have any of the following forms:
116 116
117 [ \"name\" callback <active-p> ] 117 [ "name" callback <active-p> ]
118 [ \"name\" callback <active-p> \"suffix\" ] 118 [ "name" callback <active-p> "suffix" ]
119 [ \"name\" callback :<keyword> <value> :<keyword> <value> ... ] 119 [ "name" callback :<keyword> <value> :<keyword> <value> ... ]
120 120
121 The name is the string to display on the menu; it is filtered through the 121 The name is the string to display on the menu; it is filtered through the
122 resource database, so it is possible for resources to override what string 122 resource database, so it is possible for resources to override what string
123 is actually displayed. 123 is actually displayed.
124 124
131 :active <form> Same as <active-p> in the first two forms: the 131 :active <form> Same as <active-p> in the first two forms: the
132 expression is evaluated just before the menu is 132 expression is evaluated just before the menu is
133 displayed, and the menu will be selectable only if 133 displayed, and the menu will be selectable only if
134 the result is non-nil. 134 the result is non-nil.
135 135
136 :suffix \"string\" Same as \"suffix\" in the second form: the suffix is 136 :suffix "string" Same as "suffix" in the second form: the suffix is
137 appended to the displayed name, providing a convenient 137 appended to the displayed name, providing a convenient
138 way of adding the name of a command's ``argument'' to 138 way of adding the name of a command's ``argument'' to
139 the menu, like ``Kill Buffer NAME''. 139 the menu, like ``Kill Buffer NAME''.
140 140
141 :keys \"string\" Normally, the keyboard equivalents of commands in 141 :keys "string" Normally, the keyboard equivalents of commands in
142 menus are displayed when the `callback' is a symbol. 142 menus are displayed when the `callback' is a symbol.
143 This can be used to specify keys for more complex menu 143 This can be used to specify keys for more complex menu
144 items. It is passed through `substitute-command-keys' 144 items. It is passed through `substitute-command-keys'
145 first. 145 first.
146 146
163 This specifies whether the button will be in the 163 This specifies whether the button will be in the
164 selected or unselected state. 164 selected or unselected state.
165 165
166 For example: 166 For example:
167 167
168 [ \"Save As...\" write-file t ] 168 [ "Save As..." write-file t ]
169 [ \"Revert Buffer\" revert-buffer (buffer-modified-p) ] 169 [ "Revert Buffer" revert-buffer (buffer-modified-p) ]
170 [ \"Read Only\" toggle-read-only :style toggle :selected buffer-read-only ] 170 [ "Read Only" toggle-read-only :style toggle :selected buffer-read-only ]
171 171
172 See menubar.el for many more examples. 172 See menubar.el for many more examples.
173 */ 173 */
174 (menu_desc, event)) 174 (menu_desc, event))
175 { 175 {
205 static CONST char *blank_msg = "No active menubar"; 205 static CONST char *blank_msg = "No active menubar";
206 206
207 menu_item[0] = build_string (""); 207 menu_item[0] = build_string ("");
208 menu_item[1] = Qnil; 208 menu_item[1] = Qnil;
209 menu_item[2] = Qnil; 209 menu_item[2] = Qnil;
210 Vblank_menubar = Fcons (Fcons (build_string (blank_msg), 210 Vblank_menubar = Fcons (Fcons (build_string (blank_msg),
211 Fcons (Fvector (3, &menu_item[0]), 211 Fcons (Fvector (3, &menu_item[0]),
212 Qnil)), 212 Qnil)),
213 Qnil); 213 Qnil);
214 Vblank_menubar = Fpurecopy (Vblank_menubar); 214 Vblank_menubar = Fpurecopy (Vblank_menubar);
215 staticpro (&Vblank_menubar); 215 staticpro (&Vblank_menubar);
216 } 216 }
259 which are flushright. 259 which are flushright.
260 260
261 Otherwise, the element must be a vector, which describes a menu item. 261 Otherwise, the element must be a vector, which describes a menu item.
262 A menu item can have any of the following forms: 262 A menu item can have any of the following forms:
263 263
264 [ \"name\" callback <active-p> ] 264 [ "name" callback <active-p> ]
265 [ \"name\" callback <active-p> \"suffix\" ] 265 [ "name" callback <active-p> "suffix" ]
266 [ \"name\" callback :<keyword> <value> :<keyword> <value> ... ] 266 [ "name" callback :<keyword> <value> :<keyword> <value> ... ]
267 267
268 The name is the string to display on the menu; it is filtered through the 268 The name is the string to display on the menu; it is filtered through the
269 resource database, so it is possible for resources to override what string 269 resource database, so it is possible for resources to override what string
270 is actually displayed. 270 is actually displayed.
271 271
278 :active <form> Same as <active-p> in the first two forms: the 278 :active <form> Same as <active-p> in the first two forms: the
279 expression is evaluated just before the menu is 279 expression is evaluated just before the menu is
280 displayed, and the menu will be selectable only if 280 displayed, and the menu will be selectable only if
281 the result is non-nil. 281 the result is non-nil.
282 282
283 :suffix \"string\" Same as \"suffix\" in the second form: the suffix is 283 :suffix "string" Same as "suffix" in the second form: the suffix is
284 appended to the displayed name, providing a convenient 284 appended to the displayed name, providing a convenient
285 way of adding the name of a command's ``argument'' to 285 way of adding the name of a command's ``argument'' to
286 the menu, like ``Kill Buffer NAME''. 286 the menu, like ``Kill Buffer NAME''.
287 287
288 :keys \"string\" Normally, the keyboard equivalents of commands in 288 :keys "string" Normally, the keyboard equivalents of commands in
289 menus are displayed when the `callback' is a symbol. 289 menus are displayed when the `callback' is a symbol.
290 This can be used to specify keys for more complex menu 290 This can be used to specify keys for more complex menu
291 items. It is passed through `substitute-command-keys' 291 items. It is passed through `substitute-command-keys'
292 first. 292 first.
293 293
334 Basically, the filter function should have no 334 Basically, the filter function should have no
335 side-effects. 335 side-effects.
336 336
337 For example: 337 For example:
338 338
339 (\"File\" 339 ("File"
340 :filter file-menu-filter ; file-menu-filter is a function that takes 340 :filter file-menu-filter ; file-menu-filter is a function that takes
341 ; one argument (a list of menu items) and 341 ; one argument (a list of menu items) and
342 ; returns a list of menu items 342 ; returns a list of menu items
343 [ \"Save As...\" write-file t ] 343 [ "Save As..." write-file t ]
344 [ \"Revert Buffer\" revert-buffer (buffer-modified-p) ] 344 [ "Revert Buffer" revert-buffer (buffer-modified-p) ]
345 [ \"Read Only\" toggle-read-only :style toggle 345 [ "Read Only" toggle-read-only :style toggle
346 :selected buffer-read-only ] 346 :selected buffer-read-only ]
347 ) 347 )
348 348
349 See x-menubar.el for many more examples. 349 See x-menubar.el for many more examples.
350 350