def on_condition_met(self): # disable because the clear() causes a settings write self.is_enabled = False model = self.widget.get_model() if model is None: return model.clear() for device_name, device_id, _create_audiosink_cb in get_devices(): model.append((device_id, device_name)) self.is_enabled = True self._set_value() self.show_widget() self.set_widget_sensitive(True)
def __autoconfig(): ''' If the user hasn't used our plugin before, then try to autoconfig their audio settings to use a different audio device if possible.. TODO: It would be cool if we could notify the user that a new device was plugged in... ''' from xl import settings if settings.get_option('preview_device/audiosink', None) is not None: return sink = settings.get_option('player/audiosink', None) if sink is None: return settings.set_option('preview_device/audiosink', sink) main_device = settings.get_option('player/audiosink_device', None) if main_device is None: return # TODO: If we ever add another engine, need to make sure that # gstreamer-specific stuff doesn't accidentally get loaded from xl.player.gst.sink import get_devices # pick the first one that isn't the main device and isn't 'Auto' # -> if the main device is '', then it's auto. So... we actually # iterate backwards, assuming that the ordering matters for _unused, device_id, _unused in reversed(list(get_devices())): if device_id != main_device and name != 'auto': settings.set_option('preview_device/audiosink_device', device_id) break