Page 1 of 1

GTK

Posted: Sun 28 Jun 2015, 03:48
by slavvo67
Can anyone help me pass the directory choice in the script below to a variable? The language below came with the GTK Dialog examples in one of the puppy distros. I just want to pull out the directory choice into a variable and cd to that variable.

#!/bin/sh

GTKDIALOG=gtkdialog

funcbtnCreate() {
echo '<button>
<input file stock="gtk-'$2'"></input>
<action>fileselect:ent'$1'</action>
</button>'
}

MAIN_DIALOG='
<window title="Fileselect Advanced" resizable="false" width-request="500">
<vbox>
<vbox border-width="20" spacing="10">
<hbox>
<text label="folder" width-request="80"></text>
<entry fs-title="Select an existing folder" fs-action="folder">
<variable>ent3</variable>
</entry>
'"`funcbtnCreate 3 open`"'
</hbox>
</vbox>
<hseparator></hseparator>
<hbox homogeneous="true">
<button ok></button>
</hbox>
</vbox>
</window>
'

export MAIN_DIALOG

case $1 in
-d | --dump) echo "$MAIN_DIALOG" ;;
*) $GTKDIALOG --program=MAIN_DIALOG ;;
esac

Posted: Sun 28 Jun 2015, 04:31
by MochiMoppel
The easiest way is to remove the trailing case statement.
You don't have to assign the directory choice to a variable because it is already assigned (to variable ent3):

Code: Select all

.
.
.
export MAIN_DIALOG 

eval $($GTKDIALOG --program=MAIN_DIALOG)
cd "$ent3"