Example #1
0
    def key_event(self, event):
        self.cursorCheck()

        # change focus
        if event == ord('h') or event == ord('l'):
            self.cursor += -1 if event == ord('h')  else +1
            # cursorCheck happens here, too!
            self.draw_controls()
            self.draw_info()
            return True

        elif event in [ ord('k'), ord('K'), ord('j'), ord('J') ]:
            if self.cursor >= 0:
                par.get_sink_inputs_by_client(self.index)[self.cursor].changeVolume(event == ord('k') or event == ord('K'), event == ord('K') or event == ord('J'))

            self.draw_controls()
            return True

        elif event == ord('n'):
            if self.cursor >= 0:
                par.get_sink_inputs_by_client(self.index)[self.cursor].setVolume(1.0)

            self.draw_controls()
            return True

        elif event == ord('N'):
            sink_inputs = par.get_sink_inputs_by_client(self.index)
            for sink_input in sink_inputs:
                sink_input.setVolume(1.0)

            self.draw_controls()
            return True

        elif event == ord('m'):
            if self.cursor >= 0:
                par.get_sink_inputs_by_client(self.index)[self.cursor].setVolume(0.0)

            self.draw_controls()
            return True

        elif event == ord('M'):
            sink_inputs = par.get_sink_inputs_by_client(self.index)
            for sink_input in sink_inputs:
                sink_input.setVolume(0.0)

            self.draw_controls()
            return True

        elif event == ord('X'):
            if self.cursor >= 0:
                par.get_sink_inputs_by_client(self.index)[self.cursor].kill()

            self.draw_controls()
            return True

        return False
Example #2
0
 def cursorCheck(self):
     """
     Moves the cursor to the left until there is a sink input,
     or it's at the sink's volume.
     """
     client_inputs = par.get_sink_inputs_by_client(self.index)
     while self.cursor >= len(client_inputs):
         self.cursor -= 1
     if self.cursor < 0 and len(client_inputs) > 0:
         self.cursor = 0
     if len(client_inputs) == 0:
         self.cursor = -1
Example #3
0
 def cursorCheck(self):
     """
     Moves the cursor to the left until there is a sink input,
     or it's at the sink's volume.
     """
     client_inputs = par.get_sink_inputs_by_client(self.index)
     while self.cursor >= len(client_inputs):
         self.cursor -= 1
     if self.cursor < 0 and len(client_inputs) > 0:
         self.cursor = 0
     if len(client_inputs) == 0:
         self.cursor = -1
Example #4
0
    def draw_controls(self):
        # don't proceed if it's not even our turn to draw
        if self.drawable is False:
            return

        # if we aren't active, this needn't even be considered
        self.cursorCheck()

        wcontrols = self.wcontrols
        wcontrols.erase()

        inputs = par.get_sink_inputs_by_client(self.index)
        i = 0
        for input in inputs:
            input.draw_control(wcontrols.derwin(2, 2 + i*20),  curses.A_BOLD if self.cursor == i else 0)
            i += 1
Example #5
0
    def draw_controls(self):
        # don't proceed if it's not even our turn to draw
        if self.drawable is False:
            return

        # if we aren't active, this needn't even be considered
        self.cursorCheck()

        wcontrols = self.wcontrols
        wcontrols.erase()

        inputs = par.get_sink_inputs_by_client(self.index)
        i = 0
        for input in inputs:
            input.draw_control(wcontrols.derwin(2, 2 + i * 20),
                               curses.A_BOLD if self.cursor == i else 0)
            i += 1
Example #6
0
 def getActiveVolume(self):
     self.cursorCheck()
     if self.cursor >= 0:
         return par.get_sink_inputs_by_client(self.index)[self.cursor]
     return None
Example #7
0
    def key_event(self, event):
        self.cursorCheck()

        # change focus
        if event == ord('h') or event == ord('l'):
            self.cursor += -1 if event == ord('h') else +1
            # cursorCheck happens here, too!
            self.draw_controls()
            self.draw_info()
            return True

        elif event in [ord('k'), ord('K'), ord('j'), ord('J')]:
            if self.cursor >= 0:
                par.get_sink_inputs_by_client(
                    self.index)[self.cursor].changeVolume(
                        event == ord('k') or event == ord('K'),
                        event == ord('K') or event == ord('J'))

            self.draw_controls()
            return True

        elif event == ord('n'):
            if self.cursor >= 0:
                par.get_sink_inputs_by_client(
                    self.index)[self.cursor].setVolume(1.0)

            self.draw_controls()
            return True

        elif event == ord('N'):
            sink_inputs = par.get_sink_inputs_by_client(self.index)
            for sink_input in sink_inputs:
                sink_input.setVolume(1.0)

            self.draw_controls()
            return True

        elif event == ord('m'):
            if self.cursor >= 0:
                par.get_sink_inputs_by_client(
                    self.index)[self.cursor].setVolume(0.0)

            self.draw_controls()
            return True

        elif event == ord('M'):
            sink_inputs = par.get_sink_inputs_by_client(self.index)
            for sink_input in sink_inputs:
                sink_input.setVolume(0.0)

            self.draw_controls()
            return True

        elif event == ord('X'):
            if self.cursor >= 0:
                par.get_sink_inputs_by_client(self.index)[self.cursor].kill()

            self.draw_controls()
            return True

        return False
Example #8
0
 def getActiveVolume(self):
     self.cursorCheck()
     if self.cursor >= 0:
         return par.get_sink_inputs_by_client(self.index)[self.cursor]
     return None