def enable(self, exaile): self.generator = SpectrumMoodbarGenerator() self.generator.check() self.exaile = exaile self.cache = ExaileMoodbarCache(os.path.join(xl.xdg.get_cache_dir(), 'moods')) xl.event.add_ui_callback(self._on_preview_device_enabled, 'preview_device_enabled') xl.event.add_ui_callback(self._on_preview_device_disabling, 'preview_device_disabling') previewdevice = exaile.plugins.enabled_plugins.get('previewdevice', None) if previewdevice: self.on_preview_device_enabled('', previewdevice)
class MoodbarPlugin: exaile = None generator = None cache = None def __init__(self): self.main_controller = self.preview_controller = None def enable(self, exaile): self.generator = SpectrumMoodbarGenerator() self.generator.check() self.exaile = exaile self.cache = ExaileMoodbarCache( os.path.join(xl.xdg.get_cache_dir(), 'moods')) xl.event.add_ui_callback(self._on_preview_device_enabled, 'preview_device_enabled') xl.event.add_ui_callback(self._on_preview_device_disabling, 'preview_device_disabling') previewdevice = exaile.plugins.enabled_plugins.get( 'previewdevice', None) if previewdevice: self.on_preview_device_enabled('', previewdevice) def on_gui_loaded(self): self.main_controller = MoodbarController( self, xl.player.PLAYER, self.exaile.gui.main.progress_bar) def disable(self, exaile): if not self.main_controller: # Disabled more than once or before gui_loaded return xl.event.remove_callback(self._on_preview_device_enabled, 'preview_device_enabled') xl.event.remove_callback(self._on_preview_device_disabling, 'preview_device_disabling') self.main_controller.destroy() if self.preview_controller: self.preview_controller.destroy() self.main_controller = self.preview_controller = None del self.exaile, self.cache, self.generator # Preview Device events def _on_preview_device_enabled(self, event, plugin, _=None): self.preview_controller = MoodbarController(self, plugin.player, plugin.progress_bar) def _on_preview_device_disabling(self, event, plugin, _=None): self.preview_controller.destroy() self.preview_controller = None
class MoodbarPlugin: def __init__(self): self.main_controller = self.preview_controller = None def enable(self, exaile): self.generator = SpectrumMoodbarGenerator() self.generator.check() self.exaile = exaile self.cache = ExaileMoodbarCache(os.path.join(xl.xdg.get_cache_dir(), 'moods')) self.painter = MoodbarPainter() xl.event.add_ui_callback(self._on_preview_device_enabled, 'preview_device_enabled') xl.event.add_ui_callback(self._on_preview_device_disabling, 'preview_device_disabling') previewdevice = exaile.plugins.enabled_plugins.get('previewdevice', None) if previewdevice: self.on_preview_device_enabled('', previewdevice) def on_gui_loaded(self): self.main_controller = MoodbarController(self, xl.player.PLAYER, self.exaile.gui.main.progress_bar) def disable(self, exaile): if not self.main_controller: # Disabled more than once or before gui_loaded return xl.event.remove_callback(self._on_preview_device_enabled, 'preview_device_enabled') xl.event.remove_callback(self._on_preview_device_disabling, 'preview_device_disabling') self.main_controller.destroy() if self.preview_controller: self.preview_controller.destroy() self.main_controller = self.preview_controller = None del self.exaile, self.cache, self.generator, self.painter # Preview Device events def _on_preview_device_enabled(self, event, plugin, _=None): self.preview_controller = MoodbarController(self, plugin.player, plugin.progress_bar) def _on_preview_device_disabling(self, event, plugin, _=None): self.preview_controller.destroy() self.preview_controller = None
def enable(self, exaile): self.generator = SpectrumMoodbarGenerator() self.generator.check() self.exaile = exaile self.cache = ExaileMoodbarCache(os.path.join(xl.xdg.get_cache_dir(), 'moods')) self.painter = MoodbarPainter() xl.event.add_ui_callback(self._on_preview_device_enabled, 'preview_device_enabled') xl.event.add_ui_callback(self._on_preview_device_disabling, 'preview_device_disabling') previewdevice = exaile.plugins.enabled_plugins.get('previewdevice', None) if previewdevice: self.on_preview_device_enabled('', previewdevice)