summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <wyskas@gmail.com>2009-08-28 11:03:03 +0200
committerAnton Khirnov <wyskas@gmail.com>2009-08-28 11:16:18 +0200
commit833ee22b1835c017c343fbbf1fde037e70c7f190 (patch)
tree2ca43b35142f48b06b394a44a45812b2efd7193b
parentffb97dfaeb19f9db1c14bef8a92d9ce83adb13fb (diff)
PlayControl: add a menu for controlling outputs.
-rw-r--r--gfx/outputs.pngbin0 -> 1549 bytes
-rw-r--r--nephilim/mpclient.py5
-rw-r--r--nephilim/plugins/PlayControl.py19
3 files changed, 21 insertions, 3 deletions
diff --git a/gfx/outputs.png b/gfx/outputs.png
new file mode 100644
index 0000000..e1079b3
--- /dev/null
+++ b/gfx/outputs.png
Binary files differ
diff --git a/nephilim/mpclient.py b/nephilim/mpclient.py
index 73dc44a..33b50b1 100644
--- a/nephilim/mpclient.py
+++ b/nephilim/mpclient.py
@@ -227,7 +227,10 @@ class MPClient(QtCore.QObject):
if not self.__check_command_ok('setvol'):
return
volume = min(100, max(0, volume))
- self._client.setvol(volume)
+ try:
+ self._client.setvol(volume)
+ except mpd.CommandError, e:
+ self.logger.warning('Error setting volume (probably no outputs enabled): %s.'%e)
def urlhandlers(self):
"""Returns an array of available url handlers."""
diff --git a/nephilim/plugins/PlayControl.py b/nephilim/plugins/PlayControl.py
index 1338fea..32a0e59 100644
--- a/nephilim/plugins/PlayControl.py
+++ b/nephilim/plugins/PlayControl.py
@@ -35,6 +35,7 @@ class wgPlayControl(QtGui.QToolBar):
random = None
single = None
consume = None
+ outputs_menu = None
p = None
logger = None
@@ -100,11 +101,25 @@ class wgPlayControl(QtGui.QToolBar):
self.p.mpclient.consume_changed.connect(self.consume.setChecked)
self.consume.toggled.connect(self.p.mpclient.consume)
+ self.outputs_menu = QtGui.QMenu('Audio outputs')
+ outputs = self.addAction(QtGui.QIcon('gfx/outputs.png'), 'Audio outputs')
+ outputs.triggered.connect(lambda : self.outputs_menu.popup(QtGui.QCursor.pos()))
+ self.p.mpclient.connect_changed.connect(self.__update_outputs)
+
self.orientationChanged.connect(self.vol_slider.setOrientation)
self.p.mpclient.state_changed.connect(self.onStateChange)
self.p.mpclient.volume_changed.connect(self.onVolumeChange)
+ def __update_outputs(self):
+ self.outputs_menu.clear()
+ for output in self.p.mpclient.outputs:
+ act = self.outputs_menu.addAction(output.name)
+ act.setCheckable(True)
+ act.setChecked(output.state)
+ act.toggled.connect(output.set_state)
+ output.state_changed.connect(act.setChecked)
+
def onStateChange(self, new_state):
status = self.p.mpclient.status()
@@ -137,8 +152,8 @@ class wgPlayControl(QtGui.QToolBar):
def on_next_click(self):
self.logger.info('Playing next')
self.p.mpclient.next()
- def onVolumeSliderChange(self):
- self.p.mpclient.set_volume(self.vol_slider.value())
+ def onVolumeSliderChange(self, val):
+ self.p.mpclient.set_volume(val)
class PlayControl(Plugin):
# public, const