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
|
|
19 ;; along with XEmacs; see the file COPYING. If not, write to the Free
|
|
20 ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
21
|
|
22 ;;
|
16
|
23 ;; Miscellaneous toolbar functions, useful for users to redefine, in
|
|
24 ;; order to get different behaviour.
|
|
25 ;;
|
|
26
|
22
|
27 (defvar toolbar-open-function 'find-file
|
|
28 "*Function to call when the open icon is selected.")
|
|
29
|
16
|
30 (defun toolbar-open ()
|
|
31 (interactive)
|
22
|
32 (call-interactively toolbar-open-function))
|
|
33
|
|
34 (defvar toolbar-dired-function 'dired
|
|
35 "*Function to call when the dired icon is selected.")
|
16
|
36
|
|
37 (defun toolbar-dired ()
|
|
38 (interactive)
|
22
|
39 (call-interactively toolbar-dired-function))
|
|
40
|
|
41 (defvar toolbar-save-function 'save-buffer
|
|
42 "*Function to call when the save icon is selected.")
|
16
|
43
|
|
44 (defun toolbar-save ()
|
|
45 (interactive)
|
22
|
46 (call-interactively toolbar-save-function))
|
|
47
|
|
48 (defvar toolbar-print-function 'lpr-buffer
|
|
49 "*Function to call when the print icon is selected.")
|
16
|
50
|
|
51 (defun toolbar-print ()
|
|
52 (interactive)
|
22
|
53 (call-interactively toolbar-print-function))
|
|
54
|
|
55 (defvar toolbar-cut-function 'x-kill-primary-selection
|
|
56 "*Function to call when the cut icon is selected.")
|
16
|
57
|
|
58 (defun toolbar-cut ()
|
|
59 (interactive)
|
22
|
60 (call-interactively toolbar-cut-function))
|
|
61
|
|
62 (defvar toolbar-copy-function 'x-copy-primary-selection
|
|
63 "*Function to call when the copy icon is selected.")
|
16
|
64
|
|
65 (defun toolbar-copy ()
|
|
66 (interactive)
|
22
|
67 (call-interactively toolbar-copy-function))
|
|
68
|
|
69 (defvar toolbar-paste-function 'x-yank-clipboard-selection
|
|
70 "*Function to call when the paste icon is selected.")
|
16
|
71
|
|
72 (defun toolbar-paste ()
|
|
73 (interactive)
|
22
|
74 (call-interactively toolbar-paste-function))
|
|
75
|
|
76 (defvar toolbar-undo-function 'undo
|
|
77 "*Function to call when the undo icon is selected.")
|
16
|
78
|
|
79 (defun toolbar-undo ()
|
|
80 (interactive)
|
22
|
81 (call-interactively toolbar-undo-function))
|
|
82
|
|
83 (defvar toolbar-replace-function 'query-replace
|
|
84 "*Function to call when the replace icon is selected.")
|
16
|
85
|
|
86 (defun toolbar-replace ()
|
|
87 (interactive)
|
22
|
88 (call-interactively toolbar-replace-function))
|
16
|
89
|
|
90 ;;
|
0
|
91 ;; toolbar ispell variables and defuns
|
|
92 ;;
|
|
93
|
22
|
94 (defvar toolbar-ispell-function
|
|
95 (lambda ()
|
|
96 (interactive)
|
|
97 (if (region-active-p)
|
|
98 (ispell-region (region-beginning) (region-end))
|
|
99 (ispell-buffer)))
|
|
100 "*Function to call when the ispell icon is selected.")
|
|
101
|
0
|
102 (defun toolbar-ispell ()
|
|
103 "Intelligently spell the region or buffer."
|
|
104 (interactive)
|
22
|
105 (call-interactively toolbar-ispell-function))
|
0
|
106
|
|
107 ;;
|
|
108 ;; toolbar mail variables and defuns
|
|
109 ;;
|
|
110
|
16
|
111 (defmacro toolbar-external (process &rest args)
|
|
112 `(lambda () (interactive) (call-process ,process nil 0 nil ,@args)))
|
0
|
113
|
16
|
114 (defvar toolbar-mail-commands-alist
|
|
115 `((vm . vm)
|
|
116 (gnus . gnus-no-server)
|
|
117 (rmail . rmail)
|
|
118 (mh . mh-rmail)
|
|
119 (pine . ,(toolbar-external "xterm" "-e" "pine")) ; *gag*
|
|
120 (elm . ,(toolbar-external "xterm" "-e" "elm"))
|
|
121 (mutt . ,(toolbar-external "xterm" "-e" "mutt"))
|
|
122 (exmh . ,(toolbar-external "exmh"))
|
|
123 ;; How to turn on netscape mail, command-line??
|
|
124 (netscape . ,(toolbar-external "netscape")))
|
|
125 "Alist of mail readers and their commands.
|
|
126 The car of the alist is the mail reader, and the cdr is the form
|
|
127 used to start it.")
|
0
|
128
|
16
|
129 (defvar toolbar-mail-reader 'vm
|
22
|
130 "*Mail reader toolbar will invoke.
|
16
|
131 The legal values are `vm' and `gnus', but you can add your own values
|
|
132 by customizing `toolbar-mail-commands-alist'.")
|
|
133
|
0
|
134
|
|
135 (defun toolbar-mail ()
|
|
136 "Run mail in a separate frame."
|
|
137 (interactive)
|
16
|
138 (let ((command (assq toolbar-mail-reader toolbar-mail-commands-alist)))
|
|
139 (if (not command)
|
|
140 (error "Uknown mail reader %s" toolbar-mail-reader))
|
|
141 (funcall (cdr command))))
|
0
|
142
|
|
143 ;;
|
|
144 ;; toolbar info variables and defuns
|
|
145 ;;
|
|
146
|
|
147 (defvar toolbar-info-frame nil
|
|
148 "The frame in which info is displayed.")
|
|
149
|
|
150 (defun toolbar-info ()
|
|
151 "Run info in a separate frame."
|
|
152 (interactive)
|
|
153 (if (or (not toolbar-info-frame)
|
|
154 (not (frame-live-p toolbar-info-frame)))
|
|
155 (progn
|
|
156 (setq toolbar-info-frame (make-frame))
|
|
157 (select-frame toolbar-info-frame)
|
|
158 (raise-frame toolbar-info-frame)))
|
|
159 (if (frame-iconified-p toolbar-info-frame)
|
|
160 (deiconify-frame toolbar-info-frame))
|
|
161 (select-frame toolbar-info-frame)
|
|
162 (raise-frame toolbar-info-frame)
|
|
163 (info))
|
|
164
|
|
165 ;;
|
|
166 ;; toolbar debug variables and defuns
|
|
167 ;;
|
|
168
|
|
169 (defun toolbar-debug ()
|
|
170 (interactive)
|
|
171 (if (featurep 'eos-debugger)
|
|
172 (call-interactively 'eos::start-debugger)
|
|
173 (require 'gdbsrc)
|
|
174 (call-interactively 'gdbsrc))
|
|
175 )
|
|
176
|
|
177 (defvar compile-command)
|
4
|
178 (defvar toolbar-compile-already-run nil)
|
0
|
179
|
|
180 (defun toolbar-compile ()
|
|
181 "Run compile without having to touch the keyboard."
|
|
182 (interactive)
|
|
183 (require 'compile)
|
4
|
184 (if toolbar-compile-already-run
|
|
185 (compile compile-command)
|
|
186 (setq toolbar-compile-already-run t)
|
|
187 (popup-dialog-box
|
|
188 `(,(concat "Compile:\n " compile-command)
|
|
189 ["Compile" (compile compile-command) t]
|
|
190 ["Edit command" compile t]
|
|
191 nil
|
|
192 ["Cancel" (message "Quit") t]))))
|
0
|
193
|
|
194 ;;
|
|
195 ;; toolbar news variables and defuns
|
|
196 ;;
|
|
197
|
22
|
198 (defvar toolbar-news-commands-alist
|
|
199 `((gnus . gnus) ; M-x all-hail-gnus
|
|
200 (rn . ,(toolbar-external "xterm" "-e" "rn"))
|
|
201 (nn . ,(toolbar-external "xterm" "-e" "nn"))
|
|
202 (trn . ,(toolbar-external "xterm" "-e" "trn"))
|
|
203 (xrn . ,(toolbar-external "xrn"))
|
|
204 (slrn . ,(toolbar-external "xterm" "-e" "slrn"))
|
|
205 (pine . ,(toolbar-external "xterm" "-e" "pine")) ; *gag*
|
|
206 (tin . ,(toolbar-external "xterm" "-e" "tin")) ; *gag*
|
|
207 (netscape . ,(toolbar-external "netscape" "news:")))
|
|
208 "Alist of news readers and their commands.
|
|
209 Each list element is a pair. The car of the pair is the mail
|
|
210 reader, and the cdr is the form used to start it.")
|
|
211
|
|
212 (defvar toolbar-news-reader 'gnus
|
|
213 "*News reader toolbar will invoke.
|
|
214 The legal values are gnus, rn, nn, trn, xrn, slrn, pine and netscape.
|
|
215 You can add your own values by customizing `toolbar-news-commands-alist'.")
|
|
216
|
|
217 (defvar toolbar-news-use-separate-frame t
|
|
218 "*Whether Gnus is invoked in a separate frame.")
|
|
219
|
0
|
220 (defvar toolbar-news-frame nil
|
|
221 "The frame in which news is displayed.")
|
|
222
|
14
|
223 (defvar toolbar-news-frame-properties nil
|
|
224 "The properties of the frame in which news is displayed.")
|
|
225
|
0
|
226 (defun toolbar-news ()
|
10
|
227 "Run Gnus in a separate frame."
|
0
|
228 (interactive)
|
10
|
229 (when (or (not toolbar-news-frame)
|
|
230 (not (frame-live-p toolbar-news-frame)))
|
14
|
231 (setq toolbar-news-frame (make-frame toolbar-news-frame-properties))
|
10
|
232 (add-hook 'gnus-exit-gnus-hook
|
|
233 (lambda ()
|
|
234 (when (frame-live-p toolbar-news-frame)
|
|
235 (if (cdr (frame-list))
|
|
236 (delete-frame toolbar-news-frame))
|
|
237 (setq toolbar-news-frame nil))))
|
|
238 (select-frame toolbar-news-frame)
|
|
239 (raise-frame toolbar-news-frame)
|
|
240 (gnus))
|
0
|
241 (if (frame-iconified-p toolbar-news-frame)
|
|
242 (deiconify-frame toolbar-news-frame))
|
|
243 (select-frame toolbar-news-frame)
|
|
244 (raise-frame toolbar-news-frame))
|
|
245
|
|
246 (defvar toolbar-last-win-icon nil "A `last-win' icon set.")
|
|
247 (defvar toolbar-next-win-icon nil "A `next-win' icon set.")
|
|
248 (defvar toolbar-file-icon nil "A `file' icon set.")
|
|
249 (defvar toolbar-folder-icon nil "A `folder' icon set")
|
|
250 (defvar toolbar-disk-icon nil "A `disk' icon set.")
|
|
251 (defvar toolbar-printer-icon nil "A `printer' icon set.")
|
|
252 (defvar toolbar-cut-icon nil "A `cut' icon set.")
|
|
253 (defvar toolbar-copy-icon nil "A `copy' icon set.")
|
|
254 (defvar toolbar-paste-icon nil "A `paste' icon set.")
|
|
255 (defvar toolbar-undo-icon nil "An `undo' icon set.")
|
|
256 (defvar toolbar-spell-icon nil "A `spell' icon set.")
|
|
257 (defvar toolbar-replace-icon nil "A `replace' icon set.")
|
|
258 (defvar toolbar-mail-icon nil "A `mail' icon set.")
|
|
259 (defvar toolbar-info-icon nil "An `info' icon set.")
|
|
260 (defvar toolbar-compile-icon nil "A `compile' icon set.")
|
|
261 (defvar toolbar-debug-icon nil "A `debugger' icon set.")
|
|
262 (defvar toolbar-news-icon nil "A `news' icon set.")
|
|
263
|
|
264 ;;; each entry maps a variable to the prefix used.
|
|
265
|
|
266 (defvar init-x-toolbar-list
|
|
267 '((toolbar-last-win-icon . "last-win")
|
|
268 (toolbar-next-win-icon . "next-win")
|
|
269 (toolbar-file-icon . "file")
|
|
270 (toolbar-folder-icon . "folder")
|
|
271 (toolbar-disk-icon . "disk")
|
|
272 (toolbar-printer-icon . "printer")
|
|
273 (toolbar-cut-icon . "cut")
|
|
274 (toolbar-copy-icon . "copy")
|
|
275 (toolbar-paste-icon . "paste")
|
|
276 (toolbar-undo-icon . "undo")
|
|
277 (toolbar-spell-icon . "spell")
|
|
278 (toolbar-replace-icon . "replace")
|
|
279 (toolbar-mail-icon . "mail")
|
|
280 (toolbar-info-icon . "info-def")
|
|
281 (toolbar-compile-icon . "compile")
|
|
282 (toolbar-debug-icon . "debug")
|
|
283 (toolbar-news-icon . "news")))
|
|
284
|
|
285 (defun init-x-toolbar ()
|
|
286 (mapcar
|
10
|
287 (lambda (cons)
|
|
288 (let ((prefix (expand-file-name (cdr cons) toolbar-icon-directory)))
|
|
289 (set (car cons)
|
|
290 (if (featurep 'xpm)
|
|
291 (toolbar-make-button-list
|
|
292 (concat prefix "-up.xpm")
|
|
293 nil
|
|
294 (concat prefix "-xx.xpm")
|
|
295 (concat prefix "-cap-up.xpm")
|
|
296 nil
|
|
297 (concat prefix "-cap-xx.xpm"))
|
|
298 (toolbar-make-button-list
|
|
299 (concat prefix "-up.xbm")
|
|
300 (concat prefix "-dn.xbm")
|
|
301 (concat prefix "-xx.xbm")
|
|
302 )))))
|
0
|
303 init-x-toolbar-list)
|
|
304 ;; do this now because errors will occur if the icon symbols
|
|
305 ;; are not initted
|
|
306 (set-specifier default-toolbar initial-toolbar-spec))
|
|
307
|
|
308 (defvar initial-toolbar-spec
|
|
309 '(;[toolbar-last-win-icon pop-window-configuration
|
|
310 ;;; #### illicit knowledge?
|
|
311 ;;; #### these don't work right!
|
|
312 ;;; #### not consistent.
|
|
313 ;;; I don't know what's wrong;
|
|
314 ;;; perhaps `selected-frame' is
|
|
315 ;;; wrong sometimes when this
|
|
316 ;;; is evaluated. Note that I
|
|
317 ;;; even tried to kludge-fix this
|
|
318 ;;; by calls to `set-specifier-dirty-flag'
|
|
319 ;;; in pop-window-configuration
|
|
320 ;;; and such.
|
|
321 ;(frame-property (selected-frame)
|
|
322 ; 'window-config-stack)
|
|
323 ; t
|
|
324 ; "Most recent window config"]
|
|
325 ;[toolbar-next-win-icon unpop-window-configuration
|
|
326 ;;; #### illicit knowledge?
|
|
327 ;(frame-property (selected-frame)
|
|
328 ; 'window-config-unpop-stack)
|
|
329 ; t
|
|
330 ; "Undo \"Most recent window config\""]
|
16
|
331 [toolbar-file-icon toolbar-open t "Open a file" ]
|
|
332 [toolbar-folder-icon toolbar-dired t "View directory"]
|
|
333 [toolbar-disk-icon toolbar-save t "Save buffer" ]
|
4
|
334 [toolbar-printer-icon toolbar-print t "Print buffer" ]
|
16
|
335 [toolbar-cut-icon toolbar-cut t "Kill region"]
|
|
336 [toolbar-copy-icon toolbar-copy t "Copy region"]
|
|
337 [toolbar-paste-icon toolbar-paste t "Paste from clipboard"]
|
|
338 [toolbar-undo-icon toolbar-undo t "Undo edit" ]
|
0
|
339 [toolbar-spell-icon toolbar-ispell t "Spellcheck" ]
|
4
|
340 [toolbar-replace-icon toolbar-replace t "Replace text" ]
|
0
|
341 [toolbar-mail-icon toolbar-mail t "Mail" ]
|
|
342 [toolbar-info-icon toolbar-info t "Information" ]
|
|
343 [toolbar-compile-icon toolbar-compile t "Compile" ]
|
|
344 [toolbar-debug-icon toolbar-debug t "Debug" ]
|
|
345 [toolbar-news-icon toolbar-news t "News" ])
|
|
346 "The initial toolbar for a buffer.")
|
|
347
|
|
348
|
|
349 (defun x-init-toolbar-from-resources (locale)
|
|
350 (x-init-specifier-from-resources
|
|
351 top-toolbar-height 'natnum locale
|
|
352 '("topToolBarHeight" . "TopToolBarHeight"))
|
|
353 (x-init-specifier-from-resources
|
|
354 bottom-toolbar-height 'natnum locale
|
|
355 '("bottomToolBarHeight" . "BottomToolBarHeight"))
|
|
356 (x-init-specifier-from-resources
|
|
357 left-toolbar-width 'natnum locale
|
|
358 '("leftToolBarWidth" . "LeftToolBarWidth"))
|
|
359 (x-init-specifier-from-resources
|
|
360 right-toolbar-width 'natnum locale
|
|
361 '("rightToolBarWidth" . "RightToolBarWidth")))
|
22
|
362
|
|
363 ;;; x-toolbar.el ends here
|