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