Exemple #1
0
    def cb_sink_input_scale(self, scale):
        value = int(scale.get_value())
        idx = self._find_sink_input_idx_by_scale(scale)

        m = self.volctl.pa_mgr.pa.pa_mainloop
        pa_threaded_mainloop_lock(m)
        sink_input = self.volctl.pa_mgr.pa_sink_inputs[idx]
        sink_input.set_volume(value)
        pa_threaded_mainloop_unlock(m)
Exemple #2
0
    def cb_scroll(self, widget, ev):
        old_vol = self.volume
        amount = PA_VOLUME_NORM / STEPS
        if ev.direction == Gdk.ScrollDirection.DOWN:
            amount *= -1
        elif ev.direction == Gdk.ScrollDirection.UP:
            pass
        else:
            return
        new_value = old_vol + amount
        new_value = min(PA_VOLUME_NORM, new_value)
        new_value = max(PA_VOLUME_MUTED, new_value)

        m = self.pa_mgr.pa.pa_mainloop
        pa_threaded_mainloop_lock(m)
        self.pa_mgr.set_volume(new_value)
        pa_threaded_mainloop_unlock(m)
Exemple #3
0
    def create_sliders(self):
        self.set_position()
        x = 0

        # touching pa objects here!
        pa_threaded_mainloop_lock(self.volctl.pa_mgr.pa.pa_mainloop)

        # sinks
        for idx, sink in self.volctl.pa_mgr.pa_sinks.iteritems():
            scale, icon = self.add_scale(sink)
            self.sink_scales[sink.idx] = scale
            scale.connect('value-changed', self.cb_sink_scale)
            self.update_scale(scale, sink.volume, sink.mute)
            scale.set_margin_top(6)
            icon.set_margin_bottom(6)
            self.grid.attach(scale, x, 0, 1, 1)
            self.grid.attach(icon, x, 1, 1, 1)
            x += 1

        # separator
        if len(self.volctl.pa_mgr.pa_sink_inputs) > 0:
            separator = Gtk.VSeparator()
            separator.set_margin_top(6)
            separator.set_margin_bottom(6)
            self.grid.attach(separator, x, 0, 1, 2)
            x += 1

        # sink inputs
        for idx, sink_input in self.volctl.pa_mgr.pa_sink_inputs.iteritems():
            scale, icon = self.add_scale(sink_input)
            self.sink_input_scales[sink_input.idx] = scale
            scale.connect('value-changed', self.cb_sink_input_scale)
            self.update_scale(scale, sink_input.volume, sink_input.mute)
            scale.set_margin_top(6)
            icon.set_margin_bottom(6)
            self.grid.attach(scale, x, 0, 1, 1)
            self.grid.attach(icon, x, 1, 1, 1)
            x += 1

        pa_threaded_mainloop_unlock(self.volctl.pa_mgr.pa.pa_mainloop)
Exemple #4
0
 def cb_mute(self, widget):
     m = self.pa_mgr.pa.pa_mainloop
     pa_threaded_mainloop_lock(m)
     self.pa_mgr.toggle_mute()
     pa_threaded_mainloop_unlock(m)