def __init__(self, album, height, list_type, reveal, parent):
     """
         Init row widgets
         @param album as Album
         @param height as int
         @param list_type as RowListType
         @param reveal as bool
         @param parent as AlbumListView
     """
     Gtk.ListBoxRow.__init__(self)
     TracksView.__init__(self, list_type)
     if list_type & RowListType.DND:
         DNDRow.__init__(self)
     self.__revealer = None
     self.__parent = parent
     self.__reveal = reveal
     self._artwork = None
     self._album = album
     self.__list_type = list_type
     self.__play_indicator = None
     self.set_sensitive(False)
     self.set_property("height-request", height)
     # 15 for scrollbar overlay
     self.set_margin_end(15)
     self.connect("destroy", self.__on_destroy)
 def prepend_rows(self, tracks):
     """
         Add track rows (only works for albums with merged discs)
         @param tracks as [Track]
     """
     if self._responsive_widget is not None:
         TracksView.prepend_rows(self, tracks)
 def _on_tracks_populated(self, disc_number):
     """
         Populate remaining discs
         @param disc_number as int
     """
     if not self.is_populated:
         TracksView.populate(self)
 def stop(self):
     """
         Stop view loading
     """
     self._artwork = None
     if self._responsive_widget is not None:
         TracksView.stop(self)
 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 __init__(self, album, height, view_type, reveal, cover_uri, parent):
     """
         Init row widgets
         @param album as Album
         @param height as int
         @param view_type as ViewType
         @param reveal as bool
         @param parent as AlbumListView
     """
     Gtk.ListBoxRow.__init__(self)
     TracksView.__init__(self, view_type)
     if view_type & ViewType.DND:
         DNDRow.__init__(self)
     self.__next_row = None
     self.__previous_row = None
     self.__revealer = None
     self.__parent = parent
     self.__reveal = reveal
     self.__cover_uri = cover_uri
     self._artwork = None
     self._album = album
     self.__view_type = view_type
     self.__cancellable = Gio.Cancellable()
     self.set_sensitive(False)
     self.set_property("height-request", height)
     self.connect("destroy", self.__on_destroy)
 def _on_album_updated(self, scanner, album_id, added):
     """
         On album modified, disable it
         @param scanner as CollectionScanner
         @param album_id as int
         @param added as bool
     """
     TracksView._on_album_updated(self, scanner, album_id)
Example #8
0
 def _on_album_updated(self, scanner, album_id, destroy):
     """
         On album modified, disable it
         @param scanner as CollectionScanner
         @param album id as int
         @param destroy as bool
     """
     TracksView._on_album_updated(self, scanner, album_id, destroy)
     AlbumWidget._on_album_updated(self, scanner, album_id, destroy)
Example #9
0
 def _on_loading_changed(self, player, status, track):
     """
         Update row loading status
         @param player as Player
         @param status as bool
         @param track as Track
     """
     if track.is_web:
         TracksView._on_loading_changed(self, player, status, track)
Example #10
0
 def __init__(self, album, view_type):
     """
         Init view
         @param album as Album
         @param view_type as ViewType
     """
     TracksView.__init__(self, view_type)
     self.__album = album
     self.__discs = []
     self.__discs_to_load = []
     self.__populated = False
     self.__show_tag_tracknumber = App().settings.get_value(
         "show-tag-tracknumber")
 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()
Example #12
0
 def __init__(self):
     """
         Init view
         @param album as Album
         @param view_type as ViewType
     """
     TracksView.__init__(self, ViewType.SEARCH)
     self.__track_ids = []
     self._add_disc_container(0)
     self._tracks_widget_left[0].show()
     self._tracks_widget_right[0].show()
     return [
         (App().window, "notify::folded", "_on_container_folded"),
     ]
 def set_playing_indicator(self):
     """
         Show play indicator
     """
     if self._artwork is None:
         return
     selected = self.album.id == App().player.current_track.album.id
     if self.__revealer.get_reveal_child():
         TracksView.set_playing_indicator(self)
         self.set_state_flags(Gtk.StateFlags.NORMAL, True)
     elif selected:
         self.set_state_flags(Gtk.StateFlags.VISITED, True)
     else:
         self.set_state_flags(Gtk.StateFlags.NORMAL, True)
Example #14
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()
Example #15
0
 def __init__(self, album, genre_ids, artist_ids, show_cover):
     """
         Init detailed album widget
         @param album as Album
         @param label_height as int
         @param genre ids as [int]
         @param artist ids as [int]
         @param show_cover as bool
     """
     Gtk.Bin.__init__(self)
     AlbumWidget.__init__(self, album, genre_ids, artist_ids)
     TracksView.__init__(self, RowListType.TWO_COLUMNS)
     self._widget = None
     self.__show_cover = show_cover
     self.__width_allocation = 0
     self.connect("size-allocate", self.__on_size_allocate)
 def is_populated(self):
     """
         Return True if populated
         @return bool
     """
     return True if self._responsive_widget is None or self.__reveal\
         else TracksView.get_populated(self)
 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 __init__(self, album, genre_ids, artist_ids, view_type):
     """
         Init detailed album widget
         @param album as Album
         @param label_height as int
         @param genre_ids as [int]
         @param artist_ids as [int]
         @param view_type as ViewType
     """
     Gtk.Grid.__init__(self)
     AlbumWidget.__init__(self, album, genre_ids, artist_ids)
     TracksView.__init__(self, view_type)
     self.set_row_spacing(2)
     self.set_orientation(Gtk.Orientation.VERTICAL)
     self.__width_allocation = 0
     self.__banner = None
     self.connect("size-allocate", self.__on_size_allocate)
 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")
Example #20
0
 def _init(self):
     """
         Init main widget
     """
     if TracksView._init(self):
         if self.view_type & ViewType.SINGLE_COLUMN:
             self.__discs = [self.__album.one_disc]
         else:
             self.__discs = self.__album.discs
         for disc in self.__discs:
             self._add_disc_container(disc.number)
         self.__discs_to_load = list(self.__discs)
 def __init__(self, album, artist_ids, genre_ids, view_type):
     """
         Init ArtistView
         @param album as Album
         @param artist_ids as [int]
         @param genre_ids as [int]
         @param view_type as ViewType
     """
     LazyLoadingView.__init__(self, view_type)
     TracksView.__init__(self, view_type)
     ViewController.__init__(self, ViewControllerType.ALBUM)
     self._album = album
     self.__genre_ids = genre_ids
     self.__artist_ids = artist_ids
     self.__grid = Gtk.Grid()
     self.__grid.set_property("vexpand", True)
     self.__grid.set_row_spacing(10)
     self.__grid.set_margin_start(MARGIN)
     self.__grid.set_margin_end(MARGIN)
     self.__grid.set_orientation(Gtk.Orientation.VERTICAL)
     self.__grid.show()
 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)
Example #23
0
 def _set_orientation(self, orientation):
     """
         Set columns orientation
         @param orientation as Gtk.Orientation
     """
     if not TracksView._set_orientation(self, orientation):
         return
     self._responsive_widget.insert_row(0)
     self.__label = Gtk.Label.new(_("Tracks"))
     self.__label.show()
     self.__label.set_ellipsize(Pango.EllipsizeMode.END)
     self.__label.get_style_context().add_class("dim-label")
     self.__update_label(App().window.folded)
     self.__label.set_hexpand(True)
     self.__label.set_property("halign", Gtk.Align.START)
     idx = 1
     # Vertical
     ##########################
     #  --------Label-------- #
     #  |     Column 1      | #
     #  |     Column 2      | #
     ##########################
     # Horizontal
     ###########################
     # ---------Label--------- #
     # | Column 1 | Column 2 | #
     ###########################
     if orientation == Gtk.Orientation.VERTICAL:
         self._responsive_widget.attach(self.__label, 0, 0, 1, 1)
         self._responsive_widget.attach(self._tracks_widget_left[0], 0, idx,
                                        2, 1)
         idx += 1
     else:
         self._responsive_widget.attach(self.__label, 0, 0, 2, 1)
         self._responsive_widget.attach(self._tracks_widget_left[0], 0, idx,
                                        1, 1)
     if not self.view_type & ViewType.SINGLE_COLUMN:
         if orientation == Gtk.Orientation.VERTICAL:
             self._responsive_widget.attach(self._tracks_widget_right[0], 0,
                                            idx, 2, 1)
         else:
             self._responsive_widget.attach(self._tracks_widget_right[0], 1,
                                            idx, 1, 1)
     idx += 1
Example #24
0
 def set_playing_indicator(self):
     """
         Update playing indicator
     """
     TracksView.set_playing_indicator(self)
Example #25
0
 def _set_orientation(self, orientation):
     """
         Set columns orientation
         @param orientation as Gtk.Orientation
     """
     if not TracksView._set_orientation(self, orientation):
         return
     idx = 0
     # Vertical
     ##########################
     #  --------Label-------- #
     #  |     Column 1      | #
     #  |     Column 2      | #
     ##########################
     # Horizontal
     ###########################
     # ---------Label--------- #
     # | Column 1 | Column 2 | #
     ###########################
     for disc in self.__discs:
         show_label = len(self.__discs) > 1
         disc_names = self.__album.disc_names(disc.number)
         if show_label or disc_names:
             if disc_names:
                 disc_text = ", ".join(disc_names)
             elif show_label:
                 disc_text = _("Disc %s") % disc.number
             label = Gtk.Label.new()
             label.set_ellipsize(Pango.EllipsizeMode.END)
             label.set_text(disc_text)
             label.set_property("halign", Gtk.Align.START)
             label.get_style_context().add_class("dim-label")
             label.show()
             eventbox = Gtk.EventBox()
             eventbox.connect("realize", set_cursor_type)
             eventbox.set_tooltip_text(_("Play"))
             eventbox.connect("button-press-event",
                              self.__on_disc_button_press_event,
                              disc)
             eventbox.add(label)
             eventbox.show()
             if orientation == Gtk.Orientation.VERTICAL:
                 self._responsive_widget.attach(
                     eventbox, 0, idx, 1, 1)
             else:
                 self._responsive_widget.attach(
                     eventbox, 0, idx, 2, 1)
             idx += 1
         if orientation == Gtk.Orientation.VERTICAL:
             self._responsive_widget.attach(
                       self._tracks_widget_left[disc.number],
                       0, idx, 2, 1)
             idx += 1
         else:
             self._responsive_widget.attach(
                       self._tracks_widget_left[disc.number],
                       0, idx, 1, 1)
         if not self.view_type & ViewType.SINGLE_COLUMN:
             if orientation == Gtk.Orientation.VERTICAL:
                 self._responsive_widget.attach(
                            self._tracks_widget_right[disc.number],
                            0, idx, 2, 1)
             else:
                 self._responsive_widget.attach(
                            self._tracks_widget_right[disc.number],
                            1, idx, 1, 1)
         idx += 1
Example #26
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)