From 49019a3938269ae2ecf7e55df943e6808fb86eb6 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 | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/lisp/tool-bar.el b/lisp/tool-bar.el index 20efddb..5a466bf 100644 --- a/lisp/tool-bar.el +++ b/lisp/tool-bar.el @@ -211,25 +211,48 @@ 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-style 'tango + "Specify icon style to use in tool-bar. +Possible values are `tango' and `classic'. + +If Emacs supports GTK it will use current icon theme. + +This variable should be set in your `early-init.el'." + :type 'symbol + :group 'frames) + (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 (if (eq tool-bar-icon-theme 'tango) "tango/") + 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)) + (concat (if (eq tool-bar-icon-theme 'tango) "tango/") + icon + ".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 (if (eq tool-bar-icon-theme 'tango) "tango/") + icon + ".png")) colors)) + (svg-spec (append (list :type 'svg :file + (concat (if (eq tool-bar-icon-theme 'tango) "tango/") + icon + ".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