Changeset 567b369 in tol for tolbase


Ignore:
Timestamp:
Feb 9, 2012, 4:09:14 PM (15 years ago)
Author:
Jorge Pérez <josp.jorge@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
4c5e200
Parents:
fa037e6
Message:

refs #1424, implementing the menu options to remove packages

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

Location:
tolbase/lib/toltk
Files:
2 edited

Legend:

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

    rfa037e6 r567b369  
    222222}
    223223
     224proc ::TolPkg::RemovePackage { pkg } {
     225  set tolexpr [ string map [ list %p ${pkg} ] {
     226    Real TolPackage::Client::LocalClean( "%p" )
     227  } ]
     228  return [ toltcl::eval $tolexpr ]
     229}
     230
    224231proc ::TolPkg::RemoteInstall { pkg repo } {
    225232  puts "::TolPkg::RemoteInstall $pkg $repo"
  • tolbase/lib/toltk/tolpkg_gui.tcl

    rfa037e6 r567b369  
    550550}
    551551
     552proc ::TolPkgGUI::lsearchi { i l it } {
     553  set _i 0
     554  foreach _it $l {
     555    if { $it eq [ lindex $_it $i ] } {
     556      return $_i
     557    }
     558  }
     559  return -1
     560}
     561
    552562proc ::TolPkgGUI::ReadPackSyncInfo { } {
    553563  variable packSyncInfo
    … …  
    813823  $w add command -label [ mc "Sync with servers" ] \
    814824      -command "::TolPkgGUI::SyncServers"
    815   $w add separator
    816825  # preprocess selection of packages
     826  # list of new packages available
    817827  set listNEW {}
     828  # list of package to remove including all installed versions
     829  set listDEL {}
     830  # list of individual package selected to remove
     831  set listDEL0 {}
     832  # list of packages selected needing update
    818833  set listUPD {}
     834  # list of packages selected needing upgrade
    819835  set listUPG {}
     836  # list of packages selected that can be exported 
    820837  set listEXP {}
    821838 
    … …  
    823840  foreach nid $selectionInfo(pkg) {
    824841    set pkg [ $T item text $nid 0 ]
     842    if { $nodesInfo($nid,status) ne "new" } {
     843      lappend listDEL [ list $pkg $nid ]
     844    }
    825845    array unset pkgInfo
    826846    if { [ info exists packSyncInfo($pkg) ] } {
    … …  
    857877      }
    858878    }
     879    foreach chId [ $T item children $nid ] {
     880      lappend listDEL0 [ list [ $T item text $chId 0 ] $chId ]
     881    }
    859882    lappend listEXP [ list $pkgInfo(lastremote) $nodesInfo($nid,status) $nid ]
    860883  }
    … …  
    864887    switch -exact $nodesInfo($nid,status) {
    865888      "new" {
    866         if { [ lsearch $listNEW $pkg ] == -1 } {
     889        puts "OJO: he encontrado un estado new en un pkgver $pkg"
     890        if { [ lsearchi 0 $listNEW $pkg ] == -1 } {
    867891          lappend listNEW [ list $pkg $nid ]
    868892        }
    869893      }
    870894      "update" {
    871         lappend listUPD [ list $pkg $nid ]
     895        if { [ lsearchi 0 $listUPD $pkg ] == -1 } {
     896          lappend listUPD [ list $pkg $nid ]
     897        }
    872898      }
    873899      "ok" {
    … …  
    877903      }
    878904    }
    879     if { [ lsearch $listEXP $pkg ] == -1 } {
     905    if { [ lsearchi 0 $listDEL0 $pkg ] == -1 } {
     906      lappend listDEL0 [ list $pkg $nid ]
     907    }
     908    if { [ lsearchi 0 $listEXP $pkg ] == -1 } {
    880909      lappend listEXP [ list $pkg $nodesInfo($nid,status) $nid ]
    881910    }
    882911  }
    883912  # install list
     913  $w add separator
    884914  if { [ llength $listNEW ] == 1 } {
    885915    $w add command -label [ mc "Install %s" [ lindex [ lindex $listNEW 0 ] 0 ] ] \
    … …  
    904934      -state [ EntryState nodesInfo(update) ]
    905935  # upgrade list
     936  $w add separator
    906937  if { [ llength $listUPG ] == 1 } {
    907938    $w add command \
    … …  
    927958  $w add command -label [ mc "Export all" ]... \
    928959      -command [ list ::TolPkgGUI::ExportPackageVersion ]
     960  # Remove options
     961  $w add separator
     962  if { [ llength $listDEL ] == 1 } {
     963    set _tmppkg [ lindex [ lindex $listDEL 0 ] 0 ]
     964    $w add command \
     965        -label [ mc "Remove all %s" $_tmppkg ]... \
     966        -command [ list ::TolPkgGUI::RemovePackageVersion $listDEL0 $_tmppkg ]
     967  } elseif { [ llength $listDEL0 ] == 1 } {
     968    set _tmppkg [ lindex [ lindex $listDEL0 0 ] 0 ]
     969    $w add command \
     970        -label [ mc "Remove %s" $_tmppkg ]... \
     971        -command [ list ::TolPkgGUI::RemovePackageVersion $listDEL0 ]
     972  } elseif { [ llength $listDEL0 ] > 1 } {
     973    $w add command -label [ mc "Remove selected" ]... \
     974        -command [ list ::TolPkgGUI::RemovePackageVersion $listDEL0 ]
     975  } 
     976  $w add command -label [ mc "Remove all" ]... \
     977      -command [ list ::TolPkgGUI::RemovePackageVersion ]
     978 
    929979  # SyncInfo import/export
    930980  $w add separator
    … …  
    13861436}
    13871437
     1438proc ::TolPkgGUI::RemovePackageVersion { { pkgs {} } { matchPkg {} } } {
     1439  variable installData
     1440  variable tree
     1441
     1442  set removeList {}
     1443  if { [ llength $pkgs ] } {
     1444    foreach p $pkgs {
     1445      set _p [ lindex $p 0 ]
     1446      if { $matchPkg eq "" || [ regexp "^${matchPkg}\\.(\\d+)\\.(\\d+)\$" \
     1447                                    $_p ] } {
     1448        lappend removeList $_p
     1449      }
     1450    }
     1451  } else {
     1452    Unimplemented "Remove all not implemented yet"
     1453  }
     1454  if { ![ llength $removeList ] } {
     1455    return
     1456  }
     1457  array unset installData
     1458  DlgProcess $removeList -title [ mc "Remove packages" ] \
     1459      -label [ mc "You are about to remove"]: \
     1460      -beforestart ::TolPkgGUI::Removing \
     1461      -cmditem "RemoveThisPackage" -refreshtree 1
     1462}
     1463
    13881464proc ::TolPkgGUI::ImportSyncInfo { } {
    13891465  Unimplemented "Import Sync Info"
    … …  
    14321508  foreach _p $pkgs {
    14331509    foreach { p s } $_p break
    1434     if { $s eq "upgrade" || $s eq "new" } {
     1510    if {  $s eq "upgupd" || $s eq "upgrade" || $s eq "new" } {
    14351511      lappend remote $p
    14361512    } else {
    … …  
    14671543proc ::TolPkgGUI::Upgrading { } {
    14681544  DlgProcessSetLabel [ mc "Upgrading" ]...
     1545}
     1546
     1547proc ::TolPkgGUI::Removing { } {
     1548  DlgProcessSetLabel [ mc "Removing" ]...
    14691549}
    14701550
    … …  
    15431623  set result [ TolPkg::RemoteInstall $p $repo ]
    15441624  puts "TolPkg::RemoteInstall $p: $result"
     1625  return $result
     1626}
     1627
     1628proc ::TolPkgGUI::RemoveThisPackage { p } {
     1629  set result [ TolPkg::RemovePackage $p ]
     1630  puts "TolPkg::RemovePackage $p: $result"
     1631  return $result
    15451632}
    15461633
Note: See TracChangeset for help on using the changeset viewer.