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