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
|
|
19 ;; along with XEmacs; see the file COPYING. If not, write to the Free
|
|
20 ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
21
|
|
22 ;;
|
|
23 ;; toolbar ispell variables and defuns
|
|
24 ;;
|
|
25
|
|
26 (defun toolbar-ispell ()
|
|
27 "Intelligently spell the region or buffer."
|
|
28 (interactive)
|
|
29 (if (region-active-p)
|
|
30 (ispell-region (region-beginning) (region-end))
|
|
31 (ispell-buffer)))
|
|
32
|
|
33 ;;
|
|
34 ;; toolbar mail variables and defuns
|
|
35 ;;
|
|
36
|
|
37 (defvar toolbar-use-separate-mail-frame nil
|
|
38 "If non-nil run mail in a separate frame.")
|
|
39
|
|
40 (defvar toolbar-mail-frame nil
|
|
41 "The frame in which mail is displayed.")
|
|
42
|
|
43 (defvar toolbar-mail-command 'vm
|
|
44 "The mail reader to run.")
|
|
45
|
|
46 (defun toolbar-mail ()
|
|
47 "Run mail in a separate frame."
|
|
48 (interactive)
|
|
49 (if (not toolbar-use-separate-mail-frame)
|
|
50 (funcall toolbar-mail-command)
|
|
51 (if (or (not toolbar-mail-frame)
|
|
52 (not (frame-live-p toolbar-mail-frame)))
|
|
53 (progn
|
|
54 (setq toolbar-mail-frame (make-frame))
|
|
55 (add-hook 'vm-quit-hook
|
|
56 '(lambda ()
|
|
57 (save-excursion
|
|
58 (if (frame-live-p toolbar-mail-frame)
|
|
59 (delete-frame toolbar-mail-frame)))))
|
|
60 (select-frame toolbar-mail-frame)
|
|
61 (raise-frame toolbar-mail-frame)
|
|
62 (funcall toolbar-mail-command)))
|
|
63 (if (frame-iconified-p toolbar-mail-frame)
|
|
64 (deiconify-frame toolbar-mail-frame))
|
|
65 (select-frame toolbar-mail-frame)
|
|
66 (raise-frame toolbar-mail-frame)))
|
|
67
|
|
68 ;;
|
|
69 ;; toolbar info variables and defuns
|
|
70 ;;
|
|
71
|
|
72 (defvar toolbar-info-frame nil
|
|
73 "The frame in which info is displayed.")
|
|
74
|
|
75 (defun toolbar-info ()
|
|
76 "Run info in a separate frame."
|
|
77 (interactive)
|
|
78 (if (or (not toolbar-info-frame)
|
|
79 (not (frame-live-p toolbar-info-frame)))
|
|
80 (progn
|
|
81 (setq toolbar-info-frame (make-frame))
|
|
82 (select-frame toolbar-info-frame)
|
|
83 (raise-frame toolbar-info-frame)))
|
|
84 (if (frame-iconified-p toolbar-info-frame)
|
|
85 (deiconify-frame toolbar-info-frame))
|
|
86 (select-frame toolbar-info-frame)
|
|
87 (raise-frame toolbar-info-frame)
|
|
88 (info))
|
|
89
|
|
90 ;;
|
|
91 ;; toolbar debug variables and defuns
|
|
92 ;;
|
|
93
|
|
94 (defun toolbar-debug ()
|
|
95 (interactive)
|
|
96 (if (featurep 'eos-debugger)
|
|
97 (call-interactively 'eos::start-debugger)
|
|
98 (require 'gdbsrc)
|
|
99 (call-interactively 'gdbsrc))
|
|
100 )
|
|
101
|
|
102 (defvar compile-command)
|
4
|
103 (defvar toolbar-compile-already-run nil)
|
0
|
104
|
|
105 (defun toolbar-compile ()
|
|
106 "Run compile without having to touch the keyboard."
|
|
107 (interactive)
|
|
108 (require 'compile)
|
4
|
109 (if toolbar-compile-already-run
|
|
110 (compile compile-command)
|
|
111 (setq toolbar-compile-already-run t)
|
|
112 (popup-dialog-box
|
|
113 `(,(concat "Compile:\n " compile-command)
|
|
114 ["Compile" (compile compile-command) t]
|
|
115 ["Edit command" compile t]
|
|
116 nil
|
|
117 ["Cancel" (message "Quit") t]))))
|
0
|
118
|
|
119 ;;
|
|
120 ;; toolbar news variables and defuns
|
|
121 ;;
|
|
122
|
|
123 (defvar toolbar-news-frame nil
|
|
124 "The frame in which news is displayed.")
|
|
125
|
|
126 (defun toolbar-news ()
|
|
127 "Run GNUS in a separate frame."
|
|
128 (interactive)
|
|
129 (if (or (not toolbar-news-frame)
|
|
130 (not (frame-live-p toolbar-news-frame)))
|
|
131 (progn
|
|
132 (setq toolbar-news-frame (make-frame))
|
|
133 (add-hook 'gnus-exit-gnus-hook
|
|
134 '(lambda ()
|
|
135 (if (frame-live-p toolbar-news-frame)
|
|
136 (delete-frame toolbar-news-frame))))
|
|
137 (select-frame toolbar-news-frame)
|
|
138 (raise-frame toolbar-news-frame)
|
|
139 (gnus)))
|
|
140 (if (frame-iconified-p toolbar-news-frame)
|
|
141 (deiconify-frame toolbar-news-frame))
|
|
142 (select-frame toolbar-news-frame)
|
|
143 (raise-frame toolbar-news-frame))
|
|
144
|
4
|
145 ;;
|
|
146 ;; toolbar printing variable and defun
|
|
147 ;;
|
|
148 (defvar toolbar-print-command 'lpr-buffer
|
|
149 "Command to run when the Print Icon is selected from the toolbar.
|
|
150 Set this to `ps-print-buffer-with-faces' if you primarily print with
|
|
151 a postscript printer.")
|
|
152
|
|
153 (defun toolbar-print ()
|
|
154 "Print current buffer."
|
|
155 (funcall toolbar-print-command))
|
|
156
|
|
157 ;;
|
|
158 ;; toolbar replacement variable and defun
|
|
159 ;;
|
|
160 (defvar toolbar-replace-command 'query-replace
|
|
161 "Command to run when the Replace Icon is selected from the toolbar.
|
|
162 One possibility for a different value would be `query-replace-regexp'.")
|
|
163
|
|
164 (defun toolbar-replace ()
|
|
165 "Run a query-replace -type function on the current buffer."
|
|
166 (funcall toolbar-replace-command))
|
|
167
|
0
|
168 (defvar toolbar-last-win-icon nil "A `last-win' icon set.")
|
|
169 (defvar toolbar-next-win-icon nil "A `next-win' icon set.")
|
|
170 (defvar toolbar-file-icon nil "A `file' icon set.")
|
|
171 (defvar toolbar-folder-icon nil "A `folder' icon set")
|
|
172 (defvar toolbar-disk-icon nil "A `disk' icon set.")
|
|
173 (defvar toolbar-printer-icon nil "A `printer' icon set.")
|
|
174 (defvar toolbar-cut-icon nil "A `cut' icon set.")
|
|
175 (defvar toolbar-copy-icon nil "A `copy' icon set.")
|
|
176 (defvar toolbar-paste-icon nil "A `paste' icon set.")
|
|
177 (defvar toolbar-undo-icon nil "An `undo' icon set.")
|
|
178 (defvar toolbar-spell-icon nil "A `spell' icon set.")
|
|
179 (defvar toolbar-replace-icon nil "A `replace' icon set.")
|
|
180 (defvar toolbar-mail-icon nil "A `mail' icon set.")
|
|
181 (defvar toolbar-info-icon nil "An `info' icon set.")
|
|
182 (defvar toolbar-compile-icon nil "A `compile' icon set.")
|
|
183 (defvar toolbar-debug-icon nil "A `debugger' icon set.")
|
|
184 (defvar toolbar-news-icon nil "A `news' icon set.")
|
|
185
|
|
186 ;;; each entry maps a variable to the prefix used.
|
|
187
|
|
188 (defvar init-x-toolbar-list
|
|
189 '((toolbar-last-win-icon . "last-win")
|
|
190 (toolbar-next-win-icon . "next-win")
|
|
191 (toolbar-file-icon . "file")
|
|
192 (toolbar-folder-icon . "folder")
|
|
193 (toolbar-disk-icon . "disk")
|
|
194 (toolbar-printer-icon . "printer")
|
|
195 (toolbar-cut-icon . "cut")
|
|
196 (toolbar-copy-icon . "copy")
|
|
197 (toolbar-paste-icon . "paste")
|
|
198 (toolbar-undo-icon . "undo")
|
|
199 (toolbar-spell-icon . "spell")
|
|
200 (toolbar-replace-icon . "replace")
|
|
201 (toolbar-mail-icon . "mail")
|
|
202 (toolbar-info-icon . "info-def")
|
|
203 (toolbar-compile-icon . "compile")
|
|
204 (toolbar-debug-icon . "debug")
|
|
205 (toolbar-news-icon . "news")))
|
|
206
|
|
207 (defun init-x-toolbar ()
|
|
208 (mapcar
|
|
209 #'(lambda (cons)
|
|
210 (let ((prefix (expand-file-name (cdr cons) toolbar-icon-directory)))
|
|
211 (set (car cons)
|
|
212 (if (featurep 'xpm)
|
|
213 (toolbar-make-button-list
|
|
214 (concat prefix "-up.xpm")
|
|
215 nil
|
|
216 (concat prefix "-xx.xpm")
|
|
217 (concat prefix "-cap-up.xpm")
|
|
218 nil
|
|
219 (concat prefix "-cap-xx.xpm"))
|
|
220 (toolbar-make-button-list
|
|
221 (concat prefix "-up.xbm")
|
|
222 (concat prefix "-dn.xbm")
|
|
223 (concat prefix "-xx.xbm")
|
|
224 )))))
|
|
225 init-x-toolbar-list)
|
|
226 ;; do this now because errors will occur if the icon symbols
|
|
227 ;; are not initted
|
|
228 (set-specifier default-toolbar initial-toolbar-spec))
|
|
229
|
|
230 (defvar initial-toolbar-spec
|
|
231 '(;[toolbar-last-win-icon pop-window-configuration
|
|
232 ;;; #### illicit knowledge?
|
|
233 ;;; #### these don't work right!
|
|
234 ;;; #### not consistent.
|
|
235 ;;; I don't know what's wrong;
|
|
236 ;;; perhaps `selected-frame' is
|
|
237 ;;; wrong sometimes when this
|
|
238 ;;; is evaluated. Note that I
|
|
239 ;;; even tried to kludge-fix this
|
|
240 ;;; by calls to `set-specifier-dirty-flag'
|
|
241 ;;; in pop-window-configuration
|
|
242 ;;; and such.
|
|
243 ;(frame-property (selected-frame)
|
|
244 ; 'window-config-stack)
|
|
245 ; t
|
|
246 ; "Most recent window config"]
|
|
247 ;[toolbar-next-win-icon unpop-window-configuration
|
|
248 ;;; #### illicit knowledge?
|
|
249 ;(frame-property (selected-frame)
|
|
250 ; 'window-config-unpop-stack)
|
|
251 ; t
|
|
252 ; "Undo \"Most recent window config\""]
|
|
253 [toolbar-file-icon find-file t "Open a file" ]
|
|
254 [toolbar-folder-icon dired t "View directory"]
|
|
255 [toolbar-disk-icon save-buffer t "Save buffer" ]
|
4
|
256 [toolbar-printer-icon toolbar-print t "Print buffer" ]
|
0
|
257 [toolbar-cut-icon x-kill-primary-selection t "Kill region"]
|
|
258 [toolbar-copy-icon x-copy-primary-selection t "Copy region"]
|
|
259 [toolbar-paste-icon x-yank-clipboard-selection t
|
|
260 "Paste from clipboard"]
|
|
261 [toolbar-undo-icon undo t "Undo edit" ]
|
|
262 [toolbar-spell-icon toolbar-ispell t "Spellcheck" ]
|
4
|
263 [toolbar-replace-icon toolbar-replace t "Replace text" ]
|
0
|
264 [toolbar-mail-icon toolbar-mail t "Mail" ]
|
|
265 [toolbar-info-icon toolbar-info t "Information" ]
|
|
266 [toolbar-compile-icon toolbar-compile t "Compile" ]
|
|
267 [toolbar-debug-icon toolbar-debug t "Debug" ]
|
|
268 [toolbar-news-icon toolbar-news t "News" ])
|
|
269 "The initial toolbar for a buffer.")
|
|
270
|
|
271
|
|
272 (defun x-init-toolbar-from-resources (locale)
|
|
273 (x-init-specifier-from-resources
|
|
274 top-toolbar-height 'natnum locale
|
|
275 '("topToolBarHeight" . "TopToolBarHeight"))
|
|
276 (x-init-specifier-from-resources
|
|
277 bottom-toolbar-height 'natnum locale
|
|
278 '("bottomToolBarHeight" . "BottomToolBarHeight"))
|
|
279 (x-init-specifier-from-resources
|
|
280 left-toolbar-width 'natnum locale
|
|
281 '("leftToolBarWidth" . "LeftToolBarWidth"))
|
|
282 (x-init-specifier-from-resources
|
|
283 right-toolbar-width 'natnum locale
|
|
284 '("rightToolBarWidth" . "RightToolBarWidth")))
|