I want to use enable and disable property using function.
in the following example, I can not do it
I can only clean the boxes but not set it to disable B entry
Code: Select all
#!/bin/sh
RIGHT=550 DOWN=36 WIDTH=600 HEIGHT=150 # define variables with defaults
function Onlyfile() {
length_A=${#ORIGINALFILE}
echo ${ORIGINALFILE##*"/"} | awk -F"." '{print $1}'>/tmp/pdffile
}
function init_2() {
length_A=${#ORIGINALFILE}
#Xdialog --msgbox $ORIGINALFILE" \n"$length_A x
if [ "$length_A" -eq 0 ]; then
Xdialog --msgbox "$ORIGINALFILE "" empty" x;
echo '<action>refresh:ARCHIVO_T</action>
<action>disable:PDFFILE</action>
<action>refresh:PDFFILE</action>' ;
else
Xdialog --msgbox "$ORIGINALFILE"" -->" x;
echo '<action>refresh:PDFFILE</action>
<action>enable:PDFFILE</action>
<action>refresh:PDFFILE</action>';
fi
}
export -f init_2
export -f Onlyfile
export MAIN_DIALOG='
<window title="Learning gtk: modify boxs enable disable and comments ">
<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 a file to box A</span>"
</label>
</text>
<hbox>
<text label="A" xalign="0"></text>
<entry>
<variable>ORIGINALFILE</variable>
<input>cat /tmp/original</input>
<action>refresh:PDFFILE</action>
<action signal="changed">Onlyfile</action>
<action signal="changed">init_2</action>
<action>eval ORIGINALFILE</action>
<action>refresh:PDFFILE</action>
</entry>
</hbox>
<hbox>
<text label="B" xalign="0"></text>
<entry>
<variable>PDFFILE</variable>
<input>cat /tmp/pdffile</input>
</entry>
</hbox>
<hbox>
<button>
<label>Clear A and B</label>
<action>echo "" /tmp/original</action>
<action>echo "" /tmp/pdffile</action>
<action signal="changed">init_2</action>
<action>refresh:ORIGINALFILE</action>
</button>
<button>
<label>Refresh B</label>
<action>Onlyfile</action>
<action>refresh:PDFFILE</action>
</button>
<button>
<label>Exit</label>
<action>exit:Exit</action>
</button>
</hbox>
</vbox>
</window>
'
I=$IFS; IFS=""
for STATEMENTS in $(gtkdialog -p MAIN_DIALOG -G ${1-${WIDTH}x${HEIGHT}+${RIGHT}+${DOWN}}); do
eval $STATEMENTS
done
IFS=$I
1) I need to convert to disable box entry B when the script starts
2) I need to convert to disable entry B when clicking on button 'Clear A and B'
3) How do I include comments in the code?
Iuse:
<!-- comment here -->
'$(rem comment here)'
# comment here,
but Not Works
Thank you!