Skip to content

Commit

Permalink
osd: hide window on playback error; event plugins: provide plugin_on_…
Browse files Browse the repository at this point in the history
…error()
  • Loading branch information
lazka committed Jun 3, 2014
1 parent 9e5811b commit 726f7c9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
5 changes: 5 additions & 0 deletions quodlibet/quodlibet/ext/events/animosd.py
Expand Up @@ -673,6 +673,11 @@ def plugin_on_song_started(self, song):
window.show()
window.fade_in()

def plugin_on_error(self, song, error):
if self.__current_window is not None:
self.__current_window.destroy()
self.__current_window = None

@staticmethod
def start_fade_out(window):
window.fade_out()
Expand Down
3 changes: 3 additions & 0 deletions quodlibet/quodlibet/player/__init__.py
Expand Up @@ -25,6 +25,9 @@ def __unicode__(self):
return self.short_desc + (
u"\n" + self.long_desc if self.long_desc else u"")

def __str__(self):
return unicode(self).encode('utf-8')

def __repr__(self):
return "%s(%r, %r)" % (
type(self).__name__, repr(self.short_desc), repr(self.long_desc))
Expand Down
3 changes: 2 additions & 1 deletion quodlibet/quodlibet/plugins/events.py
Expand Up @@ -30,6 +30,7 @@ class EventPlugin(object):
obj.plugin_on_paused()
obj.plugin_on_unpaused()
obj.plugin_on_seek(song, msec)
obj.plugin_on_error(song, error)
"""

PLUGIN_INSTANCE = True
Expand Down Expand Up @@ -79,7 +80,7 @@ def handler(librarian, *args):
librarian.connect(event, handler, event)

if librarian and player:
sigs = _map_signals(player, blacklist=("notify", "error"))
sigs = _map_signals(player, blacklist=("notify",))
for event, handle in sigs:
def cb_handler(librarian, *args):
self.__invoke(librarian, args[-1], *args[:-1])
Expand Down
6 changes: 5 additions & 1 deletion quodlibet/quodlibet/qltk/quodlibetwindow.py
Expand Up @@ -453,11 +453,15 @@ def delayed_song_set():
('song-started', self.__song_started),
('paused', self.__update_paused, True),
('unpaused', self.__update_paused, False),
('error', self.__player_error),
]
for sig in player_sigs:
gobject_weak(player.connect, *sig, **{"parent": self})

# make sure we redraw all error indicators before opening
# a dialog (blocking the main loop), so connect after default handlers
gobject_weak(player.connect_after, 'error',
self.__player_error, **{"parent": self})

# connect after to let SongTracker update stats
player_sigs.append(
gobject_weak(player.connect_after, "song-ended",
Expand Down

0 comments on commit 726f7c9

Please sign in to comment.