12/12/14 18:15, Ian Zimmerman wrote:
On Fri, 12 Dec 2014 14:17:27 +0100 (CET),
Makarius <makar...@sketis.net> wrote:

Makarius> Back to the original question: a public version of the
Makarius> aforementioned GTK C bindings for Poly/ML would be great.

Agreed, so could someone ping Phil Clayton about it?  I am too shy
(having been given access to an early version privately, and not having
done anything with it).

Thanks for mentioning this Ian. Unfortunately I've only just caught up with this discussion.

GTK+ bindings do exist for Poly/ML as part of Giraffe Library, which I am developing. See below for a brief overview. The same bindings are also provided for MLton, allowing the same application code to compile with either compiler.

Giraffe Library is not publicly available yet because there are a couple of little loose ends that I want to tie up. However, I would be very happy to provide a copy to anyone wanting to try it out and feedback would be welcome. Giraffe Library is LGPL simply to have the same licence as GTK+ and company.

There are quite a few omissions in the library. Despite this, a lot can be done. To get a flavour of things, the ubiquitous Hello World example from the GTK+ tutorial is attached!

Regards,
Phil


         ---------------          1.  Overview          ---------------

Giraffe Library is a Standard ML library that provides an interface to
GObject-based libraries, such as GTK+.  The interface introduces some
abstraction of the libraries to provide expected features of
Standard ML such as:

  - automatic memory management (garbage collection)
  - type-safety
  - no uninitialized values
  - portable source code

For the most part, Giraffe Library is generated automatically from the
GIR data of the libraries.  At present, interfaces to parts of the
following libraries are available:

  - GTK+
  - Pango
  - GtkSourceView
  - VTE (Virtual Terminal Emulator)

val msg = "Hello world!"
fun printMsg () = app print [msg, "\n"]

fun deleteEvent _ = false
fun destroy () = Gtk.mainQuit ()

fun setup () =
  let
    open Gtk
    val window = Window.new WindowType.TOPLEVEL
    val button = Button.newWithLabel msg
  in
    Window.setTitle window msg;
    Window.setDefaultSize window 200 75;

    Signal.connect window Widget.deleteEventSig deleteEvent;
    Signal.connect window Widget.destroySig destroy;

    Signal.connect button Button.clickedSig printMsg;

    Container.add window button;

    Widget.showAll window
  end


fun error msg =
  let
      open TextIO OS.Process
      fun printErr s = output (stdErr, s)
  in
      app printErr msg;
      flushOut stdErr;
      exit failure
  end


fun main () =
  let
    val _ = Gtk.init (CommandLine.name () :: CommandLine.arguments ())
  in
    setup ();
    Gtk.main ()
  end
    handle e => error ["Uncaught exception\n", exnMessage e, "\n"]
_______________________________________________
polyml mailing list
polyml@inf.ed.ac.uk
http://lists.inf.ed.ac.uk/mailman/listinfo/polyml

Reply via email to