#!/bin/bash # This example requires bash. GTKDIALOG=gtkdialog TMPDIR=/tmp/gtkdialog/examples/"`basename $0`" mkdir -p "$TMPDIR" treWidth=320; treHeight=200 funcbtnCreate() { echo '<button> <input file stock="'$3'"></input> <action>echo "'"$4"' '$1'"</action> <action function="'"$2"'">'$1'</action> </button>' } funcinputfileCreate() { local -a stockids=("gtk-jump-to" "gtk-leave-fullscreen" "gtk-media-forward" "gtk-media-record" "gtk-network" "gtk-new" "gtk-no" "gtk-ok" "gtk-open" "gtk-paste") local -a iconnames=("abiword" "geany" "gimp" "gnumeric" "inkscape" "midori" "scribus" "top" "viewnior" "xarchive") echo -n > "$TMPDIR"/inputfile$1 for f in 0 1 2 3 4 5 6 7 8 9; do if [ $1 = 1 ]; then echo -n "${stockids[$f]}|" >> "$TMPDIR"/inputfile$1 elif [ $1 = 2 ]; then echo -n "${iconnames[$f]}|" >> "$TMPDIR"/inputfile$1 fi echo "$RANDOM|$RANDOM|$RANDOM|$RANDOM" >> "$TMPDIR"/inputfile$1 done } functreCreate() { echo '<label>Column 0|Column 1|Column 2|Column 3</label> <variable>'$1'</variable> <width>'$treWidth'</width> <height>'$treHeight'</height> <action>echo "'$1'=$'$1' action for default signal triggered"</action> <action signal="row-activated">echo "'$1'=$'$1' row-activated signal detected"</action> <action signal="cursor-changed">echo "'$1'=$'$1' cursor-changed signal detected"</action> </tree> <hbox homogeneous="true"> '"`funcbtnCreate $1 Disable gtk-no Disabling`"' '"`funcbtnCreate $1 Enable gtk-yes Enabling`"' '"`funcbtnCreate $1 Clear gtk-clear Clearing`"' '"`funcbtnCreate $1 Removeselected gtk-delete Deleting`"' '"`funcbtnCreate $1 Refresh gtk-refresh Refreshing`"' </hbox>' } funcinputfileCreate 0 funcinputfileCreate 1 funcinputfileCreate 2 export MAIN_DIALOG=' <window title="Tree Input File Advanced" resizable="false"> <vbox> <hbox> <vbox> <text justify="2"> <label>"'"<input file> (text only) selection-mode='0' (none) exported-column='0' (default)"'"</label> </text> <tree selection-mode="0"> <input file>'"$TMPDIR"'/inputfile0</input> '"`functreCreate tre0`"' </vbox> <vseparator></vseparator> <vbox> <text justify="2"> <label>"'"<input file stock-column='0'> (text and stock icons) selection-mode='1' (single - default) headers-visible='false' exported-column='1'"'"</label> </text> <tree exported-column="1" headers-visible="false"> <input file stock-column="0">'"$TMPDIR"'/inputfile1</input> '"`functreCreate tre1`"' </vbox> </hbox> <hseparator></hseparator> <hbox> <vbox> <text justify="2"> <label>"'"<input file icon-column='0'> (text and theme icons) selection-mode='2' (browse) headers-clickable='false' exported-column='2'"'"</label> </text> <tree selection-mode="2" exported-column="2" headers-clickable="false"> <input file icon-column="0">'"$TMPDIR"'/inputfile2</input> '"`functreCreate tre2`"' </vbox> <vseparator></vseparator> <vbox> <text justify="2"> <label>"'"<input file> (default stock icon) selection-mode='3' (multiple) rules-hint='true' exported-column='3'"'"</label> </text> <tree stock-id="gtk-justify-center" selection-mode="3" exported-column="3" rules-hint="true"> <input file>'"$TMPDIR"'/inputfile0</input> '"`functreCreate tre3`"' </vbox> </hbox> <hseparator></hseparator> <hbox homogeneous="true"> <button ok></button> </hbox> </vbox> </window> ' case $1 in -d | --dump) echo "$MAIN_DIALOG" ;; *) $GTKDIALOG --program=MAIN_DIALOG ;; esac