From 81079b3a0231a6a287a0939bd89addf76e0952af Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Fri, 26 Jul 2013 20:21:05 -0600 Subject: [PATCH] Windows installer: offer to auto-launch DrRacket The 'start-menu? aux key for launcher creation changed to 'start-menu, with a real-number value indicating a request and precedence for auto-launching (where a precedence is needed because only one application can be auto-launched). --- pkgs/distro-build/installer-exe.rkt | 12 +++++++++++- .../drracket/drracket/drracket.startmenu | 5 +++++ .../scribblings/raco/launcher.scrbl | 19 ++++++++++++------- racket/collects/launcher/launcher-unit.rkt | 17 ++++++++++++++--- 4 files changed, 42 insertions(+), 11 deletions(-) diff --git a/pkgs/distro-build/installer-exe.rkt b/pkgs/distro-build/installer-exe.rkt index 53f3356836..c082ba5cb2 100644 --- a/pkgs/distro-build/installer-exe.rkt +++ b/pkgs/distro-build/installer-exe.rkt @@ -29,6 +29,15 @@ (get-exe-actions src-dir "startmenu.rktd" (lambda (k v) k))) +(define (get-auto-launch src-dir) + (define l + (filter (lambda (p) (real? (cdr p))) + (get-exe-actions src-dir "startmenu.rktd" + cons))) + (if (null? l) + #f + (path-replace-suffix (caar (sort l < #:key cdr)) #""))) + (define (try-exe f) (and (file-exists? f) f)) @@ -419,5 +428,6 @@ SectionEnd makensis #:release release? #:extension-registers (get-extreg "bundle/racket") - #:start-menus (get-startmenu "bundle/racket")) + #:start-menus (get-startmenu "bundle/racket") + #:auto-launch (get-auto-launch "bundle/racket")) exe-path) diff --git a/pkgs/drracket-pkgs/drracket/drracket/drracket.startmenu b/pkgs/drracket-pkgs/drracket/drracket/drracket.startmenu index 1b7fff9323..bcd452df43 100644 --- a/pkgs/drracket-pkgs/drracket/drracket/drracket.startmenu +++ b/pkgs/drracket-pkgs/drracket/drracket/drracket.startmenu @@ -1 +1,6 @@ +10 Existence of this file puts DrRacket in the Windows Start menu. +The fact that it starts with a number requests that the +installer offers to run DrRacket as its final action, and the +value of the number is a predence for that request relative +to other requests. diff --git a/pkgs/racket-pkgs/racket-doc/scribblings/raco/launcher.scrbl b/pkgs/racket-pkgs/racket-doc/scribblings/raco/launcher.scrbl index 6609dd497e..7acaec539c 100644 --- a/pkgs/racket-pkgs/racket-doc/scribblings/raco/launcher.scrbl +++ b/pkgs/racket-pkgs/racket-doc/scribblings/raco/launcher.scrbl @@ -68,10 +68,14 @@ the following additional associations apply to launchers: @racket[#t] means that the generated launcher should find the base GRacket executable through a relative path.} - @item{@racket['start-menu?] (Windows) --- a boolean; @racket[#t] - indicates that the launcher should be in the @onscreen{Start} - menu by an installer that includes the launcher. A - @racket['start-menu?] value is used only when + @item{@racket['start-menu] (Windows) --- a boolean or real number; + @racket[#t] indicates that the launcher should be in the + @onscreen{Start} menu by an installer that includes the + launcher. A number value is treated like @racket[#t], but also + requests that the installer automatically start the + application, where the number determines a precedence relative + to other launchers that may request starting. A + @racket['start-menu] value is used only when @racket['install-mode] is also specified.} @item{@racket['extension-register] (Windows) --- a list of document @@ -108,7 +112,7 @@ the following additional associations apply to launchers: @racket['main], indicates whether the launcher is being installed to a user-specific place or an installation-wide place, which in turn determines where to record - @racket['start-menu?] and @racket['extension-registry] + @racket['start-menu] and @racket['extension-registry] information.} ] @@ -402,8 +406,9 @@ are as follows: @item{@filepath{.wmclass} @'rarr @racket['wm-class] as the literal content, removing a trailing newline if any; for use on Unix} - @item{@filepath{.startmenu} @'rarr @racket['start-menu?] as @racket[#t] - (the file content is ignored) for use on Windows} + @item{@filepath{.startmenu} @'rarr @racket['start-menu] as the file + content if it @racket[read]s as a real number, @racket[#t] + otherwise, for use on Windows} @item{@filepath{.extreg} @'rarr @racket['extension-register] as @racket[read] content (a single S-expression), but with diff --git a/racket/collects/launcher/launcher-unit.rkt b/racket/collects/launcher/launcher-unit.rkt index 48ab27c766..04b78f6c1c 100644 --- a/racket/collects/launcher/launcher-unit.rkt +++ b/racket/collects/launcher/launcher-unit.rkt @@ -407,13 +407,13 @@ e))) (cdr m))))) ;; record Windows start-menu requests, if any - (let ([m (assoc 'start-menu? aux)]) + (let ([m (assoc 'start-menu aux)]) (when (and m (cdr m)) (update-register (cdr im) "startmenu.rktd" (path-element->string (file-name-from-path dest)) - #t)))))) + (cdr m))))))) (define (update-register mode filename key val) (define dir (if (eq? mode 'main) @@ -655,7 +655,18 @@ (path-only (path->complete-path path))) e))))))))))) - (try 'start-menu? #".startmenu") + (let ([l (try 'start-menu #".startmenu")]) + (if (null? l) + l + (with-handlers ([exn:fail:filesystem? (lambda (x) (log-fail l x) null)]) + (with-input-from-file (cdar l) + (lambda () + (list + (cons 'start-menu + (let ([d (read)]) + (if (real? d) + d + #t))))))))) (let ([l (try 'wm-class #".wmclass")]) (if (null? l) l