本文整理汇总了Python中lollypop.pop_infos.InfosPopover.set_relative_to方法的典型用法代码示例。如果您正苦于以下问题:Python InfosPopover.set_relative_to方法的具体用法?Python InfosPopover.set_relative_to怎么用?Python InfosPopover.set_relative_to使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lollypop.pop_infos.InfosPopover
的用法示例。
在下文中一共展示了InfosPopover.set_relative_to方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _on_lastfm_btn_clicked
# 需要导入模块: from lollypop.pop_infos import InfosPopover [as 别名]
# 或者: from lollypop.pop_infos.InfosPopover import set_relative_to [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 set_relative_to [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 InfosPopover.should_be_shown() and self._artist_id != Type.COMPILATIONS:
pop = InfosPopover(self._artist_id, False)
pop.set_relative_to(eventbox)
pop.show()
示例3: _on_label_button_release
# 需要导入模块: from lollypop.pop_infos import InfosPopover [as 别名]
# 或者: from lollypop.pop_infos.InfosPopover import set_relative_to [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()
示例4: _on_infos_btn_clicked
# 需要导入模块: from lollypop.pop_infos import InfosPopover [as 别名]
# 或者: from lollypop.pop_infos.InfosPopover import set_relative_to [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()
示例5: ArtistView
# 需要导入模块: from lollypop.pop_infos import InfosPopover [as 别名]
# 或者: from lollypop.pop_infos.InfosPopover import set_relative_to [as 别名]
class ArtistView(ArtistAlbumsView):
"""
Show artist albums and tracks
"""
def __init__(self, artist_id, genre_id):
"""
Init ArtistView
@param artist id as int (Current if None)
@param genre id as int
"""
ArtistAlbumsView.__init__(self, artist_id, genre_id)
self._artist_id = artist_id
self._genre_id = genre_id
self._signal_id = None
self._popover = InfosPopover(artist_id, False)
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(
Lp.artists.get_name(artist_id))
#######################
# PRIVATE #
#######################
def _on_label_realize(self, eventbox):
"""
Change pointer on label
@param eventbox as Gtk.EventBox
"""
if InfosPopover.should_be_shown() and\
self._artist_id != Type.COMPILATIONS:
eventbox.get_window().set_cursor(Gdk.Cursor(Gdk.CursorType.HAND1))
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 InfosPopover.should_be_shown() and\
self._artist_id != Type.COMPILATIONS:
self._popover.set_relative_to(eventbox)
self._popover.show()
示例6: ToolbarInfos
# 需要导入模块: from lollypop.pop_infos import InfosPopover [as 别名]
# 或者: from lollypop.pop_infos.InfosPopover import set_relative_to [as 别名]
#.........这里部分代码省略.........
#######################
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):
"""
Pop albums from current artistleft click
Show playlist menu on right
@param eventbox as Gtk.EventBox
@param event as Gdk.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:
if self._pop_tunein is None:
self._pop_tunein = TuneinPopover()
self._pop_tunein.populate()
self._pop_tunein.set_relative_to(self._infobox)
self._pop_tunein.show()
else:
if self._pop_infos is None:
self._pop_infos = InfosPopover()
self._pop_infos.set_relative_to(self._infobox)
self._pop_infos.show()
elif Lp.player.current_track.id >= 0:
menu = PopToolbarMenu(Lp.player.current_track.id, None)
popover = Gtk.Popover.new_from_model(eventbox, menu)
rating = RatingWidget(Lp.player.current_track)
rating.set_margin_top(5)
rating.set_margin_bottom(5)
rating.set_property('halign', Gtk.Align.START)
rating.set_property('hexpand', True)
rating.show()
loved = LovedWidget(Lp.player.current_track.id)
loved.set_margin_end(5)
loved.set_margin_top(5)
loved.set_margin_bottom(5)
loved.set_property('halign', Gtk.Align.END)
loved.set_property('hexpand', True)
loved.show()
# Hack to add two widgets in popover
示例7: ToolbarInfos
# 需要导入模块: from lollypop.pop_infos import InfosPopover [as 别名]
# 或者: from lollypop.pop_infos.InfosPopover import set_relative_to [as 别名]
#.........这里部分代码省略.........
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)
del pixbuf
def _on_infobox_clicked(self, eventbox, event):
"""
Pop albums from current artistleft click
Show playlist menu on right
@param eventbox as Gtk.EventBox
@param event as Gdk.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:
if self._pop_tunein is None:
self._pop_tunein = TuneinPopover()
self._pop_tunein.populate()
self._pop_tunein.set_relative_to(self._infobox)
self._pop_tunein.show()
else:
if self._pop_infos is None:
self._pop_infos = InfosPopover()
self._pop_infos.set_relative_to(self._infobox)
self._pop_infos.show()
elif Lp().player.current_track.id >= 0:
menu = PopToolbarMenu(Lp().player.current_track.id)
popover = TrackMenuPopover(
Lp().player.current_track.id,
PopToolbarMenu(Lp().player.current_track.id))
popover.set_relative_to(self._infobox)
popover.show()
return True
def _on_query_tooltip(self, widget, x, y, keyboard, tooltip):
"""
Show tooltip if needed
@param widget as Gtk.Widget
@param x as int
@param y as int
@param keyboard as bool
@param tooltip as Gtk.Tooltip
"""
# Can't add a \n in markup
# GTK bug => https://bugzilla.gnome.org/show_bug.cgi?id=749965
layout_title = self._title_label.get_layout()
layout_artist = self._artist_label.get_layout()
if layout_title.is_ellipsized() or layout_artist.is_ellipsized():
artist = escape(self._artist_label.get_text())
title = escape(self._title_label.get_text())
tooltip.set_markup("<b>%s</b> - %s" % (artist, title))
else:
return False
return True
def _on_eventbox_realize(self, eventbox):
"""
Show hand cursor over
"""
style = self.get_style_context()
padding = style.get_padding(style.get_state())
self._cover_size = self.get_allocated_height()\
- padding.top - padding.bottom
eventbox.get_window().set_cursor(Gdk.Cursor(Gdk.CursorType.HAND1))
示例8: ArtistView
# 需要导入模块: from lollypop.pop_infos import InfosPopover [as 别名]
# 或者: from lollypop.pop_infos.InfosPopover import set_relative_to [as 别名]
#.........这里部分代码省略.........
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):
"""
Change pointer on label
@param eventbox as Gtk.EventBox
"""
if Lp.lastfm is not None and self._artist_id != Type.COMPILATIONS:
eventbox.get_window().set_cursor(Gdk.Cursor(Gdk.CursorType.HAND1))
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 and self._artist_id != Type.COMPILATIONS:
self._popover.set_relative_to(eventbox)
self._popover.populate()
self._popover.show()
示例9: AlbumDetailedWidget
# 需要导入模块: from lollypop.pop_infos import InfosPopover [as 别名]
# 或者: from lollypop.pop_infos.InfosPopover import set_relative_to [as 别名]
#.........这里部分代码省略.........
if self._button_state & Gdk.ModifierType.CONTROL_MASK:
Lp.player.context.next = NextContext.STOP_TRACK
"""
Keep track of mask
@param widget as TrackWidget
@param event as Gdk.Event
"""
def _on_button_press_event(self, widget, event):
self._button_state = event.get_state()
"""
Change cursor over eventbox
@param eventbox as Gdk.Eventbox
"""
def _on_eventbox_realize(self, eventbox):
eventbox.get_window().set_cursor(Gdk.Cursor(Gdk.CursorType.PENCIL))
"""
Change pointer on label
@param eventbox as Gtk.EventBox
"""
def _on_label_realize(self, eventbox):
if Lp.lastfm is not None and self._artist_id != Type.COMPILATIONS:
eventbox.get_window().set_cursor(Gdk.Cursor(Gdk.CursorType.HAND1))
"""
On clicked label, show artist informations in a popover
@param eventbox as Gtk.EventBox
@param event as Gdk.Event
"""
def _on_label_button_release(self, eventbox, event):
if Lp.lastfm is not None and self._artist_id != Type.COMPILATIONS:
self._popover.set_relative_to(eventbox)
self._popover.populate()
self._popover.show()
"""
Popover with album art downloaded from the web (in fact google :-/)
@param: widget as eventbox
@param: data as unused
"""
def _show_web_art(self, widget, data):
popover = CoversPopover(self._artist_id, self._album_id)
popover.set_relative_to(widget)
popover.populate()
popover.show()
"""
On enter notify, change star opacity
@param widget as Gtk.EventBox
@param event as Gdk.Event
"""
def _on_enter_notify(self, widget, event):
event_star = widget.get_children()[0]
# First star is hidden (used to clear score)
if event_star.get_property("opacity") == 0.0:
found = True
else:
found = False
for star in self._stars:
if found:
star.set_property("opacity", 0.2)
else:
star.set_property("opacity", 0.8)
if star == event_star: