本文整理汇总了Python中lollypop.pop_infos.InfosPopover.populate方法的典型用法代码示例。如果您正苦于以下问题:Python InfosPopover.populate方法的具体用法?Python InfosPopover.populate怎么用?Python InfosPopover.populate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lollypop.pop_infos.InfosPopover
的用法示例。
在下文中一共展示了InfosPopover.populate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _on_lastfm_btn_clicked
# 需要导入模块: from lollypop.pop_infos import InfosPopover [as 别名]
# 或者: from lollypop.pop_infos.InfosPopover import populate [as 别名]
def _on_lastfm_btn_clicked(self, button):
if Lp.lastfm is not None:
if Lp.player.current_track.aartist_id == Type.COMPILATIONS:
artist = Lp.player.current_track.artist
else:
artist = Lp.player.current_track.aartist
popover = InfosPopover(artist, Lp.player.current_track.title)
popover.set_relative_to(button)
popover.populate()
popover.show()
示例2: _on_label_button_release
# 需要导入模块: from lollypop.pop_infos import InfosPopover [as 别名]
# 或者: from lollypop.pop_infos.InfosPopover import populate [as 别名]
def _on_label_button_release(self, eventbox, event):
"""
On clicked label, show artist informations in a popover
@param eventbox as Gtk.EventBox
@param event as Gdk.Event
"""
if (Lp.lastfm is not None or self.Wikipedia is not None) and\
self._album.artist_id != Type.COMPILATIONS:
popover = InfosPopover(self._album.artist_name)
popover.set_relative_to(eventbox)
popover.populate()
popover.show()
示例3: _on_infos_btn_clicked
# 需要导入模块: from lollypop.pop_infos import InfosPopover [as 别名]
# 或者: from lollypop.pop_infos.InfosPopover import populate [as 别名]
def _on_infos_btn_clicked(self, button):
"""
Show current artist informations
@param button as Gtk.Button
"""
if InfosPopover.should_be_shown():
artist_id = Lp.player.current_track.aartist_id
if artist_id == Type.COMPILATIONS:
artist = Lp.player.current_track.artist
else:
artist = Lp.player.current_track.aartist
popover = InfosPopover(artist, Lp.player.current_track.id)
popover.set_relative_to(button)
popover.populate()
popover.show()
示例4: ArtistView
# 需要导入模块: from lollypop.pop_infos import InfosPopover [as 别名]
# 或者: from lollypop.pop_infos.InfosPopover import populate [as 别名]
class ArtistView(View):
"""
Show artist albums and tracks
"""
def __init__(self, artist_id, genre_id):
"""
Init ArtistView
@param artist id as int
@param genre id as int
"""
View.__init__(self)
self._artist_id = artist_id
self._genre_id = genre_id
self._signal_id = None
self._artist_name = Lp.artists.get_name(artist_id)
if Lp.lastfm is not None:
self._popover = InfosPopover(self._artist_name)
builder = Gtk.Builder()
builder.add_from_resource('/org/gnome/Lollypop/ArtistView.ui')
builder.connect_signals(self)
self.attach(builder.get_object('ArtistView'), 0, 0, 1, 1)
builder.get_object('artist').set_label(self._artist_name)
self._pop_allowed = True
self._albumbox = Gtk.Grid()
self._albumbox.set_row_spacing(20)
self._albumbox.set_property("orientation", Gtk.Orientation.VERTICAL)
self._albumbox.show()
self._scrolledWindow.set_property('expand', True)
self._viewport.set_property("valign", Gtk.Align.START)
self._viewport.add(self._albumbox)
self.add(self._scrolledWindow)
def populate(self):
"""
Populate the view
@thread safe
"""
albums = self._get_albums()
GLib.idle_add(self._add_albums, albums, self._genre_id)
#######################
# PRIVATE #
#######################
def _get_albums(self):
"""
Get albums
@return album ids as [int]
@thread safe
"""
sql = Lp.db.get_cursor()
if self._artist_id == Type.COMPILATIONS:
albums = Lp.albums.get_compilations(self._genre_id,
sql)
elif self._genre_id == Type.ALL:
albums = Lp.albums.get_ids(self._artist_id,
None,
sql)
else:
albums = Lp.albums.get_ids(self._artist_id,
self._genre_id,
sql)
sql.close()
return albums
def _get_children(self):
"""
Return view children
@return [AlbumWidget]
"""
return self._albumbox.get_children()
def _add_albums(self, albums, genre_id):
"""
Pop an album and add it to the view,
repeat operation until album list is empty
@param [album ids as int]
@param genre id as int
"""
size_group = Gtk.SizeGroup(mode=Gtk.SizeGroupMode.HORIZONTAL)
if albums and not self._stop:
widget = AlbumDetailedWidget(albums.pop(0),
genre_id,
self._pop_allowed,
False,
size_group)
widget.show()
start_new_thread(widget.populate, ())
self._albumbox.add(widget)
GLib.idle_add(self._add_albums, albums, genre_id)
else:
self._stop = False
def _on_label_realize(self, eventbox):
"""
#.........这里部分代码省略.........
示例5: AlbumDetailedWidget
# 需要导入模块: from lollypop.pop_infos import InfosPopover [as 别名]
# 或者: from lollypop.pop_infos.InfosPopover import populate [as 别名]
#.........这里部分代码省略.........
self._cover = builder.get_object('cover')
self.set_cover()
self._title_label = Lp.albums.get_name(album_id)
builder.get_object('title').set_label(self._title_label)
builder.get_object('year').set_label(Lp.albums.get_year(album_id))
self.add(builder.get_object('AlbumDetailedWidget'))
if pop_allowed:
self._menu = builder.get_object('menu')
self._eventbox = builder.get_object('eventbox')
self._eventbox.connect('realize', self._on_eventbox_realize)
self._eventbox.connect("button-press-event",
self._show_web_art)
self._menu.connect('clicked',
self._pop_menu)
self._menu.show()
else:
self._eventbox = None
"""
Update playing indicator
"""
def update_playing_indicator(self):
for disc in self._discs:
self._tracks_left[disc].update_playing(Lp.player.current_track.id)
self._tracks_right[disc].update_playing(Lp.player.current_track.id)
"""
Populate tracks
@thread safe
"""
def populate(self):
self._stop = False
sql = Lp.db.get_cursor()
for disc in self._discs:
mid_tracks = int(0.5+Lp.albums.get_count_for_disc(self._album_id,
self._genre_id,
disc,
sql)/2)
tracks = Lp.albums.get_tracks_infos(self._album_id,
self._genre_id,
disc,
sql)
self.populate_list_left(tracks[:mid_tracks],
disc,
1)
self.populate_list_right(tracks[mid_tracks:],
disc,
mid_tracks + 1)
"""
Populate left list, thread safe
@param track's ids as array of int
@param track position as int
"""
def populate_list_left(self, tracks, disc, pos):
GLib.idle_add(self._add_tracks,
tracks,
self._tracks_left[disc],
pos)
"""
Populate right list, thread safe
@param track's ids as array of int