about gtk server

danil osipchuk danil at tsnet.ru
Wed Apr 7 11:00:17 UTC 2004


Hello all
Recently I played with newLISP (a very nice tiny one: 
http://newlisp.org) and noticed that it uses gtk server 
(http://www.turtle.dds.nl/gtk-server/) for GUI construction.

It is very easy to do the same with squeak (download server and sample 
config, and simply follow one of examples). However a resulting UI is 
considerably laggish (because of current network code implementation, I 
suspect).
I was not attentive during last gtk discussions, so I may be missing 
something, but anyway - what Goran and other interested think about this?

Danil
-------------- next part --------------
Object subclass: #GTKTest
	instanceVariableNames: 'socketStream win tbl btn ent txt radio1 radio2'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'GTKServerTest'!
!GTKTest commentStamp: 'dao 4/7/2004 14:35' prior: 0!
launch your 
	gtk-server.exe 127.0.0.1:5000 
	
and doIt:

		"GTKTest default demo"!


!GTKTest methodsFor: 'gtk-init' stamp: 'dao 4/7/2004 12:45'!
gtkInit
	self gtkExec: 'gtk_init(NULL, NULL)'.! !


!GTKTest methodsFor: 'gtk-private' stamp: 'dao 4/7/2004 14:17'!
gtkExec: aString
	| result |

	socketStream sendCommand: aString.
	result _ socketStream nextLineLf.
	Transcript show: aString ; space; show: result; cr.
	^result! !

!GTKTest methodsFor: 'gtk-private' stamp: 'dao 4/7/2004 14:06'!
gtkExec: aString withArgs: aCollection
	| cmdLine |
	cmdLine _ aString.
	1 to: aCollection size do: 
		[:i | 
			cmdLine _ cmdLine
				copyReplaceTokens: ('%' , i asString)
				with: (aCollection at: i)].
			
	^self gtkExec: cmdLine
! !


!GTKTest methodsFor: 'demo' stamp: 'dao 4/7/2004 14:32'!
createDemoWindow
	
	win := self gtkExec: 'gtk_window_new(0)'.
	self gtkExec: 'gtk_window_set_title (%1 , Scriptbasic Demo program)' withArgs: {win}.
	self gtkExec: 'gtk_widget_set_usize(%1 , 450, 400)' withArgs: {win}.
	
	tbl := self gtkExec: 'gtk_table_new (50, 50, 1 )'.
	self gtkExec: 'gtk_container_add(%1, %2 )' withArgs: {win. tbl}.
	
	btn := self gtkExec: 'gtk_button_new_with_label(Exit)'.
	self gtkExec: 'gtk_table_attach_defaults(%1 ,%2 , 41, 49, 45, 49)' withArgs: {tbl. btn}.
	
	ent := self gtkExec: 'gtk_entry_new()'.
	self gtkExec: 'gtk_table_attach_defaults(%1, %2, 1, 40, 45, 49)' withArgs: {tbl. ent}.
	txt := self gtkExec: 'gtk_text_new(NULL, NULL)'.
	self gtkExec: 'gtk_table_attach_defaults( %1, %2, 1, 49, 8, 44)' withArgs: {tbl. txt}.
	
	radio1 := self gtkExec: 'gtk_radio_button_new_with_label_from_widget(NULL, Yes)'.
	self gtkExec: 'gtk_table_attach_defaults(%1, %2, 1, 10, 1, 3)' withArgs: {tbl. radio1}.
	radio2 := self gtkExec: 'gtk_radio_button_new_with_label_from_widget(%1 , No)' withArgs: {radio1}.

	self gtkExec: 'gtk_table_attach_defaults( %1, %2, 1, 10, 4, 7)' withArgs: {tbl. radio2}.
	self gtkExec: 'gtk_widget_show(%1)' withArgs: {btn}.
	self gtkExec: 'gtk_widget_show(%1)' withArgs: {ent}.
	self gtkExec: 'gtk_widget_show(%1)' withArgs: {txt}.
	self gtkExec: 'gtk_widget_show(%1)' withArgs: {radio1}.
	self gtkExec: 'gtk_widget_show(%1)' withArgs: {radio2}.
	self gtkExec: 'gtk_widget_show(%1)' withArgs: {tbl}.
	self gtkExec: 'gtk_widget_show(%1)' withArgs: {win}.
	self gtkExec: 'gtk_widget_grab_focus(%1)' withArgs: {ent}.
	^ win! !

!GTKTest methodsFor: 'demo' stamp: 'dao 4/7/2004 14:42'!
demo
	
	| evt |
	evt _ 0.
	self gtkInit.
	self createDemoWindow.
	
	[evt asInteger isZero] whileTrue:
		[ | tmp |
			self gtkExec: 'gtk_main_iteration()'.
			tmp _ self gtkExec: 'gtk_server_callback(%1)' withArgs: {ent}.
			(tmp asInteger isZero) ifFalse: [
				tmp _ self gtkExec: 'gtk_entry_get_text(%1)' withArgs: {ent}.
				tmp _ self gtkExec: 'gtk_text_insert(%1, NULL, NULL, NULL, %2, -1)' withArgs: {txt. tmp}.
				tmp _ self gtkExec: 'gtk_entry_set_text(%1, )' withArgs: {ent}. ].
			
			evt _ self gtkExec: 'gtk_server_callback(%1)' withArgs: {btn}.].
		
	[self gtkExec: 'gtk_exit(0)'] on: Error do: ["socket died with server"].

		
		
		
		    				
			! !


!GTKTest methodsFor: 'accessing' stamp: 'dao 4/7/2004 12:11'!
socketStream: ss
	
	socketStream _ ss! !

"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

GTKTest class
	instanceVariableNames: ''!

!GTKTest class methodsFor: 'as yet unclassified' stamp: 'dao 4/7/2004 12:24'!
default 
	"self default"
	^self onHost: 'localhost' port: 5000
! !

!GTKTest class methodsFor: 'as yet unclassified' stamp: 'dao 4/7/2004 12:12'!
onHost: hostName port: portNumber

	^self new
		socketStream: (SocketStream 	openConnectionToHostNamed: hostName	port: portNumber)! !


More information about the Squeak-dev mailing list