>What I've been working on recently is a Perl interface to
>gtk. It's not quite ready for release yet, but I have a
>good chunk done. (A Perl port of the entire testgtk program
>works stably in Perl.) As a teaser, 'simple.c' in Perl follows.

Wow, a perl interface to gtk...never in a million years did I imagine
such a thing would exist when I started writing gtk...

I happen to have implemented a scheme interface to gtk. I'm really not
too pleased with it though as it looks an awful lot like C. But to
give you a taste: 

(define timeout 0)

(define (hello-world)
  (if (= timeout 0)
	(set! window (gtk-window-new GTK-WINDOW-TOPLEVEL))
	(set! label (gtk-label-new "hello world"))
	(gtk-container-border-width window 20)
	(gtk-container-add window label)
	(gtk-widget-show label)
	(gtk-widget-show window))
      (gtk-timeout-remove timeout))
  (set! timeout (gtk-timeout-add 5000 (lambda ()
					(begin (set! timeout 0)
					       (gtk-widget-destroy window))))))

(define (make-window)
  (define window (gtk-window-new GTK-WINDOW-TOPLEVEL))
  (gtk-container-border-width window 10)

  (define button (gtk-button-new-with-label "hello world"))
  (define signal (gtk-signal-connect button "clicked" hello-world))
  (gtk-container-add window button)
  (gtk-widget-show button)

  (gtk-widget-show window))


I'll be the first to admit that my scheme fu is weak and some things
above could probably be done better/neater in scheme.

I'm looking for suggestions on what a "good" scheme interface would
be. I guess I should go look at STk again too...

Owen, I'm curious, how did you actually create all the bindings
between C and perl. When I originally started doing the scheme/gtk
interface I created the glue between them by hand. Way too much
work. I gave up. I came back to the problem a few months later and
disovered lcc (a really small ansi compiler), wrote a special purpose
backend which searches for gtk/gdk functions and constants and
automatically generated 99% of the glue between scheme and
C. (Callbacks have to be handled specially). I'm aware that perl has
some sort of interface generator (perlxs), but I've never used it and
am curious to know if you used it and if so, how well it worked.


To unsubscribe: mail -s unsubscribe < /dev/null

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