changed button style in SongPopover

This commit is contained in:
Martin Wagner 2022-02-11 17:48:54 +01:00
parent 2b491b2307
commit f50dfbd83b

View File

@ -1300,32 +1300,34 @@ class AutoSizedIcon(Gtk.Image):
class SongPopover(Gtk.Popover): class SongPopover(Gtk.Popover):
def __init__(self, client, show_buttons=True): def __init__(self, client, show_buttons=True):
super().__init__() super().__init__(position=Gtk.PositionType.BOTTOM)
self._client=client self._client=client
self._rect=Gdk.Rectangle() self._rect=Gdk.Rectangle()
self._uri=None self._uri=None
box=Gtk.Box(orientation=Gtk.Orientation.VERTICAL, border_width=6, spacing=6) box=Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6, border_width=6, halign=Gtk.Align.END, valign=Gtk.Align.END)
# 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…"))
open_button.get_style_context().add_class("osd") open_button.get_style_context().add_class("osd")
# open button revealer # open button revealer
self._open_button_revealer=Gtk.Revealer( self._open_button_revealer=Gtk.Revealer(child=open_button, transition_duration=0)
child=open_button, transition_duration=0, margin_bottom=6, margin_end=6, halign=Gtk.Align.END, valign=Gtk.Align.END) box.pack_end(self._open_button_revealer, False, False, 0)
# buttons # buttons
if show_buttons: if show_buttons:
button_box=Gtk.ButtonBox(layout_style=Gtk.ButtonBoxStyle.EXPAND) button_box=Gtk.ButtonBox(orientation=Gtk.Orientation.VERTICAL, layout_style=Gtk.ButtonBoxStyle.EXPAND, halign=Gtk.Align.END)
data=((_("Append"), "list-add-symbolic", "append"), data=((_("Append"), "list-add-symbolic", "append"),
(_("Play"), "media-playback-start-symbolic", "play"), (_("Play"), "media-playback-start-symbolic", "play"),
(_("Enqueue"), "insert-object-symbolic", "enqueue") (_("Enqueue"), "insert-object-symbolic", "enqueue")
) )
for label, icon, mode in data: for tooltip, icon, mode in data:
button=Gtk.Button(label=label, image=Gtk.Image.new_from_icon_name(icon, Gtk.IconSize.BUTTON)) button=Gtk.Button(tooltip_text=tooltip, image=Gtk.Image.new_from_icon_name(icon, Gtk.IconSize.BUTTON))
button.get_style_context().add_class("osd")
button.connect("clicked", self._on_button_clicked, mode) button.connect("clicked", self._on_button_clicked, mode)
button_box.pack_start(button, True, True, 0) button_box.pack_start(button, True, True, 0)
box.pack_end(button_box, False, False, 0) button_box_revealer=Gtk.Revealer(child=button_box, transition_duration=0, reveal_child=True) # needed for tooltips
box.pack_end(button_box_revealer, False, False, 0)
# treeview # treeview
# (tag, display-value, tooltip) # (tag, display-value, tooltip)
@ -1349,16 +1351,15 @@ class SongPopover(Gtk.Popover):
# overlay # overlay
overlay=Gtk.Overlay(child=self._scroll) overlay=Gtk.Overlay(child=self._scroll)
overlay.add_overlay(self._open_button_revealer) overlay.add_overlay(box)
# connect # connect
open_button.connect("clicked", self._on_open_button_clicked) open_button.connect("clicked", self._on_open_button_clicked)
# packing # packing
frame=Gtk.Frame(child=overlay) frame=Gtk.Frame(child=overlay, border_width=6)
box.pack_start(frame, True, True, 0) self.add(frame)
self.add(box) frame.show_all()
box.show_all()
def open(self, uri, widget, x, y): def open(self, uri, widget, x, y):
self._uri=uri self._uri=uri