Don't use iterkeys when modifying a dict

Signed-off-by: Niklas Koep <niklas.koep@gmail.com>
Visualization: handle import errors gracefully

When a module raises an exception upon importing we now catch it and just print
the associated message on the console instead of letting the interpreter shut down
due to unhandled exceptions. After all, visualizations aren't vital for the basic
functionality so we might as well keep operating without them.

Signed-off-by: Niklas Koep <niklas.koep@gmail.com>
BlaPlaylist: flush CLI queue after adding tracks

Signed-off-by: Niklas Koep <niklas.koep@gmail.com>
Conform to Arch's interpreter naming convention

Script executables now start with an explicit `python2' instead
of python. This is how Arch Linux refers to python2 nowadays; python
is, if installed, a symlink to python3. Considering blaplay is now
developed on Arch this makes development much less of a hassle.

Signed-off-by: Niklas Koep <niklas.koep@gmail.com>
BlaFileBrowser: catch unhandled exception

Signed-off-by: Niklas Koep <niklas.koep@gmail.com>
BlaPlayer: don't use playbin2's volume property

Starting with gstreamer 0.10.24 playbin2's volume property and pulseaudio are
linked. That means if pulseaudio is configured to do so its master volume will
follow the loudest element connected to a device mixer. While a good idea at
first glance it frequently causes the system volume to jump from rather low to high
values when volume is adjusted in blaplay. We now circumvent this situation by adding
a separate volume element to our gstreamer pipeline.

Signed-off-by: Niklas Koep <niklas.koep@gmail.com>
BlaVisualization: display proper error messages

Display proper error messages depending on whether a visualization
element fails to pass our init tests or if there are no visualization
elements to activate to begin with.

Signed-off-by: Niklas Koep <niklas.koep@gmail.com>
Include mmkeys extension module

Fix up setup.py script to build the mmkeys extension module. We still try
to import a system-wide mmkeys module but resort to using our own if it's
not present. Additionally, make sure in setup.py script that numpy headers
are found by the compiler.

Signed-off-by: Niklas Koep <niklas.koep@gmail.com>
blafm.py: fix crucial bug in scrobbler filter

The scrobbler filter previously ignored everything when no exclude rules
were given in the preferences dialog. This change fixes it.

Signed-off-by: Niklas Koep <niklas.koep@gmail.com>
spectrum.pyx: don't confuse cython with a modified __builtin__

Signed-off-by: Niklas Koep <niklas.koep@gmail.com>
Minor changes, comment modifications and annotations

Signed-off-by: Niklas Koep <niklas.koep@gmail.com>
Prepone initialization of messaging functions

Messaging functions are now added to __builtin__'s __dict__ as soon as
possible so the exposed functions can already be used, for
instance, when the bladbus module fails to import dbus and wants to
complain about it. Previously this would raise a NameError exception.

Signed-off-by: Niklas Koep <niklas.koep@gmail.com>
blametadata.py: don't overwrite format builtin

Signed-off-by: Niklas Koep <niklas.koep@gmail.com>
blautils.py: catch webbrowser exception

Opening a URL in a browser is passed on to the webbrowser module.
While the behaviour is seemingly erratic, if the BROWSER environment
variable is exported and points to a non-existent binary the webbrowser
module occasionally raises an exception (originating from subprocess.py).
We now catch said (OSError) exception just to be on the save side.

Signed-off-by: Niklas Koep <niklas.koep@gmail.com>
Visualizations: pick appropriate highlight color

Previously, the gtk.STATE_ACTIVE color in the base section of a
gtk.Style was used as highlight color in visualization elements.
This color, however, might not always be clearly distinguishable
from the background. We use the gtk.STATE_SELECTED color instead
now.

Signed-off-by: Niklas Koep <niklas.koep@gmail.com>
blabrowsers.py: bugfix in BlaTreeView.__popup_menu

Catch an unhandled exception when trying to open the right-click menu
without having any entries selected in the treeview. Additionally, we
now make the "Open containing directory" option insensitive if not all
selected items reside in the same directory. Lastly, make the option
insensitive in the filesystem browser as well if the selection is not a
directory, and make sure to descend into the actual directory, not the
one containing the selected one.

Signed-off-by: Niklas Koep <niklas.koep@gmail.com>
blaplayer.py: handle import errors gracefully

Add dummy class to mimic the basic behaviour of the gst module if it
fails to import. Additionally add a function to verify that gstreamer
works as expected. This is used to inform the user about a missing
gstreamer installation/plugin-set via a message box instead of unhandled
tracebacks on the command line.

Signed-off-by: Niklas Koep <niklas.koep@gmail.com>
blabrowsers.py: search filenames as well if useful

When querying the library we usually search through artist, title, and
album name. However, if we organize the library by the underlying
directory structure it's sensible to search filenames as well as this is
what's actually presented to the user.

Signed-off-by: Niklas Koep <niklas.koep@gmail.com>
blafm.py: catch unhandled exception

The __update_now_playing method might be invoked after the __uri
attribute has been set to None in the __submit_last_track method. This
would occasionally cause an unhandled KeyError exception when looking up
the BlaTrack instance in the library.

Signed-off-by: Niklas Koep <niklas.koep@gmail.com>
blaplaylist.py: base shuffle track selection on ID

When selecting a shuffled track from the current playlist via the
`get_random' closure in the `get_track' method we try to make sure that
the last track is not played twice in a row if possible. This could
previously raise an exception if the old track wasn't in the playlist
anymore (due to filtering or removal). However, the way we checked for
duplicates was based on the absolute path in the treemodel which isn't
intuitive to begin with. Instead, we now compare playlist IDs as these
are unique. Additionally, this takes care of the unhandled exception
from before.

Signed-off-by: Niklas Koep <niklas.koep@gmail.com>