tools/gstreamer-completion: Support gst-inspect, and gst-launch element properties

Completes options like "--gst-debug-level" and the values of some of
those options; completes element names, property names, and even
property values (for enum or boolean properties only).

Doesn't complete all caps specifications, nor element names specified
earlier in the pipeline with "name=...".

For now the version number is hard-coded into the completion script:
This patch is off the 0.10 branch and has the version hard-coded as
"0.10"; it needs to be updated for the 1.0 branch. It might be worth
creating a "gstreamer-completion.in" that has the appropriate version
inserted by "configure" (but I'd rather not do that).

Note that GStreamer 0.10 installs "gst-inspect" and "gst-inspect-0.10".
"gst-inspect --help" only prints 4 flags (--help, --print, --gst-mm,
gst-list-mm) whereas "gst-inspect-0.10 --help-all" prints the full list
of flags. The same applies to "gst-launch" and "gst-launch-0.10".
GStreamer 1.0 only installs "gst-inspect-1.0", not "gst-inspect".

Requires bash 4; only tested with bash 4.2. Requires "bash-completion"
(which you install with your system's package manager).

Put this in /etc/bash_completion.d/ or in `pkg-config
--variable=compatdir bash-completion`, where it will be loaded at the
beginning of every new terminal session;
or in `pgk-config --variable=completionsdir bash-completion`, renamed to
match the name of the command it completes (e.g. "gst-launch-0.10", with
an additional symlink named "gst-inspect-0.10"), where it will be
autoloaded when needed.

test-gstreamer-completion.sh is (for now) in tests/misc -- is might be
worth creating "tests/check/tools", with all the necessary automake
boilerplate, and moving test-gstreamer-completion.sh there, and have it
run automatically with "make check".

IF YOU'RE NEW TO BASH COMPLETION SCRIPTS
----------------------------------------

"complete -F _gst_launch gst-launch gst-launch-0.10" means that bash
will run the function "_gst_launch" to generate possible completions
for the commands "gst-launch" and "gst-launch-0.10".

"_gst-launch" must return the possible completions in the array variable
COMPREPLY. (Note on bash syntax: "V=(a b c)" assigns three elements to
the array "V").

"compgen" prints a list of possible completions to standard output. Try
it:

    compgen -W "abc1 abc2 def" -- "a"
    compgen -f -- "/"

The last argument is the word currently being completed; compgen uses it
to filter out the non-matching completions. We put "--" first, in case
the word currently being completed starts with "-" or "--", so that it
isn't treated as a flag to compgen.

For the documentation of COMP_WORDS, COMP_CWORD, etc see
http://www.gnu.org/software/bash/manual/html_node/Bash-Variables.html#index-COMP_005fCWORD-180

See also:
* http://www.gnu.org/software/bash/manual/html_node/Programmable-Completion.html
* http://www.gnu.org/software/bash/manual/html_node/Programmable-Completion-Builtins.html

The bash-completion package provides the helper function
"_init_completion" which populates variables "cur", "prev", and "words".
See
http://anonscm.debian.org/gitweb/?p=bash-completion/bash-completion.git;a=blob;f=bash_completion;h=870811b4;hb=HEAD#l634

Note that by default, bash appends a space to the completed word. When
the completion is "property=" we don't want a trailing space; calling
"compopt -o nospace" modifies the currently-executing completion
accordingly. See
http://www.gnu.org/software/bash/manual/html_node/Programmable-Completion-Builtins.html#index-compopt