update pkg manage GUI for extra scopes

This commit is contained in:
Matthew Flatt 2013-07-21 20:24:08 -06:00
parent 1708fb43b4
commit aa60d32ea3
4 changed files with 37 additions and 16 deletions

View File

@ -12,10 +12,16 @@
(struct ipkg (name scope auto? checksum source)) (struct ipkg (name scope auto? checksum source))
(define (scope<? a b) (define (scope<? a b)
(case a (cond
[(installation) #t] [(path? a)
[(user) (eq? b 'shared)] (or (not (path? b))
[else #f])) (bytes<? (path->bytes a) (path->bytes b)))]
[(path? b) #f]
[else
(case a
[(installation) #t]
[(user) (eq? b 'shared)]
[else #f])]))
(define (ipkg<? a b) (define (ipkg<? a b)
(if (string=? (ipkg-name a) (ipkg-name b)) (if (string=? (ipkg-name a) (ipkg-name b))
@ -35,7 +41,7 @@
[parent this] [parent this]
[label #f] [label #f]
[choices null] [choices null]
[columns (list "Auto?/Scope" "Name" "Checksum" "Source")] [columns (list "Auto?" "Scope" "Name" "Checksum" "Source")]
[style '(multiple column-headers clickable-headers)] [style '(multiple column-headers clickable-headers)]
[callback (lambda (lb e) [callback (lambda (lb e)
(when (e . is-a? . column-control-event%) (when (e . is-a? . column-control-event%)
@ -48,6 +54,8 @@
(sort-list!)) (sort-list!))
(adjust-buttons!))])) (adjust-buttons!))]))
(send pkg-list set-column-width 0 30 2 1000)
(define sort-by 0) (define sort-by 0)
(define flip? #f) (define flip? #f)
(define installed '()) (define installed '())
@ -59,7 +67,7 @@
(define/private (reset-installed-list!) (define/private (reset-installed-list!)
(set! installed (set! installed
(for*/list ([scope (in-list '(installation user shared))] (for*/list ([scope (in-list (get-scope-list))]
[(k v) (in-hash (installed-pkg-table #:scope scope))]) [(k v) (in-hash (installed-pkg-table #:scope scope))])
(ipkg k scope (pkg-info-auto? v) (pkg-info-checksum v) (pkg-info-orig-pkg v)))) (ipkg k scope (pkg-info-auto? v) (pkg-info-checksum v) (pkg-info-orig-pkg v))))
(sort-list!)) (sort-list!))
@ -114,7 +122,7 @@
(define same-scope? (and (pair? ipkgs) (define same-scope? (and (pair? ipkgs)
;; must be all in the same scope: ;; must be all in the same scope:
(for/and ([i (cdr ipkgs)]) (for/and ([i (cdr ipkgs)])
(eq? (ipkg-scope i) (ipkg-scope (car ipkgs)))))) (equal? (ipkg-scope i) (ipkg-scope (car ipkgs))))))
(send remove-button enable same-scope?) (send remove-button enable same-scope?)
(send update-button enable (and same-scope? (send update-button enable (and same-scope?
(for/and ([i (in-list ipkgs)]) (for/and ([i (in-list ipkgs)])
@ -125,7 +133,7 @@
(lambda (a b) (lambda (a b)
((if flip? not values) ((if flip? not values)
(case sort-by (case sort-by
[(0) (if (eq? (ipkg-scope a) (ipkg-scope b)) [(0) (if (equal? (ipkg-scope a) (ipkg-scope b))
(if (eq? (ipkg-auto? a) (ipkg-auto? b)) (if (eq? (ipkg-auto? a) (ipkg-auto? b))
(string<? (ipkg-name a) (ipkg-name b)) (string<? (ipkg-name a) (ipkg-name b))
(not (ipkg-auto? a))) (not (ipkg-auto? a)))
@ -151,8 +159,9 @@
(set! sorted-installed (list->vector l)) (set! sorted-installed (list->vector l))
(send pkg-list set (send pkg-list set
(for/list ([i (in-list l)]) (for/list ([i (in-list l)])
(~a (if (ipkg-auto? i) "*" "") (if (ipkg-auto? i) "*" ""))
(ipkg-scope i))) (for/list ([i (in-list l)])
(~a (ipkg-scope i)))
(for/list ([i (in-list l)]) (for/list ([i (in-list l)])
(format "~a" (ipkg-name i))) (format "~a" (ipkg-name i)))
(for/list ([i (in-list l)]) (for/list ([i (in-list l)])
@ -164,6 +173,7 @@
[(catalog) "Catalog"] [(catalog) "Catalog"]
[(url) "URL"] [(url) "URL"]
[(link) "Link"] [(link) "Link"]
[(static-link) "Static link"]
[(file) "File"]) [(file) "File"])
(cadr s)))) (cadr s))))
(adjust-buttons!)))) (adjust-buttons!))))

View File

@ -266,7 +266,7 @@
(string-constant install-pkg-update-catalogs) (string-constant install-pkg-update-catalogs)
(string-constant install-pkg-do-not-update-catalogs) (string-constant install-pkg-do-not-update-catalogs)
#f #f
this (get-top-level-window)
'(caution default=1))) '(caution default=1)))
(db:set-catalogs! user-catalogs) (db:set-catalogs! user-catalogs)
(update-db-package-list)))) (update-db-package-list))))
@ -416,7 +416,7 @@
(define/private (refresh-installed-list! #:always? [always? #f]) (define/private (refresh-installed-list! #:always? [always? #f])
(define new-installed (define new-installed
(for*/hash ([scope (in-list '(installation user shared))] (for*/hash ([scope (in-list (get-scope-list))]
[(k v) (in-hash (installed-pkg-table #:scope scope))]) [(k v) (in-hash (installed-pkg-table #:scope scope))])
(values k (cons scope v)))) (values k (cons scope v))))
(when (or always? (when (or always?
@ -459,7 +459,7 @@
[(pkg-info-auto? info) "*"] [(pkg-info-auto? info) "*"]
[else check-mark]) [else check-mark])
(cond (cond
[(eq? (car v) default-scope) ""] [(equal? (car v) default-scope) ""]
[else "!"]) [else "!"])
(case (car (pkg-info-orig-pkg info)) (case (car (pkg-info-orig-pkg info))
[(catalog) ""] [(catalog) ""]

View File

@ -2,11 +2,13 @@
(require racket/class (require racket/class
racket/gui/base racket/gui/base
string-constants string-constants
racket/format) racket/format
setup/dirs)
(provide really-remove? (provide really-remove?
sc-install-pkg-remove sc-install-pkg-remove
pick-wider) pick-wider
get-scope-list)
(define sc-install-pkg-remove (string-constant install-pkg-remove)) (define sc-install-pkg-remove (string-constant install-pkg-remove))
(define really-uninstall?-msg (string-constant install-pkg-really-remove?)) (define really-uninstall?-msg (string-constant install-pkg-really-remove?))
@ -30,3 +32,12 @@
(if (wa . > . wb) (if (wa . > . wb)
a a
b)) b))
(define (get-scope-list)
(append (let ([main (find-pkgs-dir)])
(reverse
(for/list ([d (get-pkgs-search-dirs)])
(if (equal? d main)
'installation
d))))
'(user shared)))

View File

@ -160,4 +160,4 @@
frame) frame)
(module+ main (module+ main
(void (make-pkg-installer))) (void (make-pkg-gui)))