Commits

virtuald committed d9cba6d

Fixes most plugins to use the primary player device when hooking playback_track_start and friends

Comments (0)

Files changed (10)

plugins/audioscrobbler/__init__.py

 
 import _scrobbler as scrobbler
 import asprefs
-from xl import common, event, xdg, metadata, settings, providers
+from xl import common, event, xdg, metadata, player, settings, providers
 from xl.nls import gettext as _
 from xlgui.accelerators import Accelerator
 from xlgui.widgets import menu
         if self.use_menu:
             self.remove_menu()
         if self.connected:
-            event.remove_callback(self.on_play, 'playback_track_start')
-            event.remove_callback(self.on_stop, 'playback_track_end')
+            event.remove_callback(self.on_play, 'playback_track_start', player.PLAYER)
+            event.remove_callback(self.on_stop, 'playback_track_end', player.PLAYER)
             self.connected = False
             self.save_cache()
         providers.unregister('mainwindow-accelerators',self.accelerator)
 
         logger.info("Connected to AudioScrobbler")
 
-        event.add_callback(self.on_play, 'playback_track_start')
-        event.add_callback(self.on_stop, 'playback_track_end')
+        event.add_callback(self.on_play, 'playback_track_start', player.PLAYER)
+        event.add_callback(self.on_stop, 'playback_track_end', player.PLAYER)
         self.connected = True
         self.connecting = False
 

plugins/awn/__init__.py

         EXAILE_AWN = ExaileAwn()
     EXAILE_AWN.exaile = exaile
     for signal in TRACK_CHANGE_CALLBACKS:
-        xl.event.add_callback(EXAILE_AWN.set_cover, signal)
+        xl.event.add_callback(EXAILE_AWN.set_cover, signal, player.PLAYER)
     xl.event.add_callback(EXAILE_AWN.enable_progress,
-            'playback_player_start')
+            'playback_player_start', player.PLAYER)
     xl.event.add_callback(EXAILE_AWN.disable_progress,
-            'playback_player_end')
+            'playback_player_end', player.PLAYER)
     xl.event.add_callback(EXAILE_AWN.toggle_pause_progress,
-            'playback_toggle_pause')
+            'playback_toggle_pause', player.PLAYER)
     xl.event.add_callback(EXAILE_AWN.on_option_set, 'plugin_awn_option_set')
     EXAILE_AWN.set_cover()
 
     for signal in TRACK_CHANGE_CALLBACKS:
         xl.event.remove_callback(EXAILE_AWN.set_cover, signal)
     xl.event.remove_callback(EXAILE_AWN.enable_progress,
-            'playback_player_start')
+            'playback_player_start', player.PLAYER)
     xl.event.remove_callback(EXAILE_AWN.disable_progress,
-            'playback_player_end')
+            'playback_player_end', player.PLAYER)
     xl.event.remove_callback(EXAILE_AWN.toggle_pause_progress,
-            'playback_toggle_pause')
+            'playback_toggle_pause', player.PLAYER)
     EXAILE_AWN.unset_cover()
     EXAILE_AWN.unset_timer()
     EXAILE_AWN.exaile = None

plugins/currentsong/__init__.py

 
 import dbus
 from gettext import gettext as _
-from xl import event
+from xl import event, player
 import sys
 
 ##############################################################################
     purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface")
     client = Pidgin(purple)
     event.add_callback(on_stop_action, 'quit_application')
-    event.add_callback(on_stop_action, 'playback_player_end')
-    event.add_callback(on_begin_action, 'playback_track_start')
-    event.add_callback(on_pause_action, 'playback_toggle_pause')
+    event.add_callback(on_stop_action, 'playback_player_end', player.PLAYER)
+    event.add_callback(on_begin_action, 'playback_track_start', player.PLAYER)
+    event.add_callback(on_pause_action, 'playback_toggle_pause', player.PLAYER)
 
 def disable(exaile):
     event.remove_callback(on_stop_action, 'quit_application')
-    event.remove_callback(on_stop_action, 'playback_player_end')
-    event.remove_callback(on_begin_action, 'playback_track_start')
-    event.remove_callback(on_pause_action, 'playback_toggle_pause')
+    event.remove_callback(on_stop_action, 'playback_player_end', player.PLAYER)
+    event.remove_callback(on_begin_action, 'playback_track_start', player.PLAYER)
+    event.remove_callback(on_pause_action, 'playback_toggle_pause', player.PLAYER)

plugins/desktopcover/__init__.py

             glib.idle_add(self.update_position)
 
         for e in self._events:
-            event.add_callback(getattr(self, 'on_%s' % e), e)
+            if 'playback' in e:
+                event.add_callback(getattr(self, 'on_%s' % e), e, player.PLAYER)
+            else:
+                event.add_callback(getattr(self, 'on_%s' % e), e)
+            
         event.add_callback(self.on_option_set, 'plugin_desktopcover_option_set')
 
         self.connect('expose-event', self.on_expose_event)
             Cleanups
         """
         for e in self._events:
-            event.remove_callback(getattr(self, 'on_%s' % e), e)
+            if 'playback' in e:
+                event.remove_callback(getattr(self, 'on_%s' % e), e, player.PLAYER)
+            else:
+                event.remove_callback(getattr(self, 'on_%s' % e), e)
+        
         event.remove_callback(self.on_option_set, 'plugin_desktopcover_option_set')
 
         gtk.Window.destroy(self)

plugins/lyricsviewer/__init__.py

         self._delay = 250
         self._id = 0
 
-        event.add_callback(self.playback_cb, 'playback_track_start')
-        event.add_callback(self.playback_cb, 'track_tags_changed')
-        event.add_callback(self.end_cb, 'playback_player_end')
+        event.add_callback(self.playback_cb, 'playback_track_start', player.PLAYER)
+        event.add_callback(self.playback_cb, 'track_tags_changed', player.PLAYER)
+        event.add_callback(self.end_cb, 'playback_player_end', player.PLAYER)
         event.add_callback(self.search_method_added_cb,
                 'lyrics_search_method_added')
 
     #end initialize_widgets
     
     def remove_callbacks(self):
-        event.remove_callback(self.playback_cb, 'playback_track_start')
-        event.remove_callback(self.playback_cb, 'track_tags_changed')
-        event.remove_callback(self.end_cb, 'playback_player_end')
+        event.remove_callback(self.playback_cb, 'playback_track_start', player.PLAYER)
+        event.remove_callback(self.playback_cb, 'track_tags_changed', player.PLAYER)
+        event.remove_callback(self.end_cb, 'playback_player_end', player.PLAYER)
         event.remove_callback(self.search_method_added_cb,
                 'lyrics_search_method_added')
         self.lyrics_methods_combo.remove_callbacks()

plugins/moodbar/__init__.py

     global ExaileModbar
     ExaileModbar.readMod('')
     ExaileModbar.setupUi()
-    event.add_callback(ExaileModbar.play_start, 'playback_track_start')
-    event.add_callback(ExaileModbar.play_end, 'playback_player_end')
+    event.add_callback(ExaileModbar.play_start, 'playback_track_start', player.PLAYER)
+    event.add_callback(ExaileModbar.play_end, 'playback_player_end', player.PLAYER)
 
 def disable(exaile):
     global ExaileModbar
     ExaileModbar.changeModToBar()
-    event.remove_callback(ExaileModbar.play_start, 'playback_track_start')
-    event.remove_callback(ExaileModbar.play_end, 'playback_player_end')
+    event.remove_callback(ExaileModbar.play_start, 'playback_track_start', player.PLAYER)
+    event.remove_callback(ExaileModbar.play_end, 'playback_player_end', player.PLAYER)
     ExaileModbar.destroy()
     ExaileModbar = None
 

plugins/mpris/mpris_player.py

         dbus.service.Object.__init__(self, bus, '/Player')
         self.exaile = exaile
         self._tag_converter = mpris_tag_converter.ExaileTagConverter(exaile)
-        xl.event.add_callback(self.track_change_cb, 'playback_track_start')
+        xl.event.add_callback(self.track_change_cb, 'playback_track_start', player.PLAYER)
         # FIXME: Does not watch for shuffle, repeat
         # TODO: playback_start does not distinguish if play button was pressed
         #       or we simply moved to a new track
         for event in ('playback_player_end', 'playback_player_start',
                 'playback_toggle_pause'):
-            xl.event.add_callback(self.status_change_cb, event)
+            xl.event.add_callback(self.status_change_cb, event, player.PLAYER)
 
 
     @dbus.service.method(INTERFACE_NAME)

plugins/notify/__init__.py

 import logging
 import pynotify
 
-from xl import covers, event, common, settings
+from xl import covers, event, common, player, settings
 from xl.nls import gettext as _
 from xlgui import icons
 from xlgui.preferences import widgets
 
 def enable(exaile):
     EXAILE_NOTIFICATION.exaile = exaile
-    event.add_callback(EXAILE_NOTIFICATION.on_play, 'playback_track_start')
+    event.add_callback(EXAILE_NOTIFICATION.on_play, 'playback_track_start', player.PLAYER)
 
 def disable(exaile):
-    event.remove_callback(EXAILE_NOTIFICATION.on_play, 'playback_track_start')
+    event.remove_callback(EXAILE_NOTIFICATION.on_play, 'playback_track_start', player.PLAYER)
 
 def get_preferences_pane():
     return notifyprefs

plugins/notifyosd/__init__.py

 
 def enable(exaile):
     EXAILE_NOTIFYOSD.exaile = exaile
-    event.add_callback(EXAILE_NOTIFYOSD.on_play, 'playback_player_start')
-    event.add_callback(EXAILE_NOTIFYOSD.on_pause, 'playback_player_pause')
-    event.add_callback(EXAILE_NOTIFYOSD.on_stop, 'playback_player_end')
-    event.add_callback(EXAILE_NOTIFYOSD.on_resume, 'playback_player_resume')
+    event.add_callback(EXAILE_NOTIFYOSD.on_play, 'playback_player_start', player.PLAYER)
+    event.add_callback(EXAILE_NOTIFYOSD.on_pause, 'playback_player_pause', player.PLAYER)
+    event.add_callback(EXAILE_NOTIFYOSD.on_stop, 'playback_player_end', player.PLAYER)
+    event.add_callback(EXAILE_NOTIFYOSD.on_resume, 'playback_player_resume', player.PLAYER)
     event.add_callback(EXAILE_NOTIFYOSD.on_quit, 'quit_application')
     event.add_callback(EXAILE_NOTIFYOSD.on_changed, 'track_tags_changed')
     if hasattr(exaile, 'gui'):
         EXAILE_NOTIFYOSD.gui_callback = True
 
 def disable(exaile):
-    event.remove_callback(EXAILE_NOTIFYOSD.on_play, 'playback_player_start')
-    event.remove_callback(EXAILE_NOTIFYOSD.on_pause, 'playback_player_pause')
-    event.remove_callback(EXAILE_NOTIFYOSD.on_stop, 'playback_player_end')
-    event.remove_callback(EXAILE_NOTIFYOSD.on_resume, 'playback_player_resume')
+    event.remove_callback(EXAILE_NOTIFYOSD.on_play, 'playback_player_start', player.PLAYER)
+    event.remove_callback(EXAILE_NOTIFYOSD.on_pause, 'playback_player_pause', player.PLAYER)
+    event.remove_callback(EXAILE_NOTIFYOSD.on_stop, 'playback_player_end', player.PLAYER)
+    event.remove_callback(EXAILE_NOTIFYOSD.on_resume, 'playback_player_resume', player.PLAYER)
     event.remove_callback(EXAILE_NOTIFYOSD.on_quit, 'quit_application')
     event.remove_callback(EXAILE_NOTIFYOSD.on_changed, 'track_tags_changed')
     if EXAILE_NOTIFYOSD.exaile.gui.tray_icon:

plugins/streamripper/__init__.py

 
         if add_call:
             event.add_callback(self.quit_application, 'quit_application')
-            event.add_callback(self.start_track, 'playback_track_start')
-            event.add_callback(self.stop_playback, 'playback_player_end')
+            event.add_callback(self.start_track, 'playback_track_start', player.PLAYER)
+            event.add_callback(self.stop_playback, 'playback_player_end', player.PLAYER)
         return False
 
     def stop_ripping(self):