[GTK] Status report

goran.krampe at bluefish.se goran.krampe at bluefish.se
Thu Apr 1 09:43:56 UTC 2004


Hi all!

There are a few people interested in native UIs from Squeak so I thought
I could write a short report from what I know.

Ragnar is plumbing away with a Socket based protocol to drive Gtk,
exactly what he can do right now with it I am not sure. We are chatting
and exchanging experiences on IRC.

I have worked on getting some form of callback working and I am pleased
to say that I have gotten something together!

There are a bunch of constraints with it (like for example only working
currently with signals that have two specific arguments - I hardcoded
that to get moving) but it actually works!

Some sample code:

| gtk xml win1 win2 button1 button2 button3 button4 |
	gtk _ Gtk default.
"Start a background process calling the plugin every 5 ms to drive the
Gtk event loop and get callbacks back"
	gtk startEventProcessIfNotRunning.
	xml _ Gtk simple2ButtonsXML.
	win1 _ GladeXML fromXMLString: xml.
	xml _ xml copyReplaceAll: 'button1' with: 'button3'.
	xml _ xml copyReplaceAll: 'button2' with: 'button4'.
	win2 _ GladeXML fromXMLString: xml.
"Creates and opens the windows"
	win1 load.
	win2 load.
"Hooks up the named handlers in Gtk"
	win1 signalConnectData: 'on_button1_clicked'; signalConnectData:
'on_button2_clicked'.
	win2 signalConnectData: 'on_button3_clicked'; signalConnectData:
'on_button4_clicked'.
	button1 _ win1 widgetNamed: 'button1'.
	button2 _ win1 widgetNamed: 'button2'.
	button3 _ win2 widgetNamed: 'button3'.
	button4 _ win2 widgetNamed: 'button4'.
"Register event handlers on the Squeak side"
	button1 when: 'on_button1_clicked' asSymbol send: #show: to: Transcript
with: 'Button1 clicked!'.
	button2 when: 'on_button2_clicked' asSymbol send: #show: to: Transcript
with: 'Button2 clicked!'.
	button3 when: 'on_button3_clicked' asSymbol send: #show: to: Transcript
with: 'Button3 clicked!'.
	button4 when: 'on_button4_clicked' asSymbol send: #show: to: Transcript
with: 'Button4 clicked!'

-----
The above will open two native win32 windows with Gtk painting the UI
inside. The UI is 2 buttons in each window. Pressing any of the four
buttons will cause a printout in Transcript.

As you can see above you first need to "activate" the handlers named in
the Glade source using #signalConnectData:. Then you simply get an
instance of GtkWidget (using #widgetNamed:) and use the new event
protocol to register a message send on that same handler name.

Avi mentioned that this the event registering (last 4 lines) is not
necessarily how you would use Glade - but that is all on the Squeak side
so we can easily change it or have multiple approaches.

Anyway, just wanted to show some progress. Demo zip and plugin source is
available at:

http://anakin.bluefish.se/gohu/25

regards, Göran

PS. Getting this to build properly on win32 is an exercise in itself.
Don't try it if you don't really want to do it. Among other things I had
to rename library files to other extensions etc. Phew.



More information about the Squeak-dev mailing list