def do_draw(self, cairo_context): pixbuf = self._get_pixbuf() if not pixbuf: return alloc = self.get_allocation() width, height = alloc.width, alloc.height scale_factor = get_scale_factor(self) width *= scale_factor height *= scale_factor if self._path: if width < (2 * scale_factor) or height < (2 * scale_factor): return round_thumbs = config.getboolean("albumart", "round") pixbuf = scale( pixbuf, (width - 2 * scale_factor, height - 2 * scale_factor)) pixbuf = add_border_widget(pixbuf, self, round_thumbs) else: pixbuf = scale(pixbuf, (width, height)) style_context = self.get_style_context() pbosf = get_pbosf_for_pixbuf(self, pixbuf) pbosf_render(style_context, cairo_context, pbosf, 0, 0)
def do_draw(self, cairo_context): pixbuf = self._get_pixbuf() if not pixbuf: return alloc = self.get_allocation() width, height = alloc.width, alloc.height scale_factor = self.get_scale_factor() width *= scale_factor height *= scale_factor if self._path: if width < (2 * scale_factor) or height < (2 * scale_factor): return pixbuf = scale( pixbuf, (width - 2 * scale_factor, height - 2 * scale_factor)) pixbuf = add_border_widget(pixbuf, self) else: pixbuf = scale(pixbuf, (width, height)) style_context = self.get_style_context() surface = get_surface_for_pixbuf(self, pixbuf) Gtk.render_icon_surface(style_context, cairo_context, surface, 0, 0)
def cell_data_pb(column, cell, model, iter_, data): album = model.get_album(iter_) if album is None: cell.set_property('icon-name', Icons.FOLDER) else: cover = get_scaled_cover(album) if cover: cover = add_border_widget(cover, view) surface = get_surface_for_pixbuf(self, cover) cell.set_property("surface", surface) else: cell.set_property('icon-name', Icons.MEDIA_OPTICAL)
def cell_data_pb(column, cell, model, iter_, data): album = model.get_album(iter_) if album is None: cell.set_property('icon-name', Icons.FOLDER) else: cover = get_scaled_cover(album) if cover: cover = add_border_widget(cover, view) pbosf = get_pbosf_for_pixbuf(self, cover) set_renderer_from_pbosf(cell, pbosf) else: cell.set_property('icon-name', Icons.MEDIA_OPTICAL)
def cell_data_pb(column, cell, model, iter_, data): album = model.get_album(iter_) if album is None: cell.set_property('stock_id', Gtk.STOCK_DIRECTORY) else: cover = get_scaled_cover(album) if cover: round_ = config.getboolean("albumart", "round") cover = add_border_widget(cover, view, cell, round=round_) pbosf = get_pbosf_for_pixbuf(self, cover) set_renderer_from_pbosf(cell, pbosf) else: cell.set_property('stock_id', Gtk.STOCK_CDROM)
def cell_data_pb(view, cell, model, iter_, no_cover): item = model.get_value(iter_) if item.album is None: surface = None elif item.cover: pixbuf = item.cover pixbuf = add_border_widget(pixbuf, self.view) surface = get_surface_for_pixbuf(self, pixbuf) # don't cache, too much state has an effect on the result self.__last_render_surface = None else: surface = no_cover if self.__last_render_surface == surface: return self.__last_render_surface = surface cell.set_property("surface", surface)
def __add_cover_to_list(self, cover): try: pbloader = GdkPixbuf.PixbufLoader() pbloader.write(get_url(cover['thumbnail'])[0]) pbloader.close() scale_factor = self.get_scale_factor() size = self.THUMB_SIZE * scale_factor - scale_factor * 2 pixbuf = pbloader.get_pixbuf().scale_simple(size, size, GdkPixbuf.InterpType.BILINEAR) pixbuf = add_border_widget(pixbuf, self) surface = get_surface_for_pixbuf(self, pixbuf) except (GLib.GError, IOError): pass else: def append(data): self.liststore.append(data) GLib.idle_add(append, [surface, cover])
def cell_data_pb(column, cell, model, iter_, no_cover): album = model.get_album(iter_) if album is None: pixbuf = None elif album.cover: pixbuf = album.cover round_ = config.getboolean("albumart", "round") pixbuf = add_border_widget(pixbuf, self.view, cell, round_) pixbuf = get_pbosf_for_pixbuf(self, pixbuf) # don't cache, too much state has an effect on the result self.__last_render_pb = None else: pixbuf = no_cover if self.__last_render_pb == pixbuf: return self.__last_render_pb = pixbuf set_renderer_from_pbosf(cell, pixbuf)
def test_add_border_widget(self): widget = Gtk.Button() add_border_widget(self.small, widget, True)
def test_add_border_widget(self): widget = Gtk.Button() cell = Gtk.CellRendererText() add_border_widget(self.small, widget, cell, True) add_border_widget(self.small, widget, None, True)