From the ChangeLog:
- Added command-line option --space-expand to set the widget packing expand state at the project level.
- Added command line option --space-fill to set the widget packing fill state at the project level.
- Added the "space-expand" custom tag attribute for the h/vbox widgets to set the widget packing expand state at the container level.
- Added the "space-fill" custom tag attribute for the h/vbox widgets to set the widget packing fill state at the container level.
- Added the "space-expand" custom tag attribute for all other widgets to set the widget packing expand state at the widget level.
- Added the "space-fill" custom tag attribute for all other widgets to set the widget packing fill state at the widget level.
- By default the original quirky widget packing method is used.
- Project level --space-expand/fill override the original method.
- Container level "space-expand/fill" override the project level method and the original method.
- Widget level "space-expand/fill" override the container level method, the project level method and the original method.
Widgets are packed into containers and they may expand into and fill their allocated space. For Gtkdialog, containers means hbox and vbox but there's one embedded unreachable vbox inside the frame widget which is a pain because it's not possible to add tag attributes to the frame or embedded vbox to set expand and fill at the container level although the widget level and project level are fine. The way around this is to place a vbox inside the frame so that you have control over it. The frame widget really needs to be replaced but that's a job for another day.
The Original Method
It's a bit quirky and possibly there's an error in it but it's the default method and used by every single Gtkdialog application until now.
The frame widget and every widget normally placed inside a default scrolled window (edit, tree, list, table and optionally the h/vbox) are packed with expand and fill set to true, otherwise widgets are packed with expand and fill set to false. The possible error I've found is that the hbox uniquely packs the entry widget by default with expand and fill set to true.
The Project Level Method
The command-line options --space-expand=true/yes/1/false/no/0 and --space-fill=true/yes/1/false/no/0 will override the original method for all widgets at the project (application) level. --space-expand=true is the key to creating resizable applications.
The Container Level Method
The custom tag attributes space-expand="true/yes/1/false/no/0" and space-fill="true/yes/1/false/no/0" will override the original method and the project level method for widgets at the container level i.e. <vbox space-expand="true" space-fill="true"> will set expand and fill to true for all the widgets inside this particular vbox but not recursively into v/hboxes nested within.
The Widget Level Method
The custom tag attributes space-expand="true/yes/1/false/no/0" and space-fill="true/yes/1/false/no/0" will override the original method, the project level method and the container level method for individual widgets.
Example (examples/miscellaneous/expand_and_fill):
Code: Select all
#!/bin/sh
export GTKDIALOG=gtkdialog
funcExampleCreate() {
if [ $1 = 0 ]; then echo '
<window title="Expand and Fill - Original Method" resizable="true">'
elif [ $1 = 1 ]; then echo '
<window title="Expand and Fill - --space-expand" resizable="true">'
elif [ $1 = 2 ]; then echo '
<window title="Expand and Fill - --space-expand + --space-fill" resizable="true">'
else echo '
<window title="Expand and Fill - --space-expand + --space-fill + tweaks" resizable="true">'
fi
echo '
<vbox>
<hbox>
<tree stock-id="gtk-select-color"><item>tree widget</item></tree>
<vseparator></vseparator>
<vbox>
<entry><default>entry widget</default></entry>
<hseparator></hseparator>
<text label="text widget"></text>
</vbox>
</hbox>
<hseparator></hseparator>
<hbox>
<vbox>
<spinbutton></spinbutton>
<hseparator></hseparator>'
if [ $1 -lt 3 ]; then echo '
<colorbutton use-alpha="true">'
else echo '
<colorbutton space-expand="false" use-alpha="true">'
fi
echo '
<default>#'$(for f in 0 1 2; do printf "%02x" $(($RANDOM % 256)); done)'|43934"</default>
</colorbutton>
</vbox>
<vseparator></vseparator>
<edit><default>edit widget</default></edit>
</hbox>
<hseparator></hseparator>'
if [ $1 -lt 3 ]; then echo '
<hbox>'
else echo '
<hbox space-expand="false">'
fi
echo '
<button image-position="1">
<label>Next example</label>
<input file stock="gtk-go-forward"></input>'
if [ $1 = 0 ]; then echo '
<action>$GTKDIALOG --space-expand=true --program=CLI_EXPAND_METHOD &</action>'
elif [ $1 = 1 ]; then echo '
<action>$GTKDIALOG --space-expand=true --space-fill=true --program=CLI_EXPAND_PLUS_FILL_METHOD &</action>'
elif [ $1 = 2 ]; then echo '
<action>$GTKDIALOG --space-expand=true --space-fill=true --program=CLI_EXPAND_PLUS_FILL_PLUS_TWEAKS_METHOD &</action>'
else echo '
<sensitive>false</sensitive>'
fi
echo '
</button>
<button use-stock="true" label="gtk-ok"></button>
</hbox>
<statusbar><label>statusbar widget</label></statusbar>
</vbox>
<action signal="hide">exit:Exit</action>
</window>
'
}
export ORIGINAL_METHOD="$(funcExampleCreate 0)"
export CLI_EXPAND_METHOD="$(funcExampleCreate 1)"
export CLI_EXPAND_PLUS_FILL_METHOD="$(funcExampleCreate 2)"
export CLI_EXPAND_PLUS_FILL_PLUS_TWEAKS_METHOD="$(funcExampleCreate 3)"
$GTKDIALOG --program=ORIGINAL_METHOD
Thunor