From ab9caeb05c16e43dcb73f0bfd9d0440855666758 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Thu, 25 Apr 2013 06:13:39 -0600 Subject: [PATCH] pkg/gui: fixes for label widths --- collects/pkg/gui/by-list.rkt | 7 +++++-- collects/pkg/gui/by-source.rkt | 7 +++++-- collects/pkg/gui/common.rkt | 9 ++++++++- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/collects/pkg/gui/by-list.rkt b/collects/pkg/gui/by-list.rkt index ea1b052675..4e49cced59 100644 --- a/collects/pkg/gui/by-list.rkt +++ b/collects/pkg/gui/by-list.rkt @@ -160,7 +160,9 @@ (define install-button (new button% - [label (string-constant install-pkg-install)] + [label (pick-wider normal-control-font + (string-constant install-pkg-install) + (string-constant install-pkg-update))] [parent button-line] [style '(border)] [callback (lambda (b e) @@ -379,7 +381,8 @@ (send status-text set-label default-status)))) (define/private (->label-string s) - (substring s 0 (min 200 (string-length s)))) + (let ([s (regexp-replace* #rx"[\r\n]+" s " ")]) + (substring s 0 (min 200 (string-length s))))) (define pkgs '#()) (define tagss #(hash)) diff --git a/collects/pkg/gui/by-source.rkt b/collects/pkg/gui/by-source.rkt index c02e0c304a..7d14caaa4c 100644 --- a/collects/pkg/gui/by-source.rkt +++ b/collects/pkg/gui/by-source.rkt @@ -9,7 +9,8 @@ pkg racket/list framework - net/url) + net/url + "common.rkt") (provide by-source-panel%) @@ -105,7 +106,9 @@ (define ok-button (new button% - [label sc-install-pkg-install] + [label (pick-wider normal-control-font + sc-install-pkg-install + sc-install-pkg-update)] [parent button-panel] [style '(border)] [callback (lambda (b e) diff --git a/collects/pkg/gui/common.rkt b/collects/pkg/gui/common.rkt index a0c5249a43..d8f94c667a 100644 --- a/collects/pkg/gui/common.rkt +++ b/collects/pkg/gui/common.rkt @@ -5,7 +5,8 @@ racket/format) (provide really-remove? - sc-install-pkg-remove) + sc-install-pkg-remove + pick-wider) (define sc-install-pkg-remove (string-constant install-pkg-remove)) (define really-uninstall?-msg (string-constant install-pkg-really-remove?)) @@ -23,3 +24,9 @@ parent '(caution default=1)))) +(define (pick-wider font a b) + (define-values (wa ha) (get-window-text-extent a font)) + (define-values (wb hb) (get-window-text-extent b font)) + (if (wa . > . wb) + a + b))