diff options
| author | Juri Linkov | 2019-10-15 01:43:45 +0300 |
|---|---|---|
| committer | Juri Linkov | 2019-10-15 01:43:45 +0300 |
| commit | 8a089a95d8dc5a3b579a349785793dd52ecdb7cd (patch) | |
| tree | 051d92ba5131c6efb46de6c4cb58826b0df060a4 | |
| parent | d4cfe67e8ae4392fc1f01879f6d3a9a8b6947ac1 (diff) | |
| download | emacs-8a089a95d8dc5a3b579a349785793dd52ecdb7cd.tar.gz emacs-8a089a95d8dc5a3b579a349785793dd52ecdb7cd.zip | |
Add images on tab-bar buttons the first time the tab bar is activated
* lisp/tab-bar.el (tab-bar-mode): Set display property with image files
on tab-bar-new-button and tab-bar-close-button when tab-bar-mode is enabled
the first time.
(tab-bar-new-button, tab-bar-close-button): Use default values
without display image properties. (Bug#37685)
| -rw-r--r-- | lisp/tab-bar.el | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index 23ac243f53d..3fe750908b5 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el | |||
| @@ -99,6 +99,29 @@ | |||
| 99 | (cons (cons 'tab-bar-lines val) | 99 | (cons (cons 'tab-bar-lines val) |
| 100 | (assq-delete-all 'tab-bar-lines | 100 | (assq-delete-all 'tab-bar-lines |
| 101 | default-frame-alist))))) | 101 | default-frame-alist))))) |
| 102 | |||
| 103 | (when (and tab-bar-mode (not (get-text-property 0 'display tab-bar-new-button))) | ||
| 104 | ;; This file is pre-loaded so only here we can use the right data-directory: | ||
| 105 | (let ((file (expand-file-name "images/tabs/new.xpm" data-directory))) | ||
| 106 | (when (file-exists-p file) | ||
| 107 | (add-text-properties 0 (length tab-bar-new-button) | ||
| 108 | `(display (image :type xpm | ||
| 109 | :file ,file | ||
| 110 | :margin (2 . 0) | ||
| 111 | :ascent center)) | ||
| 112 | tab-bar-new-button)))) | ||
| 113 | |||
| 114 | (when (and tab-bar-mode (not (get-text-property 0 'display tab-bar-close-button))) | ||
| 115 | ;; This file is pre-loaded so only here we can use the right data-directory: | ||
| 116 | (let ((file (expand-file-name "images/tabs/close.xpm" data-directory))) | ||
| 117 | (when (file-exists-p file) | ||
| 118 | (add-text-properties 0 (length tab-bar-close-button) | ||
| 119 | `(display (image :type xpm | ||
| 120 | :file ,file | ||
| 121 | :margin (2 . 0) | ||
| 122 | :ascent center)) | ||
| 123 | tab-bar-close-button)))) | ||
| 124 | |||
| 102 | (when tab-bar-mode | 125 | (when tab-bar-mode |
| 103 | (global-set-key [(control shift iso-lefttab)] 'tab-previous) | 126 | (global-set-key [(control shift iso-lefttab)] 'tab-previous) |
| 104 | (global-set-key [(control shift tab)] 'tab-previous) | 127 | (global-set-key [(control shift tab)] 'tab-previous) |
| @@ -198,14 +221,7 @@ before calling the command that adds a new tab." | |||
| 198 | :group 'tab-bar | 221 | :group 'tab-bar |
| 199 | :version "27.1") | 222 | :version "27.1") |
| 200 | 223 | ||
| 201 | (defvar tab-bar-new-button | 224 | (defvar tab-bar-new-button " + " |
| 202 | (propertize " + " | ||
| 203 | 'display `(image :type xpm | ||
| 204 | :file ,(expand-file-name | ||
| 205 | "images/tabs/new.xpm" | ||
| 206 | data-directory) | ||
| 207 | :margin (2 . 0) | ||
| 208 | :ascent center)) | ||
| 209 | "Button for creating a new tab.") | 225 | "Button for creating a new tab.") |
| 210 | 226 | ||
| 211 | (defcustom tab-bar-close-button-show t | 227 | (defcustom tab-bar-close-button-show t |
| @@ -227,12 +243,6 @@ If nil, don't show it at all." | |||
| 227 | 243 | ||
| 228 | (defvar tab-bar-close-button | 244 | (defvar tab-bar-close-button |
| 229 | (propertize " x" | 245 | (propertize " x" |
| 230 | 'display `(image :type xpm | ||
| 231 | :file ,(expand-file-name | ||
| 232 | "images/tabs/close.xpm" | ||
| 233 | data-directory) | ||
| 234 | :margin (2 . 0) | ||
| 235 | :ascent center) | ||
| 236 | 'close-tab t | 246 | 'close-tab t |
| 237 | :help "Click to close tab") | 247 | :help "Click to close tab") |
| 238 | "Button for closing the clicked tab.") | 248 | "Button for closing the clicked tab.") |