The GUI generator takes XML files produced by the Glade 2 user interface builder and generates Alice source code that implements the same user interface.
Glade-2 is a graphical user interface builder for Gtk. It can be downloaded from the glade homepage, which also contains links to pre-packaged Windows and Linux binaries.
Given a file Gui.glade, aliceglade produces two files, Gui.aml and GuiSignals.aml. The former implements the static GUI (all the widgets), the latter is a functor that is used to connect your application's signal handlers to their corresponding widgets.
Let's take a very basic example. If you create a window called mainWindow with just one button called button1 and add a signal handler for the clicked signal, the XML produced by glade will look like this:
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> <!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> <glade-interface> <widget class="GtkWindow" id="mainWindow"> <property name="visible">True</property> <property name="title" translatable="yes">Hello World</property> <property name="type">GTK_WINDOW_TOPLEVEL</property> <property name="window_position">GTK_WIN_POS_NONE</property> <property name="modal">False</property> <property name="resizable">True</property> <property name="destroy_with_parent">False</property> <child> <widget class="GtkButton" id="button1"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="label" translatable="yes">Hello</property> <property name="use_underline">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> <signal name="clicked" handler="on_button1_clicked" last_modification_time="Tue, 22 Mar 2005 10:43:26 GMT"/> </widget> </child> </widget> </glade-interface>
The generated Alice code would be
structure Helloworld = struct structure Helpers = struct val accelGroup = Gtk.accelGroupNew() val tooltips = Gtk.tooltipsNew() fun containerAddList(cont, children) = List.app (fn c => Gtk.containerAdd(cont,c)) children end val mainWindow = Gtk.windowNew(Gtk.WINDOW_TOPLEVEL) val _ = Gtk.windowSetTitle(mainWindow,"Hello World") val _ = Gtk.windowAddAccelGroup(mainWindow,Helpers.accelGroup) val button1 = Gtk.buttonNewWithMnemonic("Hello") val _ = Gtk.containerAdd(mainWindow,button1) end
As you can see, the names you assigned to your widgets in glade are reused. To actually display the window, just call Gtk.widgetShowAll Helloworld.mainWindow from your application.
The signal handlers are connected using the generated file HelloworldSignals.aml:
signature HELLOWORLDSIGNALS_SIG = sig val on_button1_clicked : Gtk.callback_function end functor HelloworldSignals(structure S : HELLOWORLDSIGNALS_SIG) = struct val button1_on_button1_clicked = Gtk.signalConnect(Helloworld.button1, "clicked",S.on_button1_clicked) end
In your application, you just have to implement the HELLOWORLDSIGNALS_SIG signature and apply the HelloworldSignals functor, which will then connect your signal callbacks to their widgets.
For a realistic example, you can take a look at the source code of the Alice Explorer or the GUI of the interactive toplevel - large parts of these applications were designed using glade.