GTK

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
slavvo67
Posts: 1610
Joined: Sat 13 Oct 2012, 02:07
Location: The other Mr. 305

GTK

#1 Post 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

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#2 Post 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"

Post Reply