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)
|
|
103
|
|
104 (defun toolbar-compile ()
|
|
105 "Run compile without having to touch the keyboard."
|
|
106 (interactive)
|
|
107 (require 'compile)
|
|
108 (popup-dialog-box
|
|
109 `(,(concat "Compile:\n " compile-command)
|
|
110 ["Compile" (compile compile-command) t]
|
|
111 ["Edit command" compile t]
|
|
112 nil
|
|
113 ["Cancel" (message "Quit") t])))
|
|
114
|
|
115 ;;
|
|
116 ;; toolbar news variables and defuns
|
|
117 ;;
|
|
118
|
|
119 (defvar toolbar-news-frame nil
|
|
120 "The frame in which news is displayed.")
|
|
121
|
|
122 (defun toolbar-news ()
|
|
123 "Run GNUS in a separate frame."
|
|
124 (interactive)
|
|
125 (if (or (not toolbar-news-frame)
|
|
126 (not (frame-live-p toolbar-news-frame)))
|
|
127 (progn
|
|
128 (setq toolbar-news-frame (make-frame))
|
|
129 (add-hook 'gnus-exit-gnus-hook
|
|
130 '(lambda ()
|
|
131 (if (frame-live-p toolbar-news-frame)
|
|
132 (delete-frame toolbar-news-frame))))
|
|
133 (select-frame toolbar-news-frame)
|
|
134 (raise-frame toolbar-news-frame)
|
|
135 (gnus)))
|
|
136 (if (frame-iconified-p toolbar-news-frame)
|
|
137 (deiconify-frame toolbar-news-frame))
|
|
138 (select-frame toolbar-news-frame)
|
|
139 (raise-frame toolbar-news-frame))
|
|
140
|
|
141 (defvar toolbar-last-win-icon nil "A `last-win' icon set.")
|
|
142 (defvar toolbar-next-win-icon nil "A `next-win' icon set.")
|
|
143 (defvar toolbar-file-icon nil "A `file' icon set.")
|
|
144 (defvar toolbar-folder-icon nil "A `folder' icon set")
|
|
145 (defvar toolbar-disk-icon nil "A `disk' icon set.")
|
|
146 (defvar toolbar-printer-icon nil "A `printer' icon set.")
|
|
147 (defvar toolbar-cut-icon nil "A `cut' icon set.")
|
|
148 (defvar toolbar-copy-icon nil "A `copy' icon set.")
|
|
149 (defvar toolbar-paste-icon nil "A `paste' icon set.")
|
|
150 (defvar toolbar-undo-icon nil "An `undo' icon set.")
|
|
151 (defvar toolbar-spell-icon nil "A `spell' icon set.")
|
|
152 (defvar toolbar-replace-icon nil "A `replace' icon set.")
|
|
153 (defvar toolbar-mail-icon nil "A `mail' icon set.")
|
|
154 (defvar toolbar-info-icon nil "An `info' icon set.")
|
|
155 (defvar toolbar-compile-icon nil "A `compile' icon set.")
|
|
156 (defvar toolbar-debug-icon nil "A `debugger' icon set.")
|
|
157 (defvar toolbar-news-icon nil "A `news' icon set.")
|
|
158
|
|
159 ;;; each entry maps a variable to the prefix used.
|
|
160
|
|
161 (defvar init-x-toolbar-list
|
|
162 '((toolbar-last-win-icon . "last-win")
|
|
163 (toolbar-next-win-icon . "next-win")
|
|
164 (toolbar-file-icon . "file")
|
|
165 (toolbar-folder-icon . "folder")
|
|
166 (toolbar-disk-icon . "disk")
|
|
167 (toolbar-printer-icon . "printer")
|
|
168 (toolbar-cut-icon . "cut")
|
|
169 (toolbar-copy-icon . "copy")
|
|
170 (toolbar-paste-icon . "paste")
|
|
171 (toolbar-undo-icon . "undo")
|
|
172 (toolbar-spell-icon . "spell")
|
|
173 (toolbar-replace-icon . "replace")
|
|
174 (toolbar-mail-icon . "mail")
|
|
175 (toolbar-info-icon . "info-def")
|
|
176 (toolbar-compile-icon . "compile")
|
|
177 (toolbar-debug-icon . "debug")
|
|
178 (toolbar-news-icon . "news")))
|
|
179
|
|
180 (defun init-x-toolbar ()
|
|
181 (mapcar
|
|
182 #'(lambda (cons)
|
|
183 (let ((prefix (expand-file-name (cdr cons) toolbar-icon-directory)))
|
|
184 (set (car cons)
|
|
185 (if (featurep 'xpm)
|
|
186 (toolbar-make-button-list
|
|
187 (concat prefix "-up.xpm")
|
|
188 nil
|
|
189 (concat prefix "-xx.xpm")
|
|
190 (concat prefix "-cap-up.xpm")
|
|
191 nil
|
|
192 (concat prefix "-cap-xx.xpm"))
|
|
193 (toolbar-make-button-list
|
|
194 (concat prefix "-up.xbm")
|
|
195 (concat prefix "-dn.xbm")
|
|
196 (concat prefix "-xx.xbm")
|
|
197 )))))
|
|
198 init-x-toolbar-list)
|
|
199 ;; do this now because errors will occur if the icon symbols
|
|
200 ;; are not initted
|
|
201 (set-specifier default-toolbar initial-toolbar-spec))
|
|
202
|
|
203 (defvar initial-toolbar-spec
|
|
204 '(;[toolbar-last-win-icon pop-window-configuration
|
|
205 ;;; #### illicit knowledge?
|
|
206 ;;; #### these don't work right!
|
|
207 ;;; #### not consistent.
|
|
208 ;;; I don't know what's wrong;
|
|
209 ;;; perhaps `selected-frame' is
|
|
210 ;;; wrong sometimes when this
|
|
211 ;;; is evaluated. Note that I
|
|
212 ;;; even tried to kludge-fix this
|
|
213 ;;; by calls to `set-specifier-dirty-flag'
|
|
214 ;;; in pop-window-configuration
|
|
215 ;;; and such.
|
|
216 ;(frame-property (selected-frame)
|
|
217 ; 'window-config-stack)
|
|
218 ; t
|
|
219 ; "Most recent window config"]
|
|
220 ;[toolbar-next-win-icon unpop-window-configuration
|
|
221 ;;; #### illicit knowledge?
|
|
222 ;(frame-property (selected-frame)
|
|
223 ; 'window-config-unpop-stack)
|
|
224 ; t
|
|
225 ; "Undo \"Most recent window config\""]
|
|
226 [toolbar-file-icon find-file t "Open a file" ]
|
|
227 [toolbar-folder-icon dired t "View directory"]
|
|
228 [toolbar-disk-icon save-buffer t "Save buffer" ]
|
|
229 [toolbar-printer-icon lpr-buffer t "Print buffer" ]
|
|
230 [toolbar-cut-icon x-kill-primary-selection t "Kill region"]
|
|
231 [toolbar-copy-icon x-copy-primary-selection t "Copy region"]
|
|
232 [toolbar-paste-icon x-yank-clipboard-selection t
|
|
233 "Paste from clipboard"]
|
|
234 [toolbar-undo-icon undo t "Undo edit" ]
|
|
235 [toolbar-spell-icon toolbar-ispell t "Spellcheck" ]
|
|
236 [toolbar-replace-icon query-replace t "Replace text" ]
|
|
237 [toolbar-mail-icon toolbar-mail t "Mail" ]
|
|
238 [toolbar-info-icon toolbar-info t "Information" ]
|
|
239 [toolbar-compile-icon toolbar-compile t "Compile" ]
|
|
240 [toolbar-debug-icon toolbar-debug t "Debug" ]
|
|
241 [toolbar-news-icon toolbar-news t "News" ])
|
|
242 "The initial toolbar for a buffer.")
|
|
243
|
|
244
|
|
245 (defun x-init-toolbar-from-resources (locale)
|
|
246 (x-init-specifier-from-resources
|
|
247 top-toolbar-height 'natnum locale
|
|
248 '("topToolBarHeight" . "TopToolBarHeight"))
|
|
249 (x-init-specifier-from-resources
|
|
250 bottom-toolbar-height 'natnum locale
|
|
251 '("bottomToolBarHeight" . "BottomToolBarHeight"))
|
|
252 (x-init-specifier-from-resources
|
|
253 left-toolbar-width 'natnum locale
|
|
254 '("leftToolBarWidth" . "LeftToolBarWidth"))
|
|
255 (x-init-specifier-from-resources
|
|
256 right-toolbar-width 'natnum locale
|
|
257 '("rightToolBarWidth" . "RightToolBarWidth")))
|