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 or self.Wikipedia 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 _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: 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_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()
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()
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.album_artist_id if artist_id == Type.COMPILATIONS: artist = Lp.player.current_track.artist else: artist = Lp.player.current_track.album_artist popover = InfosPopover(artist, Lp.player.current_track.id) popover.set_relative_to(button) popover.populate() popover.show()
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 # Use a Gtk.PopoverMenu later # (GTK>3.16 available on Debian stable) stack = Gtk.Stack() grid = Gtk.Grid() grid.set_orientation(Gtk.Orientation.VERTICAL) stack.add_named(grid, 'main') stack.show_all() menu_widget = popover.get_child() menu_widget.reparent(grid) separator = Gtk.Separator() separator.show() grid.add(separator) hgrid = Gtk.Grid() hgrid.add(rating) hgrid.add(loved) hgrid.show() grid.add(hgrid) popover.add(stack) popover.show() return True