0
|
1 ;; Toolbar support for X.
|
|
2 ;; Copyright (C) 1994 Andy Piper <andyp@parallax.demon.co.uk>
|
|
3 ;; Copyright (C) 1995 Board of Trustees, University of Illinois
|
|
4 ;; Copyright (C) 1996 Ben Wing <wing@666.com>
|
|
5
|
|
6 ;; This file is part of XEmacs.
|
|
7
|
|
8 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
9 ;; under the terms of the GNU General Public License as published by
|
|
10 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
11 ;; any later version.
|
|
12
|
|
13 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
14 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
16 ;; General Public License for more details.
|
|
17
|
|
18 ;; You should have received a copy of the GNU General Public License
|
70
|
19 ;; along with XEmacs; see the file COPYING. If not, write to the
|
|
20 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
21 ;; Boston, MA 02111-1307, USA.
|
16
|
22
|
|
23 ;;
|
88
|
24 ;; Miscellaneous toolbar functions, useful for users to redefine, in
|
|
25 ;; order to get different behaviour.
|
|
26 ;;
|
|
27
|
|
28 (defun toolbar-open ()
|
|
29 (interactive)
|
|
30 (call-interactively 'find-file))
|
|
31
|
|
32 (defun toolbar-dired ()
|
|
33 (interactive)
|
|
34 (call-interactively 'dired))
|
|
35
|
|
36 (defun toolbar-save ()
|
|
37 (interactive)
|
|
38 (call-interactively 'save-buffer))
|
|
39
|
|
40 (defun toolbar-print ()
|
|
41 (interactive)
|
|
42 (call-interactively 'lpr-buffer))
|
|
43
|
|
44 (defun toolbar-cut ()
|
|
45 (interactive)
|
|
46 (call-interactively 'x-kill-primary-selection))
|
|
47
|
|
48 (defun toolbar-copy ()
|
|
49 (interactive)
|
|
50 (call-interactively 'x-copy-primary-selection))
|
|
51
|
|
52 (defun toolbar-paste ()
|
|
53 (interactive)
|
|
54 (call-interactively 'x-yank-clipboard-selection))
|
|
55
|
|
56 (defun toolbar-undo ()
|
|
57 (interactive)
|
|
58 (call-interactively 'undo))
|
|
59
|
|
60 (defun toolbar-replace ()
|
|
61 (interactive)
|
|
62 (call-interactively 'query-replace))
|
|
63
|
|
64 ;;
|
0
|
65 ;; toolbar ispell variables and defuns
|
|
66 ;;
|
|
67
|
|
68 (defun toolbar-ispell ()
|
|
69 "Intelligently spell the region or buffer."
|
|
70 (interactive)
|
70
|
71 (if (region-active-p)
|
|
72 (ispell-region (region-beginning) (region-end))
|
|
73 (ispell-buffer)))
|
0
|
74
|
|
75 ;;
|
|
76 ;; toolbar mail variables and defuns
|
|
77 ;;
|
|
78
|
88
|
79 (defmacro toolbar-external (process &rest args)
|
|
80 `(lambda () (interactive) (call-process ,process nil 0 nil ,@args)))
|
0
|
81
|
88
|
82 (defvar toolbar-mail-commands-alist
|
|
83 `((vm . vm)
|
|
84 (gnus . gnus-no-server)
|
|
85 (rmail . rmail)
|
|
86 (mh . mh-rmail)
|
|
87 (pine . ,(toolbar-external "xterm" "-e" "pine")) ; *gag*
|
|
88 (elm . ,(toolbar-external "xterm" "-e" "elm"))
|
|
89 (mutt . ,(toolbar-external "xterm" "-e" "mutt"))
|
|
90 (exmh . ,(toolbar-external "exmh"))
|
|
91 ;; How to turn on netscape mail, command-line??
|
|
92 (netscape . ,(toolbar-external "netscape")))
|
|
93 "Alist of mail readers and their commands.
|
|
94 The car of the alist is the mail reader, and the cdr is the form
|
|
95 used to start it.")
|
0
|
96
|
88
|
97 (defvar toolbar-mail-reader 'vm
|
|
98 "Mail reader toolbar will invoke.
|
|
99 The legal values are `vm' and `gnus', but you can add your own values
|
|
100 by customizing `toolbar-mail-commands-alist'.")
|
|
101
|
0
|
102
|
|
103 (defun toolbar-mail ()
|
|
104 "Run mail in a separate frame."
|
|
105 (interactive)
|
88
|
106 (let ((command (assq toolbar-mail-reader toolbar-mail-commands-alist)))
|
|
107 (if (not command)
|
|
108 (error "Uknown mail reader %s" toolbar-mail-reader))
|
|
109 (funcall (cdr command))))
|
0
|
110
|
|
111 ;;
|
|
112 ;; toolbar info variables and defuns
|
|
113 ;;
|
|
114
|
|
115 (defvar toolbar-info-frame nil
|
|
116 "The frame in which info is displayed.")
|
|
117
|
|
118 (defun toolbar-info ()
|
|
119 "Run info in a separate frame."
|
|
120 (interactive)
|
|
121 (if (or (not toolbar-info-frame)
|
|
122 (not (frame-live-p toolbar-info-frame)))
|
|
123 (progn
|
|
124 (setq toolbar-info-frame (make-frame))
|
|
125 (select-frame toolbar-info-frame)
|
|
126 (raise-frame toolbar-info-frame)))
|
|
127 (if (frame-iconified-p toolbar-info-frame)
|
|
128 (deiconify-frame toolbar-info-frame))
|
|
129 (select-frame toolbar-info-frame)
|
|
130 (raise-frame toolbar-info-frame)
|
|
131 (info))
|
|
132
|
|
133 ;;
|
|
134 ;; toolbar debug variables and defuns
|
|
135 ;;
|
|
136
|
|
137 (defun toolbar-debug ()
|
|
138 (interactive)
|
|
139 (if (featurep 'eos-debugger)
|
|
140 (call-interactively 'eos::start-debugger)
|
|
141 (require 'gdbsrc)
|
|
142 (call-interactively 'gdbsrc))
|
|
143 )
|
|
144
|
|
145 (defvar compile-command)
|
|
146
|
|
147 (defun toolbar-compile ()
|
|
148 "Run compile without having to touch the keyboard."
|
|
149 (interactive)
|
|
150 (require 'compile)
|
70
|
151 (popup-dialog-box
|
|
152 `(,(concat "Compile:\n " compile-command)
|
|
153 ["Compile" (compile compile-command) t]
|
|
154 ["Edit command" compile t]
|
|
155 nil
|
|
156 ["Cancel" (message "Quit") t])))
|
0
|
157
|
|
158 ;;
|
|
159 ;; toolbar news variables and defuns
|
|
160 ;;
|
|
161
|
|
162 (defvar toolbar-news-frame nil
|
|
163 "The frame in which news is displayed.")
|
|
164
|
80
|
165 (defvar toolbar-news-frame-properties nil
|
|
166 "The properties of the frame in which news is displayed.")
|
|
167
|
0
|
168 (defun toolbar-news ()
|
76
|
169 "Run Gnus in a separate frame."
|
0
|
170 (interactive)
|
76
|
171 (when (or (not toolbar-news-frame)
|
|
172 (not (frame-live-p toolbar-news-frame)))
|
80
|
173 (setq toolbar-news-frame (make-frame toolbar-news-frame-properties))
|
76
|
174 (add-hook 'gnus-exit-gnus-hook
|
|
175 (lambda ()
|
|
176 (when (frame-live-p toolbar-news-frame)
|
|
177 (if (cdr (frame-list))
|
|
178 (delete-frame toolbar-news-frame))
|
|
179 (setq toolbar-news-frame nil))))
|
|
180 (select-frame toolbar-news-frame)
|
|
181 (raise-frame toolbar-news-frame)
|
|
182 (gnus))
|
0
|
183 (if (frame-iconified-p toolbar-news-frame)
|
|
184 (deiconify-frame toolbar-news-frame))
|
|
185 (select-frame toolbar-news-frame)
|
|
186 (raise-frame toolbar-news-frame))
|
|
187
|
|
188 (defvar toolbar-last-win-icon nil "A `last-win' icon set.")
|
|
189 (defvar toolbar-next-win-icon nil "A `next-win' icon set.")
|
|
190 (defvar toolbar-file-icon nil "A `file' icon set.")
|
|
191 (defvar toolbar-folder-icon nil "A `folder' icon set")
|
|
192 (defvar toolbar-disk-icon nil "A `disk' icon set.")
|
|
193 (defvar toolbar-printer-icon nil "A `printer' icon set.")
|
|
194 (defvar toolbar-cut-icon nil "A `cut' icon set.")
|
|
195 (defvar toolbar-copy-icon nil "A `copy' icon set.")
|
|
196 (defvar toolbar-paste-icon nil "A `paste' icon set.")
|
|
197 (defvar toolbar-undo-icon nil "An `undo' icon set.")
|
|
198 (defvar toolbar-spell-icon nil "A `spell' icon set.")
|
|
199 (defvar toolbar-replace-icon nil "A `replace' icon set.")
|
|
200 (defvar toolbar-mail-icon nil "A `mail' icon set.")
|
|
201 (defvar toolbar-info-icon nil "An `info' icon set.")
|
|
202 (defvar toolbar-compile-icon nil "A `compile' icon set.")
|
|
203 (defvar toolbar-debug-icon nil "A `debugger' icon set.")
|
|
204 (defvar toolbar-news-icon nil "A `news' icon set.")
|
|
205
|
|
206 ;;; each entry maps a variable to the prefix used.
|
|
207
|
|
208 (defvar init-x-toolbar-list
|
|
209 '((toolbar-last-win-icon . "last-win")
|
|
210 (toolbar-next-win-icon . "next-win")
|
|
211 (toolbar-file-icon . "file")
|
|
212 (toolbar-folder-icon . "folder")
|
|
213 (toolbar-disk-icon . "disk")
|
|
214 (toolbar-printer-icon . "printer")
|
|
215 (toolbar-cut-icon . "cut")
|
|
216 (toolbar-copy-icon . "copy")
|
|
217 (toolbar-paste-icon . "paste")
|
|
218 (toolbar-undo-icon . "undo")
|
|
219 (toolbar-spell-icon . "spell")
|
|
220 (toolbar-replace-icon . "replace")
|
|
221 (toolbar-mail-icon . "mail")
|
|
222 (toolbar-info-icon . "info-def")
|
|
223 (toolbar-compile-icon . "compile")
|
|
224 (toolbar-debug-icon . "debug")
|
|
225 (toolbar-news-icon . "news")))
|
|
226
|
|
227 (defun init-x-toolbar ()
|
|
228 (mapcar
|
10
|
229 (lambda (cons)
|
|
230 (let ((prefix (expand-file-name (cdr cons) toolbar-icon-directory)))
|
|
231 (set (car cons)
|
|
232 (if (featurep 'xpm)
|
|
233 (toolbar-make-button-list
|
|
234 (concat prefix "-up.xpm")
|
|
235 nil
|
|
236 (concat prefix "-xx.xpm")
|
|
237 (concat prefix "-cap-up.xpm")
|
|
238 nil
|
|
239 (concat prefix "-cap-xx.xpm"))
|
|
240 (toolbar-make-button-list
|
|
241 (concat prefix "-up.xbm")
|
|
242 (concat prefix "-dn.xbm")
|
|
243 (concat prefix "-xx.xbm")
|
|
244 )))))
|
0
|
245 init-x-toolbar-list)
|
|
246 ;; do this now because errors will occur if the icon symbols
|
|
247 ;; are not initted
|
|
248 (set-specifier default-toolbar initial-toolbar-spec))
|
|
249
|
|
250 (defvar initial-toolbar-spec
|
70
|
251 '(;;[toolbar-last-win-icon pop-window-configuration
|
|
252 ;;(frame-property (selected-frame)
|
|
253 ;; 'window-config-stack) t "Most recent window config"]
|
|
254 ;; #### Illicit knowledge?
|
|
255 ;; #### These don't work right - not consistent!
|
|
256 ;; I don't know what's wrong; perhaps `selected-frame' is wrong
|
|
257 ;; sometimes when this is evaluated. Note that I even tried to
|
|
258 ;; kludge-fix this by calls to `set-specifier-dirty-flag' in
|
|
259 ;; pop-window-configuration and such.
|
|
260
|
|
261 ;;[toolbar-next-win-icon unpop-window-configuration
|
|
262 ;;(frame-property (selected-frame)
|
|
263 ;; 'window-config-unpop-stack) t "Undo \"Most recent window config\""]
|
|
264 ;; #### Illicit knowledge?
|
|
265
|
88
|
266 [toolbar-file-icon toolbar-open t "Open a file" ]
|
|
267 [toolbar-folder-icon toolbar-dired t "View directory"]
|
|
268 [toolbar-disk-icon toolbar-save t "Save buffer" ]
|
|
269 [toolbar-printer-icon toolbar-print t "Print buffer" ]
|
|
270 [toolbar-cut-icon toolbar-cut t "Kill region"]
|
|
271 [toolbar-copy-icon toolbar-copy t "Copy region"]
|
|
272 [toolbar-paste-icon toolbar-paste t "Paste from clipboard"]
|
|
273 [toolbar-undo-icon toolbar-undo t "Undo edit" ]
|
0
|
274 [toolbar-spell-icon toolbar-ispell t "Spellcheck" ]
|
88
|
275 [toolbar-replace-icon toolbar-replace t "Replace text" ]
|
0
|
276 [toolbar-mail-icon toolbar-mail t "Mail" ]
|
|
277 [toolbar-info-icon toolbar-info t "Information" ]
|
|
278 [toolbar-compile-icon toolbar-compile t "Compile" ]
|
|
279 [toolbar-debug-icon toolbar-debug t "Debug" ]
|
|
280 [toolbar-news-icon toolbar-news t "News" ])
|
|
281 "The initial toolbar for a buffer.")
|
|
282
|
|
283 (defun x-init-toolbar-from-resources (locale)
|
|
284 (x-init-specifier-from-resources
|
|
285 top-toolbar-height 'natnum locale
|
|
286 '("topToolBarHeight" . "TopToolBarHeight"))
|
|
287 (x-init-specifier-from-resources
|
|
288 bottom-toolbar-height 'natnum locale
|
|
289 '("bottomToolBarHeight" . "BottomToolBarHeight"))
|
|
290 (x-init-specifier-from-resources
|
|
291 left-toolbar-width 'natnum locale
|
|
292 '("leftToolBarWidth" . "LeftToolBarWidth"))
|
|
293 (x-init-specifier-from-resources
|
|
294 right-toolbar-width 'natnum locale
|
|
295 '("rightToolBarWidth" . "RightToolBarWidth")))
|