Changeset 00c4270 in tol for tolbase/lib
- Timestamp:
- Dec 15, 2011, 9:37:54 AM (15 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- 2d896ea
- Parents:
- 0da9dfe
- File:
-
- 1 edited
-
tolbase/lib/toltk/tolpkg_gui.tcl (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tolbase/lib/toltk/tolpkg_gui.tcl
r0da9dfe r00c4270 1 1 package require wtree 2 2 package require BWidget 3 package require msgcat 3 4 4 5 namespace eval ::TolPkgGUI { 5 6 7 namespace import ::msgcat::* 8 6 9 variable widgets 7 10 … … 9 12 10 13 variable urlmap 11 variable localInfo 14 15 variable localPackageInfo 16 variable localVersionInfo 17 variable nodesInfo 18 12 19 variable localSortedNames 13 20 variable treeParents … … 645 652 [ array names localInfo ] ] 646 653 } 647 array set treeParents {}654 array unset treeParents 648 655 foreach n $localNames { 649 656 array set pkg $localInfo($n) … … 672 679 variable localVersionInfo 673 680 variable treeParents 681 variable nodesInfo 674 682 675 683 $T configure -table no -filter yes -columns { … … 680 688 array set localPackageInfo $p 681 689 } 682 array set treeParents {} 690 array unset treeParents 691 array unset nodesInfo 683 692 # insert package information 684 693 foreach p [ array names localPackageInfo ] { … … 691 700 -at end -relative root \ 692 701 -button auto ] 702 set nodesInfo($treeParents($pkgRepo),type) repo 693 703 } 694 704 set lastremote $pkg(lastremote) … … 696 706 if { $lastlocal eq "" } { 697 707 set img "package_down_16" 708 set nodeStatus new 698 709 } else { 699 710 set idx [ SortVersion $lastremote $lastlocal ] 700 set img [ lindex { cdr_tick_16 software_update_16 } $idx ] 711 if { $idx <= 0 } { 712 # could be -1 (because of date error) 713 set img "cdr_tick_16" 714 set nodeStatus ok 715 } else { 716 set img "software_update_16" 717 set nodeStatus upgrade 718 } 701 719 } 702 720 set treeParents($p) [ $T insert [ list [ list $img $p ] ] \ 703 721 -at end -relative $treeParents($pkgRepo) \ 704 722 -button auto ] 723 set nodesInfo($treeParents($p),type) pkg 724 set nodesInfo($treeParents($p),status) $nodeStatus 705 725 } 706 726 } … … 723 743 set treeParents($pkgRepo) [ $T insert [ list [ list database_1_16 $pkgRepo ] ] \ 724 744 -at end -relative root -button auto ] 745 set nodesInfo($treeParents($pkgRepo),type) repo 725 746 } 726 747 set treeParents($pkgRoot) [ $T insert [ list [ list {} $pkgRoot ] ] \ 727 748 -at end -relative $treeParents($pkgRepo) \ 728 749 -button auto ] 750 set nodesInfo($treeParents($pkgRoot),type) pkg 729 751 } 730 752 set dateremote $pkg(dateremote) … … 732 754 if { $datelocal eq "TheBegin" } { 733 755 set img "package_down_16" 756 set nodesStatus new 734 757 } else { 735 758 set idx [ string compare $dateremote $datelocal ] 736 if { $idx == -1 } { 759 if { $idx <= 0 } { 760 # could be -1 (because of date error) 737 761 set img "cdr_tick_16" 762 set nodeStatus ok 738 763 } else { 739 set img [ lindex { cdr_tick_16 software_update_16 } $idx ] 764 set img "software_update_16" 765 set nodeStatus update 740 766 } 741 767 } 742 768 set nid [ $T insert [ list [ list $img $pv ] ] \ 743 769 -at end -relative $treeParents($pkgRoot) -button auto ] 770 set nodesInfo($nid,type) pkgver 771 set nodesInfo($nid,status) $nodeStatus 744 772 foreach d $pkg(dependencies) { 745 $T insert [ list [ list back_to_ou_16 $d ] ] \ 746 -at end -relative $nid -button no 773 set nid [ $T insert [ list [ list back_to_ou_16 $d ] ] \ 774 -at end -relative $nid -button no ] 775 set nodesInfo($nid,type) pkgdep 747 776 } 748 777 } … … 845 874 CreateToolBar $t 846 875 876 if { 0 } { 847 877 AddToolButton $t refresh \ 848 878 -image database_refresh_32 -text [ msgcat::mc "Refresh" ] -compound top \ … … 857 887 AddToolButton $t installzip \ 858 888 -image install_zip_32 -text [ msgcat::mc "Install Zip" ] -compound top 889 } 859 890 860 891 CreateTree $t 861 892 862 893 FillTreeInfo [ GetTree $t ] 894 set T [ GetTree $t ] 895 menu $T.cmenu -tearoff 0 \ 896 -postcommand [ list ::TolPkgGUI::PostContextMenu $T $T.cmenu ] 897 $T configure -contextmenu $T.cmenu 898 } 899 900 proc ::TolPkgGUI::PostContextMenu { T w } { 901 variable nodesInfo 902 903 $w delete 0 end 904 array set selectionInfo { 905 repo "" 906 pkg "" 907 pkgver "" 908 } 909 foreach nid [ $T selection get ] { 910 lappend selectionInfo($nodesInfo($nid,type)) $nid 911 } 912 $w add command -label "[ mc {Add New} ]..." \ 913 -command ::TolPkgGUI::AddNewRepository 914 set lenRepo [ llength $selectionInfo(repo) ] 915 if { $lenRepo } { 916 $w add cascade -label "[ mc {Check Repository} ]" \ 917 -menu $w.check 918 if { [ winfo exists $w.check ] } { 919 $w.check delete 0 end 920 } else { 921 menu $w.check -tearoff 0 922 } 923 if { $lenRepo > 1 } { 924 set labelCheck [ mc "Selected" ] 925 } else { 926 set labelCheck [ $T item text [ lindex $selectionInfo(repo) 0 ] 0 ] 927 } 928 $w.check add command -label $labelCheck \ 929 -command "::TolPkgGUI::CheckRepository $labelCheck $lenRepo" 930 $w.check add command -label [ mc "All" ] \ 931 -command "::TolPkgGUI::CheckRepository ALL -1" 932 } 933 $w add command -label [ mc "Sync with servers" ] \ 934 -command "::TolPkgGUI::SyncServers" 935 $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" 973 } 974 } 975 } else { 976 # there is a multiple selection of pkg and pkgver 977 } 978 } else { 979 # there is no pkg nor pkgver selected 980 } 981 $w add command -label "[ mc {Install ZIP} ]..." \ 982 -command "::TolPkgGUI::InstallZip" 983 $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 996 } 997 998 proc ::TolPkgGUI::AddNewRepository { } { 999 } 1000 1001 proc ::TolPkgGUI::CheckRepository { repo length } { 1002 } 1003 1004 proc ::TolPkgGUI::SyncServers { } { 1005 } 1006 1007 proc ::TolPkgGUI::InstallPackage { p } { 1008 } 1009 1010 proc ::TolPkgGUI::UpgradePackage { {p ""} } { 1011 } 1012 1013 proc ::TolPkgGUI::UpdatePackageVersion { {p ""} } { 1014 } 1015 1016 proc ::TolPkgGUI::InstallZip { } { 863 1017 } 864 1018
Note: See TracChangeset
for help on using the changeset viewer.
