本文整理汇总了Python中lollypop.pop_infos.InfosPopover类的典型用法代码示例。如果您正苦于以下问题:Python InfosPopover类的具体用法?Python InfosPopover怎么用?Python InfosPopover使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了InfosPopover类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
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)
示例2: on_current_changed
def on_current_changed(self, player):
"""
Update buttons on current changed
@param player as Player
"""
if InfosPopover.should_be_shown():
if player.current_track.id != Type.RADIOS:
self._artist_infos_btn.set_sensitive(True)
else:
self._artist_infos_btn.set_sensitive(False)
self._play_btn.set_sensitive(True)
self._prev_btn.set_sensitive(True)
self._next_btn.set_sensitive(True)
# Can add a \n in markup
# GTK bug => https://bugzilla.gnome.org/show_bug.cgi?id=749965
prev_artist = escape(player.prev_track.artist)
prev_title = escape(player.prev_track.title)
next_artist = escape(player.next_track.artist)
next_title = escape(player.next_track.title)
self._next_btn.set_tooltip_markup("<b>%s</b> - %s" %
(next_artist,
next_title))
self._prev_btn.set_tooltip_markup("<b>%s</b> - %s" %
(prev_artist,
prev_title))
示例3: _on_label_realize
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))
示例4: _on_infobox_clicked
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
示例5: ArtistView
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: _on_label_button_release
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()
示例7: _on_lastfm_btn_clicked
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()
示例8: _on_infos_btn_clicked
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()
示例9: _on_label_button_release
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()
示例10: _on_label_button_release
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 is not None:
pop = InfosPopover(self._artist_id, False)
pop.set_relative_to(eventbox)
pop.show()
示例11: __init__
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))
示例12: __init__
def __init__(self):
"""
Init toolbar
"""
Gtk.Bin.__init__(self)
builder = Gtk.Builder()
builder.add_from_resource('/org/gnome/Lollypop/ToolbarPlayback.ui')
builder.connect_signals(self)
self.add(builder.get_object('playback'))
self._prev_btn = builder.get_object('previous_button')
self._play_btn = builder.get_object('play_button')
self._next_btn = builder.get_object('next_button')
self._play_image = builder.get_object('play_image')
self._pause_image = builder.get_object('pause_image')
if InfosPopover.should_be_shown():
self._artist_infos_btn = builder.get_object('artist_infos_btn')
self._artist_infos_btn.show()
示例13: __init__
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)
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_infos = InfosPopover()
self._pop_infos.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)
示例14: AlbumDetailedWidget
class AlbumDetailedWidget(AlbumWidget):
"""
Init detailed album widget
@param album id as int
@param genre id as int
@param parent width as int
@param pop_allowed as bool if widget can show popovers
@param scrolled as bool
@param size group as Gtk.SizeGroup
"""
def __init__(self, album_id, genre_id, pop_allowed, scrolled, size_group):
AlbumWidget.__init__(self, album_id)
self._artist_id = Lp.albums.get_artist_id(album_id)
self._album_id = album_id
self._genre_id = genre_id
builder = Gtk.Builder()
if scrolled:
builder.add_from_resource(
'/org/gnome/Lollypop/AlbumContextWidget.ui')
else:
builder.add_from_resource(
'/org/gnome/Lollypop/AlbumDetailedWidget.ui')
builder.connect_signals(self)
if scrolled:
artist = translate_artist_name(Lp.albums.get_artist_name(album_id))
builder.get_object('artist').set_text(artist)
builder.get_object('artist').show()
if Lp.lastfm is not None:
self._popover = InfosPopover(artist)
self._stars = []
self._stars.append(builder.get_object('star0'))
self._stars.append(builder.get_object('star1'))
self._stars.append(builder.get_object('star2'))
self._stars.append(builder.get_object('star3'))
self._stars.append(builder.get_object('star4'))
self._on_leave_notify(None, None)
grid = builder.get_object('tracks')
self._discs = Lp.albums.get_discs(album_id, genre_id)
self._tracks_left = {}
self._tracks_right = {}
show_label = len(self._discs) > 1
i = 0
for disc in self._discs:
if show_label:
label = Gtk.Label()
label.set_text(_("Disc %s") % disc)
label.set_property('halign', Gtk.Align.START)
label.get_style_context().add_class('dim-label')
if i:
label.set_property('margin-top', 30)
label.show()
grid.attach(label, 0, i, 2, 1)
i += 1
sep = Gtk.Separator()
sep.show()
grid.attach(sep, 0, i, 2, 1)
i += 1
self._tracks_left[disc] = TracksWidget(pop_allowed)
self._tracks_right[disc] = TracksWidget(pop_allowed)
grid.attach(self._tracks_left[disc], 0, i, 1, 1)
grid.attach(self._tracks_right[disc], 1, i, 1, 1)
size_group.add_widget(self._tracks_left[disc])
size_group.add_widget(self._tracks_right[disc])
self._tracks_left[disc].connect('activated', self._on_activated)
self._tracks_left[disc].connect('button-press-event',
self._on_button_press_event)
self._tracks_right[disc].connect('activated', self._on_activated)
self._tracks_right[disc].connect('button-press-event',
self._on_button_press_event)
self._tracks_left[disc].show()
self._tracks_right[disc].show()
i += 1
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
#.........这里部分代码省略.........
示例15: ArtistView
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):
"""
#.........这里部分代码省略.........