mirror of
https://github.com/SoongNoonien/mpdevil.git
synced 2023-08-10 21:12:44 +03:00
simplified SongPopover
This commit is contained in:
parent
72588b5b66
commit
2f28b91865
25
bin/mpdevil
25
bin/mpdevil
@ -1425,7 +1425,7 @@ class FocusFrame(Gtk.Overlay):
|
||||
self._widget.connect("focus-out-event", lambda *args: self._frame.hide())
|
||||
|
||||
class SongPopover(Gtk.Popover):
|
||||
def __init__(self, song, abs_path, relative, x, y, offset=26):
|
||||
def __init__(self, uri, client, relative, x, y, offset=26):
|
||||
super().__init__()
|
||||
rect=Gdk.Rectangle()
|
||||
rect.x=x
|
||||
@ -1437,6 +1437,10 @@ class SongPopover(Gtk.Popover):
|
||||
self.set_pointing_to(rect)
|
||||
self.set_relative_to(relative)
|
||||
|
||||
# client calls
|
||||
song=client.wrapped_call("get_metadata", uri)
|
||||
abs_path=client.wrapped_call("get_absolute_path", uri)
|
||||
|
||||
# css
|
||||
style_context=self.get_style_context()
|
||||
provider=Gtk.CssProvider()
|
||||
@ -1552,12 +1556,11 @@ class SongsView(Gtk.TreeView):
|
||||
elif event.button == 2 and event.type == Gdk.EventType.BUTTON_RELEASE:
|
||||
self._client.wrapped_call("files_to_playlist", [self._store[path][self._file_column_id]], "append")
|
||||
elif event.button == 3 and event.type == Gdk.EventType.BUTTON_RELEASE:
|
||||
song=self._client.wrapped_call("get_metadata", self._store[path][self._file_column_id])
|
||||
abs_song_path=self._client.wrapped_call("get_absolute_path", self._store[path][self._file_column_id])
|
||||
uri=self._store[path][self._file_column_id]
|
||||
if self.get_property("headers-visible"):
|
||||
pop=SongPopover(song, abs_song_path, widget, int(event.x), int(event.y))
|
||||
pop=SongPopover(uri, self._client, widget, int(event.x), int(event.y))
|
||||
else:
|
||||
pop=SongPopover(song, abs_song_path, widget, int(event.x), int(event.y), offset=0)
|
||||
pop=SongPopover(uri, self._client, widget, int(event.x), int(event.y), offset=0)
|
||||
pop.popup()
|
||||
self._button_event=(None, None)
|
||||
|
||||
@ -1571,9 +1574,7 @@ class SongsView(Gtk.TreeView):
|
||||
elif event.keyval == Gdk.keyval_from_name("Menu"):
|
||||
path=self._store.get_path(treeiter)
|
||||
cell=self.get_cell_area(path, None)
|
||||
song=self._client.wrapped_call("get_metadata", self._store[path][self._file_column_id])
|
||||
abs_song_path=self._client.wrapped_call("get_absolute_path", self._store[path][self._file_column_id])
|
||||
pop=SongPopover(song, abs_song_path, widget, cell.x, cell.y)
|
||||
pop=SongPopover(self._store[path][self._file_column_id], self._client, widget, cell.x, cell.y)
|
||||
pop.popup()
|
||||
|
||||
class SongsWindow(Gtk.Box):
|
||||
@ -2887,9 +2888,7 @@ class PlaylistWindow(Gtk.Box):
|
||||
if event.button == 2 and event.type == Gdk.EventType.BUTTON_RELEASE:
|
||||
self._store.remove(self._store.get_iter(path))
|
||||
elif event.button == 3 and event.type == Gdk.EventType.BUTTON_RELEASE:
|
||||
song=self._client.wrapped_call("get_metadata", self._store[path][8])
|
||||
abs_song_path=self._client.wrapped_call("get_absolute_path", self._store[path][8])
|
||||
pop=SongPopover(song, abs_song_path, widget, int(event.x), int(event.y))
|
||||
pop=SongPopover(self._store[path][8], self._client, widget, int(event.x), int(event.y))
|
||||
pop.popup()
|
||||
self._button_event=(None, None)
|
||||
|
||||
@ -2906,9 +2905,7 @@ class PlaylistWindow(Gtk.Box):
|
||||
if treeiter is not None:
|
||||
path=self._store.get_path(treeiter)
|
||||
cell=self._treeview.get_cell_area(path, None)
|
||||
song=self._client.wrapped_call("get_metadata", self._store[path][8])
|
||||
abs_song_path=self._client.wrapped_call("get_absolute_path", self._store[path][8])
|
||||
pop=SongPopover(song, abs_song_path, widget, int(cell.x), int(cell.y))
|
||||
pop=SongPopover(self._store[path][8], self._client, widget, int(cell.x), int(cell.y))
|
||||
pop.popup()
|
||||
|
||||
def _on_row_deleted(self, model, path): # sync treeview to mpd
|
||||
|
Loading…
Reference in New Issue
Block a user