[OpenSmalltalk/opensmalltalk-vm] Allow choosing an image via zenity when no arguments are provided (#408)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[OpenSmalltalk/opensmalltalk-vm] Allow choosing an image via zenity when no arguments are provided (#408)

Eliot Miranda-4
 

You can view, comment on, or merge this pull request online at:

  https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/408

Commit Summary

  • Add file chooser dialog to squeak.sh.in
  • Add file chooser dialog to bin.squeak.sh.in

File Changes

Patch Links:


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

<script type="application/ld+json">[ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/408?email_source=notifications\u0026email_token=AIJPEW7JFVPPEBCBXYJT4QDP26RX5A5CNFSM4HYXR4FKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4GZ5CNUA", "url": "https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/408?email_source=notifications\u0026email_token=AIJPEW7JFVPPEBCBXYJT4QDP26RX5A5CNFSM4HYXR4FKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4GZ5CNUA", "name": "View Pull Request" }, "description": "View this Pull Request on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } } ]</script>
Reply | Threaded
Open this post in threaded view
|

Re: [OpenSmalltalk/opensmalltalk-vm] Allow choosing an image via zenity when no arguments are provided (#408)

Eliot Miranda-4
 

@fniephaus requested changes on this pull request.


In platforms/unix/config/bin.squeak.sh.in:

> @@ -53,4 +53,15 @@ case $PLATFORMLIBDIR in
 /lib|/usr/lib)	SVMLLP=/lib:/usr/lib;;
 *)				SVMLLP="$PLATFORMLIBDIR:/lib:/usr$PLATFORMLIBDIR:/usr/lib"
 esac
-LD_LIBRARY_PATH="$PLUGINS:$SVMLLP:${LD_LIBRARY_PATH}" exec $GDB "$BIN/squeak" "$@"
+
+# If no image file is provided as a command-line argument, allow the user to 
+# select the image file via a file-chooser dialog
+if which zenity &>/dev/null && [ $# -eq 0 ]; then

Could you please swap left and right? No need to check if zenity is installed if there are more args anyway.


In platforms/unix/config/bin.squeak.sh.in:

> @@ -53,4 +53,15 @@ case $PLATFORMLIBDIR in
 /lib|/usr/lib)	SVMLLP=/lib:/usr/lib;;
 *)				SVMLLP="$PLATFORMLIBDIR:/lib:/usr$PLATFORMLIBDIR:/usr/lib"
 esac
-LD_LIBRARY_PATH="$PLUGINS:$SVMLLP:${LD_LIBRARY_PATH}" exec $GDB "$BIN/squeak" "$@"
+
+# If no image file is provided as a command-line argument, allow the user to 
+# select the image file via a file-chooser dialog
+if which zenity &>/dev/null && [ $# -eq 0 ]; then
+  IMAGE=$(zenity --title 'Select an image' --file-selection --filename "${RESOURCES}/" --file-filter '*.image' --file-filter '*')

IMAGE is also used for all args (below), so please rename to something like VM_ARGS.
Also, ${RESOURCES} is not defined, maybe remove --filename "${RESOURCES}/"?


In platforms/unix/config/bin.squeak.sh.in:

> @@ -53,4 +53,15 @@ case $PLATFORMLIBDIR in
 /lib|/usr/lib)	SVMLLP=/lib:/usr/lib;;
 *)				SVMLLP="$PLATFORMLIBDIR:/lib:/usr$PLATFORMLIBDIR:/usr/lib"
 esac
-LD_LIBRARY_PATH="$PLUGINS:$SVMLLP:${LD_LIBRARY_PATH}" exec $GDB "$BIN/squeak" "$@"
+
+# If no image file is provided as a command-line argument, allow the user to 
+# select the image file via a file-chooser dialog
+if which zenity &>/dev/null && [ $# -eq 0 ]; then
+  IMAGE=$(zenity --title 'Select an image' --file-selection --filename "${RESOURCES}/" --file-filter '*.image' --file-filter '*')
+else
+  IMAGE=$@
+fi
+
+echo "Using image: ${IMAGE}"

Please remove this print message.


In platforms/unix/config/squeak.sh.in:

> @@ -53,4 +53,15 @@ case $PLATFORMLIBDIR in
 /lib|/usr/lib)	SVMLLP=/lib:/usr/lib;;
 *)				SVMLLP="$PLATFORMLIBDIR:/lib:/usr$PLATFORMLIBDIR:/usr/lib"
 esac
-LD_LIBRARY_PATH="$PLUGINS:$SVMLLP:${LD_LIBRARY_PATH}" exec $GDB "$BIN/squeak" "$@"

See comments for other file...


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

<script type="application/ld+json">[ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/408?email_source=notifications\u0026email_token=AIJPEW7WCKSHJGSQK57TSSLP27FDTA5CNFSM4HYXR4FKYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOB3YJA7Q#pullrequestreview-250646654", "url": "https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/408?email_source=notifications\u0026email_token=AIJPEW7WCKSHJGSQK57TSSLP27FDTA5CNFSM4HYXR4FKYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOB3YJA7Q#pullrequestreview-250646654", "name": "View Pull Request" }, "description": "View this Pull Request on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } } ]</script>
Reply | Threaded
Open this post in threaded view
|

Re: [OpenSmalltalk/opensmalltalk-vm] Allow choosing an image via zenity when no arguments are provided (#408)

Eliot Miranda-4
In reply to this post by Eliot Miranda-4
 

@MrModder pushed 1 commit.

  • e73e92d Apply suggested changes to squeak.sh.in


You are receiving this because you are subscribed to this thread.
View it on GitHub or mute the thread.

<script type="application/ld+json">[ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/408/files/fe4c3710d57d5524642a0fbe0ee5d45c975aa634..e73e92d7909d71a8e0d44714ac003ccda59d63be?email_source=notifications\u0026email_token=AIJPEWYTM3FNQRZGSFZ7AZTP4YZ4JA5CNFSM4HYXR4FKYY3PNVWWK3TUL52HS4DFXNIHK3DMKJSXC5LFON2FA5LTNBHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZF5KB2WY3BDGI4DQOBYHEYDCN2QOVZWQIZTG43DIMZUGE3TOMI", "url": "https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/408/files/fe4c3710d57d5524642a0fbe0ee5d45c975aa634..e73e92d7909d71a8e0d44714ac003ccda59d63be?email_source=notifications\u0026email_token=AIJPEWYTM3FNQRZGSFZ7AZTP4YZ4JA5CNFSM4HYXR4FKYY3PNVWWK3TUL52HS4DFXNIHK3DMKJSXC5LFON2FA5LTNBHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZF5KB2WY3BDGI4DQOBYHEYDCN2QOVZWQIZTG43DIMZUGE3TOMI", "name": "View Pull Request" }, "description": "View this Pull Request on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } } ]</script>
Reply | Threaded
Open this post in threaded view
|

Re: [OpenSmalltalk/opensmalltalk-vm] Allow choosing an image via zenity when no arguments are provided (#408)

Eliot Miranda-4
In reply to this post by Eliot Miranda-4
 

@MrModder pushed 1 commit.

  • 9b8899e Apply suggested changes to bin.squeak.sh.in


You are receiving this because you are subscribed to this thread.
View it on GitHub or mute the thread.

<script type="application/ld+json">[ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/408/files/e73e92d7909d71a8e0d44714ac003ccda59d63be..9b8899e84e40539dc9aeb72b7055889fb82bf218?email_source=notifications\u0026email_token=AIJPEW55YBGZSBIIZT2PGM3P4YZ5BA5CNFSM4HYXR4FKYY3PNVWWK3TUL52HS4DFXNIHK3DMKJSXC5LFON2FA5LTNBHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZF5KB2WY3BDGI4DQOBYHEYDCN2QOVZWQIZTG43DIMZUGI2DENA", "url": "https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/408/files/e73e92d7909d71a8e0d44714ac003ccda59d63be..9b8899e84e40539dc9aeb72b7055889fb82bf218?email_source=notifications\u0026email_token=AIJPEW55YBGZSBIIZT2PGM3P4YZ5BA5CNFSM4HYXR4FKYY3PNVWWK3TUL52HS4DFXNIHK3DMKJSXC5LFON2FA5LTNBHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZF5KB2WY3BDGI4DQOBYHEYDCN2QOVZWQIZTG43DIMZUGI2DENA", "name": "View Pull Request" }, "description": "View this Pull Request on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } } ]</script>
Reply | Threaded
Open this post in threaded view
|

Re: [OpenSmalltalk/opensmalltalk-vm] Allow choosing an image via zenity when no arguments are provided (#408)

Eliot Miranda-4
In reply to this post by Eliot Miranda-4
 

Hi Leon,

alas I think this way will fail:

if [ $# -eq 0 && which zenity &>/dev/null ]; then
VM_ARGS=$(zenity --title 'Select an image' --file-selection --file-filter '.image' --file-filter '')
else
VM_ARGS=$@
fi

LD_LIBRARY_PATH="$PLUGINS:$SVMLLP:${LD_LIBRARY_PATH}" exec $GDB "$BIN/squeak" "${VM_ARGS}"

That's illustrated by the following test programme:
-----------8<-------------
#!/bin/bash
ARGS=$@
echo; echo A
for a in "$ARGS"; do
echo $a
done
ARGS="$@"
echo; echo B
for a in "$ARGS"; do
echo $a
done
ARGS="$@"
echo; echo C
for a in $ARGS; do
echo $a
done
ARGS=$@
echo; echo D
for a in $ARGS; do
echo $a
done
-----------8<-------------

If one invokes this with ./testshellargs.sh 'arg one' 'arg two' then the output is

A
arg one arg two

B
arg one arg two

C
arg
one
arg
two

D
arg
one
arg
two

We have to find some way of writing this so that the output is
YES!!!
arg one
arg two


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

<script type="application/ld+json">[ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/408?email_source=notifications\u0026email_token=AIJPEWZLOC4E25N3NBWIGWDP42WWBA5CNFSM4HYXR4FKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODY3OEGA#issuecomment-506913304", "url": "https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/408?email_source=notifications\u0026email_token=AIJPEWZLOC4E25N3NBWIGWDP42WWBA5CNFSM4HYXR4FKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODY3OEGA#issuecomment-506913304", "name": "View Pull Request" }, "description": "View this Pull Request on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } } ]</script>
Reply | Threaded
Open this post in threaded view
|

Re: [OpenSmalltalk/opensmalltalk-vm] Allow choosing an image via zenity when no arguments are provided (#408)

Eliot Miranda-4
In reply to this post by Eliot Miranda-4
 

Hi Leon, the only way I know of doing this is to expand $@ within double quotes at the point of command dispatch. Here's the illustration of the magic incantation:

ZENITY_ARGS=
echo 'YES!!!'
for a in ${ZENITY_ARGS:="$@"}; do
echo $a
done

so the right form would be

ZENITY_ARGS=
if [ $# -eq 0 && which zenity &>/dev/null ]; then
ZENITY_ARGS=$(zenity --title 'Select an image' --file-selection --file-filter '.image' --file-filter '')
fi

LD_LIBRARY_PATH="$PLUGINS:$SVMLLP:${LD_LIBRARY_PATH}" exec $GDB "$BIN/squeak" ${ZENITY_ARGS:="$@"}


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

<script type="application/ld+json">[ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/408?email_source=notifications\u0026email_token=AIJPEWYUN374UPHRJMB354LP42YM7A5CNFSM4HYXR4FKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODY3OM2I#issuecomment-506914409", "url": "https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/408?email_source=notifications\u0026email_token=AIJPEWYUN374UPHRJMB354LP42YM7A5CNFSM4HYXR4FKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODY3OM2I#issuecomment-506914409", "name": "View Pull Request" }, "description": "View this Pull Request on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } } ]</script>
Reply | Threaded
Open this post in threaded view
|

Re: [OpenSmalltalk/opensmalltalk-vm] Allow choosing an image via zenity when no arguments are provided (#408)

timrowledge
 


> On 2019-06-28, at 6:05 PM, Eliot Miranda <[hidden email]> wrote:
>

> ZENITY_ARGS=$(zenity --title 'Select an image' --file-selection --file-filter '.image' --file-filter '')
> fi

Just a small flag-waving point - on a Pi, at least, that needs to be --file-selection '*.image' to actually show any image files.

tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
Plan to be spontaneous tomorrow.