Author |
Message |
sunburnt

Joined: 08 Jun 2005 Posts: 5087 Location: Arizona, U.S.A.
|
Posted: Sun 14 Mar 2010, 02:07 Post subject:
Can`t get gtkDialog3 version of app. to work. [Solved] |
|
I can`t make gtkDialog3 work at all, and it seems that it can`t be used with "" to enclose it,
so variables can`t be passed into the dialog`s code because of: <action type="clear">.
I modded the code so the GUI should run by itself, hard coded all the paths and data.
Variables are definately the best way to pass data. It`s hard to know how to get it to work.
Code: | #! /bin/sh
probepart |sed 's#^/dev/##' |sed 's/|.*$//' |sed 's/$/||/' > /tmp/drvinfo # make tablebox input file
export DRIVEMAN='
<window title=\"DM\" default_width=\"96\" default_height=\"150\">
<vbox>
<table><variable>DRIVES</variable><label>Drive|M|B</label>
<input>cat /tmp/drvinfo</input></table>
<hbox>
<button><label>ROX-file</label><action>/root/my-applications/driveman/driveman btnMNT \$DRIVES rox</action>
<action type="clear">DRIVES</action><action type="refresh">DRIVES</action></button>
<button><label>Boot</label><action>/root/my-applications/driveman/driveman btnBOOT \$DRIVES</action>
<action type="clear">DRIVES</action><action type="refresh">DRIVES</action></button>
</hbox><hbox>
<button><label>Mt-UnM</label><action>/root/my-applications/driveman/driveman btnMNT \$DRIVES</action>
<action type="clear">DRIVES</action><action type="refresh">DRIVES</action></button>
<button><label>CkFs</label><action>/root/my-applications/driveman/driveman ckDRV \$DRIVES</action></button>
</hbox><hbox>
<button><label>Settings</label><action>/root/my-applications/driveman/driveman btnSET</action></button>
<button><label>Exit</label><action>/root/my-applications/driveman/driveman cancel</action></button>
</hbox><hbox>
<button>
<label>launch</label>
<action>driveman btnSET</action>
</button>
<button>
<label>Exit</label>
<action>$appPATH/driveman cancel</action>
</button>
</hbox>
</vbox>
'
gtkdialog3 -p -geometry +20+30 --program=DRIVEMAN
#gtkdialog3 -p -geometry ${sizeX}x${sizeY}+${posX}+${posY} --program=DRIVEMAN
|
Last edited by sunburnt on Sun 04 Apr 2010, 16:56; edited 1 time in total
|
Back to top
|
|
 |
01micko

Joined: 11 Oct 2008 Posts: 8670 Location: qld
|
Posted: Sun 14 Mar 2010, 02:23 Post subject:
|
|
Code: | #! /bin/sh
probepart |sed 's#^/dev/##' |sed 's/|.*$//' |sed 's/$/||/' > /tmp/drvinfo # make tablebox input file
export DRIVEMAN='
<window title="DM" default_width="96" default_height="150">
<vbox>
<table><variable>DRIVES</variable><label>Drive|M|B</label>
<input>cat /tmp/drvinfo</input></table>
<hbox>
<button><label>ROX-file</label><action>/root/my-applications/driveman/driveman btnMNT $DRIVES rox</action>
<action type="clear">DRIVES</action><action type="refresh">DRIVES</action></button>
<button><label>Boot</label><action>/root/my-applications/driveman/driveman btnBOOT $DRIVES</action>
<action type="clear">DRIVES</action><action type="refresh">DRIVES</action></button>
</hbox><hbox>
<button><label>Mt-UnM</label><action>/root/my-applications/driveman/driveman btnMNT $DRIVES</action>
<action type="clear">DRIVES</action><action type="refresh">DRIVES</action></button>
<button><label>CkFs</label><action>/root/my-applications/driveman/driveman ckDRV $DRIVES</action></button>
</hbox><hbox>
<button><label>Settings</label><action>/root/my-applications/driveman/driveman btnSET</action></button>
<button><label>Exit</label><action>/root/my-applications/driveman/driveman cancel</action></button>
</hbox><hbox>
<button>
<label>launch</label>
<action>driveman btnSET</action>
</button>
<button>
<label>Exit</label>
<action>$appPATH/driveman cancel</action>
</button>
</hbox>
</vbox>
</window>
'
gtkdialog3 -p -geometry +20+30 --program=DRIVEMAN
#gtkdialog3 -p -geometry ${sizeX}x${sizeY}+${posX}+${posY} --program=DRIVEMAN |
Hi sunburnt
2 things, since you are enclosing in ' single ' quotes, none of the escapes of double quotes are needed, escapes of $ are not needed either
The other.. you forgot the </window> tag at the end
HTH
Cheers
edit: if you use double quotes, you then need to escape every double quote between the first and last
_________________ Puppy Linux Blog - contact me for access
|
Back to top
|
|
 |
sunburnt

Joined: 08 Jun 2005 Posts: 5087 Location: Arizona, U.S.A.
|
Posted: Sun 14 Mar 2010, 02:55 Post subject:
|
|
Hi 01micko; You`re right of course, I forgot the closing tag...
I added \" to all the <action type=\" and it works.
I think I`ll be able to get it working now. Thanks... Terry
P.S.
# Is it best to use:
Code: | <window title="DM" default_width="$sizeX" default_height="sizeY"></window>
and:
gtkdialog3 -p -geometry +${posX}+${posY} --program=DRIVEMAN |
# Or can it take:
Code: | <window title="DM"></window>
and:
gtkdialog3 -p -geometry ${sizeX}x${sizeY}+${posX}+${posY} --program=DRIVEMAN[code |
Last edited by sunburnt on Sun 14 Mar 2010, 03:04; edited 1 time in total
|
Back to top
|
|
 |
01micko

Joined: 11 Oct 2008 Posts: 8670 Location: qld
|
Posted: Sun 14 Mar 2010, 03:04 Post subject:
|
|
Hi sunburnt
If you copy/paste the code I posted it works.. screeny below.
I notice in your post you have ...<action type="\clear\">
should be.. <action type=\"clear\">
with the escape before the quote.
Driveman looks like a good idea to me
Description |
|
Filesize |
15.81 KB |
Viewed |
754 Time(s) |

|
_________________ Puppy Linux Blog - contact me for access
|
Back to top
|
|
 |
sunburnt

Joined: 08 Jun 2005 Posts: 5087 Location: Arizona, U.S.A.
|
Posted: Sun 14 Mar 2010, 03:06 Post subject:
|
|
Sorry 01micko; I messed up my last post ( working with the wrong file ) see the revised one above...
|
Back to top
|
|
 |
sunburnt

Joined: 08 Jun 2005 Posts: 5087 Location: Arizona, U.S.A.
|
Posted: Sun 14 Mar 2010, 03:17 Post subject:
|
|
Also the variables don`t seem to be getting into the GUI code.
Code: | <button><label>Exit</label><action>/root/my-applications/driveman/driveman cancel</action></button>
<button><label>Exit</label><action>$appPATH/driveman cancel</action></button> |
The top button with hard coded path works, but bottom one with variable doesn`t.
The argument echo shows that the path $appPATH is coming into the script.
And the Size data isn`t getting through either... <window title=\"DM\" default_width=\"$sizeX\" default_height=\"$sizeY\">
|
Back to top
|
|
 |
01micko

Joined: 11 Oct 2008 Posts: 8670 Location: qld
|
Posted: Sun 14 Mar 2010, 03:21 Post subject:
|
|
I would use your first code option (your previous post), but others may have different or better opinions, Ah use, width-request=\"100\" height-request=\"200\" or whatever size you need.
Did you export the variables?
Code: | VARIABLE=`some code`
export VARIABLE |
Cheers
_________________ Puppy Linux Blog - contact me for access
|
Back to top
|
|
 |
sunburnt

Joined: 08 Jun 2005 Posts: 5087 Location: Arizona, U.S.A.
|
Posted: Sun 14 Mar 2010, 03:29 Post subject:
|
|
Yes, I added this line:
Code: | export $sizeX $sizeY $posX $posY $appPATH
export DRIVEMAN=" |
And now even the upper [ Exit ] button doesn`t work setting the position.
I put the export line in and out and it makes no difference. Didn`t change anything...
|
Back to top
|
|
 |
sunburnt

Joined: 08 Jun 2005 Posts: 5087 Location: Arizona, U.S.A.
|
Posted: Sun 14 Mar 2010, 03:34 Post subject:
|
|
OOps... I needed to export them like this:
Code: | cxport sizeX sizeY posX posY |
But it still doesn`t work. And the GUI doesn`t run all the time, it just comes back to the prompt.
|
Back to top
|
|
 |
01micko

Joined: 11 Oct 2008 Posts: 8670 Location: qld
|
Posted: Sun 14 Mar 2010, 03:36 Post subject:
|
|
I think, and I'm no expert but it usually works for me, drop the "$" and export each var individually.
I wrote a silly slideshow program based entirely on gtkdialog, and a webcam app also base entirely on gtkdialog, and had no trouble sizing and placing on the screen, they are somewhere in zigbert's stardust puplet threads. Give me a moment and I'll find the links for you, the code could be useful.
Cheers
edit: the slideshow, http://www.murga-linux.com/puppy/viewtopic.php?p=391727#391727
and basic code for the webcam thing
Code: | #!/bin/bash
function KILL(){
kill `ps | grep PIC | awk '{print \$1}'` 2> /dev/null
kill `ps | grep -w PLAY | awk '{print $1}'` 2>/dev/null
}
export -f KILL
XSCREEN=`xrandr -q | grep current | awk '{print $8}'`
YSCREEN=`xrandr -q | grep current | awk '{print $10}'`
XPOS=`dc $XSCREEN 340 sub p`
YPOS=`dc $YSCREEN 300 sub p`
export XPOS
export YPOS
GUIYPOS=`dc $YPOS 70 sub p`
export GUIYPOS
function PLAY(){
while true ; do
ffmpeg -y -r 1 -t 1 -f video4linux2 -s qvga -i /dev/video0 /tmp/camshot%d.jpg
kill `ps | grep PIC | awk '{print \$1}'` 2> /dev/null
export PIC='<window><pixmap><input file>/tmp/camshot1.jpg</input></pixmap></window>'
gtkdialog3 --class=jwm-applet -p PIC --geometry +$XPOS+$YPOS &
sleep 1
done
}
export -f PLAY
export camshow="
<vbox>
<hbox>
<button>
<input file stock=\"gtk-media-play\"></input>
<action>PLAY &</action>
</button>
<button>
<input file stock=\"gtk-media-stop\"></input>
<action>KILL &</action>
</button>
</hbox>
</vbox>"
gtkdialog3 -p camshow --geometry +$XPOS+$GUIYPOS &
unset camshow |
Also if you want to keep the gui a set distance from top left then you wouldn't need the xrandr function, I think later I grepped screen res form xorg.conf anyway, but academic really since you want top left.
Last edited by 01micko on Sun 14 Mar 2010, 03:45; edited 1 time in total
|
Back to top
|
|
 |
8-bit

Joined: 03 Apr 2007 Posts: 3425 Location: Oregon
|
Posted: Sun 14 Mar 2010, 03:42 Post subject:
|
|
Sunburnt,
See my latest PM as far as saving and using window position and size.
And If you want the last exit button to just exit DriveManager, just do not put an action line in it.
I ran the program from a terminal and the $appPath variable was wrong for some reason and trying to find driveman in /.
Also, I modified it slightly since the Settings button tried to take it to a nonexistant program.
|
Back to top
|
|
 |
sunburnt

Joined: 08 Jun 2005 Posts: 5087 Location: Arizona, U.S.A.
|
Posted: Sun 14 Mar 2010, 14:05 Post subject:
|
|
I`ve modified it to both of these posts and it still doesn`t position or size the GUI.
In gtkDialog2 exporting variables isn`t needed to pass them, it doesn`t work either way
|
Back to top
|
|
 |
8-bit

Joined: 03 Apr 2007 Posts: 3425 Location: Oregon
|
Posted: Sun 14 Mar 2010, 15:52 Post subject:
Subject description: Modified driveman script for test |
|
sunburnt wrote: | I`ve modified it to both of these posts and it still doesn`t position or size the GUI.
In gtkDialog2 exporting variables isn`t needed to pass them, it doesn`t work either way |
I played with your driveman script and I have got the window position save to work to an extent.
I did not add a line to check for "DMconf" before trying to run it and also, I changed the "launch" button to "Save Pos."
I have not figured out how to call the subroutine while the program is running with an action line without a button.
But it is a start.
Description |
Still needs work! But may give you some ideas.
|

Download |
Filename |
driveman_test.tar.gz |
Filesize |
889 Bytes |
Downloaded |
374 Time(s) |
|
Back to top
|
|
 |
sunburnt

Joined: 08 Jun 2005 Posts: 5087 Location: Arizona, U.S.A.
|
Posted: Sun 14 Mar 2010, 17:10 Post subject:
|
|
I modded it to try to get it to work, no luck though...
You can see the info`s being saved, but the GUI stays the same, no positioning or sizing.
At least I got the exit button to do the work of saving the info and closing the GUI.
Code: | #! /bin/sh
echo '============'
probepart |grep -v none |sed 's#^/dev/##' |sed 's/|.*$//' |sed 's/$/||/' > /tmp/drvinfo # make tablebox input file
appPATH=/root/my-applications/bin
save_geometry (){
echo '### Save function.'
echo '=================='
XWININFO=`xwininfo -stats -name DM`
H=`echo "$XWININFO" | grep 'Height:' | awk '{print $2}'`
W=`echo "$XWININFO" | grep 'Width:' | awk '{print $2}'`
X1=`echo "$XWININFO" | grep 'Absolute upper-left X' | awk '{print $4}'`
Y1=`echo "$XWININFO" | grep 'Absolute upper-left Y' | awk '{print $4}'`
X2=`echo "$XWININFO" | grep 'Relative upper-left X' | awk '{print $4}'`
Y2=`echo "$XWININFO" | grep 'Relative upper-left Y' | awk '{print $4}'`
X=$(($X1-$X2))
Y=$(($Y1-$Y2))
echo "export H=$H" > $appPATH/guiinfo
echo "export W=$W" >> $appPATH/guiinfo
echo "export X=$X" >> $appPATH/guiinfo
echo "export Y=$Y" >> $appPATH/guiinfo
chmod 700 $appPATH/guiinfo
cat $appPATH/guiinfo
echo '============'
psID=`ps |grep 'program=DRIVEMAN' |egrep -v '(grep|geany)' |awk '{print $1}'` # exit... kill the GUI
if [ -n "$psID" ];then kill $psID ;fi
}
export -f save_geometry
[ -f $appPATH/guiinfo ] && $appPATH/guiinfo ######## I think this line needs to be like the next line:
#[ -f $appPATH/guiinfo ] && . $appPATH/guiinfo ######## I think it needs the " . ": " . $appPATH/guiinfo "
export DRIVEMAN='
<window title="DM" default_height="$H" default_width="$W">
<vbox>
<table><variable>DRIVES</variable><label>Drive|M|B</label>
<input>cat /tmp/drvinfo</input></table>
<hbox>
<button><label>Exit</label><action>save_geometry</action></button>
</hbox>
</vbox>
</window>
'
gtkdialog3 --program=DRIVEMAN --geometry +"$X"+"$Y" |
|
Back to top
|
|
 |
8-bit

Joined: 03 Apr 2007 Posts: 3425 Location: Oregon
|
Posted: Sun 14 Mar 2010, 17:30 Post subject:
|
|
This is the latest I came up with.
I used it with your original files with the exception of driveman.
I could not get the window resize to work, only the position.
There is a light at the end of the tunnel. Have faith!
Code: |
#! /bin/sh
probepart |sed 's#^/dev/##' |sed 's/|.*$//' |sed 's/$/||/' > /tmp/drvinfo # make tablebox input file
IN="`which /root/my-applications/driveman/DMconfig`"
if [ -z $IN ];then
echo ""
else . /root/my-applications/driveman/DMconfig
fi
save_geometry (){
XWININFO=`xwininfo -stats -name DM`
HEIGHT=`echo "$XWININFO" | grep 'Height:' | awk '{print $2}'`
WIDTH=`echo "$XWININFO" | grep 'Width:' | awk '{print $2}'`
X1=`echo "$XWININFO" | grep 'Absolute upper-left X' | awk '{print $4}'`
Y1=`echo "$XWININFO" | grep 'Absolute upper-left Y' | awk '{print $4}'`
X2=`echo "$XWININFO" | grep 'Relative upper-left X' | awk '{print $4}'`
Y2=`echo "$XWININFO" | grep 'Relative upper-left Y' | awk '{print $4}'`
X=$(($X1-$X2))
Y=$(($Y1-$Y2))
echo "export HEIGHT=$HEIGHT" > /root/my-applications/driveman/DMconfig
echo "export WIDTH=$WIDTH" >> /root/my-applications/driveman/DMconfig
echo "export X=$X" >> /root/my-applications/driveman/DMconfig
echo "export Y=$Y" >> /root/my-applications/driveman/DMconfig
chmod 700 /root/my-applications/driveman/DMconfig
}
export -f save_geometry
[ -f /root/my-applications/driveman/DMconfig ] && /root/my-applications/driveman/DMconfig
export DRIVEMAN='
<window title="DM"default_height="$HEIGHT" default_width="$WIDTH">
<vbox>
<table><variable>DRIVES</variable><label>Drive|M|B</label>
<input>cat /tmp/drvinfo</input></table>
<hbox>
<button><label>ROX-file</label><action>/root/my-applications/driveman/driveman btnMNT $DRIVES rox</action>
<action type="clear">DRIVES</action><action type="refresh">DRIVES</action></button>
<button><label>Boot</label><action>/root/my-applications/driveman/driveman btnBOOT $DRIVES</action>
<action type="clear">DRIVES</action><action type="refresh">DRIVES</action></button>
</hbox><hbox>
<button><label>Mt-UnM</label><action>/root/my-applications/driveman/driveman btnMNT $DRIVES</action>
<action type="clear">DRIVES</action><action type="refresh">DRIVES</action></button>
<button><label>CkFs</label><action>/root/my-applications/driveman/driveman ckDRV $DRIVES</action></button>
</hbox><hbox>
<button><label>Settings</label><action>/root/my-applications/driveman/driveman-set.gtk btnSET</action></button>
<button><label>Exit</label><action>/root/my-applications/driveman/driveman cancel</action></button>
</hbox><hbox>
<button>
<label>Set Pos.</label>
<action>save_geometry</action>
</button>
<button>
<label>Exit</label>
</button>
</hbox>
</vbox>
</window>
'
gtkdialog3 --program=DRIVEMAN --geometry +"$X"+"$Y"
#gtkdialog3 -p -geometry ${sizeX}x${sizeY}+${posX}+${posY} --program=DRIVEMAN
|
|
Back to top
|
|
 |
|