|
|
|
@ -185,8 +185,8 @@ class MPRISInterface: # TODO emit Seeked if needed
|
|
|
|
|
"HasTrackList": (GLib.Variant("b", False), None),
|
|
|
|
|
"Identity": (GLib.Variant("s", "mpdevil"), None),
|
|
|
|
|
"DesktopEntry": (GLib.Variant("s", "org.mpdevil.mpdevil"), None),
|
|
|
|
|
"SupportedUriSchemes": (GLib.Variant("s", "None"), None),
|
|
|
|
|
"SupportedMimeTypes": (GLib.Variant("s", "None"), None)},
|
|
|
|
|
"SupportedUriSchemes": (GLib.Variant("as", []), None),
|
|
|
|
|
"SupportedMimeTypes": (GLib.Variant("as", []), None)},
|
|
|
|
|
self._MPRIS_PLAYER_IFACE:
|
|
|
|
|
{"PlaybackStatus": (self._get_playback_status, None),
|
|
|
|
|
"LoopStatus": (self._get_loop_status, self._set_loop_status),
|
|
|
|
@ -656,41 +656,11 @@ class Client(MPDClient):
|
|
|
|
|
self._start_idle_id=None
|
|
|
|
|
self.music_directory=None
|
|
|
|
|
self.current_cover=None
|
|
|
|
|
self._bus=Gio.bus_get_sync(Gio.BusType.SESSION, None) # used for "show in file manager"
|
|
|
|
|
|
|
|
|
|
# connect
|
|
|
|
|
self._settings.connect("changed::socket-connection", lambda *args: self.reconnect())
|
|
|
|
|
|
|
|
|
|
# workaround for list group
|
|
|
|
|
# see: https://github.com/Mic92/python-mpd2/pull/187
|
|
|
|
|
def _parse_objects(self, lines, delimiters=[], lookup_delimiter=False):
|
|
|
|
|
obj = {}
|
|
|
|
|
for key, value in self._parse_pairs(lines):
|
|
|
|
|
key = key.lower()
|
|
|
|
|
if lookup_delimiter and key not in delimiters:
|
|
|
|
|
delimiters = delimiters + [key]
|
|
|
|
|
if obj:
|
|
|
|
|
if key in delimiters:
|
|
|
|
|
if lookup_delimiter:
|
|
|
|
|
if key in obj:
|
|
|
|
|
yield obj
|
|
|
|
|
obj = obj.copy()
|
|
|
|
|
while delimiters[-1] != key:
|
|
|
|
|
obj.pop(delimiters[-1], None)
|
|
|
|
|
delimiters.pop()
|
|
|
|
|
else:
|
|
|
|
|
yield obj
|
|
|
|
|
obj = {}
|
|
|
|
|
elif key in obj:
|
|
|
|
|
if not isinstance(obj[key], list):
|
|
|
|
|
obj[key] = [obj[key], value]
|
|
|
|
|
else:
|
|
|
|
|
obj[key].append(value)
|
|
|
|
|
continue
|
|
|
|
|
obj[key] = value
|
|
|
|
|
if obj:
|
|
|
|
|
yield obj
|
|
|
|
|
_parse_objects_direct = _parse_objects
|
|
|
|
|
|
|
|
|
|
# overloads to use Song class
|
|
|
|
|
def currentsong(self, *args):
|
|
|
|
|
return Song(super().currentsong(*args))
|
|
|
|
@ -868,13 +838,18 @@ class Client(MPDClient):
|
|
|
|
|
else:
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
def can_show_in_file_manager(self, uri):
|
|
|
|
|
try:
|
|
|
|
|
self._bus.call_sync("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "StartServiceByName",
|
|
|
|
|
GLib.Variant("(su)",("org.freedesktop.FileManager1",0)), GLib.VariantType("(u)"), Gio.DBusCallFlags.NONE, -1, None)
|
|
|
|
|
except GLib.GError:
|
|
|
|
|
return False
|
|
|
|
|
return self.get_absolute_path(uri) is not None
|
|
|
|
|
|
|
|
|
|
def show_in_file_manager(self, uri):
|
|
|
|
|
if (path:=self.get_absolute_path(uri)) is not None:
|
|
|
|
|
file=Gio.File.new_for_path(path)
|
|
|
|
|
bus=Gio.bus_get_sync(Gio.BusType.SESSION, None)
|
|
|
|
|
proxy=Gio.DBusProxy.new_sync(bus, Gio.DBusProxyFlags.NONE, None, "org.freedesktop.FileManager1",
|
|
|
|
|
"/org/freedesktop/FileManager1", "org.freedesktop.FileManager1", None)
|
|
|
|
|
proxy.call_sync("ShowItems", GLib.Variant("(ass)", ((file.get_uri(),),"")), Gio.DBusCallFlags.NONE, 500, None)
|
|
|
|
|
file=Gio.File.new_for_path(self.get_absolute_path(uri))
|
|
|
|
|
self._bus.call_sync("org.freedesktop.FileManager1", "/org/freedesktop/FileManager1", "org.freedesktop.FileManager1",
|
|
|
|
|
"ShowItems", GLib.Variant("(ass)", ((file.get_uri(),),"")), None, Gio.DBusCallFlags.NONE, -1, None)
|
|
|
|
|
|
|
|
|
|
def toggle_play(self):
|
|
|
|
|
status=self.status()
|
|
|
|
@ -1358,7 +1333,7 @@ class SongsList(TreeView):
|
|
|
|
|
rect=Gdk.Rectangle()
|
|
|
|
|
rect.x,rect.y=x,y
|
|
|
|
|
self._menu.set_pointing_to(rect)
|
|
|
|
|
self._show_action.set_enabled(self._client.get_absolute_path(uri) is not None)
|
|
|
|
|
self._show_action.set_enabled(self._client.can_show_in_file_manager(uri))
|
|
|
|
|
self._menu.popup()
|
|
|
|
|
|
|
|
|
|
def _on_row_activated(self, widget, path, view_column):
|
|
|
|
@ -2223,7 +2198,7 @@ class PlaylistView(TreeView):
|
|
|
|
|
rect=Gdk.Rectangle()
|
|
|
|
|
rect.x,rect.y=x,y
|
|
|
|
|
self._menu.set_pointing_to(rect)
|
|
|
|
|
self._show_action.set_enabled(self._client.get_absolute_path(uri) is not None)
|
|
|
|
|
self._show_action.set_enabled(self._client.can_show_in_file_manager(uri))
|
|
|
|
|
self._menu.popup()
|
|
|
|
|
|
|
|
|
|
def _clear(self, *args):
|
|
|
|
|