mirror of
https://github.com/SoongNoonien/mpdevil.git
synced 2023-08-10 21:12:44 +03:00
added append, play and enqueue buttons to song popovers in the browser
This commit is contained in:
parent
7113d9d5e4
commit
209e027f62
33
bin/mpdevil
33
bin/mpdevil
@ -1515,10 +1515,12 @@ class FocusFrame(Gtk.Overlay):
|
|||||||
self._widget.connect("focus-out-event", lambda *args: self._frame.hide())
|
self._widget.connect("focus-out-event", lambda *args: self._frame.hide())
|
||||||
|
|
||||||
class SongPopover(Gtk.Popover):
|
class SongPopover(Gtk.Popover):
|
||||||
def __init__(self, client):
|
def __init__(self, client, show_buttons=True):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self._client=client
|
self._client=client
|
||||||
self._rect=Gdk.Rectangle()
|
self._rect=Gdk.Rectangle()
|
||||||
|
self._uri=None
|
||||||
|
box=Gtk.Box(orientation=Gtk.Orientation.VERTICAL, border_width=6, spacing=6)
|
||||||
|
|
||||||
# open-with button
|
# open-with button
|
||||||
open_button=Gtk.Button(image=Gtk.Image.new_from_icon_name("document-open-symbolic",Gtk.IconSize.BUTTON),tooltip_text=_("Open with…"))
|
open_button=Gtk.Button(image=Gtk.Image.new_from_icon_name("document-open-symbolic",Gtk.IconSize.BUTTON),tooltip_text=_("Open with…"))
|
||||||
@ -1527,12 +1529,25 @@ class SongPopover(Gtk.Popover):
|
|||||||
style_context=open_button.get_style_context()
|
style_context=open_button.get_style_context()
|
||||||
style_context.add_class("circular")
|
style_context.add_class("circular")
|
||||||
|
|
||||||
# button revealer
|
# open button revealer
|
||||||
self._open_button_revealer=Gtk.Revealer()
|
self._open_button_revealer=Gtk.Revealer()
|
||||||
self._open_button_revealer.set_halign(Gtk.Align.END)
|
self._open_button_revealer.set_halign(Gtk.Align.END)
|
||||||
self._open_button_revealer.set_valign(Gtk.Align.END)
|
self._open_button_revealer.set_valign(Gtk.Align.END)
|
||||||
self._open_button_revealer.add(open_button)
|
self._open_button_revealer.add(open_button)
|
||||||
|
|
||||||
|
# buttons
|
||||||
|
if show_buttons:
|
||||||
|
button_box=Gtk.ButtonBox(layout_style=Gtk.ButtonBoxStyle.EXPAND)
|
||||||
|
data=((_("Append"), "list-add-symbolic", "append"),
|
||||||
|
(_("Play"), "media-playback-start-symbolic", "play"),
|
||||||
|
(_("Enqueue"), "insert-object-symbolic", "enqueue")
|
||||||
|
)
|
||||||
|
for label, icon, mode in data:
|
||||||
|
button=Gtk.Button(label=label, image=Gtk.Image.new_from_icon_name(icon, Gtk.IconSize.BUTTON))
|
||||||
|
button.connect("clicked", self._on_button_clicked, mode)
|
||||||
|
button_box.pack_start(button, True, True, 0)
|
||||||
|
box.pack_end(button_box, False, False, 0)
|
||||||
|
|
||||||
# treeview
|
# treeview
|
||||||
# (tag, display-value, tooltip)
|
# (tag, display-value, tooltip)
|
||||||
self._store=Gtk.ListStore(str, str, str)
|
self._store=Gtk.ListStore(str, str, str)
|
||||||
@ -1565,12 +1580,14 @@ class SongPopover(Gtk.Popover):
|
|||||||
open_button.connect("clicked", self._on_open_button_clicked)
|
open_button.connect("clicked", self._on_open_button_clicked)
|
||||||
|
|
||||||
# packing
|
# packing
|
||||||
frame=Gtk.Frame(border_width=6)
|
frame=Gtk.Frame()
|
||||||
frame.add(overlay)
|
frame.add(overlay)
|
||||||
self.add(frame)
|
box.pack_start(frame, True, True, 0)
|
||||||
frame.show_all()
|
self.add(box)
|
||||||
|
box.show_all()
|
||||||
|
|
||||||
def open(self, uri, widget, x, y, offset=26):
|
def open(self, uri, widget, x, y, offset=26):
|
||||||
|
self._uri=uri
|
||||||
self._rect.x=x
|
self._rect.x=x
|
||||||
# Gtk places popovers in treeviews 26px above the given position for no obvious reasons, so I move them 26px
|
# Gtk places popovers in treeviews 26px above the given position for no obvious reasons, so I move them 26px
|
||||||
# This seems to be related to the width/height of the headers in treeviews
|
# This seems to be related to the width/height of the headers in treeviews
|
||||||
@ -1609,6 +1626,10 @@ class SongPopover(Gtk.Popover):
|
|||||||
app.launch([self._gfile], None)
|
app.launch([self._gfile], None)
|
||||||
dialog.destroy()
|
dialog.destroy()
|
||||||
|
|
||||||
|
def _on_button_clicked(self, widget, mode):
|
||||||
|
self._client.files_to_playlist([self._uri], mode)
|
||||||
|
self.popdown()
|
||||||
|
|
||||||
class SongsView(Gtk.TreeView):
|
class SongsView(Gtk.TreeView):
|
||||||
def __init__(self, client, store, file_column_id):
|
def __init__(self, client, store, file_column_id):
|
||||||
super().__init__(model=store, search_column=-1, activate_on_single_click=True)
|
super().__init__(model=store, search_column=-1, activate_on_single_click=True)
|
||||||
@ -2921,7 +2942,7 @@ class PlaylistWindow(Gtk.Box):
|
|||||||
action_bar.pack_end(audio)
|
action_bar.pack_end(audio)
|
||||||
|
|
||||||
# song popover
|
# song popover
|
||||||
self._song_popover=SongPopover(self._client)
|
self._song_popover=SongPopover(self._client, show_buttons=False)
|
||||||
|
|
||||||
# connect
|
# connect
|
||||||
self._treeview.connect("row-activated", self._on_row_activated)
|
self._treeview.connect("row-activated", self._on_row_activated)
|
||||||
|
Loading…
Reference in New Issue
Block a user