]> code.delx.au - gnu-emacs/blobdiff - lisp/toolbar/tool-bar.el
Remove debugging code. From Stefan Monnier <monnier@cs.yale.edu>.
[gnu-emacs] / lisp / toolbar / tool-bar.el
index 86be7b97b960ca90881af5ea83b42ec565013f95..c4e548ef7e774539ea616128cc065c4e6c25d780 100644 (file)
@@ -1,6 +1,6 @@
 ;;; 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
@@ -50,21 +50,22 @@ conveniently adding tool bar items."
   :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.
@@ -164,8 +165,14 @@ function."
        (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.