#lang racket
(require "button-with-alternatives.rkt"

;; Defines the Whalesong tool user interface.  We add a button
;; with choices to either run the program in the browser, or
;; build a package.

(define (whalesong-tool-ui parent-widget
                           #:label (label "Run Whalesong")
                           #:on-browser (on-browser
                                         (lambda ()
                           #:on-build-package (on-build-package 
                                               (lambda ()
  (define container (new horizontal-pane%
                         [parent parent-widget]))
  (define b 
    (new button% 
         [label label]
         [callback (lambda (b ce)
                     (define selection 
                       (send alternatives get-selection))
                       [(string=? selection "Run in browser")
                       [(string=? selection "Build smartphone package")
         [parent container]))  
  (define alternatives
    (new button-with-alternatives% 
         [parent container]
         [choices-thunk (lambda () (list "Run in browser"
                                         "Build smartphone package"))]))
    #;(define ch (new choice% 
                  [label ""]
                  [choices (list "Run in browser"
                                 "Build smartphone package")]
                  [style '(horizontal-label)]
                  [parent container]))

(define (test)
  (define f (new frame% [label "test frame"]))
  (whalesong-tool-ui f
                     (lambda () 
                       (printf "on-browser\n"))
                     (lambda ()
                       (printf "on-build-package\n")))
  (send f show #t))