def __init__(self, config, on_volume_changed_hook, on_mute_changed_hook): self.mixer_handle = False self.config = config self.on_volume_changed_hook = on_volume_changed_hook self.on_mute_changed_hook = on_mute_changed_hook [card_index, control_name, cid] = self.get_config_params() MixerControlFrame.__init__(self, config, card_index, control_name, cid) self.mixer_handle = MixerHandler.connect(self.on_change) self.frame.set_shadow_type(gtk.SHADOW_OUT)
def _step_change_volume(self, step_down): inc = self.config.getfloat(self.config.get_default_section(), "scale_increment") volume = self.get_volume() volume = float(volume[0]) if (step_down): volume = max(0, volume - inc) else: volume = min(100, volume + inc) volume = int(volume) volume = [volume] * self.get_channel_count() self.set_volume(volume[0]) MixerControlFrame.on_volume_changed(self, volume) self.on_volume_changed_hook(False)
def on_slider_value_changed(self, slider, data=None): MixerControlFrame.on_slider_value_changed(self, slider, data) self.on_volume_changed_hook(False)
def on_mute_changed(self, mute): MixerControlFrame.on_mute_changed(self, mute) self.on_mute_changed_hook(True)
def on_mute_button(self, active): MixerControlFrame.on_mute_button(self, active) self.on_mute_changed_hook(False)
def on_volume_changed(self, volume): MixerControlFrame.on_volume_changed(self, volume) self.on_volume_changed_hook(True)
def __del__(self): MixerHandler.disconnect(self.mixer_handle) MixerControlFrame.__del__(self)
def update(self): [card_index, control_name, cid] = self.get_config_params() MixerHandler.disconnect(self.mixer_handle) MixerControlFrame.update(self, card_index, control_name, cid) self.frame.set_shadow_type(gtk.SHADOW_OUT) self.mixer_handle = MixerHandler.connect(self.on_change)