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