2
|
1 ;;; w3-prefs.el --- Preferences panels for Emacs-W3
|
0
|
2 ;; Author: wmperry
|
2
|
3 ;; Created: 1996/06/30 18:10:45
|
|
4 ;; Version: 1.5
|
0
|
5 ;; Keywords: hypermedia, preferences
|
|
6
|
|
7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2
|
8 ;;; Copyright (c) 1996 by William M. Perry (wmperry@cs.indiana.edu)
|
0
|
9 ;;;
|
|
10 ;;; This file is not part of GNU Emacs, but the same permissions apply.
|
|
11 ;;;
|
|
12 ;;; GNU Emacs is free software; you can redistribute it and/or modify
|
|
13 ;;; it under the terms of the GNU General Public License as published by
|
|
14 ;;; the Free Software Foundation; either version 2, or (at your option)
|
|
15 ;;; any later version.
|
|
16 ;;;
|
|
17 ;;; GNU Emacs is distributed in the hope that it will be useful,
|
|
18 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
20 ;;; GNU General Public License for more details.
|
|
21 ;;;
|
|
22 ;;; You should have received a copy of the GNU General Public License
|
|
23 ;;; along with GNU Emacs; see the file COPYING. If not, write to
|
|
24 ;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
25 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
26
|
|
27 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
28 ;;; Preferences panels for Emacs-W3
|
|
29 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
30 (require 'widget)
|
|
31 (require 'widget-edit)
|
|
32 (require 'w3-vars)
|
|
33 (require 'w3-keyword)
|
|
34 (require 'w3-widget)
|
2
|
35 (require 'w3-toolbar)
|
0
|
36
|
|
37 (defvar w3-preferences-glyph nil)
|
|
38 (defvar w3-preferences-map nil)
|
|
39 (defvar w3-preferences-panel-begin-marker nil)
|
|
40 (defvar w3-preferences-panel-end-marker nil)
|
|
41 (defvar w3-preferences-panels '(
|
|
42 (appearance . "Appearance")
|
|
43 (images . "Images")
|
|
44 (cookies . "HTTP Cookies")
|
|
45 (hooks . "Various Hooks")
|
|
46 (compatibility . "Compatibility")
|
|
47 (proxy . "Proxy")))
|
|
48
|
|
49 (defun w3-preferences-setup-glyph-map ()
|
|
50 (let* ((x 0)
|
|
51 (height (and w3-preferences-glyph
|
|
52 (glyph-height w3-preferences-glyph)))
|
|
53 (width (and height (/ (glyph-width w3-preferences-glyph)
|
|
54 (length w3-preferences-panels)))))
|
|
55 (mapcar
|
|
56 (function
|
|
57 (lambda (region)
|
|
58 (vector "rect" (list (vector (if width (* x width) 0) 0)
|
|
59 (vector (if width (* (setq x (1+ x)) width) 0)
|
|
60 (or height 0)))
|
|
61 (car region) (cdr region))))
|
|
62 w3-preferences-panels)))
|
|
63
|
|
64 (defun w3-preferences-generic-variable-callback (widget &rest ignore)
|
|
65 (condition-case ()
|
|
66 (set (widget-get widget 'variable) (widget-value widget))
|
|
67 (error (message "Invalid or incomplete data..."))))
|
|
68
|
|
69 (defun w3-preferences-restore-variables (vars)
|
|
70 (let ((temp nil))
|
|
71 (while vars
|
|
72 (setq temp (intern (format "w3-preferences-temp-%s" (car vars))))
|
|
73 (set (car vars) (symbol-value temp))
|
|
74 (setq vars (cdr vars)))))
|
|
75
|
|
76 (defun w3-preferences-create-temp-variables (vars)
|
|
77 (let ((temp nil))
|
|
78 (while vars
|
|
79 (setq temp (intern (format "w3-preferences-temp-%s" (car vars))))
|
|
80 (set (make-local-variable temp) (symbol-value (car vars)))
|
|
81 (setq vars (cdr vars)))))
|
|
82
|
|
83
|
|
84 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
85 ;;; Appearance of the frame / pages
|
|
86 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
87 (defun w3-preferences-init-appearance-panel ()
|
|
88 (let ((vars '(w3-toolbar-orientation
|
|
89 w3-use-menus
|
|
90 w3-honor-stylesheets
|
|
91 w3-default-stylesheet
|
|
92 w3-default-homepage
|
|
93 w3-toolbar-type))
|
|
94 (temp nil))
|
|
95 (set (make-local-variable 'w3-preferences-temp-use-home-page)
|
|
96 (and w3-default-homepage t))
|
|
97 (w3-preferences-create-temp-variables vars)))
|
|
98
|
|
99 (defun w3-preferences-create-appearance-panel ()
|
|
100 ;; First the toolbars
|
|
101 (widget-insert "\nToolbars\n--------\n")
|
|
102 (widget-insert "\tShow Toolbars as:\t")
|
|
103 (widget-put
|
|
104 (widget-create 'radio
|
|
105 :value (symbol-value 'w3-preferences-temp-w3-toolbar-type)
|
|
106 :notify 'w3-preferences-generic-variable-callback
|
|
107 (list 'item :format "%t\t" :tag "Pictures" :value 'pictures)
|
|
108 (list 'item :format "%t\t" :tag "Text" :value 'text)
|
|
109 (list 'item :format "%t" :tag "Both" :value 'both))
|
|
110 'variable 'w3-preferences-temp-w3-toolbar-type)
|
|
111 (widget-insert "\n\tToolbars appear on ")
|
|
112 (widget-put
|
|
113 (widget-create 'choice
|
|
114 :value (symbol-value 'w3-preferences-temp-w3-toolbar-orientation)
|
|
115 :notify 'w3-preferences-generic-variable-callback
|
|
116 :format "%v"
|
|
117 :tag "Toolbar Position"
|
|
118 (list 'choice-item :format "%[%t%]" :tag "XEmacs Default" :value 'default)
|
|
119 (list 'choice-item :format "%[%t%]" :tag "Top" :value 'top)
|
|
120 (list 'choice-item :format "%[%t%]" :tag "Bottom" :value 'bottom)
|
|
121 (list 'choice-item :format "%[%t%]" :tag "Right" :value 'right)
|
|
122 (list 'choice-item :format "%[%t%]" :tag "Left" :value 'left)
|
|
123 (list 'choice-item :format "%[%t%]" :tag "No Toolbar" :value 'none))
|
|
124 'variable 'w3-preferences-temp-w3-toolbar-orientation)
|
|
125 (widget-insert " side of window.\n")
|
|
126
|
|
127 ;; Home page
|
|
128 (widget-insert "\nStartup\n--------\n\tBrowser starts with:\t")
|
|
129 (widget-put
|
|
130 (widget-create
|
|
131 'radio
|
|
132 :value (symbol-value 'w3-preferences-temp-use-home-page)
|
|
133 :notify 'w3-preferences-generic-variable-callback
|
|
134 (list 'item :format "%t\t" :tag "Blank Page" :value nil)
|
|
135 (list 'item :format "%t" :tag "Home Page Location" :value t))
|
|
136 'variable 'w3-preferences-temp-use-home-page)
|
|
137 (widget-insert "\n\t\tURL: ")
|
|
138 (widget-put
|
|
139 (widget-create
|
|
140 'field
|
|
141 :value (or (symbol-value 'w3-preferences-temp-w3-default-homepage) "None")
|
|
142 :notify 'w3-preferences-generic-variable-callback)
|
|
143 'variable 'w3-preferences-temp-w3-default-homepage)
|
|
144
|
|
145 ;; Stylesheet
|
|
146 (widget-insert "\nStyle\n--------\n\tDefault stylesheet:\t")
|
|
147 (widget-put
|
|
148 (widget-create
|
|
149 'file
|
|
150 :value (or (symbol-value 'w3-preferences-temp-w3-default-stylesheet) "")
|
|
151 :must-match t
|
|
152 :notify 'w3-preferences-generic-variable-callback)
|
|
153 'variable 'w3-preferences-temp-w3-default-stylesheet)
|
|
154 (widget-setup)
|
|
155 )
|
|
156
|
|
157 (defun w3-preferences-save-appearance-panel ()
|
|
158 (let ((vars '(w3-toolbar-orientation
|
|
159 w3-use-menus
|
|
160 w3-honor-stylesheets
|
|
161 w3-default-stylesheet
|
|
162 w3-toolbar-type))
|
|
163 (temp nil))
|
|
164 (if (symbol-value 'w3-preferences-temp-use-home-page)
|
|
165 (setq vars (cons 'w3-default-homepage vars))
|
|
166 (setq w3-default-homepage nil))
|
|
167 (w3-preferences-restore-variables vars)
|
|
168 (w3-toolbar-make-buttons)))
|
|
169
|
|
170
|
|
171 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
172 ;;; The images panel
|
|
173 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
174 (defun w3-preferences-init-images-panel ()
|
|
175 (let ((vars '(w3-delay-image-loads
|
|
176 w3-image-mappings)))
|
|
177 (w3-preferences-create-temp-variables vars)))
|
|
178
|
|
179 (defun w3-preferences-create-images-panel ()
|
|
180 (widget-insert "\n")
|
|
181 (widget-put
|
|
182 (widget-create
|
|
183 'checkbox
|
|
184 :notify 'w3-preferences-generic-variable-callback
|
|
185 :value (symbol-value 'w3-preferences-temp-w3-delay-image-loads))
|
|
186 'variable 'w3-preferences-temp-w3-delay-image-loads)
|
|
187 (widget-insert " Delay Image Loads\n"
|
|
188 ;;; "\nAllowed Image Types\n"
|
|
189 ;;; "-------------------\n")
|
|
190 ;;; (set
|
|
191 ;;; (make-local-variable 'w3-preferences-image-type-widget)
|
|
192 ;;; (widget-create
|
|
193 ;;; 'repeat
|
|
194 ;;; :entry-format "%i %d %v"
|
|
195 ;;; :value (mapcar
|
|
196 ;;; (function
|
|
197 ;;; (lambda (x)
|
|
198 ;;; (list 'item :format "%t" :tag (car x) :value (cdr x))))
|
|
199 ;;; w3-image-mappings)
|
|
200 ;;; '(item :tag "*/*" :value 'unknown)))
|
|
201 ))
|
|
202
|
|
203 (defun w3-preferences-save-images-panel ()
|
|
204 (let ((vars '(w3-delay-image-loads
|
|
205 w3-image-mappings)))
|
|
206 (w3-preferences-restore-variables vars)))
|
|
207
|
|
208 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
209 ;;; The cookies panel
|
|
210 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
211 (defun w3-preferences-init-cookies-panel ()
|
|
212 (let ((cookies url-cookie-storage)
|
|
213 (secure-cookies url-cookie-secure-storage))
|
|
214 )
|
|
215 )
|
|
216
|
|
217 (defun w3-preferences-create-cookies-panel ()
|
|
218 (widget-insert "\n\t\tSorry, not yet implemented.\n\n"))
|
|
219
|
|
220 (defun w3-preferences-save-cookies-panel ()
|
|
221 )
|
|
222
|
|
223
|
|
224 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
225 ;;; The hooks panel
|
|
226 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
227 (defvar w3-preferences-hooks-variables
|
|
228 '(w3-file-done-hook
|
|
229 w3-file-prepare-hook
|
|
230 w3-load-hook
|
|
231 w3-mode-hook
|
|
232 w3-preferences-cancel-hook
|
|
233 w3-preferences-default-hook
|
|
234 w3-preferences-ok-hook
|
|
235 w3-preferences-setup-hook
|
|
236 w3-source-file-hook))
|
|
237
|
|
238 (defun w3-preferences-init-hooks-panel ()
|
|
239 (w3-preferences-create-temp-variables w3-preferences-hooks-variables))
|
|
240
|
|
241 (defun w3-preferences-create-hooks-panel ()
|
|
242 (let ((todo w3-preferences-hooks-variables)
|
|
243 (cur nil)
|
|
244 (pt nil)
|
|
245 (doc nil))
|
|
246 (widget-insert "\n")
|
|
247 (while todo
|
|
248 (setq cur (car todo)
|
|
249 todo (cdr todo)
|
|
250 doc (get cur 'variable-documentation))
|
|
251 (if (string-match "^\\*" doc)
|
|
252 (setq doc (substring doc 1 nil)))
|
|
253 (setq pt (point))
|
|
254 (widget-insert "\n" (symbol-name cur) " - " doc)
|
|
255 (fill-region-as-paragraph pt (point))
|
|
256 (setq cur (intern (format "w3-preferences-temp-%s" cur)))
|
|
257 (widget-put
|
|
258 (widget-create
|
|
259 'sexp
|
|
260 :notify 'w3-preferences-generic-variable-callback
|
|
261 :value (or (symbol-value cur) "nil"))
|
|
262 'variable cur))
|
|
263 (widget-setup)))
|
|
264
|
|
265 (defun w3-preferences-save-hooks-panel ()
|
|
266 (w3-preferences-restore-variables w3-preferences-hooks-variables))
|
|
267
|
|
268
|
|
269 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
270 ;;; The compatibility panel
|
|
271 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
272 (defvar w3-preferences-compatibility-variables
|
|
273 '(
|
|
274 (w3-style-ie-compatibility
|
|
275 . "Internet Explorer (tm) 3.0 compatible stylesheet parsing")
|
|
276 (w3-netscape-compatible-comments
|
|
277 . "Allow Netscape compatible comments")
|
|
278 (w3-user-colors-take-precedence
|
|
279 . "Ignore netscape document color control")
|
|
280 (url-honor-refresh-requests
|
|
281 . "Allow Netscape `Client Pull'"))
|
|
282 "A list of variables that the preferences compability pane knows about.")
|
|
283
|
|
284 (defun w3-preferences-init-compatibility-panel ()
|
|
285 (let ((compat w3-preferences-compatibility-variables)
|
|
286 (cur nil)
|
|
287 (var nil))
|
|
288 (w3-preferences-create-temp-variables
|
|
289 (mapcar 'car w3-preferences-compatibility-variables))))
|
|
290
|
|
291 (defun w3-preferences-create-compatibility-panel ()
|
|
292 (let ((compat w3-preferences-compatibility-variables)
|
|
293 (cur nil)
|
|
294 (var nil))
|
|
295 (widget-insert "\n")
|
|
296 (while compat
|
|
297 (setq cur (car compat)
|
|
298 compat (cdr compat)
|
|
299 var (intern (format "w3-preferences-temp-%s" (car cur))))
|
|
300 (widget-put
|
|
301 (widget-create 'checkbox
|
|
302 :notify 'w3-preferences-generic-variable-callback
|
|
303 :value (symbol-value var))
|
|
304 'variable var)
|
|
305 (widget-insert " " (cdr cur) "\n\n"))
|
|
306 (widget-setup)))
|
|
307
|
|
308 (defun w3-preferences-save-compatibility-panel ()
|
|
309 (w3-preferences-restore-variables
|
|
310 (mapcar 'car w3-preferences-compatibility-variables)))
|
|
311
|
|
312
|
|
313 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
314 ;;; The proxy configuration panel
|
|
315 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
316 (defun w3-preferences-init-proxy-panel ()
|
|
317 (let ((proxies '("FTP" "Gopher" "HTTP" "Security" "WAIS" "SHTTP" "News"))
|
|
318 (proxy nil)
|
|
319 (host-var nil)
|
|
320 (port-var nil)
|
|
321 (urlobj nil))
|
|
322 (widget-insert "\n")
|
|
323 (while proxies
|
|
324 (setq proxy (car proxies)
|
|
325 proxies (cdr proxies)
|
|
326 host-var (intern (format "w3-%s-proxy-host" (downcase proxy)))
|
|
327 port-var (intern (format "w3-%s-proxy-port" (downcase proxy)))
|
|
328 urlobj (url-generic-parse-url
|
|
329 (cdr-safe
|
|
330 (assoc (downcase proxy) url-proxy-services))))
|
|
331 (set (make-local-variable host-var) (or (url-host urlobj) ""))
|
|
332 (set (make-local-variable port-var) (or (url-port urlobj) "")))))
|
|
333
|
|
334 (defun w3-preferences-create-proxy-panel ()
|
|
335 (let ((proxies '("FTP" "Gopher" "HTTP" "Security" "WAIS" "SHTTP" "News"))
|
|
336 (proxy nil)
|
|
337 (host-var nil)
|
|
338 (port-var nil)
|
|
339 (urlobj nil))
|
|
340 (widget-insert "\n")
|
|
341 (while proxies
|
|
342 (setq proxy (car proxies)
|
|
343 proxies (cdr proxies)
|
|
344 host-var (intern (format "w3-%s-proxy-host" (downcase proxy)))
|
|
345 port-var (intern (format "w3-%s-proxy-port" (downcase proxy))))
|
|
346 (widget-insert (format "%10s Proxy: " proxy))
|
|
347 (widget-put
|
|
348 (widget-create 'field
|
|
349 :size 20
|
|
350 :value-face 'underline
|
|
351 :notify 'w3-preferences-generic-variable-callback
|
|
352 :value (format "%-20s" (symbol-value host-var)))
|
|
353 'variable host-var)
|
|
354 (widget-insert " Port: ")
|
|
355 (widget-put
|
|
356 (widget-create 'field
|
|
357 :size 5
|
|
358 :value-face 'underline
|
|
359 :notify 'w3-preferences-generic-variable-callback
|
|
360 :value (format "%5s" (symbol-value port-var)))
|
|
361 'variable port-var)
|
|
362 (widget-insert "\n\n"))
|
|
363 (widget-setup)))
|
|
364
|
|
365 (defun w3-preferences-save-proxy-panel ()
|
|
366 (let ((proxies '("FTP" "Gopher" "HTTP" "Security" "WAIS" "SHTTP" "News"))
|
|
367 (proxy nil)
|
|
368 (host-var nil)
|
|
369 (port-var nil)
|
|
370 (urlobj nil)
|
|
371 (host nil)
|
|
372 (port nil)
|
|
373 (new-proxy-services nil))
|
|
374 (while proxies
|
|
375 (setq proxy (car proxies)
|
|
376 proxies (cdr proxies)
|
|
377 host-var (intern (format "w3-%s-proxy-host" (downcase proxy)))
|
|
378 port-var (intern (format "w3-%s-proxy-port" (downcase proxy)))
|
|
379 urlobj (url-generic-parse-url
|
|
380 (cdr-safe
|
|
381 (assoc (downcase proxy) url-proxy-services)))
|
|
382 host (symbol-value host-var)
|
|
383 port (symbol-value port-var))
|
|
384 (if (and host (/= 0 (length host)))
|
|
385 (setq new-proxy-services (cons (cons (downcase proxy)
|
|
386 (format "http://%s:%s/" host
|
|
387 (or port "80")))
|
|
388 new-proxy-services))))
|
|
389 (setq url-proxy-services new-proxy-services)))
|
|
390
|
|
391 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
392 ;;;
|
|
393 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
394 (defun w3-preferences-create-panel (panel)
|
|
395 (let ((func (intern (format "w3-preferences-create-%s-panel" panel)))
|
|
396 (inhibit-read-only t))
|
|
397 (goto-char w3-preferences-panel-begin-marker)
|
|
398 (delete-region w3-preferences-panel-begin-marker
|
|
399 w3-preferences-panel-end-marker)
|
|
400 (set-marker-insertion-type w3-preferences-panel-end-marker t)
|
|
401 (if (fboundp func)
|
|
402 (funcall func)
|
|
403 (insert (format "You should be seeing %s right now.\n" panel))))
|
|
404 (set-marker-insertion-type w3-preferences-panel-end-marker nil)
|
|
405 (set-marker w3-preferences-panel-end-marker (point))
|
|
406 (goto-char w3-preferences-panel-begin-marker)
|
|
407 (condition-case ()
|
|
408 (widget-forward 1)
|
|
409 (error nil)))
|
|
410
|
|
411 (defun w3-preferences-notify (widget widget-ignore &optional event)
|
|
412 (let* ((glyph (and event w3-running-xemacs (event-glyph event)))
|
|
413 (x (and glyph (w3-glyphp glyph) (event-glyph-x-pixel event)))
|
|
414 (y (and glyph (w3-glyphp glyph) (event-glyph-y-pixel event)))
|
|
415 (map (widget-get widget 'usemap))
|
|
416 (value (widget-value widget)))
|
|
417 (if (and map x y)
|
|
418 (setq value (w3-point-in-map (vector x y) map)))
|
|
419 (if value
|
|
420 (w3-preferences-create-panel value))))
|
|
421
|
|
422 (defun w3-preferences-save-options ()
|
|
423 (w3-menu-save-options))
|
|
424
|
|
425 (defun w3-preferences-ok-callback (widget &rest ignore)
|
|
426 (let ((panels w3-preferences-panels)
|
|
427 (buffer (current-buffer))
|
|
428 (func nil))
|
|
429 (run-hooks 'w3-preferences-ok-hook)
|
|
430 (while panels
|
|
431 (setq func (intern
|
|
432 (format "w3-preferences-save-%s-panel" (caar panels)))
|
|
433 panels (cdr panels))
|
|
434 (if (fboundp func)
|
|
435 (funcall func)))
|
|
436 (w3-preferences-save-options)
|
|
437 (message "Options saved")
|
|
438 (sit-for 1)
|
|
439 (kill-buffer (current-buffer))))
|
|
440
|
|
441 (defun w3-preferences-reset-all-panels ()
|
|
442 (let ((panels w3-preferences-panels)
|
|
443 (func nil))
|
|
444 (while panels
|
|
445 (setq func (intern (format "w3-preferences-init-%s-panel"
|
|
446 (caar panels)))
|
|
447 panels (cdr panels))
|
|
448 (if (and func (fboundp func))
|
|
449 (funcall func)))))
|
|
450
|
|
451 (defun w3-preferences-cancel-callback (widget &rest ignore)
|
|
452 (if (not (funcall url-confirmation-func "Cancel and lose all changes? "))
|
|
453 (error "Not cancelled!"))
|
|
454 (w3-preferences-reset-all-panels)
|
|
455 (kill-buffer (current-buffer))
|
|
456 (run-hooks 'w3-preferences-cancel-hook))
|
|
457
|
|
458 (defun w3-preferences-reset-callback (widget &rest ignore)
|
|
459 (w3-preferences-reset-all-panels)
|
|
460 (run-hooks 'w3-preferences-default-hook)
|
|
461 (w3-preferences-create-panel (caar w3-preferences-panels)))
|
|
462
|
|
463 (defvar w3-preferences-setup-hook nil
|
|
464 "*Hooks to be run before setting up the preferences buffer.")
|
|
465
|
|
466 (defvar w3-preferences-cancel-hook nil
|
|
467 "*Hooks to be run when cancelling the preferences (Cancel was chosen).")
|
|
468
|
|
469 (defvar w3-preferences-default-hook nil
|
|
470 "*Hooks to be run when resetting preference defaults (Defaults was chosen).")
|
|
471
|
|
472 (defvar w3-preferences-ok-hook nil
|
|
473 "*Hooks to be run before saving the preferences (OK was chosen).")
|
|
474
|
|
475 (defun w3-preferences-init-all-panels ()
|
|
476 (let ((todo w3-preferences-panels)
|
|
477 (func nil))
|
|
478 (while todo
|
|
479 (setq func (intern (format "w3-preferences-init-%s-panel" (caar todo)))
|
|
480 todo (cdr todo))
|
|
481 (and (fboundp func) (funcall func)))))
|
|
482
|
|
483 (defun w3-preferences-edit ()
|
|
484 (interactive)
|
|
485 (if (not w3-preferences-map)
|
|
486 (setq w3-preferences-map (w3-preferences-setup-glyph-map)))
|
|
487 (let* ((prefs-buffer (get-buffer-create "W3 Preferences"))
|
|
488 (widget nil)
|
|
489 (inhibit-read-only t)
|
|
490 (window-conf (current-window-configuration)))
|
|
491 (delete-other-windows)
|
|
492 (set-buffer prefs-buffer)
|
|
493 (w3-preferences-init-all-panels)
|
|
494 (set-window-buffer (selected-window) prefs-buffer)
|
|
495 (make-local-variable 'widget-field-face)
|
|
496 (setq w3-preferences-panel-begin-marker (make-marker)
|
|
497 w3-preferences-panel-end-marker (make-marker))
|
|
498 (set-marker-insertion-type w3-preferences-panel-begin-marker nil)
|
|
499 (set-marker-insertion-type w3-preferences-panel-end-marker t)
|
|
500 (use-local-map widget-keymap)
|
|
501 (erase-buffer)
|
|
502 (run-hooks 'w3-preferences-setup-hook)
|
|
503 (setq widget (widget-create 'image
|
|
504 :notify 'w3-preferences-notify
|
|
505 :value 'appearance
|
|
506 :tag "Panel"
|
|
507 'usemap w3-preferences-map))
|
|
508 (goto-char (point-max))
|
|
509 (insert "\n\n")
|
|
510 (set-marker w3-preferences-panel-begin-marker (point))
|
|
511 (set-marker w3-preferences-panel-end-marker (point))
|
|
512 (w3-preferences-create-panel (caar w3-preferences-panels))
|
|
513 (goto-char (point-max))
|
|
514 (widget-insert "\n\n")
|
|
515 (widget-create 'push
|
|
516 :notify 'w3-preferences-ok-callback
|
|
517 :value "Ok")
|
|
518 (widget-insert " ")
|
|
519 (widget-create 'push
|
|
520 :notify 'w3-preferences-cancel-callback
|
|
521 :value "Cancel")
|
|
522 (widget-insert " ")
|
|
523 (widget-create 'push
|
|
524 :notify 'w3-preferences-reset-callback
|
|
525 :value "Reset")
|
|
526 (center-region (point-min) w3-preferences-panel-begin-marker)
|
|
527 (center-region w3-preferences-panel-end-marker (point-max))))
|
|
528
|
|
529 (provide 'w3-prefs)
|