GTK-Server: Remote Named Pipes Invocation

28 views
Skip to first unread message

M. David Peterson

unread,
Jan 6, 2007, 8:15:39 AM1/6/07
to llup
via Peter Fisk (thanks, Peter!),

http://www.gtk-server.org/intro.html

How does it work? The GTK-server is a standalone binary, which is able to communicate by a 2-way pipe, a named pipe or by a TCP/UDP port. The script invokes this binary, sets up a pipe or a TCP/UDP connection and prints the GTK call in plain text to the pipe or socket. The GTK-server then sends information back which can be used in the program or script.

Next to this binary there is also a configuration file, in which the user of the GTK-server has to describe the API call he wants to invoke. In the configfile every API call must be defined; the type of callback signal must be set, the return value, the number of arguments and the type of these arguments. If you are not familiar with the GTK API, you can download a default configfile from this place.

The list of currently supported languages is impressive,

Currently the following languages have been tested successfully with the GTK-server:

Seems to me that this could be a nice marriage between the functionality offered up by Kamaelia and remote invocation of processes.  This could present an interesting combination of functionality for the decentralized blogXast server efforts.

Thoughts?

--
/M:D

M. David Peterson
http://mdavid.name | http://www.oreillynet.com/pub/au/2354

Michael Sparks

unread,
Jan 6, 2007, 3:30:16 PM1/6/07
to ll...@googlegroups.com
Hi,


This seems simple enough to work with. A simple rewrite of:
http://www.gtk-server.org/demo-stdin.py.txt
I've shown below:

import Axon
from Kamaelia.File.UnixProcess import UnixProcess
from Kamaelia.Chassis.Graphline import Graphline

class GTKServerClient(Axon.ThreadedComponent.threadedcomponent):
def gtk(self, value, outbox="outbox", inbox="inbox"):
self.send(value, outbox)
while not self.dataReady("inbox"):
self.pause(0.1)
result = self.recv(inbox)
return result

def main(self):
self.gtk("gtk_init NULL NULL")
win = self.gtk("gtk_window_new 0")
self.gtk("gtk_window_set_title " + win + " \"Python Demo
program with STDIN\"")
self.gtk("gtk_widget_set_usize " + win + " 450 400")
table = self.gtk("gtk_table_new 50 50 1")
self.gtk("gtk_container_add " + win + " " + table)

button = self.gtk("gtk_button_new_with_label Exit")
self.gtk("gtk_table_attach_defaults " + table + " " + button +
" 41 49 45 49")
entry = self.gtk("gtk_entry_new")
self.gtk("gtk_table_attach_defaults " + table + " " + entry +
" 1 40 45 49")
text = self.gtk("gtk_text_new NULL NULL")
self.gtk("gtk_table_attach_defaults " + table + " " + text + "
1 49 8 44")

radio1 = self.gtk
("gtk_radio_button_new_with_label_from_widget NULL Yes")
self.gtk ("gtk_table_attach_defaults " + table + " " + radio1
+ " 1 10 1 4")
radio2 = self.gtk
("gtk_radio_button_new_with_label_from_widget " + radio1 + " No")
self.gtk ("gtk_table_attach_defaults " + table + " " + radio2
+ " 1 10 4 7")

self.gtk ("gtk_widget_show_all " + win)
self.gtk ("gtk_widget_grab_focus " + entry)

# Initialize
event = 0

# Mainloop
while event != button and event != win:
event = self.gtk ("gtk_server_callback WAIT")
if event == entry:
tmp = self.gtk ("gtk_entry_get_text " + entry)
self.gtk ("gtk_text_insert " + text + " NULL
NULL NULL " + tmp + " -1")
self.gtk ("gtk_entry_set_text " + entry + " \" \"")
# Exit GTK-server
self.gtk ("gtk_exit 0")

Graphline (
GTKLIB = UnixProcess('gtk-server stdin'),
APP = GTKServerClient(),
linkages = {
("GTKLIB", "outbox") : ("APP" , "inbox"),
("APP", "outbox") : ("GTKLIB" , "inbox"),
}
).run()

The list of languages would be quite impressive BTW, it appears to be
just a programme that is controlled either via a simple shell like interface
over stdin, tcp or UDP. (Don't get me wrong, it's a nice little app!)

However it's worth mentioning that you could also do this:

Pipeline (
ConsoleReader(">>> "),
UnixProcess('gtk-server stdin'),
ConsoleEchoer(),
).run()

And run that & interact with it manually as follows:

~> ./kamaelia-gtk-server.py
>>> gtk_init NULL NULL
>>> ok
gtk_window_new 0
>>> 134870432
gtk_window_set_title 134870432 "Python Demo program with STDIN"
>>> ok
gtk_widget_set_usize 134870432 450 400
>>> ok
gtk_table_new 50 50 1
>>> 134886848
gtk_container_add 134870432 134886848
>>> ok
gtk_button_new_with_label Exit
>>> 135283888
gtk_table_attach_defaults 134886848 135283888 41 49 45 49
>>> ok
gtk_entry_new
>>> 135283304
gtk_table_attach_defaults 134886848 135283304 1 40 45 49
>>> ok
gtk_text_new NULL NULL
>>> 135331488
gtk_table_attach_defaults 134886848 135331488 1 49 8 44
>>> ok
gtk_radio_button_new_with_label_from_widget NULL Yes
>>> 135373704
gtk_table_attach_defaults 134886848 135373704 1 10 1 4
>>> ok
gtk_radio_button_new_with_label_from_widget 135373704 No
>>> 135326168
gtk_table_attach_defaults 134886848 135326168 1 10 4 7
>>> ok
gtk_widget_show_all 134870432
>>> ok
gtk_widget_grab_focus 135283304
>>> ok
gtk_server_callback WAIT
>>>

(at this point in time the window appears BTW, showing this has worked)

I doubt much of the code would change dramatically for the TCP based
code, nor the UDP.


Michael.

On 1/6/07, M. David Peterson <xmlh...@gmail.com> wrote:
> via Peter Fisk (thanks, Peter!),
>

> demoscript on this site).Seems to me that this could be a nice marriage

M. David Peterson

unread,
Jan 6, 2007, 4:22:21 PM1/6/07
to ll...@googlegroups.com
Hey Michael,


Pipeline (
       ConsoleReader(">>> "),
       UnixProcess('gtk-server stdin'),
       ConsoleEchoer(),
   ).run()

Oh, very nice!  I need to play with this more...  Thanks!

Oh, one thing I should clarify >> In a follow-up email from Uche (his email address changed and it didn't make it through the Google Groups email filters) he points out that this is specific to GTK-based apps ... In other words, this doesn't allow for remote scripting of any old Unix app, and instead GTK-specific applications.  I was aware of this, but I should have clarified that this seems like a nice way to gain the benefit of using a cross-platform UI tool for interacting with decentralized peers.  So from a blogXast server perspective, this *could* become a nice way, for example, to combine Kamaelia with the ability to trigger a UI flag of some sort when a match is made to a particular query.  So if we were building a group IM client, and wanted to provide the ability to do a background search of keyword phrases that were being discussed, when a match was made, each client could be notified via a particular UI component of some sort.

M. David Peterson

unread,
Jan 6, 2007, 4:23:48 PM1/6/07
to ll...@googlegroups.com
Oh, and one other thing... from a nuXleus standpoint, given the fact that its all web-based interaction, this could provide a nice way of interacting with desktop apps built on top of GTK.

On 1/6/07, M. David Peterson <xmlh...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages