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