Can`t get gtkDialog3 version of app. to work. [Solved]
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\">
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\">
I think you may be confusing long and short options here.
The help message for gtkdialog3 is:
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:
Then you can call the script as:
Also
otherwise they are taken as literals (not allowed in this tag)
Potong
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
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
Code: Select all
./scriptname 200x400+200+300
sizeY and sizeX must be prefixed by $ e.g.For some reason this gtkDialog3 line won`t use it`s variables:
<window title=\"DM\" default_width=\"sizeX\" default_height=\"sizeY\">
Code: Select all
<window title=\"DM\" default_width=\"$sizeX\" default_height=\"$sizeY\">
Potong
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:
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...
-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"
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, 19:11, edited 2 times in total.
### 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...
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...
sunburnt: HTH
Potong
Code: Select all
#!/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
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!
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!
It boils down to this:Highlight the code above in your browser and then open a terminal and type:If you want to play with the --geometry option, enter something like this: oror or orfor the default geometry
Potong
Code: Select all
#!/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
Code: Select all
xclip -o >/tmp/gui; chmod +x /tmp/gui
Code: Select all
/tmp/gui 200x200+500+500
Code: Select all
/tmp/gui 75x75+0+0
Code: Select all
/tmp/gui 100x100
Code: Select all
/tmp/gui +200+600
Code: Select all
/tmp/gui
Potong
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?
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?
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.
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.
The thing that bothers me is that there seems to be no consistency in use of code.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.
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: Select all
#! /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"
This my experience with gtkDialog altogether... Especially gtkDialog3.The thing that bothers me is that there seems to be no consistency in use of code.
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... ):
Code: Select all
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"
sunburnt: A small change to the window directive (adding allow-shrink="true") allows the user to resize in either direction.
Save the above code to /tmp/gui and try
However the documentation does say this:
to prevent the user from resizing the gui
Potong
Code: Select all
#!/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
Code: Select all
/tmp/gui 500x500+200+200
On the other hand useThe "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
Code: Select all
<window allow-grow="false">
Potong
8-bit:
You can find a lot of information here http://library.gnome.org/devel/gtk/stable
Also see my original post http://murga-linux.com/puppy/viewtopic.php?t=38608
For instance: see the the window widget here http://library.gnome.org/devel/gtk/stab ... indow.html and look in particular at its properties
Remember most widgets have hierarchy
and so their properties can be used too.
To get a list of widgets used by gtkdialog you'll have to inspect the source code. It's pretty old now so some of the widgets are deprecated.
HTH
Potong
You can find a lot of information here http://library.gnome.org/devel/gtk/stable
Also see my original post http://murga-linux.com/puppy/viewtopic.php?t=38608
For instance: see the the window widget here http://library.gnome.org/devel/gtk/stab ... indow.html and look in particular at its properties
Code: Select all
Properties
"accept-focus" gboolean : Read / Write
"allow-grow" gboolean : Read / Write
"allow-shrink" gboolean : Read / Write
"decorated" gboolean : Read / Write
"default-height" gint : Read / Write
"default-width" gint : Read / Write
"deletable" gboolean : Read / Write
"destroy-with-parent" gboolean : Read / Write
"focus-on-map" gboolean : Read / Write
"gravity" GdkGravity : Read / Write
"has-toplevel-focus" gboolean : Read
"icon" GdkPixbuf* : Read / Write
"icon-name" gchar* : Read / Write
"is-active" gboolean : Read
"modal" gboolean : Read / Write
"opacity" gdouble : Read / Write
"resizable" gboolean : Read / Write
"role" gchar* : Read / Write
"screen" GdkScreen* : Read / Write
"skip-pager-hint" gboolean : Read / Write
"skip-taskbar-hint" gboolean : Read / Write
"startup-id" gchar* : Write
"title" gchar* : Read / Write
"transient-for" GtkWindow* : Read / Write / Construct
"type" GtkWindowType : Read / Write / Construct Only
"type-hint" GdkWindowTypeHint : Read / Write
"urgency-hint" gboolean : Read / Write
"window-position" GtkWindowPosition : Read / Write
Code: Select all
GObject
+----GInitiallyUnowned
+----GtkObject
+----GtkWidget
+----GtkContainer
+----GtkBin
+----GtkWindow
+----GtkDialog
+----GtkAssistant
+----GtkPlug
To get a list of widgets used by gtkdialog you'll have to inspect the source code. It's pretty old now so some of the widgets are deprecated.
HTH
Potong
Hope It Helps ??? Big time..!!!
This is more info about gtkDialog than I`ve seen in the 4 years I`ve been trying to use it!
potong; If you would be so kind...
-f, --file=filename Get the GUI description from a regular file.
Use like this: gtkdialog3 -f /path/file.gtk -G "$WIDTH"x"$HEIGHT"+"$LEFT"+"$TOP" &
And the body of the gtkDialog code is in: /path/file.gtk ( "kinda" like your example showed ).
-e, --event-driven=filename Execute the file as an event driven program.
This I have no idea where to begin with how to use it...
This is more info about gtkDialog than I`ve seen in the 4 years I`ve been trying to use it!
potong; If you would be so kind...
-f, --file=filename Get the GUI description from a regular file.
Use like this: gtkdialog3 -f /path/file.gtk -G "$WIDTH"x"$HEIGHT"+"$LEFT"+"$TOP" &
And the body of the gtkDialog code is in: /path/file.gtk ( "kinda" like your example showed ).
-e, --event-driven=filename Execute the file as an event driven program.
This I have no idea where to begin with how to use it...
sunburnt:
Here's a program written in two ways to show the different options.
First the --file=filename and a shell wrapper script to run it
now highlight the code above and in a terminal type:
Observe the messages when you click Display.
Also type:
and see the gui description.
Secondly --event-driven=filename
now highlight the code above and in a terminal type:
You'll see the same program but run using the gtkdialog3 program directly.
HTH
Potong
Here's a program written in two ways to show the different options.
First the --file=filename and a shell wrapper script to run it
Code: Select all
#!/bin/sh -a
display(){ echo "Display: ${!1}"; }
cat <<EOV >/tmp/gui_file
<window>
<vbox>
<text label="Run from a terminal and monitor the messages"></text>
<entry>
<variable>ENTRY</variable>
<default>Here is some text</default>
</entry>
<button use-underline="true" label="_Display">
<action>display ENTRY</action>
</button>
<button cancel></button>
</vbox>
</window>
EOV
gtkdialog3 -f /tmp/gui_file
Code: Select all
xclip -o >/tmp/a; chmod +x /tmp/a; /tmp/a
Also type:
Code: Select all
cat /tmp/gui_file
Secondly --event-driven=filename
Code: Select all
#!/usr/sbin/gtkdialog3 -e
display(){ echo "Display: ${!1}"; }
export MAIN_DIALOG='
<window>
<vbox>
<text label="Run from a terminal and monitor the messages"></text>
<entry>
<variable>ENTRY</variable>
<default>Here is some text</default>
</entry>
<button use-underline="true" label="_Display">
<action>display ENTRY</action>
</button>
<button cancel></button>
</vbox>
</window>
'
Code: Select all
xclip -o >/tmp/b; chmod +x /tmp/b; /tmp/b
HTH
Potong