(patch for Bash) GTK+2 + Bash

Discussion in 'XML' started by William Park, Jul 11, 2005.

  1. William Park

    William Park Guest

    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 <>, 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/
     
    William Park, Jul 11, 2005
    #1
    1. Advertising

  2. 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 ?
     
    =?ISO-8859-1?Q?J=FCrgen_Kahrs?=, Jul 11, 2005
    #2
    1. Advertising

  3. William Park

    William Park Guest

    J?rgen Kahrs <> wrote:
    > 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 ?



    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 <>, 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/
     
    William Park, Jul 11, 2005
    #3
  4. William Park

    William Park Guest

    William Park, Jul 14, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. William Park

    (patch for Bash) try-block and exception

    William Park, Jul 31, 2004, in forum: Python
    Replies:
    6
    Views:
    405
    William Park
    Aug 2, 2004
  2. William Park
    Replies:
    0
    Views:
    588
    William Park
    Aug 2, 2004
  3. Replies:
    2
    Views:
    525
  4. Gergely Kontra
    Replies:
    2
    Views:
    251
    Joao Pedrosa
    Jun 18, 2004
  5. Alex Shulgin
    Replies:
    1
    Views:
    180
    thefed
    Nov 21, 2007
Loading...

Share This Page