improved mpd permissons handling

This commit is contained in:
Martin Wagner 2020-12-22 12:33:21 +01:00
parent 5953d73389
commit 7ae0f1e216

View File

@ -497,9 +497,15 @@ class Client(MPDClient):
self.emitter.emit("connection_error") self.emitter.emit("connection_error")
return False return False
# connect successful # connect successful
if "status" in self.commands():
self._main_timeout_id=GLib.timeout_add(self._refresh_interval, self._main_loop) self._main_timeout_id=GLib.timeout_add(self._refresh_interval, self._main_loop)
self.emitter.emit("reconnected") self.emitter.emit("reconnected")
return True return True
else:
self.disconnect()
self.emitter.emit("connection_error")
print("No read permission, check your mpd config.")
return False
def reconnect(self): def reconnect(self):
if self._main_timeout_id is not None: if self._main_timeout_id is not None:
@ -2788,6 +2794,7 @@ class PlaylistWindow(Gtk.Box):
pop.popup() pop.popup()
def _on_row_deleted(self, model, path): # sync treeview to mpd def _on_row_deleted(self, model, path): # sync treeview to mpd
try:
if self._inserted_path is not None: # move if self._inserted_path is not None: # move
path=int(path.to_string()) path=int(path.to_string())
if path > self._inserted_path: if path > self._inserted_path:
@ -2798,7 +2805,11 @@ class PlaylistWindow(Gtk.Box):
self._inserted_path=None self._inserted_path=None
else: # delete else: # delete
self._client.wrapped_call("delete", path) # bad song index possible self._client.wrapped_call("delete", path) # bad song index possible
self._playlist_version=self._client.wrapped_call("status")["playlist"] self._playlist_version=int(self._client.wrapped_call("status")["playlist"])
except MPDBase.CommandError as e:
self._playlist_version=None
self._client.emitter.emit("playlist_changed", int(self._client.wrapped_call("status")["playlist"]))
raise e # propagate exception
def _on_row_inserted(self, model, path, treeiter): def _on_row_inserted(self, model, path, treeiter):
self._inserted_path=int(path.to_string()) self._inserted_path=int(path.to_string())