gtkNode is part of Jungerl, the “the Jungle of Erlang code,” i.e. a bag of unrelated pieces of Erlang code. gtkNode is a wrapper for the native GTK+ library, version 2.x. gtkNode is intended as a replacement for Erlang’s standard gs GUI application which is based onTcl/Tk. I am not a fan of GTK+ or Gnome (I am a happy user of KDE), but there is still no KDE wrapping library for Erlang. So let’s give gtkNode a try!
First, download all the Jungerl libraries source code from the Jungerl project’s CVSrepository:
> cvs -d:pserver:email@example.com:/cvsroot/jungerl login > cvs -z3 -d:pserver:firstname.lastname@example.org:/cvsroot/jungerl co -P jungerl
To build the gtkNode library, you need to install some packages, in addition to Erlang/OTP (package
erlang on Debian). Since only bare
Makefile files are provided with gtkNode, and sources are not “autotool’d,” we have to guess which packages are necessary. I have guessed that at least the GCC compiler and the development headers for GTK+ and Glade are necessary (and all their dependencies):
> sudo apt-get install bash gcc-4.0 make pkg-config libgtk2.0-dev libglade2-dev
In addition, if wrapper code for your installed version of GTK+ (e.g. Debian sid provides GTK+ version 2.8.10) are not provided in the gtkNode sources (only wrapper code for GTK+ versions 2.4.9 and 2.6.8 are provided by default, cf. files in the
gtkNode/priv/gendirectory), you must also build the wrapper generator. However, this may not be necessary if you apply my patch that adds the generated wrapper code for GTK+ 2.8.10, see below.
Anyway, you must apply my patch, which rewrites a few shell scripts to avoid the use of
tcsh, and to correctly determine the path to installed Erlang applications:
> cd jungerl > wget -O - http://www.berabera.info/wp-content/uploads/2015/06/gtkNode_2006-01-26.patch | patch -p1 > cd lib/gtkNode
That patch also includes the generated wrapper code for GTK+ 2.8.10. However, if you still want to build the generator (e.g. you have a different version of GTK+), packages for Python must be installed, and you must manually create a missing directory:
> sudo apt-get install python2.3 > cd priv/generator > mkdir ebin > make
This generates the proper wrapper files for your installed version of GTK+. Those files must be moved to be usable to build the gtkNode library:
> cp gen/*.h ../gen > make clean
Now, it is possible to actually build gtkNode:
> cd ../../src > make
If you don’t have
emacs installed, like me, and hence don’t have the
etags program installed, the
make command above fails. You must edit the
Makefile file and remove
TAGS dependency from the
all: target line, and execute
make again. The
TAGS file generated by
etags is not essential here.
To build and execute the two provided examples (
> cd ../examples > make > (cd simple ; erl -sname test -pa ../../ebin -s simple start) > (cd points ; erl -sname test -pa ../../ebin -s points start)
It is important to name the started Erlang node, by giving a
-name option, since it must communicate with the independent
gtkNode-linux native node, implemented by the
priv/bin/gtkNode-linux binary program just compiled above, and which handles all GUI stuff using GTK+. The
-pa option gives the path to gtkNode’s compiled Erlang modules.
simple example is a sort of graphical
top. Here is what it looks like:
points example displays colored dots at random coordinates in a canvas, with the color of the clicked button (red, blue or green). Here is what it looks like:
About the appearance of those applications: I am using KDE’s window manager’s “Soft fusion” theme for window decoration, and the Plastik theme for widget decoration. GTK+ applications, including the ones above, use KDE’s Plastik theme through the gtk-qt theme engine (package
gtk2-engines-gtk-qt on Debian). Erlang GUI applications never looked so nice!