本文整理汇总了Python中lollypop.pop_tunein.TuneinPopover.show方法的典型用法代码示例。如果您正苦于以下问题:Python TuneinPopover.show方法的具体用法?Python TuneinPopover.show怎么用?Python TuneinPopover.show使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lollypop.pop_tunein.TuneinPopover
的用法示例。
在下文中一共展示了TuneinPopover.show方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ToolbarInfos
# 需要导入模块: from lollypop.pop_tunein import TuneinPopover [as 别名]
# 或者: from lollypop.pop_tunein.TuneinPopover import show [as 别名]
class ToolbarInfos(Gtk.Bin):
"""
Init infos toolbar
"""
def __init__(self):
Gtk.Bin.__init__(self)
builder = Gtk.Builder()
builder.add_from_resource('/org/gnome/Lollypop/ToolbarInfos.ui')
builder.connect_signals(self)
infobox = builder.get_object('infos')
infobox.set_property('has-tooltip', True)
self.add(infobox)
self._title_label = builder.get_object('title')
self._artist_label = builder.get_object('artist')
self._cover = builder.get_object('cover')
self._pop_albums = AlbumsPopover()
self._pop_albums.set_relative_to(infobox)
self._pop_tunein = TuneinPopover(RadiosManager())
self._pop_tunein.set_relative_to(infobox)
Lp.art.connect('cover-changed', self._update_cover)
Lp.art.connect('logo-changed', self._update_logo)
"""
Update toolbar on current changed
@param player as Player
"""
def on_current_changed(self, player):
art = None
self._artist_label.set_text(player.current_track.artist)
self._title_label.set_text(player.current_track.title)
if player.current_track.id == Type.RADIOS:
art = Lp.art.get_radio(player.current_track.artist,
ArtSize.SMALL)
elif player.current_track.id == Type.EXTERNALS:
art = Lp.art.get_cover_for_uri(player.current_track.uri,
ArtSize.SMALL,
False)
else:
art = Lp.art.get_album(player.current_track.album_id,
ArtSize.SMALL)
if art is not None:
self._cover.set_from_pixbuf(art)
del art
self._cover.set_tooltip_text(player.current_track.album)
self._cover.show()
else:
self._cover.hide()
"""
Update infos on status changed
@param player as Player
"""
def on_status_changed(self, player):
pass
#######################
# PRIVATE #
#######################
"""
Update cover for album_id
@param art as Art
@param album id as int
"""
def _update_cover(self, art, album_id):
if Lp.player.current_track.album_id == album_id:
pixbuf = Lp.art.get_album(album_id, ArtSize.SMALL)
self._cover.set_from_pixbuf(pixbuf)
del pixbuf
"""
Update logo for name
@param art as Art
@param name as str
"""
def _update_logo(self, art, name):
if Lp.player.current_track.artist == name:
pixbuf = Lp.art.get_radio(name, ArtSize.SMALL)
self._cover.set_from_pixbuf(pixbuf)
del pixbuf
"""
Pop albums from current artistleft click
Show playlist menu on right
@param eventbox as Gtk.EventBox
@param event as Gdk.Event
"""
def _on_infobox_clicked(self, eventbox, event):
if Lp.player.current_track.id == Type.EXTERNALS:
expopover = ExternalsPopover()
expopover.set_relative_to(eventbox)
expopover.populate()
expopover.show()
elif Lp.player.current_track.id is not None:
if event.button == 1:
if Lp.player.current_track.id == Type.RADIOS:
self._pop_tunein.populate()
#.........这里部分代码省略.........
示例2: ToolbarInfo
# 需要导入模块: from lollypop.pop_tunein import TuneinPopover [as 别名]
# 或者: from lollypop.pop_tunein.TuneinPopover import show [as 别名]
class ToolbarInfo(Gtk.Bin, InfosController):
"""
Informations toolbar
"""
def __init__(self):
"""
Init toolbar
"""
Gtk.Bin.__init__(self)
InfosController.__init__(self, ArtSize.SMALL)
builder = Gtk.Builder()
builder.add_from_resource('/org/gnome/Lollypop/ToolbarInfo.ui')
builder.connect_signals(self)
self._pop_tunein = None
self._pop_info = None
self._timeout_id = None
self._width = 0
self._infobox = builder.get_object('info')
self.add(self._infobox)
self._labels = builder.get_object('nowplaying_labels')
self._title_label = builder.get_object('title')
self._artist_label = builder.get_object('artist')
self._cover_frame = builder.get_object('frame')
self._cover = builder.get_object('cover')
self._cover.set_property('has-tooltip', True)
# Since GTK 3.20, we can set cover full height
if Gtk.get_minor_version() > 18:
self._cover.get_style_context().add_class('toolbar-cover-frame')
else:
self._cover.get_style_context().add_class('small-cover-frame')
self.connect('realize', self._on_realize)
Lp().art.connect('album-artwork-changed', self._update_cover)
Lp().art.connect('radio-artwork-changed', self._update_logo)
def do_get_preferred_width(self):
"""
We force preferred width
@return (int, int)
"""
return (self._width, self._width)
def get_preferred_height(self):
"""
Return preferred height
@return (int, int)
"""
return self._labels.get_preferred_height()
def set_width(self, width):
"""
Set widget width
@param width as int
"""
self._width = width
self.set_property('width-request', width)
#######################
# PRIVATE #
#######################
def _update_cover(self, art, album_id):
"""
Update cover for album_id
@param art as Art
@param album id as int
"""
if Lp().player.current_track.album.id == album_id:
surface = Lp().art.get_album_artwork(
Lp().player.current_track.album,
ArtSize.SMALL)
self._cover.set_from_surface(surface)
del surface
def _update_logo(self, art, name):
"""
Update logo for name
@param art as Art
@param name as str
"""
if Lp().player.current_track.album_artist == name:
pixbuf = Lp().art.get_radio_artwork(name, ArtSize.SMALL)
self._cover.set_from_surface(pixbuf)
del pixbuf
def _show_track_menu(self):
"""
Show current track menu
"""
self._timeout_id = None
if Lp().player.current_track.id >= 0:
popover = TrackMenuPopover(
Lp().player.current_track.id,
PopToolbarMenu(Lp().player.current_track.id))
popover.set_relative_to(self._infobox)
popover.show()
#.........这里部分代码省略.........
示例3: RadiosView
# 需要导入模块: from lollypop.pop_tunein import TuneinPopover [as 别名]
# 或者: from lollypop.pop_tunein.TuneinPopover import show [as 别名]
class RadiosView(View):
"""
Show radios in a grid
"""
def __init__(self):
"""
Init view
"""
View.__init__(self)
self._signal = Lp().art.connect('radio-artwork-changed',
self._on_logo_changed)
self._radios_manager = Radios()
self._radios_manager.connect('radios-changed',
self._on_radios_changed)
builder = Gtk.Builder()
builder.add_from_resource('/org/gnome/Lollypop/RadiosView.ui')
builder.connect_signals(self)
widget = builder.get_object('widget')
self._empty = builder.get_object('empty')
self._pop_tunein = TuneinPopover(self._radios_manager)
self._pop_tunein.set_relative_to(builder.get_object('search_btn'))
self._sizegroup = Gtk.SizeGroup(mode=Gtk.SizeGroupMode.BOTH)
self._radiobox = Gtk.FlowBox()
self._radiobox.set_selection_mode(Gtk.SelectionMode.NONE)
self._radiobox.connect("child-activated", self._on_album_activated)
self._radiobox.set_property('column-spacing', 5)
self._radiobox.set_property('row-spacing', 5)
self._radiobox.set_homogeneous(True)
self._radiobox.set_max_children_per_line(1000)
self._radiobox.show()
self._stack = Gtk.Stack()
self._stack.set_transition_duration(500)
self._stack.set_transition_type(Gtk.StackTransitionType.CROSSFADE)
self._stack.add(self._scrolled)
self._stack.add(self._empty)
self._stack.show()
self._viewport.set_property("valign", Gtk.Align.START)
self._viewport.set_property('margin', 5)
self._viewport.add(self._radiobox)
self._scrolled.set_property('expand', True)
self.add(widget)
self.add(self._stack)
def populate(self):
"""
Populate view with tracks from playlist
Thread safe
"""
Lp().player.set_radios(self._radios_manager.get())
if Lp().player.current_track.id == Type.RADIOS:
Lp().player.set_next() # We force next update
Lp().player.set_prev() # We force prev update
t = Thread(target=self._populate)
t.daemon = True
t.start()
#######################
# PRIVATE #
#######################
def _populate(self):
"""
Populate view with tracks from playlist
Thread safe
"""
radios = []
# Get radios name
for (name, url) in self._radios_manager.get():
radios.append(name)
GLib.idle_add(self._show_stack, radios)
def _get_children(self):
"""
Return view children
@return [RadioWidget]
"""
children = []
for child in self._radiobox.get_children():
widget = child.get_child()
children.append(widget)
return children
def _on_destroy(self, widget):
"""
Disconnect signals
@param widget as Gtk.Widget
"""
if self._signal is not None:
Lp().art.disconnect(self._signal)
def _on_new_clicked(self, widget):
"""
Show popover for adding a new radio
#.........这里部分代码省略.........
示例4: ToolbarInfos
# 需要导入模块: from lollypop.pop_tunein import TuneinPopover [as 别名]
# 或者: from lollypop.pop_tunein.TuneinPopover import show [as 别名]
class ToolbarInfos(Gtk.Bin):
"""
Informations toolbar
"""
def __init__(self):
"""
Init toolbar
"""
Gtk.Bin.__init__(self)
builder = Gtk.Builder()
builder.add_from_resource('/org/gnome/Lollypop/ToolbarInfos.ui')
builder.connect_signals(self)
self._pop_tunein = None
self._pop_infos = None
self._infobox = builder.get_object('infos')
self._infobox.set_property('has-tooltip', True)
self.add(self._infobox)
self._title_label = builder.get_object('title')
self._artist_label = builder.get_object('artist')
self._cover = builder.get_object('cover')
Lp.art.connect('cover-changed', self._update_cover)
Lp.art.connect('logo-changed', self._update_logo)
def on_current_changed(self, player):
"""
Update toolbar on current changed
@param player as Player
"""
art = None
if player.current_track.artist == '':
self._artist_label.hide()
else:
self._artist_label.show()
self._artist_label.set_text(player.current_track.artist)
if player.current_track.title == '':
self._title_label.hide()
else:
self._title_label.show()
self._title_label.set_text(player.current_track.title)
if player.current_track.id == Type.RADIOS:
art = Lp.art.get_radio(player.current_track.artist,
ArtSize.SMALL*self.get_scale_factor())
elif player.current_track.id == Type.EXTERNALS:
art = Lp.art.get_cover_for_uri(
player.current_track.uri,
ArtSize.SMALL*self.get_scale_factor(),
False)
else:
art = Lp.art.get_album(player.current_track.album,
ArtSize.SMALL*self.get_scale_factor())
if art is not None:
self._cover.set_from_surface(art)
del art
self._cover.set_tooltip_text(player.current_track.album.name)
self._cover.show()
else:
self._cover.hide()
def on_status_changed(self, player):
"""
Update infos on status changed
@param player as Player
"""
pass
#######################
# PRIVATE #
#######################
def _update_cover(self, art, album_id):
"""
Update cover for album_id
@param art as Art
@param album id as int
"""
if Lp.player.current_track.album.id == album_id:
pixbuf = Lp.art.get_album(Lp.player.current_track.album,
ArtSize.SMALL)
self._cover.set_from_surface(pixbuf)
del pixbuf
def _update_logo(self, art, name):
"""
Update logo for name
@param art as Art
@param name as str
"""
if Lp.player.current_track.artist == name:
pixbuf = Lp.art.get_radio(name, ArtSize.SMALL)
self._cover.set_from_surface(pixbuf)
del pixbuf
def _on_infobox_clicked(self, eventbox, event):
"""
#.........这里部分代码省略.........
示例5: RadiosView
# 需要导入模块: from lollypop.pop_tunein import TuneinPopover [as 别名]
# 或者: from lollypop.pop_tunein.TuneinPopover import show [as 别名]
class RadiosView(View):
"""
Init radios ui with a scrolled grid of radios widgets
"""
def __init__(self):
View.__init__(self)
self._signal = None
self._radios_manager = RadiosManager()
self._radios_manager.connect('playlists-changed',
self._on_radios_changed)
builder = Gtk.Builder()
builder.add_from_resource('/org/gnome/Lollypop/RadiosView.ui')
builder.connect_signals(self)
widget = builder.get_object('widget')
self._pop_tunein = TuneinPopover(self._radios_manager)
self._pop_tunein.set_relative_to(builder.get_object('search_btn'))
self._sizegroup = Gtk.SizeGroup(mode=Gtk.SizeGroupMode.BOTH)
self._radiobox = Gtk.FlowBox()
self._radiobox.set_sort_func(self._sort_radios)
self._radiobox.set_selection_mode(Gtk.SelectionMode.NONE)
self._radiobox.connect("child-activated", self._on_album_activated)
self._radiobox.set_property('column-spacing', 5)
self._radiobox.set_property('row-spacing', 5)
self._radiobox.set_homogeneous(True)
self._radiobox.set_max_children_per_line(1000)
self._radiobox.show()
self._viewport.set_property("valign", Gtk.Align.START)
self._viewport.set_property('margin', 5)
self._viewport.add(self._radiobox)
self._scrolledWindow.set_property('expand', True)
self.add(widget)
self.add(self._scrolledWindow)
"""
Populate view with tracks from playlist
Thread safe
"""
def populate(self):
radios_name = []
# Get radios name
for (i, name) in self._radios_manager.get():
radios_name.append(name)
GLib.idle_add(self._add_radios, radios_name)
"""
Connect player signal
"""
def do_show(self):
View.do_show(self)
self._signal = Lp.art.connect('logo-changed',
self._on_logo_changed)
"""
Disconnect player signal
"""
def do_hide(self):
View.do_hide(self)
if self._signal is not None:
Lp.art.disconnect(self._signal)
#######################
# PRIVATE #
#######################
"""
Return view children
@return [RadioWidget]
"""
def _get_children(self):
children = []
for child in self._radiobox.get_children():
widget = child.get_child()
children.append(widget)
return children
"""
Sort radios
@param a as Gtk.FlowBoxChild
@param b as Gtk.FlowBoxChild
"""
def _sort_radios(self, a, b):
child1 = a.get_children()[0]
child2 = b.get_children()[0]
return child1.get_name().lower() > child2.get_name().lower()
"""
Show popover for adding a new radio
@param widget as Gtk.Widget
"""
def _on_new_clicked(self, widget):
popover = RadioPopover('', self._radios_manager)
popover.set_relative_to(widget)
popover.show()
#.........这里部分代码省略.........
示例6: ToolbarInfos
# 需要导入模块: from lollypop.pop_tunein import TuneinPopover [as 别名]
# 或者: from lollypop.pop_tunein.TuneinPopover import show [as 别名]
class ToolbarInfos(Gtk.Bin):
"""
Informations toolbar
"""
def __init__(self):
"""
Init toolbar
"""
Gtk.Bin.__init__(self)
builder = Gtk.Builder()
builder.add_from_resource('/org/gnome/Lollypop/ToolbarInfos.ui')
builder.connect_signals(self)
self._pop_tunein = None
self._pop_infos = None
self._cover_size = ArtSize.SMALL
self._infobox = builder.get_object('infos')
self._infobox.set_property('has-tooltip', True)
self.add(self._infobox)
self._title_label = builder.get_object('title')
self._artist_label = builder.get_object('artist')
self._cover_frame = builder.get_object('frame')
self._cover = builder.get_object('cover')
Lp().art.connect('album-artwork-changed', self._update_cover)
Lp().art.connect('radio-artwork-changed', self._update_logo)
def on_current_changed(self, player):
"""
Update toolbar on current changed
@param player as Player
"""
art = None
if player.current_track.artist == '':
self._artist_label.hide()
else:
self._artist_label.show()
self._artist_label.set_text(player.current_track.artist)
if player.current_track.title == '':
self._title_label.hide()
else:
self._title_label.show()
self._title_label.set_text(player.current_track.title)
if player.current_track.id == Type.RADIOS:
art = Lp().art.get_radio_artwork(
player.current_track.artist,
self._cover_size*self.get_scale_factor())
elif player.current_track.id == Type.EXTERNALS:
art = Lp().art.get_album_artwork2(
player.current_track.uri,
self._cover_size*self.get_scale_factor())
elif player.current_track.id is not None:
art = Lp().art.get_album_artwork(
player.current_track.album,
self._cover_size*self.get_scale_factor())
if art is not None:
self._cover.set_from_surface(art)
del art
self._cover.set_tooltip_text(player.current_track.album.name)
self._cover_frame.show()
else:
self._cover_frame.hide()
def on_status_changed(self, player):
"""
Update infos on status changed
@param player as Player
"""
pass
#######################
# PRIVATE #
#######################
def _update_cover(self, art, album_id):
"""
Update cover for album_id
@param art as Art
@param album id as int
"""
if Lp().player.current_track.album.id == album_id:
surface = Lp().art.get_album_artwork(
Lp().player.current_track.album,
self._cover_size)
self._cover.set_from_surface(surface)
del surface
def _update_logo(self, art, name):
"""
Update logo for name
@param art as Art
@param name as str
"""
if Lp().player.current_track.artist == name:
pixbuf = Lp().art.get_radio_artwork(name, self._cover_size)
self._cover.set_from_surface(pixbuf)
#.........这里部分代码省略.........
示例7: ToolbarInfo
# 需要导入模块: from lollypop.pop_tunein import TuneinPopover [as 别名]
# 或者: from lollypop.pop_tunein.TuneinPopover import show [as 别名]
#.........这里部分代码省略.........
@param album id as int
"""
if Lp().player.current_track.album.id == album_id:
surface = Lp().art.get_album_artwork(
Lp().player.current_track.album,
self._artsize,
self._cover.get_scale_factor())
self._cover.set_from_surface(surface)
del surface
def __update_logo(self, art, name):
"""
Update logo for name
@param art as Art
@param name as str
"""
if Lp().player.current_track.album_artist == name:
pixbuf = Lp().art.get_radio_artwork(name, self._artsize)
self._cover.set_from_surface(pixbuf)
del pixbuf
def __on_info_long(self, args):
"""
Show current track menu
@param args as []
"""
if Lp().player.current_track.id >= 0:
from lollypop.pop_menu import PlaylistsMenu
from lollypop.pop_menu import TrackMenuPopover
popover = TrackMenuPopover(
Lp().player.current_track,
PlaylistsMenu(Lp().player.current_track))
popover.set_relative_to(self._infobox)
popover.show()
def __on_info_short(self, args):
"""
Show track information popover
@param args as []
"""
if Lp().player.current_track.id == Type.EXTERNALS:
from lollypop.pop_externals import ExternalsPopover
expopover = ExternalsPopover()
expopover.set_relative_to(self._infobox)
expopover.populate()
expopover.show()
elif Lp().player.current_track.id is not None:
if Lp().player.current_track.id == Type.RADIOS:
if self.__pop_tunein is None:
from lollypop.pop_tunein import TuneinPopover
self.__pop_tunein = TuneinPopover()
self.__pop_tunein.populate()
self.__pop_tunein.set_relative_to(self._infobox)
self.__pop_tunein.show()
else:
if self.__pop_info is None:
from lollypop.pop_info import InfoPopover
self.__pop_info = InfoPopover()
self.__pop_info.set_relative_to(self._infobox)
self.__pop_info.show()
def __on_loading_changed(self, player, show):
"""
Show spinner based on loading status
@param player as player
@param show as bool