i want to learn a little bit of gtk
my auto-lesson " Using Box and Variables (no files, only variables)"
in " GtkDialog - tips" there are many examples
hence I took the following lines
but many scripts, I do not understand them
like the following
in my next script
-- entry B should display mid of A
1) I can not clean two boxes A and B
2) I can not insert mid_A value through ORIGINALFILE=${ORIGINALFILE:$mid_A} in box B
3) I can not clean box A at the time of drag and drop
Code: Select all
#!/bin/sh
RIGHT=550 DOWN=36 WIDTH=600 HEIGHT=150 # define variables with defaults
unset ORIGINALFILE
unset length_A
unset mid_A
unset PDFFILE
function change_pdf_A() {
length_A=${#ORIGINALFILE}
let mid_A=length_A/2
ORIGINALFILE=${ORIGINALFILE:$mid_A}
Xdialog --msgbox "$ORIGINALFILE"" pdf_A" x
}
function change_pdf_B() {
ORIGINALFILE=`echo "Hello John -fill box B-"`
Xdialog --msgbox "$ORIGINALFILE"" pdf_B" x
}
export -f change_pdf_A
export -f change_pdf_B
export MAIN_DIALOG='
<window title="Learning gtk: clear and modify boxs using variables">
<vbox>
<text use-markup="true">
<label>"<span color='"'blue'"' font-family='"'mono'"' weight='"'bold'"' size='"'x-large'"'><big>Learning kgt I</big></span>"
</label>
</text>
<text use-markup="true">
<label>"<span color='"'brown'"' weight='"'bold'"' size='"'large'"' >drag ando drop text to A box</span>"
</label>
</text>
<hbox>
<text label="A" xalign="0"></text>
<entry>
<variable>ORIGINALFILE</variable>
<action>refresh:PDFFILE</action>
<action signal="changed">change_pdf_A</action>
<action>eval ORIGINALFILE</action>
<action>refresh:PDFFILE</action>
</entry>
</hbox>
<hbox>
<text label="B" xalign="0"></text>
<entry>
<variable>PDFFILE</variable>
<input>echo $ORIGINALFILE</input>
</entry>
</hbox>
<hbox>
<button>
<label>Clear A and B</label>
<action>ORIGINALFILE=`ECHO ""`</action>
<action>refresh:ORIGINALFILE</action>
</button>
<button>
<label>Refresh B</label>
<action>change_pdf_B</action>
</button>
<button>
<label>Exit</label>
<action>exit:Exit</action>
</button>
</hbox>
</vbox>
</window>
'
#
# gtkdialog -p GUI -G ${1-${WIDTH}x${HEIGHT}+${RIGHT}+${DOWN}}
# for STATEMENTS in $(gtkdialog3 -p MAIN_DIALOG); do
I=$IFS; IFS=""
for STATEMENTS in $(gtkdialog -p MAIN_DIALOG -G ${1-${WIDTH}x${HEIGHT}+${RIGHT}+${DOWN}}); do
eval $STATEMENTS
done
IFS=$I
#eval gtkdialog -p MAIN_DIALOG
unset RIGHT
unset DOWN
unset WIDTH
unset HEIGHT
Xdialog --msgbox "$PDFFILE"" \n""$ORIGINALFILE" x
Thank you very much for the help
exit