mirror of
https://github.com/SoongNoonien/mpdevil.git
synced 2023-08-10 21:12:44 +03:00
added audio output control to volume button
This commit is contained in:
parent
769102b0b7
commit
ad1fd2339c
50
bin/mpdevil
50
bin/mpdevil
@ -40,7 +40,7 @@ import dbus.service
|
|||||||
from dbus.mainloop.glib import DBusGMainLoop
|
from dbus.mainloop.glib import DBusGMainLoop
|
||||||
DBusGMainLoop(set_as_default=True)
|
DBusGMainLoop(set_as_default=True)
|
||||||
|
|
||||||
VERSION="0.9.5" # sync with setup.py
|
VERSION="0.9.5-dev" # sync with setup.py
|
||||||
COVER_REGEX=r"^\.?(album|cover|folder|front).*\.(gif|jpeg|jpg|png)$"
|
COVER_REGEX=r"^\.?(album|cover|folder|front).*\.(gif|jpeg|jpg|png)$"
|
||||||
|
|
||||||
|
|
||||||
@ -3163,6 +3163,34 @@ class SeekBar(Gtk.Box):
|
|||||||
if state == "stop":
|
if state == "stop":
|
||||||
self._disable()
|
self._disable()
|
||||||
|
|
||||||
|
class OutputPopover(Gtk.Popover):
|
||||||
|
def __init__(self, client, relative):
|
||||||
|
super().__init__()
|
||||||
|
self.set_relative_to(relative)
|
||||||
|
|
||||||
|
# adding vars
|
||||||
|
self._client=client
|
||||||
|
|
||||||
|
# widgets
|
||||||
|
box=Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6, border_width=3)
|
||||||
|
for output in self._client.wrapped_call("outputs"):
|
||||||
|
button=Gtk.CheckButton(label="{} ({})".format(output["outputname"], output["plugin"]))
|
||||||
|
if output["outputenabled"] == "1":
|
||||||
|
button.set_active(True)
|
||||||
|
button.connect("toggled", self._on_button_toggled, output["outputid"])
|
||||||
|
box.pack_start(button, False, False, 0)
|
||||||
|
|
||||||
|
# packing
|
||||||
|
self.add(box)
|
||||||
|
|
||||||
|
box.show_all()
|
||||||
|
|
||||||
|
def _on_button_toggled(self, button, out_id):
|
||||||
|
if button.get_active():
|
||||||
|
self._client.wrapped_call("enableoutput", out_id)
|
||||||
|
else:
|
||||||
|
self._client.wrapped_call("disableoutput", out_id)
|
||||||
|
|
||||||
class PlaybackOptions(Gtk.Box):
|
class PlaybackOptions(Gtk.Box):
|
||||||
def __init__(self, client, settings):
|
def __init__(self, client, settings):
|
||||||
super().__init__(spacing=6)
|
super().__init__(spacing=6)
|
||||||
@ -3185,10 +3213,10 @@ class PlaybackOptions(Gtk.Box):
|
|||||||
self._consume_button.set_can_focus(False)
|
self._consume_button.set_can_focus(False)
|
||||||
self._volume_button=Gtk.VolumeButton(use_symbolic=True, size=self._settings.get_gtk_icon_size("icon-size"))
|
self._volume_button=Gtk.VolumeButton(use_symbolic=True, size=self._settings.get_gtk_icon_size("icon-size"))
|
||||||
self._volume_button.set_can_focus(False)
|
self._volume_button.set_can_focus(False)
|
||||||
self._volume_button.set_sensitive(False) # do not allow volume change by user when MPD has not yet reported volume
|
self._adj=self._volume_button.get_adjustment()
|
||||||
adj=self._volume_button.get_adjustment()
|
self._adj.set_step_increment(0.05)
|
||||||
adj.set_step_increment(0.05)
|
self._adj.set_page_increment(0.1)
|
||||||
adj.set_page_increment(0.1)
|
self._adj.set_upper(0) # do not allow volume change by user when MPD has not yet reported volume (no output enabled/avail)
|
||||||
|
|
||||||
# connect
|
# connect
|
||||||
self._random_button_toggled=self._random_button.connect("toggled", self._set_option, "random")
|
self._random_button_toggled=self._random_button.connect("toggled", self._set_option, "random")
|
||||||
@ -3201,6 +3229,7 @@ class PlaybackOptions(Gtk.Box):
|
|||||||
self._single_changed=self._client.emitter.connect("single", self._single_refresh)
|
self._single_changed=self._client.emitter.connect("single", self._single_refresh)
|
||||||
self._consume_changed=self._client.emitter.connect("consume", self._consume_refresh)
|
self._consume_changed=self._client.emitter.connect("consume", self._consume_refresh)
|
||||||
self._volume_changed=self._client.emitter.connect("volume_changed", self._volume_refresh)
|
self._volume_changed=self._client.emitter.connect("volume_changed", self._volume_refresh)
|
||||||
|
self._volume_button.connect("button-press-event", self._on_volume_button_press_event)
|
||||||
self._client.emitter.connect("disconnected", self._on_disconnected)
|
self._client.emitter.connect("disconnected", self._on_disconnected)
|
||||||
self._client.emitter.connect("reconnected", self._on_reconnected)
|
self._client.emitter.connect("reconnected", self._on_reconnected)
|
||||||
self._settings.connect("notify::mini-player", self._on_mini_player)
|
self._settings.connect("notify::mini-player", self._on_mini_player)
|
||||||
@ -3247,24 +3276,31 @@ class PlaybackOptions(Gtk.Box):
|
|||||||
def _volume_refresh(self, emitter, volume):
|
def _volume_refresh(self, emitter, volume):
|
||||||
self._volume_button.handler_block(self._volume_button_changed)
|
self._volume_button.handler_block(self._volume_button_changed)
|
||||||
if volume < 0:
|
if volume < 0:
|
||||||
self._volume_button.set_sensitive(False)
|
|
||||||
self._volume_button.set_value(0)
|
self._volume_button.set_value(0)
|
||||||
|
self._adj.set_upper(0)
|
||||||
else:
|
else:
|
||||||
|
self._adj.set_upper(1)
|
||||||
self._volume_button.set_value(volume/100)
|
self._volume_button.set_value(volume/100)
|
||||||
self._volume_button.set_sensitive(True)
|
|
||||||
self._volume_button.handler_unblock(self._volume_button_changed)
|
self._volume_button.handler_unblock(self._volume_button_changed)
|
||||||
|
|
||||||
|
def _on_volume_button_press_event(self, widget, event):
|
||||||
|
if event.button == 3 and event.type == Gdk.EventType.BUTTON_PRESS:
|
||||||
|
pop=OutputPopover(self._client, self._volume_button)
|
||||||
|
pop.popup()
|
||||||
|
|
||||||
def _on_reconnected(self, *args):
|
def _on_reconnected(self, *args):
|
||||||
self._repeat_button.set_sensitive(True)
|
self._repeat_button.set_sensitive(True)
|
||||||
self._random_button.set_sensitive(True)
|
self._random_button.set_sensitive(True)
|
||||||
self._single_button.set_sensitive(True)
|
self._single_button.set_sensitive(True)
|
||||||
self._consume_button.set_sensitive(True)
|
self._consume_button.set_sensitive(True)
|
||||||
|
self._volume_button.set_sensitive(True)
|
||||||
|
|
||||||
def _on_disconnected(self, *args):
|
def _on_disconnected(self, *args):
|
||||||
self._repeat_button.set_sensitive(False)
|
self._repeat_button.set_sensitive(False)
|
||||||
self._random_button.set_sensitive(False)
|
self._random_button.set_sensitive(False)
|
||||||
self._single_button.set_sensitive(False)
|
self._single_button.set_sensitive(False)
|
||||||
self._consume_button.set_sensitive(False)
|
self._consume_button.set_sensitive(False)
|
||||||
|
self._volume_button.set_sensitive(False)
|
||||||
self._repeat_refresh(None, False)
|
self._repeat_refresh(None, False)
|
||||||
self._random_refresh(None, False)
|
self._random_refresh(None, False)
|
||||||
self._single_refresh(None, False)
|
self._single_refresh(None, False)
|
||||||
|
Loading…
Reference in New Issue
Block a user