def _on_item_retrieved(self, order): if order.results and self._submit_tmstmp <= order.timestamp: cache, *_ = order.results pixbuf = plyr_cache_to_pixbuf(cache, width=150, height=150) if pixbuf is not None: self.set_from_pixbuf(pixbuf) self._last_query = order.query
def __init__(self, query, cache, max_width=200): Gtk.Box.__init__(self, Gtk.Orientation.HORIZONTAL) # Convert the cache to a pixbuf and configure the coverart widget: pixbuf = plyr_cache_to_pixbuf(cache) cover = CoverWidget(pixbuf) cover.set_property('margin', 3) # Configure the StarSlider for the Rating: star_slider = create_rating_slider(cache) # Now add the Metadata: lsbox = Gtk.ListBox() lsbox.set_selection_mode(Gtk.SelectionMode.NONE) lsbox.add( listbox_create_labelrow( 'Provider', Gtk.LinkButton.new_with_label( cache.source_url, cache.provider ) ) ) lsbox.add( listbox_create_labelrow('Size', Gtk.Label( '{w}x{h}px ({sz} Bytes)'.format( w=pixbuf.get_width(), h=pixbuf.get_height(), sz=sizeof_fmt(cache.size) ) )) ) lsbox.add( listbox_create_labelrow('Format', Gtk.Label( cache.image_format.upper() )) ) lsbox.add( listbox_create_labelrow('Timestamp', Gtk.Label( format_time(cache.timestamp) )) ) lsbox.add( listbox_create_labelrow('Rating', star_slider) ) control_box = ControlButtonsWidget(query, cache) star_slider.connect( 'percent-change', result_change_rating, query, cache, control_box ) # The Right Part of the widget overlay = Gtk.Overlay() overlay.add(lsbox) overlay.add_overlay(control_box) self.pack_start(cover, False, False, 0) self.pack_start(overlay, True, True, 0) self.set_vexpand(False) self.set_valign(Gtk.Align.START) self.set_size_request(100, 180)