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
self._main_timeout_id=GLib.timeout_add(self._refresh_interval, self._main_loop) if "status" in self.commands():
self.emitter.emit("reconnected") self._main_timeout_id=GLib.timeout_add(self._refresh_interval, self._main_loop)
return True self.emitter.emit("reconnected")
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,17 +2794,22 @@ 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
if self._inserted_path is not None: # move try:
path=int(path.to_string()) if self._inserted_path is not None: # move
if path > self._inserted_path: path=int(path.to_string())
path=path-1 if path > self._inserted_path:
if path < self._inserted_path: path=path-1
self._inserted_path=self._inserted_path-1 if path < self._inserted_path:
self._client.wrapped_call("move", path, self._inserted_path) self._inserted_path=self._inserted_path-1
self._inserted_path=None self._client.wrapped_call("move", path, self._inserted_path)
else: # delete self._inserted_path=None
self._client.wrapped_call("delete", path) # bad song index possible else: # delete
self._playlist_version=self._client.wrapped_call("status")["playlist"] self._client.wrapped_call("delete", path) # bad song index possible
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())