Added hscale and vscale widgets
The hscale
widget reference is
available here.
The vscale
widget reference is
available here.
[EDIT] Updated 2011-07-17 13:47 to support the "block-function-signals" custom tag attribute (the example scales with the markup use this).
Adding marks and markup (you'll need at least
GTK+ 2.16 for this) is done via <item> directives (value |
position |
markup) and the markup is optional. For myself on my own computer (lupu-520) the vertical markup isn't rendered in the right place althought the marks are correct. The only time I've managed to get them drawn correctly was when adding them twice, the first set being wrong and the second not being able to be drawn again in the wrong place managed to go to the right place.
"range-min", "range-max", "range-step" and "range-value" are custom tag attributes that accept double precision floating point numbers. The GTK "
digits" property specifies the number of decimal places that are displayed in the value.
To set the scale's value you can use the "range-value" custom tag attribute, the <default> directive, the <input> directive or the <input file> directive.
If you want to isolate signals originating from user widget manipulation from the refresh function then use the custom tag attribute block-function-signals/block_function_signals="true/yes/1".
The fourth horizontal and vertical scales include the GTK property "
update-policy" set to 1 (
GTK_UPDATE_DISCONTINUOUS) and you might want to investigate the different types.
Features Supported by Later Versions of GTK+
Some widget properties and features may be unavailable to you if you are using an older version of GTK+, but they will not prevent you from compiling and using Gtkdialog as Gtkdialog checks the user's version of GTK+ at compile time and removes support for unsupported properties and features to enable compilation against different GTK+ versions. Ultimately though, the features that the application developer chooses to implement and therefore the version of GTK+ that his application requires is not within my realm of operation.
- 2.16 for scale marks and markup.
<hscale> and <vscale> widgets example:
Code: Select all
#!/bin/sh
# NOTE: This example requires at least gtkdialog-0.7.21 (please visit
# http://code.google.com/p/gtkdialog/). Additionally if you are using
# Puppy Linux then you may find that an historical version of gtkdialog
# already exists in /usr/sbin, and if that is the case then you should
# modify the shell variable below to point to the new gtkdialog binary.
GTKDIALOG=gtkdialog
function funcbtnCreate() {
echo '<button image-position="'$3'">
<label>"'"$2"'"</label>
<input file stock="'$4'"></input>
<action>echo "'"$5"' '$1'"</action>
<action type="'"$6"'">'$1'</action>
</button>'
}
function funcscaType0Create() {
echo '<'$2'scale width-request="'$3'" height-request="'$4'" range-value="4">
<variable>'$1'</variable>
<action>echo "'$1' changed to $'$1'"</action>
</'$2'scale>
<'$2'separator></'$2'separator>'
}
function funcscaType1Create() {
echo '<'$2'scale width-request="'$3'" height-request="'$4'"
range-min="0" range-max="1" range-step="0.1"
value-pos="3" digits="2" inverted="true">
<default>0.20</default>
<variable>'$1'</variable>
<action>echo "'$1' changed to $'$1'"</action>
<item>"0.25 | '$5'"</item>
<item>"0.5 | '$6'"</item>
<item>"0.75 | '$7'"</item>
</'$2'scale>
<'$2'separator></'$2'separator>'
}
function funcscaType2Create() {
echo '<'$2'scale width-request="'$3'" height-request="'$4'"
range-min="0" range-max="255" range-step="8" value-pos="1"
block-function-signals="true">
<variable>'$1'</variable>
<input>echo 18</input>
<action>echo "'$1' changed to $'$1'"</action>
<item>"64 |'$5'|<span fgcolor='"'white'"' bgcolor='"'darkred'"'> 64 </span>"</item>
<item>"128|'$6'|<span fgcolor='"'white'"' bgcolor='"'darkgreen'"'> 128 </span>"</item>
<item>"192|'$7'|<span fgcolor='"'white'"' bgcolor='"'darkblue'"'> 192 </span>"</item>
<output file>outputfile</output>
</'$2'scale>
<'$2'box homogeneous="true">
'"$(funcbtnCreate $1 Disable $8 gtk-no Disabling disable)"'
'"$(funcbtnCreate $1 Enable $8 gtk-yes Enabling enable)"'
'"$(funcbtnCreate $1 Refresh $8 gtk-refresh Reloading refresh)"'
'"$(funcbtnCreate $1 Save $8 gtk-save Saving save)"'
</'$2'box>
<'$2'separator></'$2'separator>'
}
function funcscaType3Create() {
echo '<'$2'scale width-request="'$3'" height-request="'$4'"
range-min="0" range-max="123" range-step="1"
draw-value="false" show-fill-level="true" fill-level="56"
restrict-to-fill-level="true" update-policy="1">
<variable>'$1'</variable>
<input file>inputfile</input>
<action signal="value_changed">echo "'$1' changed to $'$1'"</action>
<output file>outputfile</output>
</'$2'scale>
<'$2'box homogeneous="true">
'"$(funcbtnCreate $1 Disable $5 gtk-no Disabling disable)"'
'"$(funcbtnCreate $1 Enable $5 gtk-yes Enabling enable)"'
'"$(funcbtnCreate $1 Refresh $5 gtk-refresh Reloading refresh)"'
'"$(funcbtnCreate $1 Save $5 gtk-save Saving save)"'
</'$2'box>'
}
if [ ! -f inputfile ]; then
echo "44" > inputfile
fi
export MAIN_DIALOG='
<window title="scaScales" resizable="false">
<vbox>
<hbox>
<frame hscale widget>
<vbox>
'"$(funcscaType0Create hscHScale0 h 360 80)"'
'"$(funcscaType1Create hscHScale1 h 360 80 2 2 2)"'
'"$(funcscaType2Create hscHScale2 h 360 -1 3 2 3 0)"'
'"$(funcscaType3Create hscHScale3 h 360 80 0)"'
</vbox>
</frame>
<frame vscale widget>
<hbox>
'"$(funcscaType0Create vscVScale0 v 50 400)"'
'"$(funcscaType1Create vscVScale1 v 50 400 1 1 1)"'
'"$(funcscaType2Create vscVScale2 v -1 400 0 1 0 2)"'
'"$(funcscaType3Create vscVScale3 v 50 400 2)"'
</hbox>
</frame>
</hbox>
<hbox homogeneous="true">
<button ok></button>
</hbox>
</vbox>
<action signal="hide">exit:Exit</action>
</window>
'
$GTKDIALOG --center --program=MAIN_DIALOG
Regards,
Thunor