guile-gtk-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: At last, a trivial success


From: Andy Wingo
Subject: Re: At last, a trivial success
Date: Sun, 15 Aug 2004 12:09:57 +0100
User-agent: Mutt/1.5.6+20040803i

Hey Ken,

On Thu, 05 Aug 2004, Ken Restivo wrote:

> I'm now in total programming nirvana: I am tweaking a GUI application
> while it is running. I find this amazing.

Good stuff, eh :)

For the record, you can also add a graphical repl to an app with
guile-gui. I don't have a URL for it, but it was for gtk 1.2.

It was adapted to guile-gnome (the 2.x wrappings) as (gnome gtk
graphical-repl). A sample file is included below. The interesting thing
is that after you've done the setup, you can just call top-repl as
usual; it's just the ports that were overridden. This makes it easy for
the same app to be available in command-line and graphical versions.

(use-modules (gnome gtk) (gnome gtk graphical-repl))

(define (guile-gtk-repl)
  (let* ((w (make <gtk-window> #:title "Guile-Gtk REPL"))
         (repl (make <guile-gtk-repl>))
         (main-loop (g-main-loop-new #f #f))
         (in-port (get repl 'in-port))
         (out-port (get repl 'out-port))
         (old-in-port #f)
         (old-out-port #f)
         (old-error-port #f)
         (old-repl-reader #f))

    (add w repl)
    (set-default-size w 600 400)
    (show-all w)
    (connect w 'delete-event (lambda args (apply throw 'quit args) #f))

    (dynamic-wind
        (lambda ()
          (set! old-in-port (set-current-input-port in-port))
          (set! old-out-port (set-current-output-port out-port))
          (set! old-error-port (set-current-error-port out-port))
          (set! old-repl-reader repl-reader)
          (set! repl-reader
                (lambda (prompt)
                  (display prompt)
                  (force-output)
                  (run-hook before-read-hook)
                  (read))))

        top-repl

        (lambda ()
          (set-current-input-port old-in-port)
          (set-current-output-port old-out-port)
          (set-current-error-port old-error-port)
          (set! repl-reader old-repl-reader)))))

(guile-gtk-repl)

Regards,
--
Andy Wingo <address@hidden>
http://ambient.2y.net/wingo/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]