当前位置: 首页>>代码示例>>Python>>正文


Python InfoCache.get_artwork方法代码示例

本文整理汇总了Python中lollypop.cache.InfoCache.get_artwork方法的典型用法代码示例。如果您正苦于以下问题:Python InfoCache.get_artwork方法的具体用法?Python InfoCache.get_artwork怎么用?Python InfoCache.get_artwork使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lollypop.cache.InfoCache的用法示例。


在下文中一共展示了InfoCache.get_artwork方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __set_artwork

# 需要导入模块: from lollypop.cache import InfoCache [as 别名]
# 或者: from lollypop.cache.InfoCache import get_artwork [as 别名]
    def __set_artwork(self):
        """
            Set artist artwork
        """
        artwork_height = 0
        if Lp().settings.get_value('artist-artwork'):
            if len(self._artist_ids) == 1 and\
                    Lp().settings.get_value('artist-artwork'):
                artist = Lp().artists.get_name(self._artist_ids[0])
                size = ArtSize.ARTIST_SMALL * 2 * self.__scale_factor
                for suffix in ["lastfm", "spotify", "wikipedia"]:
                    uri = InfoCache.get_artwork(artist, suffix, size)
                    if uri is not None:
                        f = Lio.File.new_for_path(uri)
                        (status, data, tag) = f.load_contents(None)
                        stream = Gio.MemoryInputStream.new_from_data(data,
                                                                     None)
                        pixbuf = GdkPixbuf.Pixbuf.new_from_stream_at_scale(
                                                                       stream,
                                                                       size,
                                                                       size,
                                                                       True,
                                                                       None)
                        stream.close()
                        surface = Gdk.cairo_surface_create_from_pixbuf(
                                            pixbuf, self.__scale_factor, None)
                        del pixbuf
                        self.__artwork.set_from_surface(surface)
                        del surface
                        artwork_height = ArtSize.ARTIST_SMALL * 2
                        self.__artwork.get_style_context().remove_class(
                                                                'artwork-icon')
                        self.__artwork.show()
                        self.__artwork_box.show()
                        break
            # Add a default icon
            if len(self._artist_ids) == 1 and artwork_height == 0:
                self.__artwork.set_from_icon_name(
                                            'avatar-default-symbolic',
                                            Gtk.IconSize.DND)
                artwork_height = 32
                self.__artwork.get_style_context().add_class('artwork-icon')
                self.__artwork.show()
                self.__artwork_box.show()

        # Create an self.__empty widget with header height
        ctx = self.__label.get_pango_context()
        layout = Pango.Layout.new(ctx)
        layout.set_text("a", 1)
        # Font scale 2
        font_height = int(layout.get_pixel_size()[1]) * 2

        if artwork_height > font_height:
            self.__empty.set_property('height-request', artwork_height)
        else:
            self.__empty.set_property('height-request', font_height)
开发者ID:TainakaDrums,项目名称:lollypop,代码行数:58,代码来源:view_artist.py

示例2: _set_artwork

# 需要导入模块: from lollypop.cache import InfoCache [as 别名]
# 或者: from lollypop.cache.InfoCache import get_artwork [as 别名]
    def _set_artwork(self):
        """
            Set artist artwork
        """
        artwork_height = 0
        if Lp().settings.get_value('artist-artwork'):
            if len(self._artist_ids) == 1 and\
                    Lp().settings.get_value('artist-artwork'):
                artist = Lp().artists.get_name(self._artist_ids[0])

                for suffix in ["lastfm", "spotify", "wikipedia"]:
                    uri = InfoCache.get_artwork(
                                            artist, suffix,
                                            ArtSize.ARTIST_SMALL * 2 *
                                            self._artwork.get_scale_factor())
                    if uri is not None:
                        self._artwork.set_from_file(uri)
                        artwork_height = ArtSize.ARTIST_SMALL * 2
                        self._artwork.get_style_context().remove_class(
                                                                'artwork-icon')
                        self._artwork.show()
                        self._artwork_box.show()
                        break
            # Add a default icon
            if len(self._artist_ids) == 1 and artwork_height == 0:
                self._artwork.set_from_icon_name(
                                            'avatar-default-symbolic',
                                            Gtk.IconSize.DND)
                artwork_height = 32
                self._artwork.get_style_context().add_class('artwork-icon')
                self._artwork.show()
                self._artwork_box.show()

        # Create an self._empty widget with header height
        ctx = self._label.get_pango_context()
        layout = Pango.Layout.new(ctx)
        layout.set_text("a", 1)
        # Font scale 2
        font_height = int(layout.get_pixel_size()[1]) * 2

        if artwork_height > font_height:
            self._empty.set_property('height-request', artwork_height)
        else:
            self._empty.set_property('height-request', font_height)
开发者ID:Nikhil-z,项目名称:lollypop,代码行数:46,代码来源:view_artist.py

示例3: do_own_render

# 需要导入模块: from lollypop.cache import InfoCache [as 别名]
# 或者: from lollypop.cache.InfoCache import get_artwork [as 别名]
 def do_own_render(self, ctx, widget, cell_area, size):
     surface = None
     alpha = False
     if self.rowid in self._surfaces.keys():
         surface = self._surfaces[self.rowid]
     if surface is None:
         for suffix in ["lastfm", "spotify", "wikipedia"]:
             uri = InfoCache.get_artwork(self.artist, suffix, size)
             if uri is not None:
                 pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(uri,
                                                                 size,
                                                                 size)
                 surface = Gdk.cairo_surface_create_from_pixbuf(
                                                  pixbuf,
                                                  widget.get_scale_factor(),
                                                  None)
                 self._surfaces[self.rowid] = surface
                 del pixbuf
                 break
     if surface is None:
         alpha = True
         surface = Gtk.IconTheme.get_default().load_surface(
                                          'media-optical-cd-audio-symbolic',
                                          ArtSize.ARTIST_SMALL,
                                          1,
                                          widget.get_window(),
                                          0)
     ctx.translate(cell_area.x, cell_area.y)
     ctx.new_sub_path()
     radius = ArtSize.ARTIST_SMALL / 2
     ctx.arc(ArtSize.ARTIST_SMALL/2, ArtSize.ARTIST_SMALL/2,
             radius, 0, 2 * pi)
     ctx.set_source_rgb(1, 1, 1)
     ctx.fill_preserve()
     ctx.set_line_width(2)
     ctx.set_source_rgba(0, 0, 0, 0.3)
     ctx.stroke_preserve()
     ctx.set_source_surface(surface, 0, 0)
     ctx.clip()
     if alpha:
         ctx.paint_with_alpha(0.5)
     else:
         ctx.paint()
开发者ID:ferranroig,项目名称:lollypop,代码行数:45,代码来源:cellrenderer.py

示例4: __init__

# 需要导入模块: from lollypop.cache import InfoCache [as 别名]
# 或者: from lollypop.cache.InfoCache import get_artwork [as 别名]
    def __init__(self, artist_ids, genre_ids):
        """
            Init ArtistView
            @param artist id as int (Current if None)
            @param genre id as int
        """
        ArtistAlbumsView.__init__(self, artist_ids, genre_ids)
        self._signal_id = None
        self._artist_ids = artist_ids

        empty = Gtk.Grid()
        empty.set_property('height-request', ArtSize.ARTIST_SMALL * 2)
        empty.show()
        self._albumbox.add(empty)

        builder = Gtk.Builder()
        builder.add_from_resource('/org/gnome/Lollypop/ArtistView.ui')
        builder.connect_signals(self)
        self._artwork = builder.get_object('artwork')
        self._jump_button = builder.get_object('jump-button')
        self._jump_button.set_tooltip_text(_("Go to current track"))
        self._spinner = builder.get_object('spinner')
        header = builder.get_object('header')
        header.set_property('valign', Gtk.Align.START)
        self._overlay.add_overlay(header)
        self._overlay.set_overlay_pass_through(header, True)
        if len(artist_ids) == 1 and Lp().settings.get_value('artist-artwork'):
            artist = Lp().artists.get_name(artist_ids[0])
            for suffix in ["lastfm", "spotify", "wikipedia"]:
                uri = InfoCache.get_artwork(artist, suffix,
                                            ArtSize.ARTIST_SMALL * 2 *
                                            self._artwork.get_scale_factor())
                if uri is not None:
                    self._artwork.set_from_file(uri)
                    self._artwork.show()
                    break

        artists = []
        for artist_id in artist_ids:
            artists.append(Lp().artists.get_name(artist_id))
        builder.get_object('artist').set_label(", ".join(artists))
开发者ID:ferranroig,项目名称:lollypop,代码行数:43,代码来源:view_artist.py


注:本文中的lollypop.cache.InfoCache.get_artwork方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。