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