summaryrefslogtreecommitdiff
path: root/lisp/tool-bar.el
diff options
context:
space:
mode:
authorChong Yidong <cyd@stupidchicken.com>2008-11-27 03:29:37 +0000
committerChong Yidong <cyd@stupidchicken.com>2008-11-27 03:29:37 +0000
commitb80679011823b46a777bf4e00caa7f791ab26a03 (patch)
tree457cad96bd348bb9fe71fd989a57253aa28300e5 /lisp/tool-bar.el
parent01d5aaeb1103f70ff7687fffaaa17c0792fb7e49 (diff)
downloademacs-b80679011823b46a777bf4e00caa7f791ab26a03.tar.gz
(tool-bar-find-image-cache): Var deleted.
(tool-bar-find-image): Function deleted. (tool-bar-local-item, tool-bar-local-item-from-menu): Use find-image instead of tool-bar-find-image. (tool-bar-keymap-cache): New hash table. (tool-bar-make-keymap): Use it. (tool-bar-make-keymap-1): Move body of tool-bar-make-keymap here.
Diffstat (limited to 'lisp/tool-bar.el')
-rw-r--r--lisp/tool-bar.el19
1 files changed, 10 insertions, 9 deletions
diff --git a/lisp/tool-bar.el b/lisp/tool-bar.el
index 59a73e2aa4e..4c0b213b3de 100644
--- a/lisp/tool-bar.el
+++ b/lisp/tool-bar.el
@@ -92,10 +92,18 @@ Define this locally to override the global tool bar.")
(declare-function image-mask-p "image.c" (spec &optional frame))
+(defconst tool-bar-keymap-cache (make-hash-table :weakness t :test 'equal))
+
(defun tool-bar-make-keymap (&optional ignore)
"Generate an actual keymap from `tool-bar-map'.
Its main job is to figure out which images to use based on the display's
color capability and based on the available image libraries."
+ (let ((key (cons (frame-terminal) tool-bar-map)))
+ (or (gethash key tool-bar-keymap-cache)
+ (puthash key (tool-bar-make-keymap-1) tool-bar-keymap-cache))))
+
+(defun tool-bar-make-keymap-1 ()
+ "Generate an actual keymap from `tool-bar-map', without caching."
(mapcar (lambda (bind)
(let (image-exp plist)
(when (and (eq (car-safe (cdr-safe bind)) 'menu-item)
@@ -119,13 +127,6 @@ color capability and based on the available image libraries."
bind))
tool-bar-map))
-(defconst tool-bar-find-image-cache (make-hash-table :weakness t :test 'equal))
-
-(defun tool-bar-find-image (specs)
- "Like `find-image' but with caching."
- (or (gethash specs tool-bar-find-image-cache)
- (puthash specs (find-image specs) tool-bar-find-image-cache)))
-
;;;###autoload
(defun tool-bar-add-item (icon def key &rest props)
"Add an item to the tool bar.
@@ -166,7 +167,7 @@ ICON.xbm, using `find-image'."
(concat icon ".pbm")) colors))
(xbm-spec (append (list :type 'xbm :file
(concat icon ".xbm")) colors))
- (image-exp `(tool-bar-find-image
+ (image-exp `(find-image
(cond ((not (display-color-p))
',(list pbm-spec xbm-spec xpm-lo-spec xpm-spec))
((< (display-color-cells) 256)
@@ -218,7 +219,7 @@ holds a keymap."
(concat icon ".pbm")) colors))
(xbm-spec (append (list :type 'xbm :file
(concat icon ".xbm")) colors))
- (image-exp `(tool-bar-find-image
+ (image-exp `(find-image
(cond ((not (display-color-p))
',(list pbm-spec xbm-spec xpm-lo-spec xpm-spec))
((< (display-color-cells) 256)