From 2531aebfd21de84261834d189fda87844e92b1f5 Mon Sep 17 00:00:00 2001 From: "Elias G. Perez" Date: Thu, 9 May 2024 19:18:43 -0600 Subject: [PATCH] SVG and tango icon theme support --- lisp/tool-bar.el | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/lisp/tool-bar.el b/lisp/tool-bar.el index 20efddb..d183123 100644 --- a/lisp/tool-bar.el +++ b/lisp/tool-bar.el @@ -211,25 +211,43 @@ 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)) +(defcustom tool-bar-icon-theme 'tango + "Specify icon theme for tool-bar. +Possible values are `tango' and `classic'" + :type 'symbol) + (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-spec (list :type 'xpm :file + (concat icon + (if (eq tool-bar-icon-theme 'tango) "tango/") + ".xpm"))) (xpm-lo-spec (list :type 'xpm :file (concat "low-color/" icon ".xpm"))) (pbm-spec (append (list :type 'pbm :file - (concat icon ".pbm")) colors)) + (concat icon + (if (eq tool-bar-icon-theme 'tango) "tango/") + ".pbm")) colors)) (xbm-spec (append (list :type 'xbm :file (concat icon ".xbm")) colors)) (png-spec (append (list :type 'png :file - (concat icon ".png")) colors))) + (concat icon + (if (eq tool-bar-icon-theme 'tango) "tango/") + ".png")) colors)) + (svg-spec (append (list :type 'svg :file + (concat icon + (if (eq tool-bar-icon-theme 'tango) "tango/") + ".svg")) colors))) `(find-image (cond ((not (display-color-p)) ',(list pbm-spec xbm-spec xpm-lo-spec xpm-spec)) ((< (display-color-cells) 256) ',(list xpm-lo-spec xpm-spec pbm-spec xbm-spec)) + ((fboundp 'svg-image) + ',(list png-spec xpm-spec pbm-spec xbm-spec svg-spec)) (t ',(list png-spec xpm-spec pbm-spec xbm-spec))) t))) -- 2.44.0.windows.1