avoid errors on accelerator use

This commit is contained in:
Martin Wagner 2020-09-30 11:21:41 +02:00
parent 7d3a440ac1
commit 784a62cee2

View File

@ -3316,6 +3316,7 @@ class MPDActionGroup(Gio.SimpleActionGroup):
self.add_action(action)
# connect
self._client.emitter.connect("state", self._on_state)
self._client.emitter.connect("disconnected", self._on_disconnected)
self._client.emitter.connect("reconnected", self._on_reconnected)
@ -3355,6 +3356,11 @@ class MPDActionGroup(Gio.SimpleActionGroup):
def _on_consume(self, action, param):
self._client.wrapped_call("toggle_option", "consume")
def _on_state(self, emitter, state):
state_dict={"play": True, "pause": True, "stop": False}
for action in ("next","prev","seek-forward","seek-backward"):
self.lookup_action(action).set_enabled(state_dict[state])
def _on_disconnected(self, *args):
for action in self._simple_actions_data:
self.lookup_action(action).set_enabled(False)