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
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
|
if {$state} {
$tree expandall
} else {
$tree collapseall
}
}
# Copy a file from one directory to the other
method CopyFile {node from} {
global dirdiff
set lf [$tree rowattrib $node leftfull]
set rf [$tree rowattrib $node rightfull]
set parent [$tree parent $node]
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]]
} else {
return
}
} elseif {$from eq "right"} {
set src $rf
if {$lf ne ""} {
set dst $lf
} elseif {$lp ne ""} {
set dst [file join $lp [file tail $src]]
} else {
return
}
} else {
error "Bad from argument to CopyFile: $from"
}
if {[file exists $dst]} {
if {[tk_messageBox -icon question -title "Overwrite file?" -message \
"Copy\n$src\noverwriting\n$dst ?" -type yesno] eq "yes"} {
file copy -force $src $dst
# FIXA: update file info in tree too
$self SetNodeStatus $node equal
}
} else {
if {[tk_messageBox -icon question -title "Copy file?" -message \
"Copy\n$src\nto\n$dst ?" -type yesno] eq "yes"} {
file copy $src $dst
# FIXA: update file info in tree too
$self SetNodeStatus $node equal
}
}
}
|
|
<
<
|
|
<
<
|
|
<
<
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
|
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
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
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
|
if {$state} {
$tree expandall
} else {
$tree collapseall
}
}
# Create a directory missing on one side
method CreateDir {node to} {
set lf [$tree rowattrib $node leftfull]
set rf [$tree rowattrib $node rightfull]
set parent [$tree parent $node]
set lp [$tree rowattrib $parent leftfull]
set rp [$tree rowattrib $parent rightfull]
if {$to eq "right"} {
set src $lf
if {$rp ne ""} {
set dst [file join $rp [file tail $src]]
} else {
return
}
} elseif {$to eq "left"} {
set src $rf
if {$lp ne ""} {
set dst [file join $lp [file tail $src]]
} else {
return
}
} else {
error "Bad from argument to CreateDir: $to"
}
if {[tk_messageBox -icon question -title "Create dir?" -message \
"Create\n$dst ?" -type yesno] eq "yes"} {
file mkdir $dst
# FIXA: update file info in tree too
#$self SetNodeStatus $node equal
}
}
# Copy a file from one directory to the other
method CopyFile {node from} {
if {$from eq "left"} {
set to right
} elseif {$from eq "right"} {
set to left
} else {
error "Bad from argument to CopyFile: $from"
}
set fromf [$tree rowattrib $node ${from}full]
set tof [$tree rowattrib $node ${to}full]
set parent [$tree parent $node]
set fromp [$tree rowattrib $parent ${from}full]
set top [$tree rowattrib $parent ${to}full]
set src $fromf
if {$tof ne ""} {
set dst $tof
} else {
# Go up until we find a common parent
set dst [file tail $src]
set Count 0 ;# Safety check while debugging
while {$Count < 1000} {
if {[incr Count] > 999} {
error "Internal error in CopyFile $from"
}
if {$top ne ""} {
set dst [file join $top $dst]
break
}
# Continue up to a commmon parent
set dst [file join [file tail $fromp] $dst]
set parent [$tree parent $parent]
set fromp [$tree rowattrib $parent ${from}full]
set top [$tree rowattrib $parent ${to}full]
}
}
if {[file exists $dst]} {
if {[tk_messageBox -icon question -title "Overwrite file?" -message \
"Copy\n$src\noverwriting\n$dst ?" -type yesno] eq "yes"} {
file copy -force $src $dst
# FIXA: update file info in tree too
$self SetNodeStatus $node equal
}
} else {
set msg "Copy\n$src\nto\n$dst ?"
set dstdir [file dirname $dst]
if {![file isdirectory $dstdir]} {
append msg "\nCreating Directory\n$dstdir ?"
}
if {[tk_messageBox -icon question -title "Copy file?" -message \
$msg -type yesno] eq "yes"} {
if {![file isdirectory $dstdir]} {
file mkdir $dstdir
}
file copy $src $dst
# FIXA: update file info in tree too
$self SetNodeStatus $node equal
}
}
}
|
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
|
if {$lf ne "" && $rf ne ""} {
# Directory, both exist
$m add command -label "Go down" -command [mymethod \
newTopDir $lf $rf]
}
if {$lf ne ""} {
# Directory, left exist
$m add command -label "Go down left" -command [mymethod \
newTopDir $lf ""]
}
if {$rf ne ""} {
# Directory, right exist
$m add command -label "Go down right" -command [mymethod \
newTopDir "" $rf]
}
}
if {$type eq "file"} {
if {([string match left* $colname] || $oneside) && $lf ne ""} {
$m add command -label "Copy File to Right" \
-command [mymethod CopyFile $node left]
$m add command -label "Edit Left File" \
|
|
|
>
>
>
>
>
|
|
>
>
>
>
>
|
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
|
if {$lf ne "" && $rf ne ""} {
# Directory, both exist
$m add command -label "Go down" -command [mymethod \
newTopDir $lf $rf]
}
if {$lf ne ""} {
# Directory, left exist
$m add command -label "Go down left" -command \
[mymethod newTopDir $lf ""]
if {$rf eq ""} {
# Only left exist
$m add command -label "Create Dir right" -command \
[mymethod CreateDir $node right]
}
}
if {$rf ne ""} {
# Directory, right exist
$m add command -label "Go down right" -command \
[mymethod newTopDir "" $rf]
if {$lf eq ""} {
# Only right exist
$m add command -label "Create Dir left" -command \
[mymethod CreateDir $node left]
}
}
}
if {$type eq "file"} {
if {([string match left* $colname] || $oneside) && $lf ne ""} {
$m add command -label "Copy File to Right" \
-command [mymethod CopyFile $node left]
$m add command -label "Edit Left File" \
|
882
883
884
885
886
887
888
889
890
891
892
893
894
895
|
$self SetNodeStatus $id unknown
$self AddNodeToIdle $id
}
return [$tree rowattrib $id status]
}
method addCmdCol {tbl row col w} {
set key [$tree getfullkeys $row]
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
|
>
|
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
|
$self SetNodeStatus $id unknown
$self AddNodeToIdle $id
}
return [$tree rowattrib $id status]
}
method addCmdCol {tbl row col w} {
puts "addCmdCol $row $col"
set key [$tree getfullkeys $row]
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
|