Changeset 2d896ea in tol
- Timestamp:
- Dec 15, 2011, 2:53:25 PM (15 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- be70fb2
- Parents:
- 00c4270
- File:
-
- 1 edited
-
tolbase/lib/toltk/tolpkg_gui.tcl (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tolbase/lib/toltk/tolpkg_gui.tcl
r00c4270 r2d896ea 618 618 } 619 619 620 proc ::TolPkgGUI:: SortVersion { v1 v2 } {620 proc ::TolPkgGUI::CmpVersion { v1 v2 } { 621 621 foreach { v11 v12 } { {} {} } break 622 622 foreach { n1 v11 v12 } [ split $v1 . ] break … … 627 627 return $cmp 628 628 } else { 629 set cmp [ string compare $v11 $v21 ] 630 if { $cmp } { 631 return $cmp 632 } else { 633 return [ string compare $v12 $v22 ] 634 } 635 } 636 } 637 638 proc ::TolPkgGUI::FillTreeInfo_0 { T } { 639 variable localInfo 640 variable localNames 641 variable treeParents 642 643 $T configure -table no -filter yes -columns { 644 { {text} -tags NAME -label "Name" } 645 } 646 647 if { ![llength [ array names localInfo ] ] } { 648 foreach p [ ::TolPkg::GetLocalPackages ] { 649 array set localInfo $p 650 } 651 set localNames [ lsort -decreasing -command ::TolPkgGUI::SortVersion \ 652 [ array names localInfo ] ] 653 } 654 array unset treeParents 655 foreach n $localNames { 656 array set pkg $localInfo($n) 657 set pkgRoot $pkg(name) 658 set pkgRepo [ expr { [ string range $pkg(url) end-13 end ] eq "repository.php" ? 659 $pkg(url) : "$pkg(url)repository.php" } ] 660 if { ![ info exists treeParents($pkgRoot) ] } { 661 if { ![ info exists treeParents($pkgRepo) ] } { 662 set treeParents($pkgRepo) [ $T insert [ list [ list $pkgRepo ] ] \ 663 -at end -relative root ] 664 } 665 set treeParents($pkgRoot) [ $T insert [ list [ list $pkgRoot ] ] \ 666 -at end -relative $treeParents($pkgRepo) ] 667 } 668 set nid [ $T insert [ list [ list $n ] ] \ 669 -at end -relative $treeParents($pkgRoot) ] 670 foreach d [ lindex $pkg(dependencies) 1 ] { 671 $T insert [ list [ list $d ] ] \ 672 -at end -relative $nid 673 } 629 return [ expr { $v11 < $v21 ? -1 : ( $v11 > $v21 ? 1 : ( $v12 < $v22 ? -1 : ( $v12 > $v22 ? 1 : 0 ) ) ) } ] 674 630 } 675 631 } … … 708 664 set nodeStatus new 709 665 } else { 710 set idx [ SortVersion $lastremote $lastlocal ]666 set idx [ CmpVersion $lastremote $lastlocal ] 711 667 if { $idx <= 0 } { 712 668 # could be -1 (because of date error) … … 728 684 array set localVersionInfo $pv 729 685 } 730 set localVersionNames [ lsort -decreasing -command ::TolPkgGUI:: SortVersion \686 set localVersionNames [ lsort -decreasing -command ::TolPkgGUI::CmpVersion \ 731 687 [ array names localVersionInfo ] ] 732 688 # insert version information … … 754 710 if { $datelocal eq "TheBegin" } { 755 711 set img "package_down_16" 756 set node sStatus new712 set nodeStatus new 757 713 } else { 758 714 set idx [ string compare $dateremote $datelocal ] … … 900 856 proc ::TolPkgGUI::PostContextMenu { T w } { 901 857 variable nodesInfo 858 variable localPackageInfo 859 variable localVersionInfo 902 860 903 861 $w delete 0 end … … 934 892 -command "::TolPkgGUI::SyncServers" 935 893 $w add separator 936 set lenPkg [ llength $selectionInfo(pkg) ] 937 set lenPkgVer [ llength $selectionInfo(pkgver) ] 938 set lenPkgAll [ expr { $lenPkg + $lenPkgVer } ] 939 if { $lenPkgAll } { 940 if { $lenPkgAll == 1 } { 941 if { $lenPkg } { 942 # process a single node pkg 943 set nid [ lindex $selectionInfo(pkg) 0 ] 944 set pkg [ $T item text $nid 0 ] 945 set status $nodesInfo($nid,status) 946 if { $status eq "new" } { 947 $w add command -label [ mc "Install %s" $pkg ] \ 948 -command "::TolPkgGUI::InstallPackage $pkg" 949 } elseif { $status eq "upgrade" } { 950 $w add command -label [ mc "Upgrade %s" $pkg ] \ 951 -command "::TolPkgGUI::UpgradePackage $pkg" 952 $w add command -label [ mc "Upgrade all" ] \ 953 -command "::TolPkgGUI::UpgradePackage" 954 } elseif { $status ne "ok" } { 955 puts "unexpected status $status for pkg $pkg" 956 } 957 } else { 958 # process a single node pkgver 959 set nid [ lindex $selectionInfo(pkgver) 0 ] 960 set pkgver [ $T item text $nid 0 ] 961 puts "process a single node pkgver $pkgver" 962 set status $nodesInfo($nid,status) 963 if { $status eq "new" } { 964 $w add command -label [ mc "Install %s" $pkgver ] \ 965 -command "::TolPkgGUI::InstallPackage $pkgver" 966 } elseif { $status eq "update" } { 967 $w add command -label [ mc "Update version %s" $pkgver ] \ 968 -command "::TolPkgGUI::UpdatePackageVersion $pkgver" 969 $w add command -label [ mc "Update all" ] \ 970 -command "::TolPkgGUI::UpdatePackageVersion" 971 } elseif { $status ne "ok" } { 972 puts "unexpected status $status for pkgver $pkgver" 894 # preprocess selection of packages 895 set listNEW {} 896 set listUPD {} 897 set listUPG {} 898 set listEXP {} 899 900 # process first the list of pkg 901 foreach nid $selectionInfo(pkg) { 902 set pkg [ $T item text $nid 0 ] 903 array unset pkgInfo 904 array set pkgInfo $localPackageInfo($pkg) 905 switch -exact $nodesInfo($nid,status) { 906 "new" { 907 lappend listNEW $pkgInfo(lastremote) 908 } 909 "upgrade" { 910 lappend listUPG $pkg 911 } 912 "ok" { 913 } 914 default { 915 puts "unexpected status $status for pkg $pkg" 916 } 917 } 918 if { $pkgInfo(lastlocal) ne "" } { 919 lappend listEXP $pkgInfo(lastlocal) 920 } 921 } 922 # next process the list of pkgver 923 foreach nid $selectionInfo(pkgver) { 924 set pkg [ $T item text $nid 0 ] 925 switch -exact $nodesInfo($nid,status) { 926 "new" { 927 if { [ lsearch $listNEW $pkg ] == -1 } { 928 lappend listNEW $pkg 973 929 } 974 930 } 975 } else { 976 # there is a multiple selection of pkg and pkgver 977 } 978 } else { 979 # there is no pkg nor pkgver selected 931 "update" { 932 lappend listUPD $pkg 933 } 934 "ok" { 935 } 936 default { 937 puts "unexpected status $status for pkg $pkg" 938 } 939 } 940 if { [ lsearch $listEXP $pkg ] == -1 && 941 $nodesInfo($nid,status) ne "new"} { 942 lappend listEXP $pkg 943 } 944 945 } 946 # install list 947 if { [ llength $listNEW ] == 1 } { 948 $w add command -label [ mc "Install %s" [ lindex $listNEW 0 ] ] \ 949 -command [ list ::TolPkgGUI::InstallPackage [ lindex $listNEW 0 ] ] 950 } elseif { [ llength $listNEW ] > 1 } { 951 $w add command -label [ mc "Install selected" ] \ 952 -command [ list ::TolPkgGUI::InstallPackage $listNEW ] 980 953 } 981 954 $w add command -label "[ mc {Install ZIP} ]..." \ 982 955 -command "::TolPkgGUI::InstallZip" 956 # update list 957 if { [ llength $listUPD ] == 1 } { 958 $w add command -label [ mc "Update %s" [ lindex $listUPD 0 ] ] \ 959 -command [ list ::TolPkgGUI::UpdatePackageVersion [ lindex $listUPD 0 ] ] 960 } elseif { [ llength $listUPD ] > 1 } { 961 $w add command -label [ mc "Update selected" ] \ 962 -command [ list ::TolPkgGUI::UpdatePackageVersion $listUPD ] 963 } 964 $w add command -label [ mc "Update all" ] \ 965 -command "::TolPkgGUI::UpdatePackageVersion" 966 # upgrade list 967 if { [ llength $listUPG ] == 1 } { 968 $w add command -label [ mc "Upgrade %s" [ lindex $listUPG 0 ] ] \ 969 -command "::TolPkgGUI::UpgradePackage [ lindex $listUPG 0 ]" 970 } elseif { [ llength $listUPG ] > 1 } { 971 $w add command -label [ mc "Upgrade selected" ] \ 972 -command [ list ::TolPkgGUI::UpgradePackage $listUPG ] 973 } 974 $w add command -label [ mc "Upgrade all" ] \ 975 -command "::TolPkgGUI::UpgradePackage" 976 # export options 983 977 $w add separator 984 # export options 985 986 set selection [$T selection get] 987 set has_selection [ llength $selection ] 988 puts "selction = $selection" 989 puts [ $T item text [ lindex $selection 0 ] 0 ] 990 return 991 $w add command -label [ mc "Update" ] \ 992 -command ::TolPkgGUI::Update 993 $w add command -label [ mc "" ] \ 994 -command ::TolPkgGUI::Update 995 978 if { [ llength $listEXP ] == 1 } { 979 $w add command -label [ mc "Export %s" [ lindex $listEXP 0 ] ] \ 980 -command [ list ::TolPkgGUI::ExportPackageVersion [ lindex $listEXP 0 ] ] 981 } elseif { [ llength $listEXP ] > 1 } { 982 $w add command -label [ mc "Export selected" ] \ 983 -command [ list ::TolPkgGUI::ExportPackageVersion $listEXP ] 984 } 985 $w add command -label [ mc "Export all" ] \ 986 -command [ list ::TolPkgGUI::ExportPackageVersion ] 996 987 } 997 988 … … 1008 999 } 1009 1000 1001 proc ::TolPkgGUI::InstallZip { } { 1002 } 1003 1010 1004 proc ::TolPkgGUI::UpgradePackage { {p ""} } { 1011 1005 } … … 1014 1008 } 1015 1009 1016 proc ::TolPkgGUI:: InstallZip {} {1010 proc ::TolPkgGUI::ExportPackageVersion { {p ""} } { 1017 1011 } 1018 1012
Note: See TracChangeset
for help on using the changeset viewer.
