A thought I had was an executable or function library for support of commonly needed code.
A function library is the usual way of bringing support code into a program. But I dislike
dragging in an entire library of code into my program just for one function that may not run.
So an executable library can do pretty much the same thing ( mostly ) without loading up ram.
Here`s a start on a library: help, saving of position and size, and kill window for an exit button.
Code: Select all
#!/bin/sh
###### Exec. library for gtkDialog
if [ "$1" = '-h' -o "$1" = '--help' ];then # help
echo -e \\n'### gtkdialog.lib -e = Example GUI code.'\\n'### List of executibles:'
echo -e '# saveGeometry: Save GUI`s ($LEFT x $TOP) and ($WIDTH x $HEIGHT).'
echo -e ' Argument $2 = GUI`s window title.'\\n' Argument $3 = GUI`s path.'
echo -e '# killWindow: Close GUI.'\\n' Argument $2 = gtkDialog`s "export" program name.'
elif [ "$1" = '-e' ];then # example
echo -e \\n'### Example code for a GUI that remembers it`s size and position:'\\n
echo -e '#!/bin/sh'
echo -e '[ -e $1/GUI_geometry ]&& . $1/GUI_geometry'
echo -e 'export GUI="'
echo -e '<window title=\"GUI\" default_width=\"$WIDTH\" default_height=\"$HEIGHT\"><vbox>'
echo -e ' <button><label>Exit</label><action>. gtkDialog.lib saveGeometry GUI $1</action>'
echo -e ' <action>gtkDialog.lib killWindow GUI</action></button></vbox></window>'
echo -e '</vbox></window>"'
echo -e 'gtkdialog3 --program=GUI --geometry +"$LEFT"+"$TOP"'\\n
elif [ "$1" = 'saveGeometry' ];then # save the GUIs geometry
XWININFO=`xwininfo -stats -name $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}'`
echo "LEFT=$(($X1-$X2))" > $3/$2_geometry ; echo "TOP=$(($Y1-$Y2))" >> $3/$2_geometry
echo WIDTH=`echo "$XWININFO" | grep 'Width:' | awk '{print $2}'` >> $3/$2_geometry
echo HEIGHT=`echo "$XWININFO" | grep 'Height:' | awk '{print $2}'` >> $3/$2_geometry
elif [ "$1" = 'killWindow' ];then # kill the GUI
psID=`ps |grep program=$2 |egrep -v '(grep|geany)' |awk '{print $1}'`
[ "$psID" ]&& kill $psID
fi
Anyone`s thoughts ??? ... Maybe Barry could add a word as to Puppy including it.
.