Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sat 19 Apr 2014, 05:36
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Can`t get gtkDialog3 version of app. to work. [Solved]
Post new topic   Reply to topic View previous topic :: View next topic
Page 2 of 4 [53 Posts]   Goto page: Previous 1, 2, 3, 4 Next
Author Message
sunburnt


Joined: 08 Jun 2005
Posts: 4982
Location: Arizona, U.S.A.

PostPosted: Sun 14 Mar 2010, 19:07    Post subject:  

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\">
Back to top
View user's profile Send private message 
potong

Joined: 06 Mar 2009
Posts: 88

PostPosted: Mon 15 Mar 2010, 01:18    Post subject:  

I think you may be confusing long and short options here.

The help message for gtkdialog3 is:
Code:
# 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:
gtkdialog3 --geometry=${1-+20+30} --program=DRIVEMAN

Then you can call the script as:
Code:
./scriptname 200x400+200+300


Also
Quote:
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:
<window title=\"DM\" default_width=\"$sizeX\" default_height=\"$sizeY\">

otherwise they are taken as literals (not allowed in this tag)

Potong
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 4982
Location: Arizona, U.S.A.

PostPosted: Mon 15 Mar 2010, 12:57    Post subject:  

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

Last edited by sunburnt on Mon 15 Mar 2010, 15:11; edited 2 times in total
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 4982
Location: Arizona, U.S.A.

PostPosted: Mon 15 Mar 2010, 14:59    Post subject:  

### 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...
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 4982
Location: Arizona, U.S.A.

PostPosted: Tue 16 Mar 2010, 01:52    Post subject:  

Fortunately there is a way to get gtkDialog3 to do what you want...
Last edited by sunburnt on Tue 16 Mar 2010, 14:25; edited 1 time in total
Back to top
View user's profile Send private message 
potong

Joined: 06 Mar 2009
Posts: 88

PostPosted: Tue 16 Mar 2010, 02:04    Post subject:  

sunburnt: HTH
Code:
#!/bin/sh -a
# -a option exports all variables and functions

RIGHT=14 DOWN=36 WIDTH=80 HEIGHT=150 # define variables with defaults
DRIVE= # export this variable now so the script can use it after gtkdialog3
       # has assigned it a value

#probepart |grep -v none |sed 's#^/dev/##' |sed 's/|.*$//' |sed 's/$/||/' > /tmp/drvinfo       # make tablebox input file
# Do we need a temp file?
# Stick it in a function and you can refresh it from the gui.

pp(){ probepart|sed '/\(none\|swap\)/d;s|/dev/||;s/|.*//'; }

display(){ echo "drive selected: ${!1}"; }

GUI=$(cat <<EOV|sed 's/#.*//'|tee /tmp/gui1 /tmp/gui3 # interpolate and allow comments in gui
#<window title="GUI" default_width="$WIDTH" default_height="$HEIGHT"> # comment
<window title="GUI"> # let the geometry option control the size and placement
 <vbox>
  <table>
   #<label>Drive|M|B</label>
   <label>Drive</label>
   <variable>DRIVE</variable>
   <input>pp</input>
  </table>
  <button use-underline="true" label="_Refresh">
   #<action>echo \$DRIVE</action> # must escape variable. Do you understand why?
   <action>display DRIVE</action> # call display use DRIVE indirectly
   <action type="clear">DRIVE</action>
   <action type="refresh">DRIVE</action>
  </button>
  <button cancel></button>
 </vbox>
</window>
EOV)

# run gui 3 times (peruse files /tmp/gui1 /tmp/gui2 /tmp/gui3)
gtkdialog3 -d -p GUI -G ${1-${WIDTH}x${HEIGHT}+${RIGHT}+${DOWN}} # --program
gtkdialog3 -d -f /tmp/gui1 -G ${1-${WIDTH}x${HEIGHT}+${RIGHT}+${DOWN}} # --file
# prepare files to run --event-driven (/tmp/gui2 & /tmp/gui3)
# N.B. --geometry not effective when used in this context
#      so use width/height request instead
sed '/^GUI/,$d' $0 >/tmp/gui2
sed -i '$a\gtkdialog3 -e /tmp/gui3' /tmp/gui2
sed -i -e "1i\export MAIN_DIALOG='" -e "\$a\'" /tmp/gui3
sed -i 's/GUI"/& width-request="'$WIDTH'" height-request="'$HEIGHT'"/' /tmp/gui3
chmod +x /tmp/gui2
/tmp/gui2


Potong
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 4982
Location: Arizona, U.S.A.

PostPosted: Tue 16 Mar 2010, 02:50    Post subject:  

Very interesting potong, lots of nifty code... You`re right, a file isn`t needed for the Table.
But I can`t figure out what code made the GUI capable of being smaller.
Is it using only the geometry option? Please simplify what made it behave properly.
You`ve changed so much about the way the GUI works, it`s very hard to tell...

P.S. Ahhh yes... Now I remember why the Table needs a file, a variable won`t display right!
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 4982
Location: Arizona, U.S.A.

PostPosted: Tue 16 Mar 2010, 03:19    Post subject:  

Three cheers for potang, I got it sizing the gtkDialog3 GUI to any size in code..!!!
So weird that the GUI only gets bigger and never smaller with the mouse. Serious Bug!
But anyway... If you shutdown the GUI it will come back to the specified size when run again.
Back to top
View user's profile Send private message 
potong

Joined: 06 Mar 2009
Posts: 88

PostPosted: Tue 16 Mar 2010, 03:33    Post subject:  

It boils down to this:
Code:
#!/bin/sh -a

RIGHT=14 DOWN=36 WIDTH=80 HEIGHT=80 # define variables with defaults

GUI='
 <vbox>
  <button cancel></button>
 </vbox>
'
gtkdialog3 -p GUI -G ${1-${WIDTH}x${HEIGHT}+${RIGHT}+${DOWN}} # --program
Highlight the code above in your browser and then open a terminal and type:
Code:
xclip -o >/tmp/gui; chmod +x /tmp/gui
If you want to play with the --geometry option, enter something like this:
Code:
/tmp/gui 200x200+500+500
or
Code:
/tmp/gui 75x75+0+0
or
Code:
/tmp/gui 100x100
or
Code:
/tmp/gui +200+600
or
Code:
/tmp/gui
for the default geometry

Potong
Back to top
View user's profile Send private message 
8-bit


Joined: 03 Apr 2007
Posts: 3280
Location: Oregon

PostPosted: Tue 16 Mar 2010, 13:27    Post subject:
Subject description: Temporary file retention with a full install.
 

I have noticed in a number of gtkdialog3 programs that temporary file(s) are created in /tmp.
The reasoning is that the /tmp directory will be rebuilt when Puppy is next run.
This is true for frugal installs of Puppy.
But with a full install of Puppy, the /tmp directory does not get rebuilt and the temporary files do not get automatically removed on reboot.
So it would be good practice to add lines to the gtkdialog3 script when one creates it to remove those temporary files.

Comments?
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 4982
Location: Arizona, U.S.A.

PostPosted: Tue 16 Mar 2010, 14:41    Post subject:  

Actually the /tmp dir. use to be in ram only, so it was erased by default upon rebooting.
But now that Puppy unions on "/", the /tmp dir. has to be deleted by code at shutdown.
This means temp. files in /tmp aren`t really temp. at all... They`re written to the Save layer.
This slows the read / write procedure down as accessing /tmp is an access to the HD usually.

potong; Thanks, I got my small test GUI ( like the one you`ve shown above...) working..!
I like your extended strung out sed command, I`ve tried ones like it but have had little luck.
Defining the body of the GUI code differently is interesting also, it has some possibilities.
Back to top
View user's profile Send private message 
8-bit


Joined: 03 Apr 2007
Posts: 3280
Location: Oregon

PostPosted: Tue 16 Mar 2010, 16:17    Post subject:  

sunburnt wrote:
Three cheers for potang, I got it sizing the gtkDialog3 GUI to any size in code..!!!
So weird that the GUI only gets bigger and never smaller with the mouse. Serious Bug!
But anyway... If you shutdown the GUI it will come back to the specified size when run again.


The thing that bothers me is that there seems to be no consistency in use of code.

For example, Zigbert's example of saving window size and position slightly modified by me, works and will let you resize the window down to it's original size.
But the same code segments placed in your Driveman script will NOT let you shrink the size of the window.

The modified code from Zigbert so you can see what I mean.
Run it once and exit. Then when you run it again, it will show the window with the new size and position. And it WILL let you shrink the window back to its original size!

Code:

#! /bin/bash
. /tmp/geometry
save_geometry (){
   XWININFO=`xwininfo -stats -name SizeMe`
   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"   > /tmp/geometry
   echo "export WIDTH=$WIDTH"      >> /tmp/geometry
   echo "export X=$X"            >> /tmp/geometry
   echo "export Y=$Y"            >> /tmp/geometry
   chmod 700 /tmp/geometry
}

export -f save_geometry
[ -f /tmp/geometry ] && /tmp/geometry

export DIALOG="
<window title=\"SizeMe\" default_height=\"$HEIGHT\" default_width=\"$WIDTH\">
  <vbox>
    <frame>
      <text>
        <label>If you resize or move this window, it will be remembered for next time.</label>
      </text>
    </frame>
    <hbox>
    <button>
      <label>Exit</label>
      <action signal=\"button-press-event\">save_geometry</action>
      <action type=\"Exit\">exit 0</action>
    </button>
    </hbox>
  </vbox>
</window>"

./tmp/geometry

gtkdialog3 --program=DIALOG --geometry +"$X"+"$Y"

Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 4982
Location: Arizona, U.S.A.

PostPosted: Tue 16 Mar 2010, 17:14    Post subject:  

Quote:
The thing that bothers me is that there seems to be no consistency in use of code.

This my experience with gtkDialog altogether... Especially gtkDialog3.
Users are driven to inconsistent use by no docs. and gtkDialog`s twitchy behavior.
gtkDialog is to blame...

This is what I finally settled upon that works ( works for me at least... Rolling Eyes ):
Code:
export GUI="<window title=\"GUI\"><vbox>
  <button><label>Exit</label><action>gtkdialog.lib saveGeometry GUI $appPATH</action>
    <action type=\"Exit\">exit</action></button></vbox></window>"
gtkdialog3 -p GUI -G "$WIDTH"x"$HEIGHT"+"$LEFT"+"$TOP"
Back to top
View user's profile Send private message 
potong

Joined: 06 Mar 2009
Posts: 88

PostPosted: Tue 16 Mar 2010, 20:00    Post subject:  

sunburnt: A small change to the window directive (adding allow-shrink="true") allows the user to resize in either direction.
Code:
#!/bin/sh -a

RIGHT=14 DOWN=36 WIDTH=80 HEIGHT=80 # define variables with defaults

GUI='
<window allow-shrink="true">
 <vbox>
  <button cancel></button>
 </vbox>
</window>
'
gtkdialog3 -p GUI -G ${1-${WIDTH}x${HEIGHT}+${RIGHT}+${DOWN}} # --program

Save the above code to /tmp/gui and try
Code:
/tmp/gui 500x500+200+200

However the documentation does say this:
Quote:
The "allow-shrink" property

"allow-shrink" gboolean : Read / Write

If TRUE, the window has no minimum size. Setting this to TRUE is 99% of the time a bad idea.

Default value: FALSE

On the other hand use
Code:
<window allow-grow="false">

to prevent the user from resizing the gui

Potong
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 4982
Location: Arizona, U.S.A.

PostPosted: Tue 16 Mar 2010, 20:57    Post subject:  

Yep, that allows the GUI to be made to any size with the mouse.
Another code scrap for zigbert`s tutorial on gtkDialog...
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 2 of 4 [53 Posts]   Goto page: Previous 1, 2, 3, 4 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0951s ][ Queries: 12 (0.0047s) ][ GZIP on ]