with this problem I'm struggling for a long time and I don't see a easy solution.
I have a file with one item per line and want another one with several selected items from the first.
I can add selected items to the new file and I can clear (delete) it. Where I'm struggling is, if I want to remove an item from the new list and saving it.
For better understanding I wrote a small example:
Code: Select all
#!/bin/sh
[ ! -s /tmp/items ] && echo -e -n 'item1\n22222\n33333\nitem4\n55555\n66666\n77777\n' > /tmp/items
GTKDIALOG=gtkdialog4
export MAIN_DIALOG='
<hbox>
<tree>
<label>available Items:</label>
<variable>TREE1</variable>
<width>150</width><height>250</height>
<input file> /tmp/items</input>
</tree>
<vbox homogeneous="true">
<button>
<label>"Add"</label>
<action>"echo $TREE1 >>/tmp/selected" </action>
<action>refresh:TREE2</action>
</button>
<button>
<label>"Remove"</label>
<action>removeselected:TREE2</action>
<action>"echo $TREE2_ALL > /tmp/selected2"</action>
</button>
<button>
<label>"Clear"</label>
<action>clear:TREE2</action>
<action>" rm /tmp/selected"</action>
</button>
<button ok> </button>
</vbox>
<tree>
<label>Selected items:</label>
<variable>TREE2</variable>
<width>150</width><height>250</height>
<input file> /tmp/selected</input>
<action>removeselected:TREE2</action>
<action>"echo $TREE2_ALL > /tmp/selected2"</action>
</tree>
</hbox>
'
case $1 in
-d | --dump) echo "$MAIN_DIALOG" ;;
*) $GTKDIALOG --program=MAIN_DIALOG ;;
esac
Code: Select all
"'22222' '77777' '33333'"
Code: Select all
22222
77777
33333
Code: Select all
<action>save:TREE2</action>
I've found a lot of examples about tree widgets but nothing about saving back to a file.
Can anybody help please?
Thanks in advance,
Rolf