(patch for Bash) GTK+2 + Bash

W

William Park

I'm very excited to announce shell interface to GTK+2 (2.6.1) for Bash.
It read XML syntax describing the widget layout, and returns user selection as
shell variable or runs shell command as callback. It's designed for
simple GUI dialog or layout, with the emphasis on getting the user data
back into shell.

For the moment, the shell variable and command are disabled. It just
prints to stdout, instead. But, you can change it easily.


Ref:
http://freshmeat.net/projects/bashdiff/
http://home.eol.ca/~parkw/index.html#gtk

Usage:
gtk < file.xml
gtk file.xml...


For example, GTK+2 tutorial has 2 button 'helloworld2.c',

http://www.gtk.org/tutorial/sec-anupgradedhelloworld.html
http://www.gtk.org/tutorial/images/helloworld2.png

You can now build the same thing with

<window border="10" label="Hello Buttons!">
<hbox>
<button label="Button 1" clicked="echo Button 1 was pressed" />
<button label="Button 2" clicked="echo Button 2 was pressed" />
</hbox>
</window>

Or,

gtk << EOF
<window>
...
</window>
EOF


Feedbacks are welcome. Enjoy!

--
William Park <[email protected]>, Toronto, Canada
ThinFlash: Linux thin-client on USB key (flash) drive
http://home.eol.ca/~parkw/thinflash.html
BashDiff: Super Bash shell
http://freshmeat.net/projects/bashdiff/
 
?

=?ISO-8859-1?Q?J=FCrgen_Kahrs?=

Hello William,
http://www.gtk.org/tutorial/images/helloworld2.png

You can now build the same thing with

<window border="10" label="Hello Buttons!">
<hbox>
<button label="Button 1" clicked="echo Button 1 was pressed" />
<button label="Button 2" clicked="echo Button 2 was pressed" />
</hbox>
</window>

Do you have a pointer to a description of the XML
data that is accepted by GTK and by your extended bash ?
Is this some kind of competition for Mozilla's XUL ?
 
W

William Park

J?rgen Kahrs said:
Hello William,


Do you have a pointer to a description of the XML
data that is accepted by GTK and by your extended bash ?


Hi Juergen,

It uses Expat to parse the input syntax. As for the actual format, you
can only have 2 variations:
<tag att="value" ...></tag>
<tag att="value"/>
where
<tag></tag> is used for widget which contains child widget.

Currently supported tags are listed in
http://home.eol.ca/~parkw/index.html#gtk
It's the same help file that you get from
help gtk

I'll add more examples to the website. Right now, it can do most
'dialog' and 'Xdialog' stuffs, except for calendar. I'll add it soon.
It's really designed for presenting relatively static and simple GUI
layout or dialog. And, getting the info back into shell script.

Is this some kind of competition for Mozilla's XUL ?

Unfortunately, no. I looked at XUL, and couldn't understand it. You
can display buttons or text fields. Okey, so user clicks a button or
types some text. How do you find out which button he clicked or what he
typed? Because I need that info in my shell script.

I looked at Tk + Ksh. I could've done the same thing for GTK+, that is,
function for function binding. But, it's downright criminal to force
that kind of details onto users.

The best comparison is 'gtkdialog'. It also uses XML syntax, but uses
lex/yacc to parse it. Because it's separate program, I have the same
problem of getting data back into shell, as using 'awk' or 'sed'.

Since I do Expat already, I used the same mechanism. Expat calls
start_handler
end_handler
data_handler
as it encounters various tags. From here, I call relevant GTK+
functions and in right order. 'start_handler' is massive. :)
Fortunately, the order of GTK+ call is pretty much in sync with the
order of Expat callbacks. You don't have to fake it much.

--
William Park <[email protected]>, Toronto, Canada
ThinFlash: Linux thin-client on USB key (flash) drive
http://home.eol.ca/~parkw/thinflash.html
BashDiff: Super Bash shell
http://freshmeat.net/projects/bashdiff/
 
W

William Park

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,001
Messages
2,570,249
Members
46,846
Latest member
BettinaOsw

Latest Threads

Top