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