-;;; tool-bar.el --- Setting up the tool bar
+;;; tool-bar.el --- setting up the tool bar
;;
-;; Copyright (C) 2000 Free Software Foundation, Inc.
+;; Copyright (C) 2000, 2001 Free Software Foundation, Inc.
;;
;; Author: Dave Love <fx@gnu.org>
;; Keywords: mouse frames
:global t
:group 'mouse
:group 'frames
- (let ((lines (if tool-bar-mode 1 0)))
- ;; Alter existing frames...
- (mapc (lambda (frame)
- (modify-frame-parameters frame
- (list (cons 'tool-bar-lines lines))))
- (frame-list))
- ;; ...and future ones.
- (let ((elt (assq 'tool-bar-lines default-frame-alist)))
- (if elt
- (setcdr elt lines)
- (add-to-list 'default-frame-alist (cons 'tool-bar-lines lines)))))
- (if (and tool-bar-mode
- (display-graphic-p)
- (= 1 (length (default-value 'tool-bar-map)))) ; not yet setup
- (tool-bar-setup)))
+ (and (display-images-p)
+ (let ((lines (if tool-bar-mode 1 0)))
+ ;; Alter existing frames...
+ (mapc (lambda (frame)
+ (modify-frame-parameters frame
+ (list (cons 'tool-bar-lines lines))))
+ (frame-list))
+ ;; ...and future ones.
+ (let ((elt (assq 'tool-bar-lines default-frame-alist)))
+ (if elt
+ (setcdr elt lines)
+ (add-to-list 'default-frame-alist (cons 'tool-bar-lines lines)))))
+ (if (and tool-bar-mode
+ (display-graphic-p)
+ (= 1 (length (default-value 'tool-bar-map)))) ; not yet setup
+ (tool-bar-setup))))
(defvar tool-bar-map (make-sparse-keymap)
"Keymap for the tool bar.
(append (list :type 'xbm :file (concat icon ".xbm"))
colors)
(list :type 'xpm :file (concat icon ".xpm")))))))
- (when image
+ (when (and (display-images-p) image)
(unless (image-mask-p image)
(setq image (append image '(:mask heuristic))))
(define-key-after tool-bar-map (vector key)
(list :type 'xpm :file (concat icon ".xpm")))))
(image (find-image spec))
submap key)
- (when image
+ (when (and (display-images-p) image)
;; We'll pick up the last valid entry in the list of keys if
;; there's more than one.
(dolist (k keys)
(setq submap (eval submap)))
(unless (image-mask-p image)
(setq image (append image '(:mask heuristic))))
- (define-key-after tool-bar-map (vector key)
- (append (cdr (assq key (cdr submap))) (list :image image) props)))))
+ (let ((defn (assq key (cdr submap))))
+ (if (eq (cadr defn) 'menu-item)
+ (define-key-after tool-bar-map (vector key)
+ (append (cdr defn) (list :image image) props))
+ (setq defn (cdr defn))
+ (define-key-after tool-bar-map (vector key)
+ (append `(menu-item ,(car defn) ,(cddr defn))
+ (list :image image) props)))))))
;;; Set up some global items. Additions/deletions up for grabs.
(defun tool-bar-setup ()
- (tool-bar-add-item-from-menu 'save-buffers-kill-emacs "exit")
+ ;; People say it's bad to have EXIT on the tool bar, since users
+ ;; might inadvertently click that button.
+ ;;(tool-bar-add-item-from-menu 'save-buffers-kill-emacs "exit")
(tool-bar-add-item-from-menu 'find-file "new")
(tool-bar-add-item-from-menu 'dired "open")
(tool-bar-add-item-from-menu 'kill-this-buffer "close")