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