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