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
|
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
|
-
+
+
+
|
#----------------------------------------------------------------------
# Eskil, Directory diff section
#
# Copyright (c) 1998-2007, Peter Spjuth (peter.spjuth@gmail.com)
# Copyright (c) 1998-2010, Peter Spjuth (peter.spjuth@gmail.com)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING. If not, write to
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
#
#----------------------------------------------------------------------
# $Revision$
#----------------------------------------------------------------------
package require tablelist_tile
# Compare file names
proc FStrCmp {s1 s2} {
# Equality is based on platform's standard
# Order is dictionary order
# Exact equal is equal regardless of platform.
|
︙ | | |
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
|
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
|
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
|
lsort -dictionary $l
}
# Compare two files or dirs
# Return true if equal
proc CompareFiles {file1 file2} {
global Pref
if {[catch {file stat $file1 stat1}]} {
if {[catch {file lstat $file1 stat1}]} {
return 0
}
if {[catch {file stat $file2 stat2}]} {
if {[catch {file lstat $file2 stat2}]} {
return 0
}
# Same type?
set isdir1 [FileIsDirectory $file1]
set isdir2 [FileIsDirectory $file2]
if {$isdir1 != $isdir2} {
return 0
}
# Handle links
if {$stat1(type) eq "link" && $stat2(type) eq "link"} {
set l1 [file link $file1]
set l2 [file link $file2]
# Equal links are considered equal, otherwise check contents
if {$l1 eq $l2} {
return 1
}
file stat $file1 stat1
file stat $file2 stat2
}
# If contents is not checked, same size is enough to be equal
if {$stat1(size) == $stat2(size) && $Pref(dir,comparelevel) == 0} {
return 1
}
set ignorekey $Pref(dir,ignorekey)
# Different size is enough when doing binary compare
if {$stat1(size) != $stat2(size) && $Pref(dir,comparelevel) == 2 \
|
︙ | | |
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
|
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
|
+
+
+
+
-
+
-
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
+
+
+
+
-
-
-
+
+
-
-
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
|
if {$newdir != ""} {
set dir $newdir
$entryW xview end
}
}
snit::widget DirCompareTree {
hulltype ttk::frame
component tree
component hsb
component vsb
option -leftdirvariable -default "" -configuremethod SetDirOption
option -rightdirvariable -default "" -configuremethod SetDirOption
option -statusvar -default ""
variable AfterId ""
variable PauseBgProcessing 0
variable ScheduledRestart 0
variable IdleQueue {}
variable IdleQueueArr
variable leftMark ""
variable rightMark ""
variable leftDir ""
variable rightDir ""
variable img
constructor {args} {
variable color
install tree using ttk::treeview $win.tree -height 20 \
install tree using tablelist::tablelist $win.tree -height 20 \
-columns {type status leftfull leftname leftsize leftdate rightfull rightname rightsize rightdate} \
-displaycolumns {leftsize leftdate rightsize rightdate}
-movablecolumns no -setgrid no -showseparators yes \
# Experiment to show less. FIXA
# -displaycolumns {leftname leftsize leftdate rightname rightsize rightdate}
-expandcommand [mymethod expandCmd] \
-collapsecommand [mymethod collapseCmd] \
-fullseparators yes -selectmode none \
-columns {0 "Structure" 0 Size 0 Date 0 Copy 0 Size 0 Date}
install vsb using scrollbar $win.vsb -orient vertical \
-command "$tree yview"
install hsb using scrollbar $win.hsb -orient horizontal \
-command "$tree xview"
# Use demo images from Tablelist
set dir $::eskil(thisDir)/../lib/tablelist/demos
set img(clsd) [image create photo -file [file join $dir clsdFolder.gif]]
set img(open) [image create photo -file [file join $dir openFolder.gif]]
set img(file) [image create photo -file [file join $dir file.gif]]
# Local images
set dir $::eskil(thisDir)/images
set img(link) [image create photo -file [file join $dir link.gif]]
set img(left) [image create photo -file [file join $dir arrow_left.gif]]
set img(right) [image create photo -file [file join $dir arrow_right.gif]]
set AfterId ""
set IdleQueue {}
$tree configure -yscroll "$vsb set" -xscroll "$hsb set"
$tree configure -yscrollcommand "$vsb set" -xscrollcommand "$hsb set"
$tree heading \#0 -text "Structure"
$tree heading leftname -text "Name"
$tree heading leftsize -text "Size"
$tree heading leftdate -text "Date"
$tree columnconfigure 0 -name structure
$tree columnconfigure 1 -name leftsize -align right
$tree columnconfigure 2 -name leftdate
$tree columnconfigure 3 -name command
$tree heading rightname -text "Name"
$tree heading rightsize -text "Size"
$tree heading rightdate -text "Date"
$tree columnconfigure 4 -name rightsize -align right
$tree columnconfigure 5 -name rightdate
$tree column leftsize -stretch 0 -width 70 -anchor e
$tree column rightsize -stretch 0 -width 70 -anchor e
$tree column leftdate -stretch 0 -width 120
destroy [$tree separatorpath 1] [$tree separatorpath 4]
$tree column rightdate -stretch 0 -width 120
$tree tag configure unknown -foreground grey
$tree tag configure empty -foreground grey
$tree tag configure equal -foreground {}
$tree tag configure new -foreground green
$tree tag configure old -foreground blue
$tree tag configure change -foreground red
set color(unknown) grey
set color(empty) grey
set color(equal) {}
set color(new) green
set color(old) blue
set color(change) red
#-expandcommand expandCmd
bind $tree <<TreeviewOpen>> "[mymethod UpdateDirNode] \[%W focus\]"
bind $tree <Button-3> "[mymethod ContextMenu] %x %y %X %Y"
bind $tree <Double-ButtonPress-1> "[mymethod DoubleClick] %x %y"
bind $tree <Key-Return> [mymethod KeyReturn]
#bind $tree <<TreeviewOpen>> "[mymethod UpdateDirNode] \[%W focus\]"
set bodyTag [$tree bodytag]
bind $bodyTag <<Button3>> [bind TablelistBody <Button-1>]
bind $bodyTag <<Button3>> +[bind TablelistBody <ButtonRelease-1>]
bind $bodyTag <<Button3>> "+[mymethod ContextMenu] %W %x %y %X %Y"
bind $bodyTag <Double-1> "[mymethod DoubleClick] %W %x %y"
bind $bodyTag <Key-Return> [mymethod KeyReturn]
grid $tree $vsb -sticky nsew
grid $hsb -sticky nsew
grid columnconfigure $win 0 -weight 1
grid rowconfigure $win 0 -weight 1
$self configurelist $args
|
︙ | | |
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
|
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
|
+
+
-
+
+
+
+
-
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
+
+
-
+
-
-
-
+
-
-
+
-
-
-
-
-
-
-
+
+
-
-
+
+
|
if {$options(-rightdirvariable) eq ""} return
upvar \#0 $options(-rightdirvariable) right
if {![info exists right]} return
if {![file isdirectory $right]} return
set leftDir $left
set rightDir $right
if {!$ScheduledRestart} {
set ScheduledRestart 1
after idle [mymethod ReStart]
after idle [mymethod ReStart]
}
}
method newTopDir {newLeft newRight} {
if {$newLeft ne "" && [file isdirectory $newLeft]} {
upvar \#0 $options(-leftdirvariable) left
set left $newLeft
set leftDir $left
}
if {$newRight ne "" && [file isdirectory $newRight]} {
upvar \#0 $options(-rightdirvariable) right
set right $newRight
set rightDir $right
}
if {!$ScheduledRestart} {
set ScheduledRestart 1
after idle [mymethod ReStart]
after idle [mymethod ReStart]
}
}
method ReStart {} {
# Delete all idle processing
if {$AfterId ne ""} {
after cancel $AfterId
}
set AfterId ""
set IdleQueue {}
set ScheduledRestart 0
array unset IdleQueueArr
# Fill in clean root data
$tree delete [$tree children {}]
$tree set {} type directory
$self SetNodeStatus {} empty
$tree set {} leftfull $leftDir
$tree set {} leftname [file tail $leftDir]
$tree set {} rightfull $rightDir
$tree set {} rightname [file tail $rightDir]
$self UpdateDirNode {}
$tree delete 0 end
set topIndex [$tree insertchild root end {}]
set d1 [file tail $leftDir]
set d2 [file tail $rightDir]
if {$d1 eq $d2} {
$tree cellconfigure $topIndex,structure -text $d1
} else {
$tree cellconfigure $topIndex,structure -text "$d1 vs $d2"
}
$tree cellconfigure $topIndex,structure -image $img(open)
$tree rowattrib $topIndex type directory
$self SetNodeStatus $topIndex empty
$tree rowattrib $topIndex leftfull $leftDir
$tree rowattrib $topIndex rightfull $rightDir
$self UpdateDirNode $topIndex
}
method expandCmd {tbl row} {
if {[$tree childcount $row] != 0} {
$tree cellconfigure $row,0 -image $img(open)
}
}
method collapseCmd {tbl row} {
$tree cellconfigure $row,0 -image $img(clsd)
}
# Format a time stamp for display
proc FormatDate {date} {
clock format $date -format "%Y-%m-%d %H:%M:%S"
}
# Remove all equal nodes from tree
method PruneEqual {} {
set todo [$tree children {}]
set todo [$tree childkeys root]
while {[llength $todo] > 0} {
set todoNow $todo
set todo {}
foreach node $todoNow {
set status [$tree set $node status]
set status [$tree rowattrib $node status]
if {$status eq "equal"} {
$tree delete $node
} else {
lappend todo {*}[$tree children $node]
lappend todo {*}[$tree childkeys $node]
}
}
}
}
# Open or close all directories in the tree view
method OpenAll {{state 1}} {
if {$state} {
set todo [$tree children {}]
$tree expandall
while {[llength $todo] > 0} {
set todoNow $todo
set todo {}
} else {
foreach node $todoNow {
set children [$tree children $node]
$tree collapseall
if {[llength $children] > 0} {
$tree item $node -open $state
lappend todo {*}$children
}
}
}
}
# Copy a file from one directory to the other
method CopyFile {node from} {
global dirdiff Pref
set lf [$tree set $node leftfull]
set rf [$tree set $node rightfull]
set lf [$tree rowattrib $node leftfull]
set rf [$tree rowattrib $node rightfull]
set parent [$tree parent $node]
set lp [$tree set $parent leftfull]
set rp [$tree set $parent rightfull]
set lp [$tree rowattrib $parent leftfull]
set rp [$tree rowattrib $parent rightfull]
if {$from eq "left"} {
set src $lf
if {$rf ne ""} {
set dst $rf
} elseif {$rp ne ""} {
set dst [file join $rp [file tail $src]]
|
︙ | | |
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
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
|
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
|
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
+
-
+
|
# FIXA: update file info in tree too
$self SetNodeStatus $node equal
}
}
}
# React on double-click
method DoubleClick {x y} {
set node [$tree identify row $x $y]
method DoubleClick {W x y} {
foreach {W x y} [tablelist::convEventFields $W $x $y] break
set node [$tree index @$x,$y]
set lf [$tree set $node leftfull]
set rf [$tree set $node rightfull]
set type [$tree set $node type]
set lf [$tree rowattrib $node leftfull]
set rf [$tree rowattrib $node rightfull]
set type [$tree rowattrib $node type]
# On a file that exists on both sides, start a file diff
if {$type eq "file" && $lf ne "" && $rf ne ""} {
set PauseBgProcessing 1
newDiff $lf $rf
set PauseBgProcessing 0
# Stop the default bindings from running
return -code break
}
}
# React on Return key
method KeyReturn {} {
set node [$tree focus]
if {$node eq ""} return
set lf [$tree set $node leftfull]
set rf [$tree set $node rightfull]
set type [$tree set $node type]
set lf [$tree rowattrib $node leftfull]
set rf [$tree rowattrib $node rightfull]
set type [$tree rowattrib $node type]
# On a file that exists on both sides, start a file diff
if {$type eq "file" && $lf ne "" && $rf ne ""} {
set PauseBgProcessing 1
newDiff $lf $rf
set PauseBgProcessing 0
# Stop the default bindings from running
return -code break
}
}
# Bring up a context menu on a file.
method ContextMenu {x y X Y} {
#global dirdiff Pref
method ContextMenu {W x y X Y} {
foreach {W x y} [tablelist::convEventFields $W $x $y] break
set node [$tree identify row $x $y]
set col [$tree identify column $x $y]
set colname [$tree column $col -id]
set node [$tree index @$x,$y]
set col [$tree columnindex @$x,$y]
set colname [$tree columncget $col -name]
set lf [$tree set $node leftfull]
set rf [$tree set $node rightfull]
set type [$tree set $node type]
set lf [$tree rowattrib $node leftfull]
set rf [$tree rowattrib $node rightfull]
set type [$tree rowattrib $node type]
set oneside [expr {($lf ne "") ^ ($rf ne "")}]
set m $win.popup
destroy $m
menu $m
if {$col eq "#0"} {
if {$colname eq "structure"} {
$m add command -label "Prune equal" -command [mymethod PruneEqual]
$m add command -label "Expand all" -command [mymethod OpenAll]
$m add command -label "Collaps all" -command [mymethod OpenAll 0]
$m add command -label "Collapse all" -command [mymethod OpenAll 0]
}
if {$type eq "file" && $lf ne "" && $rf ne ""} {
# Files, both exist
$m add command -label "Compare Files" -command [list \
newDiff $lf $rf]
}
|
︙ | | |
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
|
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
|
-
+
|
set pre [clock clicks -milliseconds]
set errors {}
while {[llength $IdleQueue] > 0} {
set node [lindex $IdleQueue 0]
set IdleQueue [lrange $IdleQueue 1 end]
unset IdleQueueArr($node)
if {[$tree set $node type] ne "directory"} {
if {[$tree rowattrib $node type] ne "directory"} {
set sts [catch {$self UpdateFileNode $node} err]
} else {
set sts [catch {$self UpdateDirNode $node} err]
}
if {$sts} {
lappend errors $err
}
|
︙ | | |
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
|
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
|
-
-
+
+
+
-
-
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
-
+
-
+
-
+
-
-
+
+
-
-
+
+
-
-
-
-
-
-
-
-
|
set statusvar ""
set AfterId ""
return
}
}
if {[llength $IdleQueue] > 0} {
set leftfull [$tree set $node leftfull]
set rightfull [$tree set $node rightfull]
set leftfull [$tree rowattrib $node leftfull]
set rightfull [$tree rowattrib $node rightfull]
if {$leftfull ne ""} {
set statusvar $leftfull
} else {
set statusvar $rightfull
}
set AfterId [after 1 [mymethod UpdateIdle]]
} else {
set statusvar ""
set AfterId ""
}
}
method SetNodeStatus {node status} {
variable color
$tree set $node status $status
$tree item $node -tags $status
$tree rowattrib $node status $status
$tree rowconfigure $node -foreground $color($status) \
-selectforeground $color($status)
#puts "Set [$tree item $node -text] to $status"
# Loop through children to update parent
set parent [$tree parent $node]
if {$parent eq ""} { return }
set parent [$tree parentkey $node]
if {$parent eq "" || $parent eq "root"} { return }
# If this is only present on one side, there is no need to update
set lf [$tree set $parent leftfull]
set rf [$tree set $parent rightfull]
set lf [$tree rowattrib $parent leftfull]
set rf [$tree rowattrib $parent rightfull]
if {$lf eq "" || $rf eq ""} { return }
set pstatus equal
foreach child [$tree children $parent] {
set status [$tree set $child status]
foreach child [$tree childkeys $parent] {
set status [$tree rowattrib $child status]
switch $status {
unknown {
set pstatus unknown
break
}
new - old - change {
set pstatus change
break
}
}
}
#puts "Setting parent [$tree set $parent leftname] to $pstatus"
$self SetNodeStatus $parent $pstatus
}
method UpdateDirNode {node} {
if {[$tree set $node type] ne "directory"} {
if {[$tree rowattrib $node type] ne "directory"} {
return
}
if {[$tree set $node status] ne "empty"} {
if {[$tree rowattrib $node status] ne "empty"} {
#puts "Dir [$tree set $node leftfull] already done"
return
}
$tree delete [$tree children $node]
$tree delete [$tree childkeys $node]
set leftfull [$tree set $node leftfull]
set rightfull [$tree set $node rightfull]
set leftfull [$tree rowattrib $node leftfull]
set rightfull [$tree rowattrib $node rightfull]
$self CompareDirs $leftfull $rightfull $node
}
method UpdateFileNode {node} {
set leftfull [$tree set $node leftfull]
set rightfull [$tree set $node rightfull]
set leftfull [$tree rowattrib $node leftfull]
set rightfull [$tree rowattrib $node rightfull]
set equal [CompareFiles $leftfull $rightfull]
if {$equal} {
$self SetNodeStatus $node equal
} else {
$self SetNodeStatus $node change
}
#$self CompareDirs $leftfull $rightfull $node
#$self SetNodeStatus $node unknown
#$tree set $node leftfull
#$tree set $node leftname
#$tree set $node rightfull
#$tree set $node rightname
}
# List files under a directory node
# Returns status for the new node
method ListFiles {df1 df2 node} {
if {$df1 ne ""} {
set type [file type $df1]
|
︙ | | |
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
|
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
|
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
set size2 ""
set time2 ""
} else {
set size2 $stat2(size)
set time2 [FormatDate $stat2(mtime)]
}
if {$type eq "directory"} {
# If a directory is present in only one side, make sure it shows
# up in that side's listing
set showleft ""
set showright ""
if {$df1 eq ""} {
set showright $name/
} elseif {$df2 eq ""} {
set showleft $name/
}
set values [list $type unknown \
$df1 $showleft "" "" \
$df2 $showright "" ""]
set values [list $name \
"" "" \
"" \
"" ""]
} else {
set name1 [file tail $df1]
set name2 [file tail $df2]
set values [list $type unknown \
$df1 $name1 $size1 $time1 \
$df2 $name2 $size2 $time2]
set values [list $name \
$size1 $time1 \
"" \
$size2 $time2]
}
set id [$tree insert $node end -text $name \
-values $values]
set id [$tree insertchild $node end $values]
$tree rowattrib $id type $type
$tree rowattrib $id status unknown
$tree rowattrib $id leftfull $df1
$tree rowattrib $id rightfull $df2
if {$type ne "directory"} {
if {$type eq "link"} {
$tree cellconfigure $id,structure -image $img(link)
} else {
$tree cellconfigure $id,structure -image $img(file)
$tree cellconfigure $id,command -window [mymethod addCmdCol]
}
}
if {$type eq "directory"} {
## Make it so that this node is openable
$tree collapse $id
$tree insert $id 0 -text dummy ;# a dummy
$tree item $id -text $name/
#$tree insertchild $id end dummy ;# a dummy
$tree cellconfigure $id,structure -text $name/
$self SetNodeStatus $id empty
$self AddNodeToIdle $id
$tree cellconfigure $id,structure -image $img(clsd)
} elseif {$size1 == $size2 && \
$time1 == $time2} {
$self SetNodeStatus $id equal
} elseif {$size1 == ""} {
$self SetNodeStatus $id new
} elseif {$size2 == ""} {
$self SetNodeStatus $id old
} else {
$self SetNodeStatus $id unknown
$self AddNodeToIdle $id
}
return [$tree set $id status]
return [$tree rowattrib $id status]
}
method addCmdCol {tbl row col w} {
set status [$tree rowattrib $row status]
set type [$tree rowattrib $row type]
set lf [$tree rowattrib $row leftfull]
set rf [$tree rowattrib $row rightfull]
set bg [$tbl cget -background]
ttk::style configure Apa.TFrame -background $bg
ttk::style configure Apa.Toolbutton -background $bg
ttk::frame $w -style Apa.TFrame
ttk::button $w.bl -image $img(left) -style Apa.Toolbutton \
-command [mymethod CopyFile $row right]
ttk::button $w.br -image $img(right) -style Apa.Toolbutton \
-command [mymethod CopyFile $row left]
pack $w.bl $w.br -side left -fill y
if {$lf eq ""} {
$w.br configure -state disabled
}
if {$rf eq ""} {
$w.bl configure -state disabled
}
}
# Compare two directories.
method CompareDirs {dir1 dir2 node} {
global Pref
if {$dir1 eq ""} {
set files1 {}
|
︙ | | |
852
853
854
855
856
857
858
859
860
861
862
863
864
865
|
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
|
+
+
+
+
+
+
+
+
|
variable statusVar
constructor {args} {
eskilRegisterToplevel $win
wm title $win "Eskil Dir"
wm protocol $win WM_DELETE_WINDOW [list cleanupAndExit $win]
set dir $::eskil(thisDir)/images
set img(open) [image create photo -file [file join $dir folderopen1.gif]]
set img(up) [image create photo -file [file join $dir arrow_up.gif]]
set h [image height $img(up)]
set w [image width $img(up)]
set img(upup) [image create photo -height $h -width [expr {2 * $w}]]
$img(upup) copy $img(up) -to 0 0 [expr {2 * $w - 1}] [expr {$h - 1}]
install tree using DirCompareTree $win.dc \
-leftdirvariable ::dirdiff(leftDir) \
-rightdirvariable ::dirdiff(rightDir) \
-statusvar [myvar statusVar]
ttk::frame $win.fe1
ttk::frame $win.fe2
|
︙ | | |
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
|
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
|
-
+
-
-
-
+
+
+
-
-
-
-
+
+
+
+
-
+
-
+
|
}
$win.m.md add command -label "Reread Source" -underline 0 \
-command {EskilRereadSource}
$win.m.md add separator
$win.m.md add command -label "Redraw Window" -command {makeDirDiffWin 1}
}
ttk::button $win.bu -text "Up Both" -command [mymethod UpDir] \
ttk::button $win.bu -image $img(upup) -command [mymethod UpDir] \
-underline 0
bind $win <Alt-u> "$win.bu invoke"
#catch {font delete myfont}
#font create myfont -family $Pref(fontfamily) -size $Pref(fontsize)
ttk::entryX $win.e1 -textvariable dirdiff(leftDir)
ttk::button $win.bu1 -text "Up" -command [mymethod UpDir 1]
ttk::button $win.bb1 -text "Browse" \
ttk::entryX $win.e1 -textvariable dirdiff(leftDir) -width 30
ttk::button $win.bu1 -image $img(up) -command [mymethod UpDir 1]
ttk::button $win.bb1 -image $img(open) \
-command "[list BrowseDir dirdiff(leftDir) $win.e1]
[mymethod DoDirCompare]"
$win.e1 xview end
ttk::entryX $win.e2 -textvariable dirdiff(rightDir)
ttk::button $win.bu2 -text "Up" -command [mymethod UpDir 2]
ttk::button $win.bb2 -text "Browse" \
after 50 [list after idle [list $win.e1 xview end]]
ttk::entryX $win.e2 -textvariable dirdiff(rightDir) -width 30
ttk::button $win.bu2 -image $img(up) -command [mymethod UpDir 2]
ttk::button $win.bb2 -image $img(open) \
-command "[list BrowseDir dirdiff(rightDir) $win.e2]
[mymethod DoDirCompare]"
$win.e2 xview end
after 50 [list after idle [list $win.e2 xview end]]
bind $win.e1 <Return> [mymethod DoDirCompare]
bind $win.e2 <Return> [mymethod DoDirCompare]
ttk::label $win.sl -anchor w -textvariable [myvar statusVar]
pack $win.bb1 $win.bu1 -in $win.fe1 -side right -pady 1 -ipadx 10
pack $win.bb1 $win.bu1 -in $win.fe1 -side left -pady 1 -ipadx 10
pack $win.bu1 -padx 6
pack $win.e1 -in $win.fe1 -side left -fill x -expand 1
pack $win.bb2 $win.bu2 -in $win.fe2 -side right -pady 1 -ipadx 10
pack $win.bu2 -padx 6
pack $win.e2 -in $win.fe2 -side left -fill x -expand 1
grid $win.fe1 $win.bu $win.fe2 -sticky we
|
︙ | | |