def _on_tracks_populated(self, disc_number):
     """
         Populate remaining discs
         @param disc_number as int
     """
     if not self.is_populated:
         TracksView.populate(self)
Ejemplo n.º 2
0
 def _on_tracks_populated(self, disc_number):
     """
         Emit populated signal
         @param disc_number as int
     """
     if TracksView.get_populated(self):
         from lollypop.view_albums_box import AlbumsBoxView
         for artist_id in self.__artist_ids:
             if artist_id == Type.COMPILATIONS:
                 album_ids = App().albums.get_compilation_ids(
                     self.__genre_ids)
             else:
                 album_ids = App().albums.get_ids([artist_id], [])
             if self._album.id in album_ids:
                 album_ids.remove(self._album.id)
             if not album_ids:
                 continue
             artist = GLib.markup_escape_text(
                 App().artists.get_name(artist_id))
             label = Gtk.Label.new()
             label.set_markup('''<span size="large" alpha="40000"
                                  weight="bold">%s %s</span>''' %
                              (_("Others albums from"), artist))
             label.set_property("halign", Gtk.Align.START)
             label.set_margin_top(40)
             label.show()
             self.__grid.add(label)
             self.__others_box = AlbumsBoxView([], [artist_id],
                                               ViewType.SMALL)
             self.__others_box.show()
             self.__grid.add(self.__others_box)
             self.__others_box.populate([Album(id) for id in album_ids])
     else:
         TracksView.populate(self)
 def populate(self):
     """
         Populate widget content
     """
     TracksView.populate(self)
     if not self.get_children():
         self.__banner = AlbumBannerWidget(
             self._album, self._view_type | ViewType.MEDIUM)
         self.__banner.show()
         self.add(self.__banner)
         self.add(self._responsive_widget)
         self._responsive_widget.show()
         self.set_selection()
Ejemplo n.º 4
0
 def _on_album_artwork(self, surface):
     """
         Set album artwork
         @param surface as str
     """
     if surface is None:
         self._artwork.set_from_icon_name("folder-music-symbolic",
                                          Gtk.IconSize.DIALOG)
     else:
         self._artwork.set_from_surface(surface)
     if self._responsive_widget is None:
         self._artwork.show()
         TracksView.populate(self)
         self._widget.add(self._responsive_widget)
         self._responsive_widget.show()
Ejemplo n.º 5
0
 def populate(self):
     """
         Populate the view with album
     """
     TracksView.populate(self)
     self.__grid.add(self._responsive_widget)
     self._viewport.add(self.__grid)
     self._overlay = Gtk.Overlay.new()
     self._overlay.add(self._scrolled)
     self._overlay.show()
     self.__banner = AlbumBannerWidget(self._album,
                                       self._view_type | ViewType.ALBUM)
     self.__banner.show()
     self._overlay.add_overlay(self.__banner)
     self.add(self._overlay)
     self._responsive_widget.show()
     self._scrolled.get_vscrollbar().set_margin_top(self.__banner.height)
 def reveal(self, reveal=None):
     """
         Reveal/Unreveal tracks
         @param reveal as bool or None to just change state
     """
     if self.__revealer.get_reveal_child() and reveal is not True:
         self.__revealer.set_reveal_child(False)
         self.get_style_context().remove_class("albumrow-hover")
         if self.album.id == App().player.current_track.album.id:
             self.set_state_flags(Gtk.StateFlags.VISITED, True)
     else:
         if self._responsive_widget is None:
             TracksView.populate(self)
             self._responsive_widget.show()
             self.__revealer.add(self._responsive_widget)
         self.__revealer.set_reveal_child(True)
         self.unset_state_flags(Gtk.StateFlags.VISITED)
         self.get_style_context().add_class("albumrow-hover")
Ejemplo n.º 7
0
 def reveal(self,
            reveal=None,
            transition_type=Gtk.RevealerTransitionType.SLIDE_DOWN):
     """
         Reveal/Unreveal tracks
         @param revleal as bool or None to just change state
         @param transition_type as Gtk.RevealerTransitionType
     """
     self.__revealer.set_transition_type(transition_type)
     if self.__revealer.get_reveal_child() and reveal is not True:
         self.__revealer.set_reveal_child(False)
         self.get_style_context().add_class("albumrow-hover")
         if self.album.id == App().player.current_track.album.id:
             self.set_state_flags(Gtk.StateFlags.VISITED, True)
     else:
         if self._responsive_widget is None:
             TracksView.populate(self)
             self._responsive_widget.show()
             self.__revealer.add(self._responsive_widget)
         self.get_style_context().remove_class("albumrow-hover")
         self.__revealer.set_reveal_child(True)
         self.set_state_flags(Gtk.StateFlags.NORMAL, True)
Ejemplo n.º 8
0
    def populate(self):
        """
            Populate widget content
        """
        if self._widget is None:
            OverlayAlbumHelper.__init__(self)
            self.__context = None
            grid = Gtk.Grid()
            grid.set_margin_start(5)
            grid.set_margin_end(5)
            grid.set_row_spacing(1)
            grid.set_vexpand(True)
            grid.show()
            self.__title_label = Gtk.Label()
            self.__title_label.set_margin_end(10)
            self.__title_label.set_ellipsize(Pango.EllipsizeMode.END)
            self.__title_label.get_style_context().add_class("dim-label")
            self.__title_label.set_property("has-tooltip", True)
            self.__title_label.connect("query-tooltip",
                                       self.__on_query_tooltip)
            self.__title_label.show()
            self.__artist_label = Gtk.Label()
            self.__artist_label.set_margin_end(10)
            self.__artist_label.set_ellipsize(Pango.EllipsizeMode.END)
            self.__artist_label.set_property("has-tooltip", True)
            self.__artist_label.connect("query-tooltip",
                                        self.__on_query_tooltip)
            self.__artist_label.show()
            self.__year_label = Gtk.Label()
            self.__year_label.set_margin_end(10)
            self.__year_label.get_style_context().add_class("dim-label")
            self.__year_label.show()
            self.__duration_label = Gtk.Label()
            self.__duration_label.get_style_context().add_class("dim-label")
            self.__duration_label.show()
            self.__context_button = Gtk.Button.new_from_icon_name(
                "go-next-symbolic", Gtk.IconSize.BUTTON)
            self.__context_button.set_relief(Gtk.ReliefStyle.NONE)
            self.__context_button.connect("clicked", self.__on_context_clicked)
            self.__context_button.get_style_context().add_class("menu-button")
            self.__context_button.get_style_context().add_class(
                                                          "album-menu-button")
            self.__context_button.show()
            self._widget = Gtk.Grid()
            self._widget.set_orientation(Gtk.Orientation.VERTICAL)
            self._widget.set_row_spacing(2)
            self._widget.show()
            self.__header = Gtk.Grid()
            self.__header.add(self.__artist_label)
            self.__header.add(self.__title_label)
            self.__header.add(self.__year_label)
            self.__header.add(self.__context_button)
            self.__header.show()
            self._widget.add(self.__header)
            separator = Gtk.Separator.new(Gtk.Orientation.HORIZONTAL)
            separator.show()
            self._widget.add(separator)

            loved = LovedWidget(self._album)
            loved.set_property("valign", Gtk.Align.CENTER)
            loved.set_margin_end(10)
            loved.show()

            rating = RatingWidget(self._album)
            rating.set_property("valign", Gtk.Align.CENTER)
            rating.set_property("halign", Gtk.Align.END)
            rating.set_margin_end(10)
            rating.show()

            if self.__show_cover:
                self.__header.add(self.__duration_label)
                self.__duration_label.set_hexpand(True)
                self.__duration_label.set_property("halign", Gtk.Align.END)
                eventbox = Gtk.EventBox()
                eventbox.connect("enter-notify-event", self._on_enter_notify)
                eventbox.connect("leave-notify-event", self._on_leave_notify)
                eventbox.connect("button-press-event", self._on_button_press)
                eventbox.show()
                self.set_property("valign", Gtk.Align.CENTER)
                self._artwork = App().art_helper.get_image(ArtSize.BIG,
                                                           ArtSize.BIG,
                                                           "cover-frame")
                self._artwork.show()
                eventbox.add(self._artwork)
                self.__duration_label.set_hexpand(True)
                self._overlay = Gtk.Overlay.new()
                self._overlay.add(eventbox)
                self._overlay.show()
                self.__coverbox = Gtk.Grid()
                self.__coverbox.set_row_spacing(2)
                self.__coverbox.set_margin_end(10)
                self.__coverbox.set_orientation(Gtk.Orientation.VERTICAL)
                self.__coverbox.show()
                self.__coverbox.attach(self._overlay, 0, 0, 2, 1)
                loved.set_property("halign", Gtk.Align.START)
                self.__coverbox.attach(rating, 0, 1, 1, 1)
                self.__coverbox.attach_next_to(loved,
                                               rating,
                                               Gtk.PositionType.RIGHT,
                                               1,
                                               1)
                if App().window.container.stack.get_allocation().width <\
                        Sizing.MEDIUM:
                    self.__coverbox.hide()
                if len(self._artist_ids) > 1:
                    self.__artist_label.set_text(
                        ", ".join(self._album.artists))
                    self.__artist_label.show()
            else:
                self._artwork = None
                loved.set_property("halign", Gtk.Align.END)
                self.__header.add(rating)
                self.__header.add(loved)
                rating.set_hexpand(True)
                self.__header.add(self.__duration_label)
                self.__artist_label.set_text(", ".join(self._album.artists))
                self.__artist_label.show()
            self.__set_duration()
            album_name = GLib.markup_escape_text(self._album.name)
            artist_name = GLib.markup_escape_text(
                ", ".join(self._album.artists))
            self.__title_label.set_markup("<b>%s</b>" % album_name)
            self.__artist_label.set_markup("<b>%s</b>" % artist_name)
            if self._album.year is not None:
                self.__year_label.set_label(str(self._album.year))
                self.__year_label.show()
            self.set_selection()
            if self._artwork is None:
                TracksView.populate(self)
                self._widget.add(self._responsive_widget)
                self._responsive_widget.show()
            else:
                grid.add(self.__coverbox)
                self.set_artwork()
            grid.add(self._widget)
            self.add(grid)
        else:
            TracksView.populate(self)