aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorChong Yidong2010-12-20 08:17:26 +0800
committerChong Yidong2010-12-20 08:17:26 +0800
commit949752705efd6a4b7478623d41b3552f93e9596c (patch)
tree3f41f09628f8c7ac17c1c771c69cdb2916cc5fb8 /lisp
parentef1b0ba7e5a82308514b8427cd84994805e61a4f (diff)
downloademacs-949752705efd6a4b7478623d41b3552f93e9596c.tar.gz
emacs-949752705efd6a4b7478623d41b3552f93e9596c.zip
Implement tool-bar separators for non-GTK tool-bars.
* lisp/tool-bar.el (tool-bar--image-expression): New function. (tool-bar-local-item, tool-bar--image-exp): Use it. (tool-bar-setup): Initialize tool-bar-separator-image-expression. Use :enable instead of :visible to avoid changing the tool-bar configuration unnecessarily. * src/keyboard.c (Vtool_bar_separator_image_expression): New variable. (parse_tool_bar_item): Use it to obtain image separators for displays not using native tool-bar separators. * src/xdisp.c (build_desired_tool_bar_string): Don't handle separators specially, since this is now done in parse_tool_bar_item. * lisp/info.el (info-tool-bar-map): Add separators.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog14
-rw-r--r--lisp/info.el3
-rw-r--r--lisp/tool-bar.el70
3 files changed, 46 insertions, 41 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 4ed1a75cda2..0c363ab7a03 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,17 @@
12010-12-20 Chong Yidong <cyd@stupidchicken.com>
2
3 * vc/diff.el (diff-better-file-name): Function deleted;
4 abbreviating file name creates problems with shell-quote-argument.
5 (diff-no-select): Just use expand-file-name.
6
7 * tool-bar.el (tool-bar--image-expression): New function.
8 (tool-bar-local-item, tool-bar--image-exp): Use it.
9 (tool-bar-setup): Initialize tool-bar-separator-image-expression.
10 Use :enable instead of :visible to avoid changing the tool-bar
11 configuration unnecessarily.
12
13 * info.el (info-tool-bar-map): Add separators.
14
12010-12-17 Ken Brown <kbrown@cornell.edu> 152010-12-17 Ken Brown <kbrown@cornell.edu>
2 16
3 * loadup.el: Use version numbers in Cygwin build. 17 * loadup.el: Use version numbers in Cygwin build.
diff --git a/lisp/info.el b/lisp/info.el
index 7c0333f6b8e..ad92914a54d 100644
--- a/lisp/info.el
+++ b/lisp/info.el
@@ -3769,14 +3769,17 @@ If FORK is non-nil, it is passed to `Info-goto-node'."
3769 :rtl "left-arrow" 3769 :rtl "left-arrow"
3770 :label "Forward" 3770 :label "Forward"
3771 :vert-only t) 3771 :vert-only t)
3772 (define-key-after map [separator-1] menu-bar-separator)
3772 (tool-bar-local-item-from-menu 'Info-prev "prev-node" map Info-mode-map 3773 (tool-bar-local-item-from-menu 'Info-prev "prev-node" map Info-mode-map
3773 :rtl "next-node") 3774 :rtl "next-node")
3774 (tool-bar-local-item-from-menu 'Info-next "next-node" map Info-mode-map 3775 (tool-bar-local-item-from-menu 'Info-next "next-node" map Info-mode-map
3775 :rtl "prev-node") 3776 :rtl "prev-node")
3776 (tool-bar-local-item-from-menu 'Info-up "up-node" map Info-mode-map 3777 (tool-bar-local-item-from-menu 'Info-up "up-node" map Info-mode-map
3777 :vert-only t) 3778 :vert-only t)
3779 (define-key-after map [separator-2] menu-bar-separator)
3778 (tool-bar-local-item-from-menu 'Info-top-node "home" map Info-mode-map) 3780 (tool-bar-local-item-from-menu 'Info-top-node "home" map Info-mode-map)
3779 (tool-bar-local-item-from-menu 'Info-goto-node "jump-to" map Info-mode-map) 3781 (tool-bar-local-item-from-menu 'Info-goto-node "jump-to" map Info-mode-map)
3782 (define-key-after map [separator-3] menu-bar-separator)
3780 (tool-bar-local-item-from-menu 'Info-index "index" map Info-mode-map 3783 (tool-bar-local-item-from-menu 'Info-index "index" map Info-mode-map
3781 :label "Index Search") 3784 :label "Index Search")
3782 (tool-bar-local-item-from-menu 'Info-search "search" map Info-mode-map) 3785 (tool-bar-local-item-from-menu 'Info-search "search" map Info-mode-map)
diff --git a/lisp/tool-bar.el b/lisp/tool-bar.el
index 7c7216ed7d3..e819cbe99a8 100644
--- a/lisp/tool-bar.el
+++ b/lisp/tool-bar.el
@@ -139,6 +139,26 @@ Use this function only to make bindings in the global value of `tool-bar-map'.
139To define items in any other map, use `tool-bar-local-item'." 139To define items in any other map, use `tool-bar-local-item'."
140 (apply 'tool-bar-local-item icon def key tool-bar-map props)) 140 (apply 'tool-bar-local-item icon def key tool-bar-map props))
141 141
142(defun tool-bar--image-expression (icon)
143 "Return an expression that evaluates to an image spec for ICON."
144 (let* ((fg (face-attribute 'tool-bar :foreground))
145 (bg (face-attribute 'tool-bar :background))
146 (colors (nconc (if (eq fg 'unspecified) nil (list :foreground fg))
147 (if (eq bg 'unspecified) nil (list :background bg))))
148 (xpm-spec (list :type 'xpm :file (concat icon ".xpm")))
149 (xpm-lo-spec (list :type 'xpm :file
150 (concat "low-color/" icon ".xpm")))
151 (pbm-spec (append (list :type 'pbm :file
152 (concat icon ".pbm")) colors))
153 (xbm-spec (append (list :type 'xbm :file
154 (concat icon ".xbm")) colors)))
155 `(find-image (cond ((not (display-color-p))
156 ',(list pbm-spec xbm-spec xpm-lo-spec xpm-spec))
157 ((< (display-color-cells) 256)
158 ',(list xpm-lo-spec xpm-spec pbm-spec xbm-spec))
159 (t
160 ',(list xpm-spec pbm-spec xbm-spec))))))
161
142;;;###autoload 162;;;###autoload
143(defun tool-bar-local-item (icon def key map &rest props) 163(defun tool-bar-local-item (icon def key map &rest props)
144 "Add an item to the tool bar in map MAP. 164 "Add an item to the tool bar in map MAP.
@@ -151,24 +171,7 @@ ICON is the base name of a file containing the image to use. The
151function will first try to use low-color/ICON.xpm if `display-color-cells' 171function will first try to use low-color/ICON.xpm if `display-color-cells'
152is less or equal to 256, then ICON.xpm, then ICON.pbm, and finally 172is less or equal to 256, then ICON.xpm, then ICON.pbm, and finally
153ICON.xbm, using `find-image'." 173ICON.xbm, using `find-image'."
154 (let* ((fg (face-attribute 'tool-bar :foreground)) 174 (let* ((image-exp (tool-bar--image-expression icon)))
155 (bg (face-attribute 'tool-bar :background))
156 (colors (nconc (if (eq fg 'unspecified) nil (list :foreground fg))
157 (if (eq bg 'unspecified) nil (list :background bg))))
158 (xpm-spec (list :type 'xpm :file (concat icon ".xpm")))
159 (xpm-lo-spec (list :type 'xpm :file
160 (concat "low-color/" icon ".xpm")))
161 (pbm-spec (append (list :type 'pbm :file
162 (concat icon ".pbm")) colors))
163 (xbm-spec (append (list :type 'xbm :file
164 (concat icon ".xbm")) colors))
165 (image-exp `(find-image
166 (cond ((not (display-color-p))
167 ',(list pbm-spec xbm-spec xpm-lo-spec xpm-spec))
168 ((< (display-color-cells) 256)
169 ',(list xpm-lo-spec xpm-spec pbm-spec xbm-spec))
170 (t
171 ',(list xpm-spec pbm-spec xbm-spec))))))
172 (define-key-after map (vector key) 175 (define-key-after map (vector key)
173 `(menu-item ,(symbol-name key) ,def :image ,image-exp ,@props)))) 176 `(menu-item ,(symbol-name key) ,def :image ,image-exp ,@props))))
174 177
@@ -203,24 +206,7 @@ holds a keymap."
203 (setq from-map global-map)) 206 (setq from-map global-map))
204 (let* ((menu-bar-map (lookup-key from-map [menu-bar])) 207 (let* ((menu-bar-map (lookup-key from-map [menu-bar]))
205 (keys (where-is-internal command menu-bar-map)) 208 (keys (where-is-internal command menu-bar-map))
206 (fg (face-attribute 'tool-bar :foreground)) 209 (image-exp (tool-bar--image-expression icon))
207 (bg (face-attribute 'tool-bar :background))
208 (colors (nconc (if (eq fg 'unspecified) nil (list :foreground fg))
209 (if (eq bg 'unspecified) nil (list :background bg))))
210 (xpm-spec (list :type 'xpm :file (concat icon ".xpm")))
211 (xpm-lo-spec (list :type 'xpm :file
212 (concat "low-color/" icon ".xpm")))
213 (pbm-spec (append (list :type 'pbm :file
214 (concat icon ".pbm")) colors))
215 (xbm-spec (append (list :type 'xbm :file
216 (concat icon ".xbm")) colors))
217 (image-exp `(find-image
218 (cond ((not (display-color-p))
219 ',(list pbm-spec xbm-spec xpm-lo-spec xpm-spec))
220 ((< (display-color-cells) 256)
221 ',(list xpm-lo-spec xpm-spec pbm-spec xbm-spec))
222 (t
223 ',(list xpm-spec pbm-spec xbm-spec)))))
224 submap key) 210 submap key)
225 ;; We'll pick up the last valid entry in the list of keys if 211 ;; We'll pick up the last valid entry in the list of keys if
226 ;; there's more than one. 212 ;; there's more than one.
@@ -257,32 +243,34 @@ holds a keymap."
257;;; Set up some global items. Additions/deletions up for grabs. 243;;; Set up some global items. Additions/deletions up for grabs.
258 244
259(defun tool-bar-setup () 245(defun tool-bar-setup ()
246 (setq tool-bar-separator-image-expression
247 (tool-bar--image-expression "separator"))
260 (tool-bar-add-item-from-menu 'find-file "new" nil :label "New File" 248 (tool-bar-add-item-from-menu 'find-file "new" nil :label "New File"
261 :vert-only t) 249 :vert-only t)
262 (tool-bar-add-item-from-menu 'menu-find-file-existing "open" nil 250 (tool-bar-add-item-from-menu 'menu-find-file-existing "open" nil
263 :label "Open" :vert-only t) 251 :label "Open" :vert-only t)
264 (tool-bar-add-item-from-menu 'dired "diropen" nil :vert-only t) 252 (tool-bar-add-item-from-menu 'dired "diropen" nil :vert-only t)
265 (tool-bar-add-item-from-menu 'kill-this-buffer "close" nil :vert-only t) 253 (tool-bar-add-item-from-menu 'kill-this-buffer "close" nil :vert-only t)
266 (tool-bar-add-item-from-menu 'save-buffer "save" nil :vert-only t 254 (tool-bar-add-item-from-menu 'save-buffer "save" nil
267 :label "Save" 255 :label "Save"
268 :visible '(or buffer-file-name 256 :enable '(or buffer-file-name
269 (not (eq 'special 257 (not (eq 'special
270 (get major-mode 258 (get major-mode
271 'mode-class))))) 259 'mode-class)))))
272 (define-key-after (default-value 'tool-bar-map) [separator-1] menu-bar-separator) 260 (define-key-after (default-value 'tool-bar-map) [separator-1] menu-bar-separator)
273 (tool-bar-add-item-from-menu 'undo "undo" nil :vert-only t 261 (tool-bar-add-item-from-menu 'undo "undo" nil :vert-only t
274 :visible '(not (eq 'special (get major-mode 262 :enable '(not (eq 'special (get major-mode
275 'mode-class)))) 263 'mode-class))))
276 (define-key-after (default-value 'tool-bar-map) [separator-2] menu-bar-separator) 264 (define-key-after (default-value 'tool-bar-map) [separator-2] menu-bar-separator)
277 (tool-bar-add-item-from-menu (lookup-key menu-bar-edit-menu [cut]) 265 (tool-bar-add-item-from-menu (lookup-key menu-bar-edit-menu [cut])
278 "cut" nil :vert-only t 266 "cut" nil :vert-only t
279 :visible '(not (eq 'special (get major-mode 267 :enable '(not (eq 'special (get major-mode
280 'mode-class)))) 268 'mode-class))))
281 (tool-bar-add-item-from-menu (lookup-key menu-bar-edit-menu [copy]) 269 (tool-bar-add-item-from-menu (lookup-key menu-bar-edit-menu [copy])
282 "copy" nil :vert-only t) 270 "copy" nil :vert-only t)
283 (tool-bar-add-item-from-menu (lookup-key menu-bar-edit-menu [paste]) 271 (tool-bar-add-item-from-menu (lookup-key menu-bar-edit-menu [paste])
284 "paste" nil :vert-only t 272 "paste" nil :vert-only t
285 :visible '(not (eq 'special (get major-mode 273 :enable '(not (eq 'special (get major-mode
286 'mode-class)))) 274 'mode-class))))
287 (define-key-after (default-value 'tool-bar-map) [separator-3] menu-bar-separator) 275 (define-key-after (default-value 'tool-bar-map) [separator-3] menu-bar-separator)
288 (tool-bar-add-item-from-menu 'nonincremental-search-forward "search" 276 (tool-bar-add-item-from-menu 'nonincremental-search-forward "search"