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