2
|
1 ;;; w3-prefs.el --- Preferences panels for Emacs-W3
|
0
|
2 ;; Author: wmperry
|
44
|
3 ;; Created: 1997/03/21 15:52:22
|
|
4 ;; Version: 1.23
|
0
|
5 ;; Keywords: hypermedia, preferences
|
|
6
|
|
7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2
|
8 ;;; Copyright (c) 1996 by William M. Perry (wmperry@cs.indiana.edu)
|
16
|
9 ;;; Copyright (c) 1996, 1997 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-panel-begin-marker nil)
|
|
39 (defvar w3-preferences-panel-end-marker nil)
|
|
40 (defvar w3-preferences-panels '(
|
|
41 (appearance . "Appearance")
|
|
42 (images . "Images")
|
|
43 (cookies . "HTTP Cookies")
|
|
44 (hooks . "Various Hooks")
|
|
45 (compatibility . "Compatibility")
|
32
|
46 (proxy . "Proxy")
|
|
47 (privacy . "Privacy")))
|
0
|
48
|
|
49 (defun w3-preferences-generic-variable-callback (widget &rest ignore)
|
|
50 (condition-case ()
|
|
51 (set (widget-get widget 'variable) (widget-value widget))
|
|
52 (error (message "Invalid or incomplete data..."))))
|
|
53
|
|
54 (defun w3-preferences-restore-variables (vars)
|
|
55 (let ((temp nil))
|
|
56 (while vars
|
|
57 (setq temp (intern (format "w3-preferences-temp-%s" (car vars))))
|
|
58 (set (car vars) (symbol-value temp))
|
|
59 (setq vars (cdr vars)))))
|
|
60
|
|
61 (defun w3-preferences-create-temp-variables (vars)
|
|
62 (let ((temp nil))
|
|
63 (while vars
|
|
64 (setq temp (intern (format "w3-preferences-temp-%s" (car vars))))
|
|
65 (set (make-local-variable temp) (symbol-value (car vars)))
|
|
66 (setq vars (cdr vars)))))
|
|
67
|
|
68
|
|
69 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
70 ;;; Appearance of the frame / pages
|
|
71 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
72 (defun w3-preferences-init-appearance-panel ()
|
|
73 (let ((vars '(w3-toolbar-orientation
|
|
74 w3-use-menus
|
|
75 w3-honor-stylesheets
|
|
76 w3-default-stylesheet
|
|
77 w3-default-homepage
|
|
78 w3-toolbar-type))
|
|
79 (temp nil))
|
|
80 (set (make-local-variable 'w3-preferences-temp-use-home-page)
|
|
81 (and w3-default-homepage t))
|
|
82 (w3-preferences-create-temp-variables vars)))
|
|
83
|
|
84 (defun w3-preferences-create-appearance-panel ()
|
|
85 ;; First the toolbars
|
|
86 (widget-insert "\nToolbars\n--------\n")
|
|
87 (widget-insert "\tShow Toolbars as:\t")
|
|
88 (widget-put
|
|
89 (widget-create 'radio
|
|
90 :value (symbol-value 'w3-preferences-temp-w3-toolbar-type)
|
|
91 :notify 'w3-preferences-generic-variable-callback
|
14
|
92 :format "%v"
|
0
|
93 (list 'item :format "%t\t" :tag "Pictures" :value 'pictures)
|
|
94 (list 'item :format "%t\t" :tag "Text" :value 'text)
|
|
95 (list 'item :format "%t" :tag "Both" :value 'both))
|
|
96 'variable 'w3-preferences-temp-w3-toolbar-type)
|
|
97 (widget-insert "\n\tToolbars appear on ")
|
|
98 (widget-put
|
|
99 (widget-create 'choice
|
|
100 :value (symbol-value 'w3-preferences-temp-w3-toolbar-orientation)
|
|
101 :notify 'w3-preferences-generic-variable-callback
|
|
102 :format "%v"
|
|
103 :tag "Toolbar Position"
|
|
104 (list 'choice-item :format "%[%t%]" :tag "XEmacs Default" :value 'default)
|
|
105 (list 'choice-item :format "%[%t%]" :tag "Top" :value 'top)
|
|
106 (list 'choice-item :format "%[%t%]" :tag "Bottom" :value 'bottom)
|
|
107 (list 'choice-item :format "%[%t%]" :tag "Right" :value 'right)
|
|
108 (list 'choice-item :format "%[%t%]" :tag "Left" :value 'left)
|
|
109 (list 'choice-item :format "%[%t%]" :tag "No Toolbar" :value 'none))
|
|
110 'variable 'w3-preferences-temp-w3-toolbar-orientation)
|
|
111 (widget-insert " side of window.\n")
|
|
112
|
|
113 ;; Home page
|
|
114 (widget-insert "\nStartup\n--------\n\tBrowser starts with:\t")
|
|
115 (widget-put
|
|
116 (widget-create
|
|
117 'radio
|
14
|
118 :format "%v"
|
0
|
119 :value (symbol-value 'w3-preferences-temp-use-home-page)
|
|
120 :notify 'w3-preferences-generic-variable-callback
|
|
121 (list 'item :format "%t\t" :tag "Blank Page" :value nil)
|
|
122 (list 'item :format "%t" :tag "Home Page Location" :value t))
|
|
123 'variable 'w3-preferences-temp-use-home-page)
|
|
124 (widget-insert "\n\t\tURL: ")
|
|
125 (widget-put
|
|
126 (widget-create
|
14
|
127 'editable-field
|
0
|
128 :value (or (symbol-value 'w3-preferences-temp-w3-default-homepage) "None")
|
|
129 :notify 'w3-preferences-generic-variable-callback)
|
|
130 'variable 'w3-preferences-temp-w3-default-homepage)
|
|
131
|
|
132 ;; Stylesheet
|
|
133 (widget-insert "\nStyle\n--------\n\tDefault stylesheet:\t")
|
|
134 (widget-put
|
|
135 (widget-create
|
|
136 'file
|
|
137 :value (or (symbol-value 'w3-preferences-temp-w3-default-stylesheet) "")
|
|
138 :must-match t
|
|
139 :notify 'w3-preferences-generic-variable-callback)
|
|
140 'variable 'w3-preferences-temp-w3-default-stylesheet)
|
|
141 (widget-setup)
|
|
142 )
|
|
143
|
|
144 (defun w3-preferences-save-appearance-panel ()
|
|
145 (let ((vars '(w3-toolbar-orientation
|
|
146 w3-use-menus
|
|
147 w3-honor-stylesheets
|
|
148 w3-default-stylesheet
|
|
149 w3-toolbar-type))
|
|
150 (temp nil))
|
|
151 (if (symbol-value 'w3-preferences-temp-use-home-page)
|
|
152 (setq vars (cons 'w3-default-homepage vars))
|
|
153 (setq w3-default-homepage nil))
|
|
154 (w3-preferences-restore-variables vars)
|
|
155 (w3-toolbar-make-buttons)))
|
|
156
|
|
157
|
|
158 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
159 ;;; The images panel
|
|
160 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
161 (defun w3-preferences-init-images-panel ()
|
|
162 (let ((vars '(w3-delay-image-loads
|
|
163 w3-image-mappings)))
|
|
164 (w3-preferences-create-temp-variables vars)))
|
|
165
|
|
166 (defun w3-preferences-create-images-panel ()
|
|
167 (widget-insert "\n")
|
|
168 (widget-put
|
|
169 (widget-create
|
|
170 'checkbox
|
|
171 :notify 'w3-preferences-generic-variable-callback
|
|
172 :value (symbol-value 'w3-preferences-temp-w3-delay-image-loads))
|
|
173 'variable 'w3-preferences-temp-w3-delay-image-loads)
|
|
174 (widget-insert " Delay Image Loads\n"
|
|
175 ))
|
|
176
|
|
177 (defun w3-preferences-save-images-panel ()
|
|
178 (let ((vars '(w3-delay-image-loads
|
|
179 w3-image-mappings)))
|
|
180 (w3-preferences-restore-variables vars)))
|
|
181
|
|
182 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
183 ;;; The cookies panel
|
|
184 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
185 (defun w3-preferences-init-cookies-panel ()
|
|
186 (let ((cookies url-cookie-storage)
|
|
187 (secure-cookies url-cookie-secure-storage))
|
|
188 )
|
|
189 )
|
|
190
|
|
191 (defun w3-preferences-create-cookies-panel ()
|
|
192 (widget-insert "\n\t\tSorry, not yet implemented.\n\n"))
|
|
193
|
|
194 (defun w3-preferences-save-cookies-panel ()
|
|
195 )
|
|
196
|
|
197
|
|
198 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
199 ;;; The hooks panel
|
|
200 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
201 (defvar w3-preferences-hooks-variables
|
30
|
202 '(w3-load-hook
|
0
|
203 w3-mode-hook
|
|
204 w3-preferences-cancel-hook
|
|
205 w3-preferences-default-hook
|
|
206 w3-preferences-ok-hook
|
|
207 w3-preferences-setup-hook
|
|
208 w3-source-file-hook))
|
|
209
|
|
210 (defun w3-preferences-init-hooks-panel ()
|
|
211 (w3-preferences-create-temp-variables w3-preferences-hooks-variables))
|
|
212
|
|
213 (defun w3-preferences-create-hooks-panel ()
|
|
214 (let ((todo w3-preferences-hooks-variables)
|
|
215 (cur nil)
|
|
216 (pt nil)
|
|
217 (doc nil))
|
|
218 (widget-insert "\n")
|
|
219 (while todo
|
|
220 (setq cur (car todo)
|
|
221 todo (cdr todo)
|
36
|
222 doc (documentation-property cur 'variable-documentation))
|
0
|
223 (if (string-match "^\\*" doc)
|
|
224 (setq doc (substring doc 1 nil)))
|
|
225 (setq pt (point))
|
|
226 (widget-insert "\n" (symbol-name cur) " - " doc)
|
|
227 (fill-region-as-paragraph pt (point))
|
|
228 (setq cur (intern (format "w3-preferences-temp-%s" cur)))
|
|
229 (widget-put
|
|
230 (widget-create
|
|
231 'sexp
|
|
232 :notify 'w3-preferences-generic-variable-callback
|
|
233 :value (or (symbol-value cur) "nil"))
|
|
234 'variable cur))
|
|
235 (widget-setup)))
|
|
236
|
|
237 (defun w3-preferences-save-hooks-panel ()
|
|
238 (w3-preferences-restore-variables w3-preferences-hooks-variables))
|
|
239
|
|
240
|
|
241 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
242 ;;; The compatibility panel
|
|
243 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
244 (defvar w3-preferences-compatibility-variables
|
|
245 '(
|
|
246 (w3-netscape-compatible-comments
|
|
247 . "Allow Netscape compatible comments")
|
|
248 (w3-user-colors-take-precedence
|
|
249 . "Ignore netscape document color control")
|
|
250 (url-honor-refresh-requests
|
|
251 . "Allow Netscape `Client Pull'"))
|
|
252 "A list of variables that the preferences compability pane knows about.")
|
|
253
|
|
254 (defun w3-preferences-init-compatibility-panel ()
|
|
255 (let ((compat w3-preferences-compatibility-variables)
|
|
256 (cur nil)
|
|
257 (var nil))
|
|
258 (w3-preferences-create-temp-variables
|
|
259 (mapcar 'car w3-preferences-compatibility-variables))))
|
|
260
|
|
261 (defun w3-preferences-create-compatibility-panel ()
|
|
262 (let ((compat w3-preferences-compatibility-variables)
|
|
263 (cur nil)
|
|
264 (var nil))
|
|
265 (widget-insert "\n")
|
|
266 (while compat
|
|
267 (setq cur (car compat)
|
|
268 compat (cdr compat)
|
|
269 var (intern (format "w3-preferences-temp-%s" (car cur))))
|
|
270 (widget-put
|
|
271 (widget-create 'checkbox
|
|
272 :notify 'w3-preferences-generic-variable-callback
|
|
273 :value (symbol-value var))
|
|
274 'variable var)
|
|
275 (widget-insert " " (cdr cur) "\n\n"))
|
|
276 (widget-setup)))
|
|
277
|
|
278 (defun w3-preferences-save-compatibility-panel ()
|
|
279 (w3-preferences-restore-variables
|
|
280 (mapcar 'car w3-preferences-compatibility-variables)))
|
|
281
|
|
282
|
|
283 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
284 ;;; The proxy configuration panel
|
|
285 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
286 (defun w3-preferences-init-proxy-panel ()
|
|
287 (let ((proxies '("FTP" "Gopher" "HTTP" "Security" "WAIS" "SHTTP" "News"))
|
|
288 (proxy nil)
|
|
289 (host-var nil)
|
|
290 (port-var nil)
|
32
|
291 (host nil)
|
|
292 (port nil)
|
|
293 (proxy-entry nil))
|
0
|
294 (widget-insert "\n")
|
|
295 (while proxies
|
|
296 (setq proxy (car proxies)
|
|
297 proxies (cdr proxies)
|
|
298 host-var (intern (format "w3-%s-proxy-host" (downcase proxy)))
|
|
299 port-var (intern (format "w3-%s-proxy-port" (downcase proxy)))
|
32
|
300 proxy-entry (cdr-safe (assoc (downcase proxy) url-proxy-services)))
|
|
301 (if (and proxy-entry (string-match "\\(.*\\):\\([0-9]+\\)" proxy-entry))
|
|
302 (setq host (match-string 1 proxy-entry)
|
|
303 port (match-string 2 proxy-entry))
|
|
304 (setq host proxy-entry
|
|
305 port nil))
|
|
306 (set (make-local-variable host-var) (or host ""))
|
44
|
307 (set (make-local-variable port-var) (or port ""))))
|
|
308 (set (make-local-variable 'w3-preferences-temp-no-proxy)
|
|
309 (cdr-safe (assoc "no_proxy" url-proxy-services))))
|
0
|
310
|
|
311 (defun w3-preferences-create-proxy-panel ()
|
|
312 (let ((proxies '("FTP" "Gopher" "HTTP" "Security" "WAIS" "SHTTP" "News"))
|
|
313 (proxy nil)
|
|
314 (host-var nil)
|
|
315 (port-var nil)
|
|
316 (urlobj nil))
|
|
317 (widget-insert "\n")
|
|
318 (while proxies
|
|
319 (setq proxy (car proxies)
|
|
320 proxies (cdr proxies)
|
|
321 host-var (intern (format "w3-%s-proxy-host" (downcase proxy)))
|
|
322 port-var (intern (format "w3-%s-proxy-port" (downcase proxy))))
|
|
323 (widget-insert (format "%10s Proxy: " proxy))
|
|
324 (widget-put
|
14
|
325 (widget-create 'editable-field
|
0
|
326 :size 20
|
|
327 :value-face 'underline
|
|
328 :notify 'w3-preferences-generic-variable-callback
|
|
329 :value (format "%-20s" (symbol-value host-var)))
|
|
330 'variable host-var)
|
|
331 (widget-insert " Port: ")
|
|
332 (widget-put
|
14
|
333 (widget-create 'editable-field
|
0
|
334 :size 5
|
|
335 :value-face 'underline
|
|
336 :notify 'w3-preferences-generic-variable-callback
|
|
337 :value (format "%5s" (symbol-value port-var)))
|
|
338 'variable port-var)
|
|
339 (widget-insert "\n\n"))
|
44
|
340 (widget-insert " No proxy: ")
|
|
341 (widget-put
|
|
342 (widget-create 'editable-field
|
|
343 :size 40
|
|
344 :value-face 'underline
|
|
345 :notify 'w3-preferences-generic-variable-callback
|
|
346 :value (or (symbol-value 'w3-preferences-temp-no-proxy) ""))
|
|
347 'variable 'w3-preferences-temp-no-proxy)
|
0
|
348 (widget-setup)))
|
|
349
|
|
350 (defun w3-preferences-save-proxy-panel ()
|
|
351 (let ((proxies '("FTP" "Gopher" "HTTP" "Security" "WAIS" "SHTTP" "News"))
|
|
352 (proxy nil)
|
|
353 (host-var nil)
|
|
354 (port-var nil)
|
|
355 (urlobj nil)
|
|
356 (host nil)
|
|
357 (port nil)
|
|
358 (new-proxy-services nil))
|
44
|
359 (if (/= 0 (length (symbol-value 'w3-preferences-temp-no-proxy)))
|
|
360 (setq new-proxy-services (cons
|
|
361 (cons
|
|
362 "no_proxy"
|
|
363 (symbol-value 'w3-preferences-temp-no-proxy))
|
|
364 new-proxy-services)))
|
0
|
365 (while proxies
|
|
366 (setq proxy (car proxies)
|
|
367 proxies (cdr proxies)
|
|
368 host-var (intern (format "w3-%s-proxy-host" (downcase proxy)))
|
|
369 port-var (intern (format "w3-%s-proxy-port" (downcase proxy)))
|
|
370 urlobj (url-generic-parse-url
|
|
371 (cdr-safe
|
|
372 (assoc (downcase proxy) url-proxy-services)))
|
|
373 host (symbol-value host-var)
|
|
374 port (symbol-value port-var))
|
|
375 (if (and host (/= 0 (length host)))
|
|
376 (setq new-proxy-services (cons (cons (downcase proxy)
|
32
|
377 (format "%s:%s" host
|
0
|
378 (or port "80")))
|
|
379 new-proxy-services))))
|
|
380 (setq url-proxy-services new-proxy-services)))
|
|
381
|
|
382 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
32
|
383 ;;; Privacy panel
|
|
384 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
385
|
|
386 (defsubst w3-preferences-privacy-bits-sort (bits)
|
|
387 (sort bits (function (lambda (a b)
|
|
388 (memq b (memq a '(email os lastloc agent cookie)))))))
|
|
389
|
|
390 (defvar url-valid-privacy-levels
|
|
391 '((paranoid . (email os lastloc agent cookie))
|
|
392 (high . (email lastloc))
|
|
393 (low . (lastloc))
|
|
394 (none . nil)))
|
|
395
|
|
396 (defvar w3-preferences-privacy-bit-widgets nil)
|
|
397 (defvar w3-preferences-privacy-level-widget nil)
|
|
398 (defvar w3-preferences-temp-url-privacy-level nil)
|
|
399 ;; darnit i just noticed the checklist widget, this should probably be
|
|
400 ;; reimplemented with that instead of checkboxes, but i've almost finished.
|
|
401 (defun w3-preferences-privacy-bit-callback (widget &rest ignore)
|
|
402 (let ((privacy-bits (if (listp w3-preferences-temp-url-privacy-level)
|
|
403 w3-preferences-temp-url-privacy-level
|
|
404 (copy-list (cdr-safe (assq w3-preferences-temp-url-privacy-level url-valid-privacy-levels)))))
|
|
405 (bit (widget-get widget 'bit))
|
|
406 (val (widget-value widget)))
|
|
407 (if val
|
|
408 (setq privacy-bits (delq bit privacy-bits))
|
|
409 (setq privacy-bits (w3-preferences-privacy-bits-sort (cons bit (delq bit privacy-bits)))))
|
|
410 (setq w3-preferences-temp-url-privacy-level
|
|
411 (or (car (rassoc privacy-bits url-valid-privacy-levels))
|
|
412 privacy-bits))
|
|
413 (widget-value-set w3-preferences-privacy-level-widget
|
|
414 (if (listp w3-preferences-temp-url-privacy-level)
|
|
415 'custom
|
|
416 w3-preferences-temp-url-privacy-level))
|
|
417 ))
|
|
418
|
|
419
|
|
420 (defun w3-preferences-privacy-level-callback (widget &rest ignore)
|
|
421 (let* ((val (widget-value widget))
|
|
422 (privacy-bits (cdr-safe (assq val url-valid-privacy-levels))))
|
|
423 (if (eq val 'custom) nil
|
|
424 (setq w3-preferences-temp-url-privacy-level val)
|
|
425 (mapcar (function (lambda (bit)
|
|
426 (widget-value-set (cdr bit)
|
|
427 (not (memq (car bit)
|
|
428 privacy-bits)))))
|
|
429 w3-preferences-privacy-bit-widgets))
|
|
430 ))
|
|
431
|
|
432 (defun w3-preferences-init-privacy-panel ()
|
|
433 (w3-preferences-create-temp-variables '(url-privacy-level
|
|
434 url-cookie-confirmation))
|
|
435 (setq w3-preferences-privacy-bit-widgets nil)
|
|
436 (setq w3-preferences-privacy-level-widget nil))
|
|
437
|
|
438 (defsubst w3-preferences-create-privacy-bit-widget (bit bit-text current-bits)
|
|
439 (let ((bit-widget (widget-create
|
|
440 'checkbox
|
|
441 :value (not (memq bit current-bits))
|
|
442 :notify 'w3-preferences-privacy-bit-callback
|
|
443 )))
|
|
444 (widget-put bit-widget 'bit bit)
|
|
445 (setq w3-preferences-privacy-bit-widgets (cons (cons bit bit-widget)
|
|
446 w3-preferences-privacy-bit-widgets))
|
|
447 (widget-insert " " bit-text "\n")))
|
|
448
|
|
449
|
|
450 (defun w3-preferences-create-privacy-panel ()
|
|
451 (let ((privacy-bits (if (listp url-privacy-level)
|
|
452 url-privacy-level
|
|
453 (cdr-safe (assq url-privacy-level url-valid-privacy-levels)))))
|
|
454 (widget-insert "\n")
|
|
455 (widget-insert "General Privacy Level: ")
|
|
456 ;;; XXX something is weird with case folding in the following widget if you
|
|
457 ;;; type an option in lower case it accepts it but doesn't do anything
|
|
458 (setq w3-preferences-privacy-level-widget
|
|
459 (widget-create
|
|
460 'choice
|
|
461 :value (if (listp w3-preferences-temp-url-privacy-level)
|
|
462 'custom
|
|
463 w3-preferences-temp-url-privacy-level)
|
|
464 :notify 'w3-preferences-privacy-level-callback
|
|
465 :format "%v"
|
|
466 :tag "Privacy Level"
|
|
467 (list 'choice-item :format "%[%t%]" :tag "Paranoid" :value 'paranoid)
|
|
468 (list 'choice-item :format "%[%t%]" :tag "High" :value 'high)
|
|
469 (list 'choice-item :format "%[%t%]" :tag "Low" :value 'low)
|
|
470 (list 'choice-item :format "%[%t%]" :tag "None" :value 'none)
|
|
471 (list 'choice-item :format "%[%t%]" :tag "Custom" :value 'custom)))
|
|
472 (widget-put w3-preferences-privacy-level-widget 'variable 'w3-preferences-temp-url-privacy-level)
|
|
473
|
|
474 (widget-insert "\n(controls the options below)\n\nSend the following information with each request:\n")
|
|
475 (setq w3-preferences-privacy-bit-widgets nil)
|
|
476 (w3-preferences-create-privacy-bit-widget 'email "E-mail address" privacy-bits)
|
|
477 (w3-preferences-create-privacy-bit-widget 'lastloc "Last location visited" privacy-bits)
|
|
478 (w3-preferences-create-privacy-bit-widget 'os "Operating system information" privacy-bits)
|
|
479 (w3-preferences-create-privacy-bit-widget 'agent "User agent information" privacy-bits)
|
|
480 (w3-preferences-create-privacy-bit-widget 'cookie "Accept cookies" privacy-bits)
|
|
481 (widget-insert " ")
|
|
482 (widget-put
|
|
483 (widget-create
|
|
484 'checkbox
|
|
485 :value (symbol-value 'w3-preferences-temp-url-cookie-confirmation)
|
|
486 :notify 'w3-preferences-generic-variable-callback)
|
|
487 'variable 'w3-preferences-temp-url-cookie-confirmation)
|
|
488 (widget-insert " Ask before accepting cookies\n"))
|
|
489 (widget-setup))
|
|
490
|
|
491 (defun w3-preferences-save-privacy-panel ()
|
|
492 (w3-preferences-restore-variables '(url-privacy-level
|
|
493 url-cookie-confirmation))
|
|
494 (url-setup-privacy-info))
|
|
495
|
|
496 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
0
|
497 ;;;
|
|
498 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
499 (defun w3-preferences-create-panel (panel)
|
|
500 (let ((func (intern (format "w3-preferences-create-%s-panel" panel)))
|
|
501 (inhibit-read-only t))
|
|
502 (goto-char w3-preferences-panel-begin-marker)
|
|
503 (delete-region w3-preferences-panel-begin-marker
|
|
504 w3-preferences-panel-end-marker)
|
|
505 (set-marker-insertion-type w3-preferences-panel-end-marker t)
|
|
506 (if (fboundp func)
|
|
507 (funcall func)
|
|
508 (insert (format "You should be seeing %s right now.\n" panel))))
|
|
509 (set-marker-insertion-type w3-preferences-panel-end-marker nil)
|
|
510 (set-marker w3-preferences-panel-end-marker (point))
|
|
511 (goto-char w3-preferences-panel-begin-marker)
|
|
512 (condition-case ()
|
|
513 (widget-forward 1)
|
|
514 (error nil)))
|
|
515
|
|
516 (defun w3-preferences-notify (widget widget-ignore &optional event)
|
|
517 (let* ((glyph (and event w3-running-xemacs (event-glyph event)))
|
14
|
518 (x (and glyph (widget-glyphp glyph) (event-glyph-x-pixel event)))
|
|
519 (y (and glyph (widget-glyphp glyph) (event-glyph-y-pixel event)))
|
0
|
520 (map (widget-get widget 'usemap))
|
|
521 (value (widget-value widget)))
|
|
522 (if (and map x y)
|
|
523 (setq value (w3-point-in-map (vector x y) map)))
|
|
524 (if value
|
|
525 (w3-preferences-create-panel value))))
|
|
526
|
|
527 (defun w3-preferences-save-options ()
|
|
528 (w3-menu-save-options))
|
|
529
|
|
530 (defun w3-preferences-ok-callback (widget &rest ignore)
|
|
531 (let ((panels w3-preferences-panels)
|
|
532 (buffer (current-buffer))
|
|
533 (func nil))
|
|
534 (run-hooks 'w3-preferences-ok-hook)
|
|
535 (while panels
|
|
536 (setq func (intern
|
|
537 (format "w3-preferences-save-%s-panel" (caar panels)))
|
|
538 panels (cdr panels))
|
|
539 (if (fboundp func)
|
|
540 (funcall func)))
|
|
541 (w3-preferences-save-options)
|
|
542 (message "Options saved")
|
|
543 (sit-for 1)
|
|
544 (kill-buffer (current-buffer))))
|
|
545
|
|
546 (defun w3-preferences-reset-all-panels ()
|
|
547 (let ((panels w3-preferences-panels)
|
|
548 (func nil))
|
|
549 (while panels
|
|
550 (setq func (intern (format "w3-preferences-init-%s-panel"
|
|
551 (caar panels)))
|
|
552 panels (cdr panels))
|
|
553 (if (and func (fboundp func))
|
|
554 (funcall func)))))
|
|
555
|
|
556 (defun w3-preferences-cancel-callback (widget &rest ignore)
|
|
557 (if (not (funcall url-confirmation-func "Cancel and lose all changes? "))
|
|
558 (error "Not cancelled!"))
|
|
559 (w3-preferences-reset-all-panels)
|
|
560 (kill-buffer (current-buffer))
|
|
561 (run-hooks 'w3-preferences-cancel-hook))
|
|
562
|
|
563 (defun w3-preferences-reset-callback (widget &rest ignore)
|
|
564 (w3-preferences-reset-all-panels)
|
|
565 (run-hooks 'w3-preferences-default-hook)
|
|
566 (w3-preferences-create-panel (caar w3-preferences-panels)))
|
|
567
|
|
568 (defvar w3-preferences-setup-hook nil
|
|
569 "*Hooks to be run before setting up the preferences buffer.")
|
|
570
|
|
571 (defvar w3-preferences-cancel-hook nil
|
|
572 "*Hooks to be run when cancelling the preferences (Cancel was chosen).")
|
|
573
|
|
574 (defvar w3-preferences-default-hook nil
|
|
575 "*Hooks to be run when resetting preference defaults (Defaults was chosen).")
|
|
576
|
|
577 (defvar w3-preferences-ok-hook nil
|
|
578 "*Hooks to be run before saving the preferences (OK was chosen).")
|
|
579
|
|
580 (defun w3-preferences-init-all-panels ()
|
|
581 (let ((todo w3-preferences-panels)
|
|
582 (func nil))
|
|
583 (while todo
|
|
584 (setq func (intern (format "w3-preferences-init-%s-panel" (caar todo)))
|
|
585 todo (cdr todo))
|
|
586 (and (fboundp func) (funcall func)))))
|
|
587
|
16
|
588 ;;###autoload
|
0
|
589 (defun w3-preferences-edit ()
|
|
590 (interactive)
|
|
591 (let* ((prefs-buffer (get-buffer-create "W3 Preferences"))
|
|
592 (widget nil)
|
|
593 (inhibit-read-only t)
|
|
594 (window-conf (current-window-configuration)))
|
|
595 (delete-other-windows)
|
|
596 (set-buffer prefs-buffer)
|
32
|
597 (set (make-local-variable 'widget-push-button-gui) nil)
|
0
|
598 (w3-preferences-init-all-panels)
|
|
599 (set-window-buffer (selected-window) prefs-buffer)
|
|
600 (make-local-variable 'widget-field-face)
|
|
601 (setq w3-preferences-panel-begin-marker (make-marker)
|
|
602 w3-preferences-panel-end-marker (make-marker))
|
|
603 (set-marker-insertion-type w3-preferences-panel-begin-marker nil)
|
|
604 (set-marker-insertion-type w3-preferences-panel-end-marker t)
|
|
605 (use-local-map widget-keymap)
|
|
606 (erase-buffer)
|
|
607 (run-hooks 'w3-preferences-setup-hook)
|
30
|
608 (setq widget (apply 'widget-create 'menu-choice
|
|
609 :tag "Panel"
|
|
610 :notify 'w3-preferences-notify
|
|
611 :value 'appearance
|
|
612 (mapcar
|
|
613 (function
|
|
614 (lambda (x)
|
|
615 (list 'choice-item
|
|
616 :format "%[%t%]"
|
|
617 :tag (cdr x)
|
|
618 :value (car x))))
|
|
619 w3-preferences-panels)))
|
0
|
620 (goto-char (point-max))
|
|
621 (insert "\n\n")
|
|
622 (set-marker w3-preferences-panel-begin-marker (point))
|
|
623 (set-marker w3-preferences-panel-end-marker (point))
|
|
624 (w3-preferences-create-panel (caar w3-preferences-panels))
|
|
625 (goto-char (point-max))
|
|
626 (widget-insert "\n\n")
|
14
|
627 (widget-create 'push-button
|
0
|
628 :notify 'w3-preferences-ok-callback
|
|
629 :value "Ok")
|
|
630 (widget-insert " ")
|
14
|
631 (widget-create 'push-button
|
0
|
632 :notify 'w3-preferences-cancel-callback
|
|
633 :value "Cancel")
|
|
634 (widget-insert " ")
|
14
|
635 (widget-create 'push-button
|
0
|
636 :notify 'w3-preferences-reset-callback
|
|
637 :value "Reset")
|
|
638 (center-region (point-min) w3-preferences-panel-begin-marker)
|
|
639 (center-region w3-preferences-panel-end-marker (point-max))))
|
|
640
|
|
641 (provide 'w3-prefs)
|