comparison lisp/tool-bar.el @ 91040:14c4a6aac623

Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (patch 866-879) - Merge multi-tty branch - Update from CVS - Merge from emacs--rel--22 Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-257
author Miles Bader <miles@gnu.org>
date Thu, 11 Oct 2007 16:14:00 +0000
parents 65663fcd2caa
children 107ccd98fa12
comparison
equal deleted inserted replaced
91039:eefadc1e1d5e 91040:14c4a6aac623
53 :init-value nil 53 :init-value nil
54 :global t 54 :global t
55 :group 'mouse 55 :group 'mouse
56 :group 'frames 56 :group 'frames
57 (and (display-images-p) 57 (and (display-images-p)
58 (let ((lines (if tool-bar-mode 1 0))) 58 (modify-all-frames-parameters (list (cons 'tool-bar-lines
59 ;; Alter existing frames... 59 (if tool-bar-mode 1 0))))
60 (mapc (lambda (frame)
61 (modify-frame-parameters frame
62 (list (cons 'tool-bar-lines lines))))
63 (frame-list))
64 ;; ...and future ones.
65 (let ((elt (assq 'tool-bar-lines default-frame-alist)))
66 (if elt
67 (setcdr elt lines)
68 (add-to-list 'default-frame-alist (cons 'tool-bar-lines lines)))))
69 (if (and tool-bar-mode 60 (if (and tool-bar-mode
70 (display-graphic-p) 61 (display-graphic-p))
71 (= 1 (length (default-value 'tool-bar-map)))) ; not yet setup
72 (tool-bar-setup)))) 62 (tool-bar-setup))))
63
64 ;;;###autoload
65 ;; Used in the Show/Hide menu, to have the toggle reflect the current frame.
66 (defun toggle-tool-bar-mode-from-frame (&optional arg)
67 "Toggle tool bar on or off, based on the status of the current frame.
68 See `tool-bar-mode' for more information."
69 (interactive (list (or current-prefix-arg 'toggle)))
70 (if (eq arg 'toggle)
71 (tool-bar-mode (if (> (frame-parameter nil 'tool-bar-lines) 0) 0 1))
72 (tool-bar-mode arg)))
73 73
74 ;;;###autoload 74 ;;;###autoload
75 ;; We want to pretend the toolbar by standard is on, as this will make 75 ;; We want to pretend the toolbar by standard is on, as this will make
76 ;; customize consider disabling the toolbar a customization, and save 76 ;; customize consider disabling the toolbar a customization, and save
77 ;; that. We could do this for real by setting :init-value above, but 77 ;; that. We could do this for real by setting :init-value above, but
226 (append `(menu-item ,(car defn) ,rest) 226 (append `(menu-item ,(car defn) ,rest)
227 (list :image image) props)))))))) 227 (list :image image) props))))))))
228 228
229 ;;; Set up some global items. Additions/deletions up for grabs. 229 ;;; Set up some global items. Additions/deletions up for grabs.
230 230
231 (defun tool-bar-setup () 231 (defvar tool-bar-setup nil
232 ;; People say it's bad to have EXIT on the tool bar, since users 232 "t if the tool-bar has been set up by `tool-bar-setup'.")
233 ;; might inadvertently click that button. 233
234 ;;(tool-bar-add-item-from-menu 'save-buffers-kill-emacs "exit") 234 (defun tool-bar-setup (&optional frame)
235 (tool-bar-add-item-from-menu 'find-file "new") 235 (unless tool-bar-setup
236 (tool-bar-add-item-from-menu 'menu-find-file-existing "open") 236 (with-selected-frame (or frame (selected-frame))
237 (tool-bar-add-item-from-menu 'dired "diropen") 237 ;; People say it's bad to have EXIT on the tool bar, since users
238 (tool-bar-add-item-from-menu 'kill-this-buffer "close") 238 ;; might inadvertently click that button.
239 (tool-bar-add-item-from-menu 'save-buffer "save" nil 239 ;;(tool-bar-add-item-from-menu 'save-buffers-kill-emacs "exit")
240 :visible '(or buffer-file-name 240 (tool-bar-add-item-from-menu 'find-file "new")
241 (not (eq 'special 241 (tool-bar-add-item-from-menu 'menu-find-file-existing "open")
242 (get major-mode 242 (tool-bar-add-item-from-menu 'dired "diropen")
243 'mode-class))))) 243 (tool-bar-add-item-from-menu 'kill-this-buffer "close")
244 (tool-bar-add-item-from-menu 'write-file "saveas" nil 244 (tool-bar-add-item-from-menu 'save-buffer "save" nil
245 :visible '(or buffer-file-name 245 :visible '(or buffer-file-name
246 (not (eq 'special 246 (not (eq 'special
247 (get major-mode 247 (get major-mode
248 'mode-class))))) 248 'mode-class)))))
249 (tool-bar-add-item-from-menu 'undo "undo" nil 249 (tool-bar-add-item-from-menu 'write-file "saveas" nil
250 :visible '(not (eq 'special (get major-mode 250 :visible '(or buffer-file-name
251 'mode-class)))) 251 (not (eq 'special
252 (tool-bar-add-item-from-menu (lookup-key menu-bar-edit-menu [cut]) 252 (get major-mode
253 "cut" nil 253 'mode-class)))))
254 :visible '(not (eq 'special (get major-mode 254 (tool-bar-add-item-from-menu 'undo "undo" nil
255 'mode-class)))) 255 :visible '(not (eq 'special (get major-mode
256 (tool-bar-add-item-from-menu (lookup-key menu-bar-edit-menu [copy]) 256 'mode-class))))
257 "copy") 257 (tool-bar-add-item-from-menu (lookup-key menu-bar-edit-menu [cut])
258 (tool-bar-add-item-from-menu (lookup-key menu-bar-edit-menu [paste]) 258 "cut" nil
259 "paste" nil 259 :visible '(not (eq 'special (get major-mode
260 :visible '(not (eq 'special (get major-mode 260 'mode-class))))
261 'mode-class)))) 261 (tool-bar-add-item-from-menu (lookup-key menu-bar-edit-menu [copy])
262 (tool-bar-add-item-from-menu 'nonincremental-search-forward "search") 262 "copy")
263 ;;(tool-bar-add-item-from-menu 'ispell-buffer "spell") 263 (tool-bar-add-item-from-menu (lookup-key menu-bar-edit-menu [paste])
264 264 "paste" nil
265 ;; There's no icon appropriate for News and we need a command rather 265 :visible '(not (eq 'special (get major-mode
266 ;; than a lambda for Read Mail. 266 'mode-class))))
267 (tool-bar-add-item-from-menu 'nonincremental-search-forward "search")
268 ;;(tool-bar-add-item-from-menu 'ispell-buffer "spell")
269
270 ;; There's no icon appropriate for News and we need a command rather
271 ;; than a lambda for Read Mail.
267 ;;(tool-bar-add-item-from-menu 'compose-mail "mail/compose") 272 ;;(tool-bar-add-item-from-menu 'compose-mail "mail/compose")
268 273
269 (tool-bar-add-item-from-menu 'print-buffer "print") 274 (tool-bar-add-item-from-menu 'print-buffer "print")
270 275
271 ;; tool-bar-add-item-from-menu itself operates on 276 ;; tool-bar-add-item-from-menu itself operates on
279 (tool-bar-add-item "help" (lambda () 284 (tool-bar-add-item "help" (lambda ()
280 (interactive) 285 (interactive)
281 (popup-menu menu-bar-help-menu)) 286 (popup-menu menu-bar-help-menu))
282 'help 287 'help
283 :help "Pop up the Help menu")) 288 :help "Pop up the Help menu"))
284 ) 289 (setq tool-bar-setup t))))
290
285 291
286 (provide 'tool-bar) 292 (provide 'tool-bar)
287
288 ;;; arch-tag: 15f30f0a-d0d7-4d50-bbb7-f48fd0c8582f 293 ;;; arch-tag: 15f30f0a-d0d7-4d50-bbb7-f48fd0c8582f
289 ;;; tool-bar.el ends here 294 ;;; tool-bar.el ends here