Mercurial > emacs
annotate lisp/toolbar/tool-bar.el @ 31995:6a45a15137b0
(menu_bar_one_keymap): If KEYMAP is a symbol,
use its function definition.
(tool_bar_items): Likewise.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Fri, 29 Sep 2000 12:41:40 +0000 |
parents | 742016ea45ce |
children | 5554c8f22e37 |
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 |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
31 ;;; Code: |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
32 |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
33 ;;;###autoload |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
34 (define-minor-mode tool-bar-mode |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
35 "Toggle use of the tool bar. |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
36 With ARG, display the tool bar if and only if ARG is positive. |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
37 |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
38 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
|
39 conveniently adding tool bar items." |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
40 nil nil nil |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
41 :global t |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
42 :group 'mouse |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
43 :group 'frames |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
44 (let ((lines (if tool-bar-mode 1 0))) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
45 ;; Alter existing frames... |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
46 (mapc (lambda (frame) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
47 (modify-frame-parameters frame |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
48 (list (cons 'tool-bar-lines lines)))) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
49 (frame-list)) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
50 ;; ...and future ones. |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
51 (let ((elt (assq 'tool-bar-lines default-frame-alist))) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
52 (if elt |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
53 (setcdr elt lines) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
54 (add-to-list 'default-frame-alist (cons 'tool-bar-lines lines)))))) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
55 |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
56 (defvar tool-bar-global-map (let ((map (make-sparse-keymap))) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
57 (global-set-key [tool-bar] map)) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
58 "Keymap for the tool bar in the global map.") |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
59 |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
60 ;;;###autoload |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
61 (defun tool-bar-add-item (icon def key &optional map &rest props) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
62 "Add an item to the tool bar. |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
63 ICON names the image, DEF is the key definition and KEY is a symbol |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
64 for the fake function key in the menu keymap. MAP is the tool bar |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
65 keymap in which to define the item; it defaults to |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
66 `tool-bar-global-map'. Remaining arguments PROPS are additional items |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
67 to add to the menu item specification. See Info node `(elisp)Tool |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
68 Bar'. Items are added from left to right. |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
69 |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
70 ICON is the base name of a file cnntaining the image to use. The |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
71 function will try to use first ICON.xpm, then ICON.xbm using |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
72 `find-image'. If PROPS contains `:enable', a `disabled' version of |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
73 the icon is generated automatically using the Laplace algorithm (see |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
74 Info node `(elisp)Image Descriptors')." |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
75 (let ((image (find-image `((:type xbm :file ,(concat icon ".xbm")) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
76 (:type xpm :file ,(concat icon ".xpm")))))) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
77 (when image |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
78 (unless (image-mask-p image) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
79 (setq image (append image '(:mask heuristic)))) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
80 (define-key-after (or map tool-bar-global-map) (vector key) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
81 `(menu-item ,(symbol-name key) ,def :image ,image ,@props))))) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
82 |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
83 (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
|
84 "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
|
85 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
|
86 `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
|
87 is looked for as by `tool-bar-add-item'. |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
88 MAP must contain appropriate keymaps bound to `[menu-bar]' and |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
89 `[tool-bar]'. |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
90 PROPS is a list of additional properties to add to the binding." |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
91 (unless map |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
92 (setq map global-map)) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
93 (let* ((menu-bar-map (lookup-key map [menu-bar])) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
94 (keys (where-is-internal command menu-bar-map)) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
95 (tb-map (key-binding [tool-bar] map)) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
96 (image (find-image `((:type xpm :file ,(concat icon ".xpm")) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
97 (:type xbm :file ,(concat icon ".xbm"))))) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
98 submap key) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
99 (when image |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
100 ;; 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
|
101 ;; there's more than one. |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
102 (dolist (k keys) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
103 ;; 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
|
104 ;; 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
|
105 ;; long. |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
106 (if (and (vectorp k) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
107 (> (length k) 1)) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
108 (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
|
109 ;; Last element in the bound key sequence: |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
110 (kk (aref k (1- (length k))))) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
111 (if (and (keymapp m) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
112 (symbolp kk)) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
113 (setq submap m |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
114 key kk))))) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
115 (when (and (symbolp submap) (boundp submap)) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
116 (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
|
117 (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
|
118 (setq image (append image '(:mask heuristic)))) |
31738
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
119 (define-key-after tb-map (vector key) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
120 (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
|
121 |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
122 ;;; 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
|
123 |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
124 (tool-bar-add-item-from-menu 'save-buffers-kill-emacs "exit") |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
125 (tool-bar-add-item-from-menu 'find-file "new") |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
126 (tool-bar-add-item-from-menu 'dired "open") |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
127 (tool-bar-add-item-from-menu 'kill-this-buffer "close") |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
128 (tool-bar-add-item-from-menu 'save-buffer "save" nil |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
129 :visible '(not (eq 'special (get major-mode |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
130 'mode-class)))) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
131 (tool-bar-add-item-from-menu 'write-file "saveas" nil |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
132 :visible '(not (eq 'special (get major-mode |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
133 'mode-class)))) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
134 (tool-bar-add-item-from-menu 'undo "undo" nil |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
135 :visible '(not (eq 'special (get major-mode |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
136 'mode-class)))) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
137 (tool-bar-add-item-from-menu 'kill-region "cut" nil |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
138 :visible '(not (eq 'special (get major-mode |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
139 'mode-class)))) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
140 (tool-bar-add-item-from-menu 'menu-bar-kill-ring-save "copy") |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
141 (tool-bar-add-item-from-menu 'yank "paste" nil |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
142 :visible '(not (eq 'special (get major-mode |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
143 'mode-class)))) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
144 (tool-bar-add-item-from-menu 'nonincremental-search-forward "search") |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
145 ;;(tool-bar-add-item-from-menu 'ispell-buffer "spell") |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
146 |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
147 ;; There's no icon appropriate for News and we need a command rather |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
148 ;; than a lambda for Read Mail. |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
149 ;;(tool-bar-add-item-from-menu 'compose-mail "mail_compose") |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
150 |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
151 (tool-bar-add-item-from-menu 'print-buffer "print") |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
152 (tool-bar-add-item "preferences" 'customize 'customize nil |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
153 :help "Edit preferences (customize)") |
31895
6d04db7a9256
(tool-bar-help): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
31751
diff
changeset
|
154 |
6d04db7a9256
(tool-bar-help): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
31751
diff
changeset
|
155 (defun tool-bar-help () |
6d04db7a9256
(tool-bar-help): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
31751
diff
changeset
|
156 "Pop up the help menu from the tool-bar." |
6d04db7a9256
(tool-bar-help): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
31751
diff
changeset
|
157 (interactive) |
31921
742016ea45ce
(tool-bar-help): Use `mouse-pixel-position'.
Miles Bader <miles@gnu.org>
parents:
31895
diff
changeset
|
158 (let* ((p (mouse-pixel-position)) |
31895
6d04db7a9256
(tool-bar-help): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
31751
diff
changeset
|
159 (menu menu-bar-help-menu) |
6d04db7a9256
(tool-bar-help): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
31751
diff
changeset
|
160 (selection (x-popup-menu (list (list (cadr p) (cddr p)) (car p)) |
6d04db7a9256
(tool-bar-help): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
31751
diff
changeset
|
161 menu)) |
6d04db7a9256
(tool-bar-help): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
31751
diff
changeset
|
162 binding) |
6d04db7a9256
(tool-bar-help): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
31751
diff
changeset
|
163 (while selection |
6d04db7a9256
(tool-bar-help): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
31751
diff
changeset
|
164 (setq binding (lookup-key (or binding menu) (vector (car selection))) |
6d04db7a9256
(tool-bar-help): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
31751
diff
changeset
|
165 selection (cdr selection))) |
6d04db7a9256
(tool-bar-help): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
31751
diff
changeset
|
166 (when binding |
6d04db7a9256
(tool-bar-help): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
31751
diff
changeset
|
167 (call-interactively binding)))) |
6d04db7a9256
(tool-bar-help): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
31751
diff
changeset
|
168 |
6d04db7a9256
(tool-bar-help): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
31751
diff
changeset
|
169 (tool-bar-add-item "help" 'tool-bar-help |
31738
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
170 'help nil :help "Pop up the Help menu") |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
171 |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
172 (provide 'tool-bar) |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
173 |
e8458588eb55
Renamed from toolbar.el. Change `toolbar'
Dave Love <fx@gnu.org>
parents:
diff
changeset
|
174 ;;; tool-bar.el ends here |