Hi Smokey
I'm not sure if I understand what exactly you want to achieve (maybe a short example?), but since Bash won't accept a variable with a dot:
Code: Select all
# some.var=5
bash: some.var=5: command not found
#
then probably Gtkdialog too.
I assume you have those "variables" stored in some file, haven't you?
So you could (before using) replace the dot with e.g. _underline , like this:
Code: Select all
# eval $(echo 'some.var="Smith, John A."' | sed '0,/\./s/\./_/')
# echo $some_var
Smith, John A.
#
and, after change has been made, but before saving to a file, replace it back:
Code: Select all
# some_var="Brown, James E."
# echo "$(echo some_var | sed '0,/\_/s/\_/./')="$some_var"" > storefile
# cat storefile
some.var="Brown, James E."
#
But this method isn't too pretty.
Anyway, hope it'll help you somehow.
________________
zigbert wrote:Nested expanders - can be used for 'tree-view' of folders.
Really nice
Thanks!
I just wrote crude and simple equivalent of 'tree' in Bash, but I think I'll pass on trying to write dynamic GUI builder.
Besides, I'm afraid that Gtk(dialog) can have serious problems in handling such amount of widgets (thousands of expanders + buttons
).
But perhaps it would work nice with some small, local structures..?
Anyway, here's the 'tree' code, maybe someone find it useful:
Code: Select all
#!/bin/bash
# Simple equivalent of 'tree' in Bash by SFR'2013
parse_dirs () {
CWD="$1"
cd "$CWD"
local DIRS=( $(find -maxdepth 1 -mindepth 1 -type d | sort | grep -v "$CWD$" | cut -f2 -d'/') )
local FILES=( $(find -maxdepth 1 -mindepth 1 ! -type d | sort | cut -f2 -d'/') )
if [ ${#DIRS[@]} -ne 0 ]; then
while read LINE; do
echo -e "${INDENT}${BLUECOL}$LINE${OFFCOL}"
INDENT="${INDENT} "
parse_dirs "$LINE"
done <<< `echo ${DIRS[@]}`
fi
if [ ${#FILES[@]} -ne 0 ]; then
while read LINE; do
echo "${INDENT}$LINE"
done <<< `echo ${FILES[@]}`
fi
unset DIRS FILES
INDENT=$(echo "${INDENT%?}")
cd ..
}
CWD="$1"
[ ! "$CWD" ] && CWD="`pwd`"
[ ! -d "$CWD" ] && echo "Directory doesn't exist!" && exit 1
BLUECOL="\e[0;34m"
OFFCOL="\e[00m"
OLD_IFS=$IFS; IFS=' '
echo -e "${BLUECOL}$(basename "$CWD")${OFFCOL}"
INDENT=" "
parse_dirs "$CWD"
IFS=$OLD_IFS
exit
Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]