blob: 0b981253f06f807dc6e647585e7b9acb069caa71 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
|
# RCS: @(#) $Id: firefox.tcl,v 1.20 2006/12/07 03:53:05 treectrl Exp $
proc DemoFirefoxPrivacy {} {
global FirefoxPrivacy
set T [DemoList]
#
# Configure the treectrl widget
#
$T configure -showroot no -showbuttons yes -showlines no \
-selectmode extended -xscrollincrement 20 -showheader yes
if {$::clip} {
$T configure -xscrollincrement 4 -yscrollincrement 4
} else {
# Hide the borders because child windows appear on top of them
$T configure -borderwidth 0 -highlightthickness 0
}
#
# Create columns
#
# Create 2 new images for the button sort arrow
if {[lsearch -exact [image names] arrow-up] == -1} {
set color #ACA899 ; # WinXP arrow color
set img arrow-down
image create photo $img
$img put [list [string repeat "$color " 9]] -to 0 0
$img put [list [string repeat "$color " 7]] -to 1 1
$img put [list [string repeat "$color " 5]] -to 2 2
$img put [list [string repeat "$color " 3]] -to 3 3
$img put [list [string repeat "$color " 1]] -to 4 4
set img arrow-up
image create photo $img
$img put [list [string repeat "$color " 1]] -to 4 0
$img put [list [string repeat "$color " 3]] -to 3 1
$img put [list [string repeat "$color " 5]] -to 2 2
$img put [list [string repeat "$color " 7]] -to 1 3
$img put [list [string repeat "$color " 9]] -to 0 4
}
$T column create -expand yes -arrowimage {arrow-down !up arrow-up {}} \
-arrow up -arrowpadx {10 2} -textlines 0 -tags C0 \
-text "This is a multi-line column title\nwith an image for the arrow"
$T configure -treecolumn C0
# This binding toggles the sort arrow
$T notify bind $T <Header-invoke> {
if {[%T column cget %C -arrow] eq "up"} {
%T column configure %C -arrow down
} else {
%T column configure %C -arrow up
}
}
#
# Create elements
#
$T element create eWindow window
if {$::clip} { $T element configure eWindow -clip yes }
$T element create eText1 text -font [list DemoFontBold]
$T element create eRectTop rect -outline black -fill #FFFFCC \
-outlinewidth 1 -open s
$T element create eRectBottom rect -outline black -fill #FFFFCC \
-outlinewidth 1 -open n
# Destroy the window when the element is deleted. Could also bind to the
# <ItemDelete> event.
$T element configure eWindow -destroy yes
#
# Create styles using the elements
#
set S [$T style create styCategory -orient horizontal]
$T style elements $S {eRectTop eText1 eWindow}
$T style layout $S eRectTop -detach yes -indent no -iexpand xy -draw {yes open no {}}
# note: using -iexpand x so clicking in the text works better
$T style layout $S eText1 -expand ns -iexpand x -sticky w
$T style layout $S eWindow -expand ns -padx 10 -pady 6
set S [$T style create styFrame -orient horizontal]
$T style elements $S {eRectBottom eWindow}
$T style layout $S eRectBottom -detach yes -indent no -iexpand xy
$T style layout $S eWindow -iexpand x -squeeze x -padx {0 2} -pady {0 8}
#
# Create items and assign styles
#
foreach category {
"History"
"Saved Form Information"
"Saved Passwords"
"Download Manager History"
"Cookies"
"Cache"} {
set I [$T item create -button yes]
$T item style set $I C0 styCategory
$T item element configure $I C0 eText1 -text $category
if {$::clip} {
set wClip [frame $T.clip$I -background red]
set b [$::buttonCmd $wClip.b$I -text "Clear" -command "" -width 11]
$T item element configure $I C0 eWindow -window $wClip
} else {
set b [$::buttonCmd $T.b$I -text "Clear" -command "" -width 11]
$T item element configure $I C0 eWindow -window $b
}
$T item lastchild root $I
}
set bg #FFFFCC
set textBg $bg
if {$::tile} {
ttk::style configure DemoCheckbutton -background $bg
ttk::style layout DemoCheckbutton [ttk::style layout TCheckbutton]
}
# History
set I [$T item create]
$T item style set $I C0 styFrame
if {$::clip} {
set wClip [frame $T.clip$I -background red]
set f [frame $wClip.f$I -borderwidth 0 -background $bg]
} else {
set f [frame $T.f$I -borderwidth 0 -background $bg]
}
label $f.l1 -background $bg -text "Remember visited pages for the last"
$::entryCmd $f.e1 -width 6
$f.e1 insert end 20
label $f.l2 -background $bg -text "days" -background $bg
pack $f.l1 -side left
pack $f.e1 -side left -padx 8
pack $f.l2 -side left
if {$::clip} {
$T item element configure $I C0 eWindow -window $wClip
} else {
$T item element configure $I C0 eWindow -window $f
}
$T item lastchild "root child 0" $I
# Saved Form Information
set I [$T item create]
$T item style set $I C0 styFrame
if {$::clip} {
set wClip [frame $T.clip$I -background red]
set f [frame $wClip.f$I -borderwidth 0 -background $bg]
} else {
set f [frame $T.f$I -borderwidth 0 -background $bg]
}
text $f.t1 -background $textBg -borderwidth 0 -highlightthickness 0 \
-width 10 -height 1 -wrap word -cursor ""
$f.t1 insert end "Information entered in web page forms and the Search\
Bar is saved to make filling out forms and searching faster."
bindtags $f.t1 TextWrapBindTag
if {$::tile} {
$::checkbuttonCmd $f.cb1 -text "Save information I enter in web page forms and the Search Bar" \
-variable ::cbvar($f.cb1) -style DemoCheckbutton
} else {
checkbutton $f.cb1 -background $bg -highlightthickness 0 -text "Save\
information I enter in web page forms and the Search Bar" \
-variable ::cbvar($f.cb1)
}
set ::cbvar($f.cb1) 1
pack $f.t1 -side top -anchor w -fill x -padx {0 8} -pady {0 4}
pack $f.cb1 -side top -anchor w
if {$::clip} {
$T item element configure $I C0 eWindow -window $wClip
} else {
$T item element configure $I C0 eWindow -window $f
}
$T item lastchild "root child 1" $I
# Saved Passwords
set I [$T item create]
$T item style set $I C0 styFrame
if {$::clip} {
set wClip [frame $T.clip$I -background red]
set f [frame $wClip.f$I -borderwidth 0 -background $bg]
} else {
set f [frame $T.f$I -borderwidth 0 -background $bg]
}
set fLeft [frame $f.fLeft -borderwidth 0 -background $bg]
text $fLeft.t1 -background $textBg -borderwidth 0 -highlightthickness 0 \
-width 10 -height 1 -wrap word -cursor ""
$fLeft.t1 insert end "Login information for web pages can be kept in the\
Password Manager so that you do not need to re-enter your login\
details every time you visit."
bindtags $fLeft.t1 TextWrapBindTag
if {$::tile} {
$::checkbuttonCmd $fLeft.cb1 -text "Remember Passwords" \
-variable ::cbvar($fLeft.cb1) -style DemoCheckbutton
} else {
checkbutton $fLeft.cb1 -background $bg -highlightthickness 0 \
-text "Remember Passwords" -variable ::cbvar($fLeft.cb1)
}
set ::cbvar($fLeft.cb1) 1
pack $fLeft.t1 -side top -expand yes -fill x -pady {0 6}
pack $fLeft.cb1 -side top -anchor w
set fRight [frame $f.fRight -borderwidth 0 -background $bg]
$::buttonCmd $fRight.b1 -text "View Saved Passwords"
$::buttonCmd $fRight.b2 -text "Change Master Password..."
pack $fRight.b1 -side top -expand yes -fill x
pack $fRight.b2 -side top -expand yes -fill x -pady {8 0}
pack $fLeft -side left -expand yes -fill x
pack $fRight -side right -padx 12 -anchor n
if {$::clip} {
$T item element configure $I C0 eWindow -window $wClip
} else {
$T item element configure $I C0 eWindow -window $f
}
$T item lastchild "root child 2" $I
# Download Manager History
set I [$T item create]
$T item style set $I C0 styFrame
if {$::clip} {
set wClip [frame $T.clip$I -background red]
set f [frame $wClip.f$I -borderwidth 0 -background $bg]
} else {
set f [frame $T.f$I -borderwidth 0 -background $bg]
}
text $f.t1 -background $textBg -borderwidth 0 -highlightthickness 0 \
-width 10 -height 1 -wrap word -cursor ""
$f.t1 insert end "The Download Manager keeps track of recently downloaded files."
bindtags $f.t1 TextWrapBindTag
set f1 [frame $f.f1 -borderwidth 0 -background $bg]
label $f1.l1 -background $bg -text "Remove files from the Download Manager:"
if {$::tile} {
ttk::combobox $f1.mb1 -values {
"Upon successful download"
"When firefox exits"
Manually
} -state readonly -width [string length "Upon successful download"]
$f1.mb1 current 2
} else {
menubutton $f1.mb1 -indicatoron yes -menu $f1.mb1.m -text Manually \
-width [string length "Upon successful download"] -justify left
set m [menu $f1.mb1.m -tearoff no]
foreach label {
"Upon successful download"
"When firefox exits"
Manually} {
$m add command -label $label -command [list $f1.mb1 configure\
-text $label]
}
}
pack $f1.l1 -side left
pack $f1.mb1 -side left -padx {8 10}
pack $f.t1 -side top -expand yes -fill x -padx {0 10}
pack $f1 -side top -anchor w
if {$::clip} {
$T item element configure $I C0 eWindow -window $wClip
} else {
$T item element configure $I C0 eWindow -window $f
}
$T item lastchild "root child 3" $I
# Cookies
set I [$T item create]
$T item style set $I C0 styFrame
if {$::clip} {
set wClip [frame $T.clip$I -background red]
set f [frame $wClip.f$I -borderwidth 0 -background $bg]
} else {
set f [frame $T.f$I -borderwidth 0 -background $bg]
}
text $f.t1 -background $textBg -borderwidth 0 -highlightthickness 0 \
-width 10 -height 1 -wrap word -cursor ""
$f.t1 insert end "Cookies are pieces of information stored by web pages\
on your computer. They are used to remember login information and\
other data."
bindtags $f.t1 TextWrapBindTag
set fLeft [frame $f.fLeft -borderwidth 0 -background $bg]
if {$::tile} {
$::checkbuttonCmd $fLeft.cb1 -style DemoCheckbutton \
-text "Allow sites to set cookies" -variable ::cbvar($fLeft.cb1)
} else {
checkbutton $fLeft.cb1 -background $bg -highlightthickness 0 \
-text "Allow sites to set cookies" -variable ::cbvar($fLeft.cb1)
}
set ::cbvar($fLeft.cb1) 1
if {$::tile} {
$::checkbuttonCmd $fLeft.cb2 -style DemoCheckbutton \
-text "for the originating web site only" \
-variable ::cbar($fLeft.cb2)
} else {
checkbutton $fLeft.cb2 -background $bg -highlightthickness 0 \
-text "for the originating web site only" \
-variable ::cbar($fLeft.cb2)
}
set ::cbar($fLeft.cb2) 0
pack $fLeft.cb1 -side top -anchor w
pack $fLeft.cb2 -side top -anchor w -padx {20 0}
set fRight [frame $f.fRight -borderwidth 0 -background $bg]
$::buttonCmd $fRight.b1 -text "Exceptions"
$::buttonCmd $fRight.b2 -text "View Cookies"
pack $fRight.b1 -side left -padx {0 10}
pack $fRight.b2 -side left
set f1 [frame $fLeft.f1 -borderwidth 0 -background $bg]
label $f1.l1 -background $bg -text "Keep Cookies:"
if {$::tile} {
ttk::combobox $f1.mb1 -values {
"until they expire"
"until I close Firefox"
"ask me every time"
} -state readonly -width [string length "until I close Firefox"]
$f1.mb1 current 0
} else {
menubutton $f1.mb1 -indicatoron yes -menu $f1.mb1.m \
-text "until they expire" \
-width [string length "until I close Firefox"] -justify left
set m [menu $f1.mb1.m -tearoff no]
foreach label {
"until they expire"
"until I close Firefox"
"ask me every time"
} {
$m add command -label $label -command [list $f1.mb1 configure -text $label]
}
}
pack $f1.l1 -side left
pack $f1.mb1 -side left -padx {8 0}
pack $f1 -side top -anchor w
pack $f.t1 -side top -expand yes -fill x -padx {0 10} -pady {0 8}
pack $fLeft -side left -expand yes -fill x
pack $fRight -side right -padx 14 -anchor n
if {$::clip} {
$T item element configure $I C0 eWindow -window $wClip
} else {
$T item element configure $I C0 eWindow -window $f
}
$T item lastchild "root child 4" $I
# Cache
set I [$T item create]
$T item style set $I C0 styFrame
if {$::clip} {
set wClip [frame $T.clip$I -background red]
set f [frame $wClip.f$I -borderwidth 0 -background $bg]
} else {
set f [frame $T.f$I -borderwidth 0 -background $bg]
}
text $f.t1 -background $textBg -borderwidth 0 -highlightthickness 0 \
-width 10 -height 1 -wrap word -cursor ""
$f.t1 insert end "Pages you view are stored in the cache for quicker\
viewing later on."
bindtags $f.t1 TextWrapBindTag
set f1 [frame $f.f1 -borderwidth 0 -background $bg]
label $f1.l1 -background $bg -text "Use up to:"
$::entryCmd $f1.e1 -width 10
$f1.e1 insert end 50000
label $f1.l2 -background $bg -text "KB of disk space for the cache." \
-background $bg
pack $f1.l1 -side left
pack $f1.e1 -side left -padx 8
pack $f1.l2 -side left
pack $f.t1 -side top -expand yes -fill x -padx {0 10}
pack $f1 -side top -anchor w
if {$::clip} {
$T item element configure $I C0 eWindow -window $wClip
} else {
$T item element configure $I C0 eWindow -window $f
}
$T item lastchild "root child 5" $I
# This binding configures the -height option of a Text widget to the
# number of lines it is displaying
bind TextWrapBindTag <Configure> {
scan [textlayout [%W cget -font] [%W get 1.0 "end - 1 chars"] \
-width %w] "%%d %%d" width height
set height [expr {$height / [font metrics [%W cget -font] -linespace]}]
if {$height != [%W cget -height]} {
%W configure -height $height
}
}
# This binding collapses all items before expanding a new one
$T notify bind $T <Expand-before> {
%T item collapse all
}
$T item collapse all
bind DemoFirefoxPrivacy <Double-ButtonPress-1> {
if {[lindex [%W identify %x %y] 0] eq "header"} {
TreeCtrl::DoubleButton1 %W %x %y
} else {
DemoFirefoxPrivacyButton1 %W %x %y
}
break
}
bind DemoFirefoxPrivacy <ButtonPress-1> {
DemoFirefoxPrivacyButton1 %W %x %y
break
}
bind DemoFirefoxPrivacy <Button1-Motion> {
# noop
}
bind DemoFirefoxPrivacy <Button1-Leave> {
# noop
}
bind DemoFirefoxPrivacy <Motion> {
DemoFirefoxPrivacyMotion %W %x %y
}
bind DemoFirefoxPrivacy <Leave> {
DemoFirefoxPrivacyMotion %W %x %y
}
if {$::tile} {
bind DemoFirefoxPrivacy <<ThemeChanged>> {
ttk::style configure DemoCheckbutton -background #FFFFCC
ttk::style layout DemoCheckbutton [ttk::style layout TCheckbutton]
}
}
set FirefoxPrivacy(prev) ""
bindtags $T [list $T DemoFirefoxPrivacy TreeCtrl [winfo toplevel $T] all]
return
}
proc DemoFirefoxPrivacyButton1 {w x y} {
variable TreeCtrl::Priv
focus $w
set id [$w identify $x $y]
set Priv(buttonMode) ""
if {[lindex $id 0] eq "header"} {
TreeCtrl::ButtonPress1 $w $x $y
} elseif {[lindex $id 0] eq "item"} {
set item [lindex $id 1]
# click a button
if {[llength $id] != 6} {
TreeCtrl::ButtonPress1 $w $x $y
return
}
if {[lindex $id 5] eq "eText1"} {
$w item toggle $item
DisplayStylesInItem $item
}
}
return
}
proc DemoFirefoxPrivacyMotion {w x y} {
global FirefoxPrivacy
set id [$w identify $x $y]
if {[lindex $id 0] eq "item"} {
set item [lindex $id 1]
if {[llength $id] == 6 && [lindex $id 5] eq "eText1"} {
if {$item ne $FirefoxPrivacy(prev)} {
$w configure -cursor hand2
set FirefoxPrivacy(prev) $item
}
return
}
}
if {$FirefoxPrivacy(prev) ne ""} {
$w configure -cursor ""
set FirefoxPrivacy(prev) ""
}
return
}
|