[Gd-hackers] GTK+-2 DUIM port
Hannes Mehnert
hannes at mehnert.org
Fri May 25 03:14:42 CEST 2007
Dear Dylan Hacker,
Andreas and I started to work on a GTK+-2 backend for DUIM with opendylan.
There were already some code in place:
* gtk C-FFI binding for Dylan Works with meta (fundev/sources/gtk-2)
This is a C-FFI binding for gtk-2. It has been ported to gtk-2.6.9
by Daniel Brockman in 2006. But gtk header files need to be modified,
making a updates quite painful.
Also, the glib type hierarchy and interface infrastructure (their
OO stuff in C) was not mapped properly in Dylan, requiring doing
pointer casts (for example, gtk-window-new returns a GtkWidget*,
which is really a GtkWindow.
* gtk melange bindings for gwydion dylan
(archive/stuff-from-gwydion/duim/platform/gtk+)
* gobject2-tool, a C tool which uses the introspection of glib
to get information like type hierarchy. It generates a interface
definition file for melange.
melange
After that, melange is used to generate an interface definition
for d2c. D2c has a different C-Interface than Dylan Works, so those
bindings could not be used with Dylan Works.
That was our starting point.
The whole port is developed in the branches/opendylan-melange directory.
* melange
We decided a proper mapping of the type hierarchy as well as a nice way
to register callbacks for signals and events was useful. So we started
to hack up melange to output C-FFI code.
Basically we introduced <back-end> classes and wrote an outputter for
C-FFI.
* gobject2-tool
We implement output for properties of the gobjects. There is a general
way to get a property with a given name in GLib, we added a new syntax
to Dylan for properties: @. So, GtkWindow. at title will return the title
property of an instance of GtkWindow (named here GtkWindow).
* glue code in gtk directory
A meta marshaller to automatically wrap arguments and results to Dylan
types. Also, some magic to instantiate the proper subclass of
<GTypeInstance> for each value returned by C.
Since we only define a C-subclass of a given type if it is in the GLib
type hierarchy, there is no access to the struct members. This is the
design of GLib, wrapping access to structs via a function. But in some
rare cases, access via functions is not granted to struct members, like
GtkWidget->window. This is done manually in support.c for the rare cases.
* gtk-c-ffi
generated code, the interface code generated by melange
* gtk-duim
A copy of the gtk subdirectory in fundev/sources/duim/gtk. This
is cleaned up for our interface, using our signal-connect and most
of the pointer casts are gone. It has still 40 serious warnings
(most in pixmaps, colors, x-stuff).
This is where we need your help. Looking in the GTK API and in the
DUIM API to look what glue has to be written. Currently, click boxes,
list views (currently with deprecated CList from GTK) are basically
working. Also, mouse input handling should work. Not sure about keyboard
handling.
Basically, reversi is working (well, without colors, so you can't see
what you're doing). Also, duim-gui-test-suite is at least starting up.
Sadly, it crashes when a new window is created on linux; but works on
Windows. Development on Windows is easier because there is this nice
IDE.
Some stuff which has to be done:
- of course, tracing the bug which causes the thread (something
about multiple threads calling gtk_main, but I don't know enough
gtk to fix that right now.
- texteditor gadget
- list/tree/tableview gadgets
- Colors
- Fonts
- Pixmaps
If you wish to help, please follow the installation instructions:
* Get opendylan-1.0beta4 from
http://www.opendylan.org/downloads/opendylan/1.0beta4/
* Get GTK development libraries, from your linux the development
packages, Windows-GTK can be downloaded
http://gladewin32.sourceforge.net/modules/news/
* checkout the opendylan-melange branch
svn co svn+ssh://svn.opendylan.org/scm/svn/dylan/branches/opendylan-melange
remove the following registry entries:
fundev/sources/registry: x86-linux/gtk-duim x86-linux/duim
x86-win32/duim x86-win32/gtk-duim x86-win32/gtk
make sure to remove them from both the svn trunk of fundev and
your installed version (/usr/local/opendylan-1.0beta4 or
c:\program files\Open Dylan\Sources\registry ).
Also, add `pwd`/opendylan-melange/registry to your set of
registries with environment variable OPEN_DYLAN_USER_REGISTRIES
Afterwards you should be able to compile reversi by
$ opendylan -build reversi
and duim-gui-test-suite
$ opendylan -build duim-gui-test-suite
Of course, help is welcome. If you encounter any problems,
please ask via mail or in #dylan on irc.freenode.net.
Happy hacking,
Hannes
More information about the hackers
mailing list