Ignore:
Timestamp:
Dec 22, 2011, 6:44:11 PM (15 years ago)
Author:
Jorge Pérez <josp.jorge@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
d7ed887
Parents:
e83ccac
Message:

refs 1191

  • se elimina el nodo para los repositorios y se añade una columna con el alias del repositorio al cual pertence el paquete

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@3962 be4846ae-f051-483a-831f-b64e7d08527f

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tolbase/lib/toltk/tolpkg_gui.tcl

    re83ccac re4c69c1  
    1212
    1313  variable urlmap
     14
     15  array set urlmap {
     16    http://packages.tol-project.org/OfficialTolArchiveNetwork/repository.php OTAN
     17    http://packages.localbayes.es/BayesPrivateTolPackages/repository.php BPTP
     18  }
    1419 
    1520  variable packSyncInfo
    … …  
    563568source [ file join $::TolPkgGUI::cwd tolpkg.tcl ]
    564569
    565 proc ::TolPkgGUI::FillRepositories { T } {
    566   variable urlmap
    567 
    568   $T configure -table yes -columns {
    569     { text -tags ID -label "Identifier" }
    570     { text -tags SHORT -label "Short Name" }
    571     { text -tags Name -label "Name" }
    572     { text -tags TYPE -label "Type" }
    573     { text -tags DESC -label Description }
    574     { text -tags DESC -label Authors }
    575     { text -tags URL -label Url }
    576   }
    577   foreach r [ ::TolPkg::GetKnownRepositories ] {
    578     set rinfo [ list ]
    579     set rinfo_ [ ::TolPkg::GetRepositoryInfo $r ]
    580     set urlmap($r) [ lindex $rinfo_ 0 ]
    581     foreach i $rinfo_ {
    582       lappend rinfo [ list $i ]
    583     }
    584     lappend rinfo [ list $r ]
    585     $T insert $rinfo
    586   }
    587 }
    588 
    589 proc ::TolPkgGUI::FillPackages { T } {
    590   variable urlmap
    591 
    592   $T configure -table yes -filter yes -columns {
    593     { {image text} -tags NAME -label "Name" }
    594     { text -tags LASTREMOTE -label "Installed" }
    595     { text -tags DESC -label "Description" }
    596     { text -tags TOLVER -label "Minimun TOL" }
    597     { text -tags LASTREMOTE -label "Last Available" }
    598     { text -tags REPO -label "Repository" }
    599   }
    600   set pkginfo [ list ]
    601   foreach i [ ::TolPkg::GetPackagesInfo ] {
    602     set available [ lindex $i 6 ]
    603     set installed [ lindex $i 7 ]
    604     if { $installed eq "" } {
    605       set img "package_down_16"
    606     } else {
    607       set img [ lindex {cdr_tick_16 software_update_16} \
    608                     [ string compare $available $installed ] ]
    609     }
    610     set reg [ list \
    611                   [ list $img [ lindex $i 1 ] ] \
    612                   [list [ lindex $i 7 ] ] \
    613                   [list [ lindex $i 2 ] ] \
    614                   [list [ lindex $i 4 ] ] \
    615                   [list [ lindex $i 6 ] ] \
    616                   $urlmap([lindex $i 0]) ]
    617     $T insert $reg
    618   }
    619 }
    620 
    621570proc ::TolPkgGUI::CmpVersion { v1 v2 } {
    622571  foreach { v11 v12 } { {} {} } break
    … …  
    659608}
    660609
    661 proc ::TolPkgGUI::GetPkgNode { T repo p } {
     610proc ::TolPkgGUI::GetPkgNode { T url p } {
     611  variable urlmap
    662612  variable treeParents
    663613  variable nodesInfo
    … …  
    667617    return treeParents($p)
    668618  }
    669   if { ![ info exists treeParents($repo) ] } {
    670     set treeParents($repo) [ $T insert [ list [ list database_1_16 $repo ] "" ] \
    671                                     -at end -relative root \
    672                                     -button auto ]
    673     set nodesInfo($treeParents($repo),type) repo
    674   }
     619  set url [ expr { [ string range $url end-13 end ] eq "repository.php" ?
     620                   $url : "${url}repository.php" } ]
     621  set repo $urlmap($url)
    675622  if { [ info exists packSyncInfo($p) ] } {
    676623    array set packSync $packSyncInfo($p)
    … …  
    700647    set statusLabel "unknown"
    701648 }
    702   set treeParents($p) [ $T insert [ list [ list $img $p ] [ list $statusLabel ] ] \
    703                             -at end -relative $treeParents($repo) \
    704                             -button auto ]
    705   set nodesInfo($treeParents($p),type) pkg
     649  set treeParents($p) [ $T insert [ list [ list $img $p ] [ list $statusLabel ] \
     650                                        [ list $repo ] ] -at end -relative root \
     651                                        -button auto ]
     652                        set nodesInfo($treeParents($p),type) pkg
    706653  set nodesInfo($treeParents($p),status) $nodeStatus
    707654}
    … …  
    724671    { {image text} -tags NAME -label "Name" }
    725672    { {text} -tags STATUS -label "Status" }
     673    { {text} -tags REPO -label "Repository" }
    726674  }
    727675
    … …  
    791739}
    792740
    793 proc ::TolPkgGUI::CreateToolBar { page } {
    794   set f [ ::TolPkgGUI::GetToolbar $page ]
    795   frame $f
    796   grid $f -row 0 -column 0 -sticky "snew"
    797 }
    798 
    799 proc ::TolPkgGUI::AddToolButton { page name args } {
    800   set f [ ::TolPkgGUI::GetToolbar $page ]
    801   set c [ llength [ grid slaves $f ] ]
    802   set w [ eval button $f.b$name $args ]
    803   grid columnconfigure $f $c -weight 0 -uniform buttons
    804   grid $w -row 0 -column $c -sticky snew
    805   incr c
    806   grid columnconfigure $f $c -weight 1
    807 }
    808 
    809 proc ::TolPkgGUI::GetToolbar { PageOrWin } {
    810   variable widgets
    811 
    812   if { [ winfo exists $PageOrWin ] } {
    813     set f $PageOrWin
    814   } else {
    815     set f [ $widgets(notebook) getframe $PageOrWin ]
    816   }
    817   return $f.tbar
    818 }
    819 
    820 proc ::TolPkgGUI::CreateTree { page } {
    821   set T [ GetTree $page ]
    822   wtree $T
    823   grid $T -row 1 -column 0 -sticky "snew"
    824   set f [ winfo parent $T ]
     741proc ::TolPkgGUI::CreateTreeWidget { t } {
     742  variable tree $t
     743
     744  wtree $t
     745  grid $t -row 1 -column 0 -sticky "snew"
     746  set f [ winfo parent $t ]
    825747  grid rowconfigure $f 1 -weight 1
    826748  grid columnconfigure $f 0 -weight 1
    827749}
    828750
    829 proc ::TolPkgGUI::GetTree { PageOrWin } {
     751proc ::TolPkgGUI::CreateTree { t } {
    830752  variable widgets
    831  
    832   if { [ winfo exist $PageOrWin ] } {
    833     set f $PageOrWin
    834   } else {
    835     set f [ $widgets(notebook) getframe $page ]
    836   }
    837   return $f.tree
    838 }
    839 
    840 proc ::TolPkgGUI::CreateRepositoryTab { } {
    841   variable widgets
    842 
    843   $widgets(notebook) insert end repos -text [ msgcat::mc Repositories ]
    844 
    845   CreateToolBar repos
    846 
    847   AddToolButton repos refresh \
    848       -image database_refresh_32 -text  [ msgcat::mc "Refresh" ] -compound top \
    849       -command ::TolPkgGUI::Refresh
    850   AddToolButton repos addrepo \
    851       -image database_add_32 -text  [ msgcat::mc "Add Repository" ] -compound top
    852 
    853   AddToolButton repos checkrepo \
    854       -image check_connection_32 -text  [ msgcat::mc "Check Selected" ] -compound top
    855 
    856   CreateTree repos
    857 
    858   FillRepositories [ GetTree repos ]
    859 }
    860 
    861 proc ::TolPkgGUI::CreatePackagesTab { } {
    862   variable widgets
    863 
    864   $widgets(notebook) insert end pkgs -text [ msgcat::mc Packages ]
    865  
    866   CreateToolBar pkgs
    867 
    868   AddToolButton pkgs update \
    869       -image product_update_32 -text [ msgcat::mc "Update" ] -compound top
    870   AddToolButton pkgs upgrade \
    871       -image system_upgrade_32 -text [ msgcat::mc "Upgrade" ] -compound top
    872   AddToolButton pkgs remove \
    873       -image file_remove_32 -text [ msgcat::mc "Remove" ] -compound top
    874   AddToolButton pkgs installzip \
    875       -image install_zip_32 -text [ msgcat::mc "Install Zip" ] -compound top
    876 
    877   CreateTree pkgs
    878 
    879   FillPackages [ GetTree pkgs ]
    880 }
    881 
    882 proc ::TolPkgGUI::CreateTreeInfoTab { { t treeinfo } } {
    883   variable widgets
    884 
    885   #$widgets(notebook) insert end treeinfo -text [ msgcat::mc "Tree Info" ]
    886  
    887   CreateToolBar $t
    888 
    889   if { 0 } {
    890   AddToolButton $t refresh \
    891       -image database_refresh_32 -text  [ msgcat::mc "Refresh" ] -compound top \
    892       -command ::TolPkgGUI::Refresh
    893 
    894   AddToolButton $t addrepo \
    895       -image database_add_32 -text  [ msgcat::mc "Add Repository" ] -compound top
    896 
    897   AddToolButton $t checkrepo \
    898       -image check_connection_32 -text  [ msgcat::mc "Check Selected" ] -compound top
    899 
    900   AddToolButton $t installzip \
    901       -image install_zip_32 -text [ msgcat::mc "Install Zip" ] -compound top
    902   }
    903 
    904   CreateTree $t
    905 
    906   FillTreeInfo [ GetTree $t ]
    907   set T [ GetTree $t ]
    908   menu $T.cmenu -tearoff 0 \
    909       -postcommand [ list ::TolPkgGUI::PostContextMenu $T $T.cmenu ]
    910   $T configure -contextmenu $T.cmenu
     753
     754  CreateTreeWidget $t
     755
     756  menu $t.cmenu -tearoff 0 \
     757      -postcommand [ list ::TolPkgGUI::PostContextMenu $t $t.cmenu ]
     758  $t configure -contextmenu $t.cmenu
    911759}
    912760
    … …  
    1038886  $w add separator
    1039887  if { [ llength $listEXP ] == 1 } {
    1040     $w add command -label [ mc "Export %s" [ lindex [ lindex $listEXP 0 ] 0 ] ] \
     888    $w add command -label [ mc "Export %s" [ lindex [ lindex $listEXP 0 ] 0 ] ]... \
    1041889        -command [ list ::TolPkgGUI::ExportPackageVersion [ lindex $listEXP 0 ] ]
    1042890  } elseif { [ llength $listEXP ] > 1 } {
    1043     $w add command -label [ mc "Export selected" ] \
     891    $w add command -label [ mc "Export selected" ]... \
    1044892        -command [ list ::TolPkgGUI::ExportPackageVersion $listEXP ]
    1045893  } 
    1046   $w add command -label [ mc "Export all" ] \
     894  $w add command -label [ mc "Export all" ]... \
    1047895      -command [ list ::TolPkgGUI::ExportPackageVersion ]
    1048896  # SyncInfo import/export
    … …  
    1062910
    1063911proc ::TolPkgGUI::SyncServers { } {
     912  variable tree
     913  update
    1064914  ::TolPkg::UpdateRepositoryInfo
     915  $tree item delete all
     916  FillTreeInfo $tree
    1065917}
    1066918
    … …  
    1097949}
    1098950
    1099 proc ::TolPkgGUI::Clear { } {
    1100   foreach t "repos pkgs" {
    1101     set T [ GetTree $t ]
    1102     $T item delete all
    1103   }
    1104 }
    1105 
    1106 proc ::TolPkgGUI::Refresh { } {
    1107   return
    1108   # this must updated to new GUI
    1109   ::TolPkg::UpdateRepositoryInfo
    1110   Clear
    1111   FillRepositories [ GetTree repos ]
    1112   FillPackages [ GetTree pkgs ]
    1113 }
    1114 
    1115 proc ::TolPkgGUI::Create_0 { parent } {
    1116   variable widgets
    1117 
    1118   set w $parent
    1119 
    1120   # create the tabwindow
    1121  
    1122   set nb [ NoteBook $w.nb ]
    1123   set widgets(notebook) $nb
    1124  
    1125   # repository tab
    1126  
    1127   #CreateRepositoryTab
    1128 
    1129   # package tab
    1130 
    1131   #CreatePackagesTab
    1132 
    1133   # unified tab
    1134 
    1135   CreateTreeInfoTab
    1136  
    1137   # gridding
    1138  
    1139   grid $w.nb -row 0 -column 0 -sticky snew
    1140   grid rowconfigure $w 0 -weight 1
    1141   grid columnconfigure $w 0 -weight 1
    1142 
    1143   #$w.nb raise 0
    1144 }
    1145 
    1146 proc ::TolPkgGUI::Create { parent } {
    1147   variable widgets
    1148 
    1149   set w $parent
    1150 
    1151 
    1152   CreateTreeInfoTab $w
    1153  
    1154   return
    1155   # gridding
    1156  
    1157   grid $w.nb -row 0 -column 0 -sticky snew
    1158   grid rowconfigure $w 0 -weight 1
    1159   grid columnconfigure $w 0 -weight 1
    1160 
    1161   #$w.nb raise 0
    1162 }
    1163 
    1164951proc ::TolPkgGUI::Show { } {
    1165952  set w .tolpkg
    … …  
    1170957    toplevel $w
    1171958    wm state $w withdrawn
    1172     ::TolPkgGUI::Create $w
     959    CreateTree $w.tree
     960    FillTreeInfo $w.tree
    1173961    wm state $w normal
    1174962  }
    … …  
    1176964
    1177965proc ::TolPkgGUI::test { } {
    1178   destroy .t
    1179   toplevel .t
    1180   ::TolPkgGUI::Create .t
     966  destroy .tolpkg
     967  ::TolPkgGUI::Show
    1181968}
    1182969
Note: See TracChangeset for help on using the changeset viewer.