Mercurial > emacs
annotate lisp/toolbar/tool-bar.el @ 34479:aab24f62ad6b
(setup_echo_area_for_printing, with_echo_area_buffer):
Bind `inhibit-read-only' to t.
(unwind_with_echo_area_buffer): Use AREF.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Tue, 12 Dec 2000 13:31:47 +0000 |
parents | 3d6f9638e8e5 |
children | 0a2ba9c8fde1 |
rev | line source |
---|---|
31738
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
1 ;;; tool-bar.el --- Setting up the tool bar |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
2 ;; |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
3 ;; Copyright (C) 2000 Free Software Foundation, Inc. |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
4 ;; |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
5 ;; Author: Dave Love <fx@gnu.org> |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
6 ;; Keywords: mouse frames |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
7 |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
8 ;; This file is part of GNU Emacs. |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
9 |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
10 ;; GNU Emacs is free software; you can redistribute it and/or modify |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
11 ;; it under the terms of the GNU General Public License as published by |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
12 ;; the Free Software Foundation; either version 2, or (at your option) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
13 ;; any later version. |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
14 |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
15 ;; GNU Emacs is distributed in the hope that it will be useful, |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
18 ;; GNU General Public License for more details. |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
19 |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
20 ;; You should have received a copy of the GNU General Public License |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
23 ;; Boston, MA 02111-1307, USA. |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
24 |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
25 ;;; Commentary: |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
26 |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
27 ;; Provides `tool-bar-mode' to control display of the tool -bar and |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
28 ;; bindings for the global tool bar with convenience functions |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
29 ;; `tool-bar-add-item' and `tool-bar-add-item-from-menu'. |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
30 |
32285 | 31 ;; The normal global binding for [tool-bar] (below) uses the value of |
33574 | 32 ;; `tool-bar-map' as the actual keymap to define the tool bar. Modes |
33 ;; may either bind items under the [tool-bar] prefix key of the local | |
34 ;; map to add to the global bar or may set `tool-bar-map' | |
32382 | 35 ;; buffer-locally to override it. (Some items are removed from the |
32285 | 36 ;; global bar in modes which have `special' as their `mode-class' |
37 ;; properlty.) | |
38 | |
32331
d1c0cf83e365
(tool-bar-mode): Check whether tool-bar-map
Dave Love <fx@gnu.org>
parents:
32285
diff
changeset
|
39 ;; Todo: Somehow make tool bars easily customizable by the naive? |
d1c0cf83e365
(tool-bar-mode): Check whether tool-bar-map
Dave Love <fx@gnu.org>
parents:
32285
diff
changeset
|
40 |
31738
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
41 ;;; Code: |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
42 |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
43 ;;;###autoload |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
44 (define-minor-mode tool-bar-mode |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
45 "Toggle use of the tool bar. |
34004 | 46 With numeric ARG, display the tool bar if and only if ARG is positive. |
31738
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
47 |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
48 See `tool-bar-add-item' and `tool-bar-add-item-from-menu' for |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
49 conveniently adding tool bar items." |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
50 :global t |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
51 :group 'mouse |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
52 :group 'frames |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
53 (let ((lines (if tool-bar-mode 1 0))) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
54 ;; Alter existing frames... |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
55 (mapc (lambda (frame) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
56 (modify-frame-parameters frame |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
57 (list (cons 'tool-bar-lines lines)))) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
58 (frame-list)) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
59 ;; ...and future ones. |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
60 (let ((elt (assq 'tool-bar-lines default-frame-alist))) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
61 (if elt |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
62 (setcdr elt lines) |
32124 | 63 (add-to-list 'default-frame-alist (cons 'tool-bar-lines lines))))) |
32331
d1c0cf83e365
(tool-bar-mode): Check whether tool-bar-map
Dave Love <fx@gnu.org>
parents:
32285
diff
changeset
|
64 (if (and tool-bar-mode |
d1c0cf83e365
(tool-bar-mode): Check whether tool-bar-map
Dave Love <fx@gnu.org>
parents:
32285
diff
changeset
|
65 (display-graphic-p) |
d1c0cf83e365
(tool-bar-mode): Check whether tool-bar-map
Dave Love <fx@gnu.org>
parents:
32285
diff
changeset
|
66 (= 1 (length (default-value 'tool-bar-map)))) ; not yet setup |
32124 | 67 (tool-bar-setup))) |
31738
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
68 |
32285 | 69 (defvar tool-bar-map (make-sparse-keymap) |
70 "Keymap for the tool bar. | |
71 Define this locally to override the global tool bar.") | |
72 | |
73 (global-set-key [tool-bar] | |
74 '(menu-item "tool bar" ignore | |
75 :filter (lambda (ignore) tool-bar-map))) | |
31738
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
76 |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
77 ;;;###autoload |
32285 | 78 (defun tool-bar-add-item (icon def key &rest props) |
31738
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
79 "Add an item to the tool bar. |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
80 ICON names the image, DEF is the key definition and KEY is a symbol |
32285 | 81 for the fake function key in the menu keymap. Remaining arguments |
82 PROPS are additional items to add to the menu item specification. See | |
83 Info node `(elisp)Tool Bar'. Items are added from left to right. | |
31738
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
84 |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
85 ICON is the base name of a file cnntaining the image to use. The |
32285 | 86 function will try to use first ICON.xpm, ICON.pbm then ICON.xbm using |
87 `find-image'. | |
88 | |
89 Keybindings are made in the map `tool-bar-map'. To define items in | |
90 some local map, bind `tool-bar-map' with `let' around calls of this | |
91 function." | |
34019
3d6f9638e8e5
(tool-bar-add-item-from-menu): Use
Gerd Moellmann <gerd@gnu.org>
parents:
34004
diff
changeset
|
92 (let* ((fg (face-attribute 'tool-bar :foreground)) |
3d6f9638e8e5
(tool-bar-add-item-from-menu): Use
Gerd Moellmann <gerd@gnu.org>
parents:
34004
diff
changeset
|
93 (bg (face-attribute 'tool-bar :background)) |
3d6f9638e8e5
(tool-bar-add-item-from-menu): Use
Gerd Moellmann <gerd@gnu.org>
parents:
34004
diff
changeset
|
94 (colors (nconc (if (eq fg 'unspecified) nil (list :foreground fg)) |
3d6f9638e8e5
(tool-bar-add-item-from-menu): Use
Gerd Moellmann <gerd@gnu.org>
parents:
34004
diff
changeset
|
95 (if (eq bg 'unspecified) nil (list :background bg)))) |
32788 | 96 (image (find-image |
32358 | 97 (if (display-color-p) |
34019
3d6f9638e8e5
(tool-bar-add-item-from-menu): Use
Gerd Moellmann <gerd@gnu.org>
parents:
34004
diff
changeset
|
98 (list (list :type 'xpm :file (concat icon ".xpm")) |
3d6f9638e8e5
(tool-bar-add-item-from-menu): Use
Gerd Moellmann <gerd@gnu.org>
parents:
34004
diff
changeset
|
99 (append (list :type 'pbm :file (concat icon ".pbm")) |
3d6f9638e8e5
(tool-bar-add-item-from-menu): Use
Gerd Moellmann <gerd@gnu.org>
parents:
34004
diff
changeset
|
100 colors) |
3d6f9638e8e5
(tool-bar-add-item-from-menu): Use
Gerd Moellmann <gerd@gnu.org>
parents:
34004
diff
changeset
|
101 (append (list :type 'xbm :file (concat icon ".xbm")) |
3d6f9638e8e5
(tool-bar-add-item-from-menu): Use
Gerd Moellmann <gerd@gnu.org>
parents:
34004
diff
changeset
|
102 colors)) |
3d6f9638e8e5
(tool-bar-add-item-from-menu): Use
Gerd Moellmann <gerd@gnu.org>
parents:
34004
diff
changeset
|
103 (list (append (list :type 'pbm :file (concat icon ".pbm")) |
3d6f9638e8e5
(tool-bar-add-item-from-menu): Use
Gerd Moellmann <gerd@gnu.org>
parents:
34004
diff
changeset
|
104 colors) |
3d6f9638e8e5
(tool-bar-add-item-from-menu): Use
Gerd Moellmann <gerd@gnu.org>
parents:
34004
diff
changeset
|
105 (append (list :type 'xbm :file (concat icon ".xbm")) |
3d6f9638e8e5
(tool-bar-add-item-from-menu): Use
Gerd Moellmann <gerd@gnu.org>
parents:
34004
diff
changeset
|
106 colors) |
3d6f9638e8e5
(tool-bar-add-item-from-menu): Use
Gerd Moellmann <gerd@gnu.org>
parents:
34004
diff
changeset
|
107 (list :type 'xpm :file (concat icon ".xpm"))))))) |
31738
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
108 (when image |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
109 (unless (image-mask-p image) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
110 (setq image (append image '(:mask heuristic)))) |
32285 | 111 (define-key-after tool-bar-map (vector key) |
31738
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
112 `(menu-item ,(symbol-name key) ,def :image ,image ,@props))))) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
113 |
32340
97bfc5c6e1c1
(tool-bar-add-item-from-menu): Add autoload cookie.
Dave Love <fx@gnu.org>
parents:
32331
diff
changeset
|
114 ;;;###autoload |
31738
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
115 (defun tool-bar-add-item-from-menu (command icon &optional map &rest props) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
116 "Define tool bar binding for COMMAND using the given ICON in keymap MAP. |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
117 The binding of COMMAND is looked up in the menu bar in MAP (default |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
118 `global-map') and modified to add an image specification for ICON, which |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
119 is looked for as by `tool-bar-add-item'. |
32285 | 120 MAP must contain an appropriate keymap bound to `[menu-bar]'. |
121 PROPS is a list of additional properties to add to the binding. | |
122 | |
123 Keybindings are made in the map `tool-bar-map'. To define items in | |
124 some local map, bind `tool-bar-map' with `let' around calls of this | |
125 function." | |
31738
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
126 (unless map |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
127 (setq map global-map)) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
128 (let* ((menu-bar-map (lookup-key map [menu-bar])) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
129 (keys (where-is-internal command menu-bar-map)) |
34019
3d6f9638e8e5
(tool-bar-add-item-from-menu): Use
Gerd Moellmann <gerd@gnu.org>
parents:
34004
diff
changeset
|
130 (fg (face-attribute 'tool-bar :foreground)) |
3d6f9638e8e5
(tool-bar-add-item-from-menu): Use
Gerd Moellmann <gerd@gnu.org>
parents:
34004
diff
changeset
|
131 (bg (face-attribute 'tool-bar :background)) |
3d6f9638e8e5
(tool-bar-add-item-from-menu): Use
Gerd Moellmann <gerd@gnu.org>
parents:
34004
diff
changeset
|
132 (colors (nconc (if (eq fg 'unspecified) nil (list :foreground fg)) |
3d6f9638e8e5
(tool-bar-add-item-from-menu): Use
Gerd Moellmann <gerd@gnu.org>
parents:
34004
diff
changeset
|
133 (if (eq bg 'unspecified) nil (list :background bg)))) |
33895
3683396305bc
(tool-bar-add-item-from-menu): Handle case
Gerd Moellmann <gerd@gnu.org>
parents:
33574
diff
changeset
|
134 (spec (if (display-color-p) |
3683396305bc
(tool-bar-add-item-from-menu): Handle case
Gerd Moellmann <gerd@gnu.org>
parents:
33574
diff
changeset
|
135 (list (list :type 'xpm :file (concat icon ".xpm")) |
3683396305bc
(tool-bar-add-item-from-menu): Handle case
Gerd Moellmann <gerd@gnu.org>
parents:
33574
diff
changeset
|
136 (append (list :type 'pbm :file (concat icon ".pbm")) |
3683396305bc
(tool-bar-add-item-from-menu): Handle case
Gerd Moellmann <gerd@gnu.org>
parents:
33574
diff
changeset
|
137 colors) |
3683396305bc
(tool-bar-add-item-from-menu): Handle case
Gerd Moellmann <gerd@gnu.org>
parents:
33574
diff
changeset
|
138 (append (list :type 'xbm :file (concat icon ".xbm")) |
3683396305bc
(tool-bar-add-item-from-menu): Handle case
Gerd Moellmann <gerd@gnu.org>
parents:
33574
diff
changeset
|
139 colors)) |
3683396305bc
(tool-bar-add-item-from-menu): Handle case
Gerd Moellmann <gerd@gnu.org>
parents:
33574
diff
changeset
|
140 (list (append (list :type 'pbm :file (concat icon ".pbm")) |
3683396305bc
(tool-bar-add-item-from-menu): Handle case
Gerd Moellmann <gerd@gnu.org>
parents:
33574
diff
changeset
|
141 colors) |
3683396305bc
(tool-bar-add-item-from-menu): Handle case
Gerd Moellmann <gerd@gnu.org>
parents:
33574
diff
changeset
|
142 (append (list :type 'xbm :file (concat icon ".xbm")) |
3683396305bc
(tool-bar-add-item-from-menu): Handle case
Gerd Moellmann <gerd@gnu.org>
parents:
33574
diff
changeset
|
143 colors) |
3683396305bc
(tool-bar-add-item-from-menu): Handle case
Gerd Moellmann <gerd@gnu.org>
parents:
33574
diff
changeset
|
144 (list :type 'xpm :file (concat icon ".xpm"))))) |
3683396305bc
(tool-bar-add-item-from-menu): Handle case
Gerd Moellmann <gerd@gnu.org>
parents:
33574
diff
changeset
|
145 (image (find-image spec)) |
31738
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
146 submap key) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
147 (when image |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
148 ;; We'll pick up the last valid entry in the list of keys if |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
149 ;; there's more than one. |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
150 (dolist (k keys) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
151 ;; We're looking for a binding of the command in a submap of |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
152 ;; the menu bar map, so the key sequence must be two or more |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
153 ;; long. |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
154 (if (and (vectorp k) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
155 (> (length k) 1)) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
156 (let ((m (lookup-key menu-bar-map (substring k 0 -1))) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
157 ;; Last element in the bound key sequence: |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
158 (kk (aref k (1- (length k))))) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
159 (if (and (keymapp m) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
160 (symbolp kk)) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
161 (setq submap m |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
162 key kk))))) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
163 (when (and (symbolp submap) (boundp submap)) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
164 (setq submap (eval submap))) |
31751
3c4b8a33fed9
Reapply Gerd's change from 2000-09-18, which seems to have gotten lost:
Miles Bader <miles@gnu.org>
parents:
31738
diff
changeset
|
165 (unless (image-mask-p image) |
3c4b8a33fed9
Reapply Gerd's change from 2000-09-18, which seems to have gotten lost:
Miles Bader <miles@gnu.org>
parents:
31738
diff
changeset
|
166 (setq image (append image '(:mask heuristic)))) |
32285 | 167 (define-key-after tool-bar-map (vector key) |
31738
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
168 (append (cdr (assq key (cdr submap))) (list :image image) props))))) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
169 |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
170 ;;; Set up some global items. Additions/deletions up for grabs. |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
171 |
32124 | 172 (defun tool-bar-setup () |
173 (tool-bar-add-item-from-menu 'save-buffers-kill-emacs "exit") | |
174 (tool-bar-add-item-from-menu 'find-file "new") | |
175 (tool-bar-add-item-from-menu 'dired "open") | |
176 (tool-bar-add-item-from-menu 'kill-this-buffer "close") | |
177 (tool-bar-add-item-from-menu 'save-buffer "save" nil | |
178 :visible '(not (eq 'special (get major-mode | |
179 'mode-class)))) | |
180 (tool-bar-add-item-from-menu 'write-file "saveas" nil | |
181 :visible '(not (eq 'special (get major-mode | |
182 'mode-class)))) | |
183 (tool-bar-add-item-from-menu 'undo "undo" nil | |
184 :visible '(not (eq 'special (get major-mode | |
185 'mode-class)))) | |
186 (tool-bar-add-item-from-menu 'kill-region "cut" nil | |
187 :visible '(not (eq 'special (get major-mode | |
188 'mode-class)))) | |
189 (tool-bar-add-item-from-menu 'menu-bar-kill-ring-save "copy") | |
190 (tool-bar-add-item-from-menu 'yank "paste" nil | |
191 :visible '(not (eq 'special (get major-mode | |
192 'mode-class)))) | |
193 (tool-bar-add-item-from-menu 'nonincremental-search-forward "search") | |
194 ;;(tool-bar-add-item-from-menu 'ispell-buffer "spell") | |
31738
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
195 |
32124 | 196 ;; There's no icon appropriate for News and we need a command rather |
197 ;; than a lambda for Read Mail. | |
198 ;;(tool-bar-add-item-from-menu 'compose-mail "mail_compose") | |
31895
6d04db7a9256
(tool-bar-help): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
31751
diff
changeset
|
199 |
32124 | 200 (tool-bar-add-item-from-menu 'print-buffer "print") |
32285 | 201 (tool-bar-add-item "preferences" 'customize 'customize |
32124 | 202 :help "Edit preferences (customize)") |
31895
6d04db7a9256
(tool-bar-help): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
31751
diff
changeset
|
203 |
32285 | 204 (tool-bar-add-item "help" (lambda () |
205 (interactive) | |
206 (popup-menu menu-bar-help-menu)) | |
207 'help | |
208 :help "Pop up the Help menu") | |
32124 | 209 ) |
31738
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
210 |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
211 (provide 'tool-bar) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
212 |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
213 ;;; tool-bar.el ends here |