I have the following code form Dolphin Smalltalk:
digitalClockProcess := [[
Processor sleep: 1000.
(View desktop canvas)
font: (Font name: 'Arial' pointSize: 36) beBold;
text: Time now printString at: 10@10;
free
] repeat] fork.
which shows a digital clock on the desktop. Can this code be run on GNU Smalltalk? I tried gst
and gst-blox
on Fedora on a VirtualBox VM and it didn't work, and gst-blox
doesn't exist on Ubuntu, and gst-browser
on both Fedora and Ubuntu gave a
Object: CFunctionDescriptor new: 1 "<0x7ffb3a010dc0>" error: Invalid C call-out g_date_get_type
when starting up the app. How is it done in GNU Smalltalk?
I am not familiar with GNU Smalltalk (I use Pharo), so maybe there is better way to write the code, but regardless.
gst
installed from package manager doesn't need any GUI (it's a CLI), and even though it offers them, it doesn't pull the necessary system libraries to run them, so you have to install them manually:
gst-browser
(new ui): libgtk2.0
libcairo2
(tested on ubuntu)gst-blox
(old ui): tcl
tk
(not tested)I see two problems with the code: GST doesn't support Process>>sleep:
, and it uses GUI.
As for GUI, Smalltalks have very different UI libraries, Dolphin is geared towards MS Windows, GNU Smalltalk uses GNU stuff (GTK for the newser gst-browser, and TK/TCL for older gst-blox it seems), Pharo uses Athens, etc. Even if they share some concepts (such as MVC pattern), they do not really share API.
In fact it seems that GNUSmalltalk has "new" UI --- VisualGST (gst-browser) and that gst-blox is deprecated.
In any case, after some digging I end up with the following code. It creates a GTK window (UI used by gst-browser), and then it continuously updates the text.
window := GTK.GtkWindow new: GTK.Gtk gtkWindowToplevel.
window setTitle: 'Time'.
window resize: 400 height: 300.
label := GTK.GtkLabel new.
label setText: Time now printString.
label show.
window add: label.
window show.
digitalClockProcess := [[
(Delay forSeconds: 1) wait.
label setText: Time now printString.
] repeat] fork.
The code for gst-blox
would have to use tcl/tk instead, which I am not familiar with.
To run the code in gst-browser
, from top menu select 'Tools > Bottom Pane', and then paste the code to a 'Workspace' that will be in the bottom pane (you can add more workspaces via 'File > New Workspace'.