Page 1 of 3

Can`t get gtkDialog3 version of app. to work. [Solved]

Posted: Sun 14 Mar 2010, 06:07
by sunburnt
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: Select all

#! /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

Posted: Sun 14 Mar 2010, 06:23
by 01micko

Code: Select all

#! /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

Posted: Sun 14 Mar 2010, 06:55
by sunburnt
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: Select all

<window title="DM" default_width="$sizeX" default_height="sizeY"></window>
and:
gtkdialog3 -p -geometry +${posX}+${posY} --program=DRIVEMAN
# Or can it take:

Code: Select all

<window title="DM"></window>
and:
gtkdialog3 -p -geometry ${sizeX}x${sizeY}+${posX}+${posY} --program=DRIVEMAN[code

Posted: Sun 14 Mar 2010, 07:04
by 01micko
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 :)

Posted: Sun 14 Mar 2010, 07:06
by sunburnt
Sorry 01micko; I messed up my last post ( working with the wrong file ) see the revised one above...

Posted: Sun 14 Mar 2010, 07:17
by sunburnt
Also the variables don`t seem to be getting into the GUI code.

Code: Select all

  <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\">

Posted: Sun 14 Mar 2010, 07:21
by 01micko
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: Select all

VARIABLE=`some code`
export VARIABLE

Cheers

Posted: Sun 14 Mar 2010, 07:29
by sunburnt
Yes, I added this line:

Code: Select all

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...

Posted: Sun 14 Mar 2010, 07:34
by sunburnt
OOps... I needed to export them like this:

Code: Select all

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.

Posted: Sun 14 Mar 2010, 07:36
by 01micko
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/viewto ... 727#391727

and basic code for the webcam thing

Code: Select all

#!/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.

Posted: Sun 14 Mar 2010, 07:42
by 8-bit
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.

Posted: Sun 14 Mar 2010, 18:05
by sunburnt
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

Posted: Sun 14 Mar 2010, 19:52
by 8-bit
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.

Posted: Sun 14 Mar 2010, 21:10
by sunburnt
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: Select all

#! /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"

Posted: Sun 14 Mar 2010, 21:30
by 8-bit
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: Select all

#! /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

Posted: Sun 14 Mar 2010, 23:07
by sunburnt
Yep... At one point the position was working for me too, then it quit for no reason I could see.
Position works because it`s used outside of the gtkDialog3 code " between the main double quotes ".
If like gtkDialog2 it used the full line at the end, then like gtkDialog2 it would work also...
gtkdialog3 -p -geometry ${sizeX}x${sizeY}+${posX}+${posY} --program=DRIVEMAN

I added this line to test if variables were getting into the gtkdialog3 code and they are...
<button><label>Test Path</label><action>echo $appPATH</action></button>

For some reason this gtkDialog3 line won`t use it`s variables:
<window title=\"DM\" default_width=\"sizeX\" default_height=\"sizeY\">

Posted: Mon 15 Mar 2010, 05:18
by potong
I think you may be confusing long and short options here.

The help message for gtkdialog3 is:

Code: Select all

# gtkdialog3 -?
Usage:
  gtkdialog3 [OPTION...] 
Create dialog boxes and windows according to the given dialog description.For more information try 'info gtkdialog'.

Help Options:
  -?, --help                      Show help options
  --help-all                      Show all help options
  --help-gtk                      Show GTK+ Options

Application Options:
  -v, --version                   Print version information and exit.
  -d, --debug                     Debug mode prints the processed characters.
  -p, --program=variable          Get the GUI description from the environment.
  -g, --glade-xml=filename        Get the GUI description from this Glade file.
  -f, --file=filename             Get the GUI description from a regular file.
  -i, --include=filename          Include the given file when executing.
  -e, --event-driven=filename     Execute the file as an event driven program.
  -s, --stdin                     Get the GUI description from standard input.
  -w, --no-warning                Suppress warning messages.
  -G, --geometry=[XxY][+W+H]      The placement and the size of the window.
  -c, --center                    Center the windows on the screen.
  --print-ir                      Print the internal representation and exit.
  --display=DISPLAY               X display to use
So it's either -G XxY+W+H or --geometry=XxY+W+H

Also -p XXX is short for --program=XXX. (you only need one!)

If you want to add command line parameters to the geometry try:

Code: Select all

gtkdialog3 --geometry=${1-+20+30} --program=DRIVEMAN 
Then you can call the script as:

Code: Select all

./scriptname 200x400+200+300
Also
For some reason this gtkDialog3 line won`t use it`s variables:
<window title=\"DM\" default_width=\"sizeX\" default_height=\"sizeY\">
sizeY and sizeX must be prefixed by $ e.g.

Code: Select all

<window title=\"DM\" default_width=\"$sizeX\" default_height=\"$sizeY\">
otherwise they are taken as literals (not allowed in this tag)

Potong

Posted: Mon 15 Mar 2010, 16:57
by sunburnt
Thanks potong; The options that I want to know how they work are:
-f, --file=filename Get the GUI description from a regular file.
-e, --event-driven=filename Execute the file as an event driven program.

Back to basics, this code shows that gtkDialog3 also doesn`t need the variables to be exported:

Code: Select all

#! /bin/sh
LEFT=14 ; TOP=36 ; WIDTH=96 ; HEIGHT=122 #; export WIDTH ; export HEIGHT
probepart |grep -v none |sed 's#^/dev/##' |sed 's/|.*$//' |sed 's/$/||/' > /tmp/drvinfo       # make tablebox input file
export GUI="<window title=\"GUI\" default_width=\"$WIDTH\" default_height=\"$HEIGHT\"><vbox>
  <table><variable>DRIVES</variable><label>Drive|M|B</label><input>cat /tmp/drvinfo</input></table>
  <button><label>Exit</label></button></vbox></window>"
gtkdialog3 --program=GUI --geometry +"$LEFT"+"$TOP"
I`ll do more work getting the "geometry" working...

Note: It appears that gtkDialog3 won`t allow my GUI to be any narrower than about "210".
This makes my app. driveman worthless...

Posted: Mon 15 Mar 2010, 18:59
by sunburnt
### Anyone know how to get gtkDialog3 to make GUIs smaller than Width=210 , Height=140 ?

This seems to be the limit on how small the GUI will popup... DriveMan is worthless this large.

At least gtkDialog2 could control the width and height enough that my app. worked.
Barry... Are you sure you want to have gtkDialog3 only in Puppy??? It seems twitchy...

Posted: Tue 16 Mar 2010, 05:52
by sunburnt
Fortunately there is a way to get gtkDialog3 to do what you want...