Same trouble calling functions from gtkdialog...

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

Same trouble calling functions from gtkdialog...

#1 Post by sunburnt »

I keep running into this snag... :roll: Calling functions from gtkdialog.
It`s a PATH selector button and entry box.
Full GUI has inPATH, inFILE, outPATH, outFILE buttons and entry boxes.
If there`s a better way to get path and file dialogs... Please!

Code: Select all

#!/bin/sh
appNAME=`basename $0`
appDIR=/root/my-applications/$appNAME
mkdir -p $appDIR
if [ ! -s $appDIR/input.path ];then echo '/mnt' > $appDIR/input.path ;fi

inPATH() {
	SEL=`Xdialog --stdout --title " Input Path" --dselect $(<$appDIR/input.path) 0 0`
	if [ $? -eq 0 ];then echo $SEL > $appDIR/input.path ;fi
}
Encode() {
	export -f inPATH
	export appDIR

	export Encode="<window><hbox>
	<vbox>
	<frame Input File><vbox>
		<button><label>Input Path</label>
			<action>inPATH</action>
			<action>refresh:INPATH</action>
		</button>
		<entry><variable>INPATH</variable><input>cat $appDIR/input.path</input></entry>
	</vbox></frame>
	</vbox>
	</hbox></window>"
	gtkdialog3 -p Encode > $appDIR/vob-avi.encode
}

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#2 Post by zigbert »

Code: Select all

#!/bin/sh
appNAME=`basename $0`
export appDIR=/root/my-applications/$appNAME
mkdir -p $appDIR
[ ! "$INPATH" ] && INPATH=/mnt

Encode() {
   export Encode="<window>
   <frame Input File><vbox>
	<button><label>Input Path</label>
     <action type=\"fileselect\">INPATH</action>
     <action>refresh:INPATH</action>
    </button>
    <entry accept=\"directory\"><variable>INPATH</variable><input>echo $INPATH</input></entry>
   </vbox></frame>
   </window>"
   gtkdialog3 -p Encode > $appDIR/vob-avi.encode
}

Encode

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#3 Post by sunburnt »

Thanks zigbert... I can`t figure what "INPATH" does in this line.

Code: Select all

<action type=\"fileselect\">INPATH</action>
When you click the button you get /root for a path.
I wanted the dialog to come up with the path in the Entry Box.

Also the tag is "fileselect", but it`s a path or directory dialog.
What makes it that way? And how do you get a file dialog?

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#4 Post by zigbert »

sunburnt wrote:I can`t figure what "INPATH" does in this line.

Code: Select all

<action type="fileselect">INPATH</action>
INPATH defines what variable that should store the result of the file-selection box. When you refresh the <entry>, you get its new value.
sunburnt wrote:When you click the button you get /root for a path.
I wanted the dialog to come up with the path in the Entry Box.
The easy way is to add 'cd "$INPATH"' before executing the gtkdialog code. This works fine for simple tasks, but for more sophisticated guis, I think you need to build your own file-selection box. I have done that for Pburn. - You'll find it in /usr/local/pburn/box_chooser.
sunburnt wrote:Also the tag is "fileselect", but it`s a path or directory dialog.
What makes it that way? And how do you get a file dialog?
File-select is a special kind of gtk-button. -> to open the file-chooser widget. To accept only directories, <entry> is defined as 'accept="directory"'.


Sigmund

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#5 Post by sunburnt »

Thanks again zigbert. It`s strange that the Entry box would effect the FileSelect button that way.
You would think that they would be separate entities.

Post Reply