Revision history for gtkdialogDocTips4.1
Additions:
[[HomePage]] > [[SoftwareIndex|Software Index]] > [[SoftwareDevelopment|Development]] > [[gtkdialog|gtkdialog]] > [[gtkdialogDocTips|Tips and Tricks]]
By default, gtkdialog always activates the first ##[[https://github.com/puppylinux-woof-CE/gtkdialog/wiki/radiobutton <radiobutton>]]## and the first list-item for ##[[https://github.com/puppylinux-woof-CE/gtkdialog/wiki/combobox <combobox>]]##.
Now let's go to the main script. For the ##[[https://github.com/puppylinux-woof-CE/gtkdialog/wiki/radiobutton <radiobutton>]]## and the ##[[https://github.com/puppylinux-woof-CE/gtkdialog/wiki/entry <entry>]]##, we set the ##<default>## tag to the corresponding variable in the config file. Since the ##[[https://github.com/puppylinux-woof-CE/gtkdialog/wiki/combobox <combobox>]]## doesn't support the ##<default>## tag, we need a workaround. We simply build the ##[[https://github.com/puppylinux-woof-CE/gtkdialog/wiki/combobox <combobox>]]## item-list so show our saved variable first.
===@@**#%[[gtkdialogDocTips3|❰❰❰ Previous]]#% #%[[gtkdialogDocTips|Index]]#% #%[[gtkdialogDocTips4.2|Next ❱❱❱]]#%**@@===
By default, gtkdialog always activates the first ##[[https://github.com/puppylinux-woof-CE/gtkdialog/wiki/radiobutton <radiobutton>]]## and the first list-item for ##[[https://github.com/puppylinux-woof-CE/gtkdialog/wiki/combobox <combobox>]]##.
Now let's go to the main script. For the ##[[https://github.com/puppylinux-woof-CE/gtkdialog/wiki/radiobutton <radiobutton>]]## and the ##[[https://github.com/puppylinux-woof-CE/gtkdialog/wiki/entry <entry>]]##, we set the ##<default>## tag to the corresponding variable in the config file. Since the ##[[https://github.com/puppylinux-woof-CE/gtkdialog/wiki/combobox <combobox>]]## doesn't support the ##<default>## tag, we need a workaround. We simply build the ##[[https://github.com/puppylinux-woof-CE/gtkdialog/wiki/combobox <combobox>]]## item-list so show our saved variable first.
===@@**#%[[gtkdialogDocTips3|❰❰❰ Previous]]#% #%[[gtkdialogDocTips|Index]]#% #%[[gtkdialogDocTips4.2|Next ❱❱❱]]#%**@@===
Deletions:
By default, gtkdialog always activates the first ##[[http://01micko.com/reference/radiobutton.html <radiobutton>]]## and the first list-item for ##[[http://01micko.com/reference/combobox.html <combobox>]]##.
Now let's go to the main script. For the ##[[http://01micko.com/reference/radiobutton.html <radiobutton>]]## and the ##[[http://01micko.com/reference/entry.html <entry>]]##, we set the ##<default>## tag to the corresponding variable in the config file. Since the ##[[http://01micko.com/reference/combobox.html <combobox>]]## doesn't support the ##<default>## tag, we need a workaround. We simply build the ##[[http://01micko.com/reference/combobox.html <combobox>]]## item-list so show our saved variable first.
@@**#%[[gtkdialogDocTips3|❰❰❰ Previous]]#% #%[[gtkdialogDocTips|Index]]#% #%[[gtkdialogDocTips4.2|Next ❱❱❱]]#%**@@
Additions:
@@**#%[[gtkdialogDocTips3|❰❰❰ Previous]]#% #%[[gtkdialogDocTips|Index]]#% #%[[gtkdialogDocTips4.2|Next ❱❱❱]]#%**@@
Deletions:
Additions:
===@@**#%[[gtkdialogDocTips3|❰❰❰ Previous]]#% #%[[gtkdialogDocTips|Index]]#% #%[[gtkdialogDocTips4.2|Next ❱❱❱]]#%**@@===
Deletions:
No Differences
Additions:
====4.1 Set default status of radiobuttons, Comboboxes...====
@@**#%[[gtkdialogDocTips3|❰❰❰ Previous]]#% #%[[gtkdialogDocTips|Index]]#% #%[[gtkdialogDocTips4.2|Next ❱❱❱]]#%**@@
@@**#%[[gtkdialogDocTips3|❰❰❰ Previous]]#% #%[[gtkdialogDocTips|Index]]#% #%[[gtkdialogDocTips4.2|Next ❱❱❱]]#%**@@
Deletions:
==**Set default status of radiobuttons, Comboboxes...**==
==**How to store window size/placement**==
This example shows how we can save settings for window size and placement for next startup. Be also aware that this solution makes it possible to let user rescale gui smaller than the default size. Normally you define the size of, for example, a <tree>, and the user can only resize the gui larger, but when using <window default_height="$HEIGHT" default_width="$WIDTH">, you don't need to define <height> and <width> for the tree widget.
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\">
<frame>
<text>
<label>If you resize or move this window, it will be remembered for next time.</label>
</text>
<button ok>
</button>
<action signal=\"hide\">save_geometry</action>
gtkdialog --program=DIALOG --geometry +"$X"+"$Y"
Another approach for size/placement is to make a call of your app from the cli.
RIGHT=14; DOWN=36; WIDTH=80; HEIGHT=80 # define variables with defaults
GUI='
<button cancel></button>
</vbox>'
gtkdialog -p GUI -G ${1-${WIDTH}x${HEIGHT}+${RIGHT}+${DOWN}}