emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

scratch/icons 4de626ea22 08/11: Support using icons.el in toolbar


From: Stefan Kangas
Subject: scratch/icons 4de626ea22 08/11: Support using icons.el in toolbar
Date: Wed, 24 Aug 2022 02:40:44 -0400 (EDT)

branch: scratch/icons
commit 4de626ea229f9237a2db69737d803a8ad65b6452
Author: Stefan Kangas <stefan@marxist.se>
Commit: Stefan Kangas <stefankangas@gmail.com>

    Support using icons.el in toolbar
---
 lisp/tool-bar.el | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/lisp/tool-bar.el b/lisp/tool-bar.el
index b1f7a70e33..4445c193a2 100644
--- a/lisp/tool-bar.el
+++ b/lisp/tool-bar.el
@@ -156,25 +156,32 @@ To define items in any other map, use 
`tool-bar-local-item'."
   (apply #'tool-bar-local-item icon def key tool-bar-map props)
   (tool-bar--flush-cache))
 
+(defun tool-bar--image-expression-make-spec (type icon ext &optional colors)
+  (append (list :type type
+                :file (if (and (file-name-absolute-p icon)
+                               (equal (file-name-extension icon) ext))
+                          icon
+                        (concat icon "." ext)))
+          colors))
+
 (defun tool-bar--image-expression (icon)
   "Return an expression that evaluates to an image spec for ICON."
   (let* ((fg (face-attribute 'tool-bar :foreground))
         (bg (face-attribute 'tool-bar :background))
         (colors (nconc (if (eq fg 'unspecified) nil (list :foreground fg))
                        (if (eq bg 'unspecified) nil (list :background bg))))
-        (xpm-spec (list :type 'xpm :file (concat icon ".xpm")))
-        (xpm-lo-spec (list :type 'xpm :file
-                           (concat "low-color/" icon ".xpm")))
-        (pbm-spec (append (list :type 'pbm :file
-                                 (concat icon ".pbm")) colors))
-        (xbm-spec (append (list :type 'xbm :file
-                                 (concat icon ".xbm")) colors)))
+         (xpm-spec (tool-bar--image-expression-make-spec 'xpm icon "xpm"))
+         (xpm-lo-spec (tool-bar--image-expression-make-spec
+                       'xpm (concat "low-color/" icon) "xpm"))
+         (pbm-spec (tool-bar--image-expression-make-spec 'pbm icon "pbm" 
colors))
+         (xbm-spec (tool-bar--image-expression-make-spec 'xbm icon "xbm" 
colors))
+         (svg-spec (tool-bar--image-expression-make-spec 'svg icon "svg" 
colors)))
     `(find-image (cond ((not (display-color-p))
-                       ',(list pbm-spec xbm-spec xpm-lo-spec xpm-spec))
+                        ',(list svg-spec pbm-spec xbm-spec xpm-lo-spec 
xpm-spec))
                       ((< (display-color-cells) 256)
-                       ',(list xpm-lo-spec xpm-spec pbm-spec xbm-spec))
+                        ',(list svg-spec xpm-lo-spec xpm-spec pbm-spec 
xbm-spec))
                       (t
-                       ',(list xpm-spec pbm-spec xbm-spec)))
+                        ',(list svg-spec xpm-spec pbm-spec xbm-spec)))
                  t)))
 
 ;;;###autoload



reply via email to

[Prev in Thread] Current Thread [Next in Thread]