def __init__(self, album_id, genre_ids, artist_ids, show_cover): """ Init detailed album widget @param album id as int @param genre ids as [int] @param artist ids as [int] @param lazy as LazyLoadingView @param show cover as bool """ Gtk.Bin.__init__(self) AlbumWidget.__init__(self, album_id, genre_ids) # Check if we need to limit the view to artist album for artist_id in self._album.artist_ids: if artist_id in artist_ids: self._album.set_artists(artist_ids) self._width = None # Cover + rating + spacing self._height = ArtSize.BIG + 26 self._orientation = None self._stop = False self._child_height = TrackRow.get_best_height(self) # Header + separator + spacing + margin self._requested_height = self._child_height + 6 # Discs to load, will be emptied self._discs = self._album.discs self._locked_widget_right = True self._filter_ids = artist_ids self.set_property('height-request', self._height) self.connect('size-allocate', self._on_size_allocate) builder = Gtk.Builder() builder.add_from_resource('/org/gnome/Lollypop/AlbumDetailedWidget.ui') self._widget = builder.get_object('widget') self._overlay = builder.get_object('overlay') self._play_button = builder.get_object('play-button') self._play_all_button = builder.get_object('playall-button') self._artwork_button = builder.get_object('artwork-button') self._action_button = builder.get_object('action-button') self._action_event = builder.get_object('action-event') builder.connect_signals(self) rating = RatingWidget(self._album) rating.show() self._artist_label = builder.get_object('artist') if show_cover: self._cover = builder.get_object('cover') builder.get_object('duration').set_hexpand(True) self._cover.get_style_context().add_class('cover-frame') self._coverbox = builder.get_object('coverbox') self._coverbox.show() # 6 for 2*3px (application.css) self._coverbox.set_property('width-request', ArtSize.BIG + 6) self._coverbox.add(rating) if Lp().window.get_view_width() < WindowSize.MEDIUM: self._coverbox.hide() if len(artist_ids) > 1: self._artist_label.set_text(", ".join(self._album.artists)) self._artist_label.show() else: builder.get_object('header').attach(rating, 4, 0, 1, 1) rating.set_hexpand(True) rating.set_property('halign', Gtk.Align.END) rating.set_property('valign', Gtk.Align.CENTER) self._artist_label.set_text(", ".join(self._album.artists)) self._artist_label.show() self._cover = None label = builder.get_object('duration') duration = Lp().albums.get_duration(album_id, genre_ids) hours = int(duration / 3600) mins = int(duration / 60) if hours > 0: mins -= hours * 60 if mins > 0: label.set_text(_("%s h %s m") % (hours, mins)) else: label.set_text(_("%s h") % hours) else: label.set_text(_("%s m") % mins) self._box = Gtk.Grid() self._box.set_column_homogeneous(True) self._box.set_property('valign', Gtk.Align.START) self._box.show() builder.get_object('albuminfo').add(self._box) self._tracks_left = {} self._tracks_right = {} self.set_cover() self.update_state() builder.get_object('title').set_label(self._album.name) if self._album.year: year = builder.get_object('year') year.set_label(self._album.year) year.show() for disc in self._discs: self._add_disc_container(disc.number) self._set_disc_height(disc) self.add(self._widget) # We start transparent, we switch opaque at size allocation # This prevent artifacts self.set_opacity(0) self._menu = builder.get_object('menu') self._menu.connect('clicked', self._pop_menu) # TODO Remove this later if Gtk.get_minor_version() > 16: self._menu.show() else: self.connect('map', self._on_map)
def __init__(self, album_id, genre_ids, artist_ids, art_size): """ Init detailed album widget @param album id as int @param genre ids as [int] @param artist ids as [int] @param lazy as LazyLoadingView @param art size as ArtSize """ Gtk.Bin.__init__(self) AlbumWidget.__init__(self, album_id, genre_ids, artist_ids, art_size) self._rounded_class = "rounded-icon-small" self.__width = None self.__context = None # Cover + rating + spacing self.__height = ArtSize.BIG + 26 self.__orientation = None self.__child_height = TrackRow.get_best_height(self) # Header + separator + spacing + margin self.__requested_height = self.__child_height + 6 # Discs to load, will be emptied self.__discs = self._album.discs self.__locked_widget_right = True self.set_property("height-request", self.__height) self.connect("size-allocate", self.__on_size_allocate) builder = Gtk.Builder() builder.add_from_resource("/org/gnome/Lollypop/AlbumDetailedWidget.ui") builder.connect_signals(self) self._widget = builder.get_object("widget") album_info = builder.get_object("albuminfo") title_label = builder.get_object("title") title_label.set_property("has-tooltip", True) artist_label = builder.get_object("artist") artist_label.set_property("has-tooltip", True) year_label = builder.get_object("year") self.__header = builder.get_object("header") self.__overlay = builder.get_object("overlay") self.__duration_label = builder.get_object("duration") self.__context_button = builder.get_object("context") if art_size == ArtSize.NONE: self._cover = None rating = RatingWidget(self._album) rating.set_hexpand(True) rating.set_property("halign", Gtk.Align.END) rating.set_property("valign", Gtk.Align.CENTER) rating.show() self.__header.attach(rating, 4, 0, 1, 1) loved = LovedWidget(self._album) loved.set_property("halign", Gtk.Align.END) loved.set_property("valign", Gtk.Align.CENTER) loved.show() self.__header.attach(loved, 5, 0, 1, 1) artist_label.set_text(", ".join(self._album.artists)) artist_label.show() if self._album.year is not None: year_label.set_label(str(self._album.year)) year_label.show() else: self.__duration_label.set_hexpand(True) builder = Gtk.Builder() builder.add_from_resource("/org/gnome/Lollypop/CoverBox.ui") builder.connect_signals(self) self._play_button = builder.get_object("play-button") self._action_button = builder.get_object("action-button") self._action_event = builder.get_object("action-event") self._cover = builder.get_object("cover") self.__coverbox = builder.get_object("coverbox") # 6 for 2*3px (application.css) self.__coverbox.set_property("width-request", art_size + 6) if art_size == ArtSize.BIG: self._cover.get_style_context().add_class("cover-frame") self._artwork_button = builder.get_object("artwork-button") if self._album.year is not None: year_label.set_label(str(self._album.year)) year_label.show() grid = Gtk.Grid() grid.set_column_spacing(10) grid.set_property("halign", Gtk.Align.CENTER) grid.show() rating = RatingWidget(self._album) loved = LovedWidget(self._album) rating.show() loved.show() grid.add(rating) grid.add(loved) self.__coverbox.add(grid) self._widget.attach(self.__coverbox, 0, 0, 1, 1) if Lp().window.get_view_width() < WindowSize.MEDIUM: self.__coverbox.hide() if len(artist_ids) > 1: artist_label.set_text(", ".join(self._album.artists)) artist_label.show() elif art_size == ArtSize.HEADER: # Here we are working around default CoverBox ui # Do we really need to have another ui file? # So just hack values on the fly self._cover.get_style_context().add_class("small-cover-frame") overlay_grid = builder.get_object("overlay-grid") overlay_grid.set_margin_bottom(2) overlay_grid.set_margin_end(2) overlay_grid.set_column_spacing(0) play_event = builder.get_object("play-event") play_event.set_margin_start(2) play_event.set_margin_bottom(2) album_info.attach(self.__coverbox, 0, 0, 1, 1) artist_label.set_text(", ".join(self._album.artists)) artist_label.show() self.__set_duration() self.__box = Gtk.Grid() self.__box.set_column_homogeneous(True) self.__box.set_property("valign", Gtk.Align.START) self.__box.show() album_info.add(self.__box) self._tracks_left = {} self._tracks_right = {} self.set_cover() self.update_state() title_label.set_label(self._album.name) for disc in self.__discs: self.__add_disc_container(disc.number) self.__set_disc_height(disc) self.add(self._widget) # We start transparent, we switch opaque at size allocation # This prevent artifacts self.set_opacity(0) self._lock_overlay = False
def __init__(self, album_id, genre_ids, artist_ids, update_albums=True): """ Init detailed album widget @param album id as int @param genre ids as [int] @param artist ids as [int] @param lazy as LazyLoadingView @param update albums as bool: update albums on play """ Gtk.Bin.__init__(self) AlbumWidget.__init__(self, album_id, genre_ids) # Check if we need to limit the view to artist album for artist_id in self._album.artist_ids: if artist_id in artist_ids: self._album.set_artists(artist_ids) self._width = None self._orientation = None self._stop = False self._child_height = TrackRow.get_best_height(self) # Discs to load, will be emptied self._discs = self._album.discs self._locked_widget_right = True self._artist_ids = artist_ids self._limit_to_current = not update_albums self.set_property('height-request', ArtSize.BIG * self.get_scale_factor()) self.connect('size-allocate', self._on_size_allocate) builder = Gtk.Builder() builder.add_from_resource('/org/gnome/Lollypop/%s.ui' % type(self).__name__) self._widget = builder.get_object('widget') self._play_button = builder.get_object('play-button') self._play_all_button = builder.get_object('playall-button') self._artwork_button = builder.get_object('artwork-button') self._action_button = builder.get_object('action-button') self._action_event = builder.get_object('action-event') builder.connect_signals(self) rating = RatingWidget(self._album) rating.show() self._coverbox = builder.get_object('coverbox') # 6 for 2*3px (application.css) self._coverbox.set_property('width-request', ArtSize.BIG * self.get_scale_factor() + 6) self._coverbox.add(rating) if Lp().window.get_view_width() < WindowSize.MEDIUM: self._coverbox.hide() self._artist_label = builder.get_object('artist') if len(artist_ids) > 1: self._artist_label.set_text(", ".join(self._album.artists)) self._artist_label.show() label = builder.get_object('duration') duration = Lp().albums.get_duration(album_id, genre_ids) hours = int(duration / 3600) mins = int(duration / 60) if hours > 0: mins -= hours * 60 if mins > 0: label.set_text(_("%s h %s m") % (hours, mins)) else: label.set_text(_("%s h") % hours) else: label.set_text(_("%s m") % mins) self._box = Gtk.Grid() self._box.set_column_homogeneous(True) self._box.set_property('valign', Gtk.Align.START) self._box.show() builder.get_object('albuminfo').add(self._box) self._tracks_left = {} self._tracks_right = {} self._cover = builder.get_object('cover') self._cover.get_style_context().add_class('cover-frame') self.set_cover() self.update_state() builder.get_object('title').set_label(self._album.name) if self._album.year: year = builder.get_object('year') year.set_label(self._album.year) year.show() for disc in self._discs: self._add_disc_container(disc.number) self._set_disc_height(disc) self.add(self._widget) # We start transparent, we switch opaque at size allocation # This prevent artifacts self.set_opacity(0) self._menu = builder.get_object('menu') self._menu.connect('clicked', self._pop_menu) # TODO Remove this later if Gtk.get_minor_version() > 16: self._menu.show() else: self.connect('map', self._on_map)
def __init__(self, album_id, genre_ids, artist_ids, art_size): """ Init detailed album widget @param album id as int @param genre ids as [int] @param artist ids as [int] @param lazy as LazyLoadingView @param art size as ArtSize """ Gtk.Bin.__init__(self) AlbumWidget.__init__(self, album_id, genre_ids, artist_ids, art_size) self._album.set_artists(artist_ids) self.__width = None self.__context = None # Cover + rating + spacing self.__height = ArtSize.BIG + 26 self.__orientation = None self.__child_height = TrackRow.get_best_height(self) # Header + separator + spacing + margin self.__requested_height = self.__child_height + 6 # Discs to load, will be emptied self.__discs = self._album.discs self.__locked_widget_right = True self.set_property('height-request', self.__height) self.connect('size-allocate', self.__on_size_allocate) builder = Gtk.Builder() builder.add_from_resource('/org/gnome/Lollypop/AlbumDetailedWidget.ui') builder.connect_signals(self) self._widget = builder.get_object('widget') album_info = builder.get_object('albuminfo') title_label = builder.get_object('title') title_label.set_property('has-tooltip', True) artist_label = builder.get_object('artist') artist_label.set_property('has-tooltip', True) year_label = builder.get_object('year') self.__header = builder.get_object('header') self.__overlay = builder.get_object('overlay') self.__duration_label = builder.get_object('duration') self.__context_button = builder.get_object('context') if art_size == ArtSize.NONE: self._cover = None rating = RatingWidget(self._album) rating.set_hexpand(True) rating.set_property('halign', Gtk.Align.END) rating.set_property('valign', Gtk.Align.CENTER) rating.show() self.__header.attach(rating, 4, 0, 1, 1) loved = LovedWidget(self._album) loved.set_property('halign', Gtk.Align.END) loved.set_property('valign', Gtk.Align.CENTER) loved.show() self.__header.attach(loved, 5, 0, 1, 1) artist_label.set_text(", ".join(self._album.artists)) artist_label.show() if self._album.year: year_label.set_label(self._album.year) year_label.show() else: self.__duration_label.set_hexpand(True) builder = Gtk.Builder() builder.add_from_resource('/org/gnome/Lollypop/CoverBox.ui') builder.connect_signals(self) self._play_button = builder.get_object('play-button') self._action_button = builder.get_object('action-button') self._action_event = builder.get_object('action-event') self._cover = builder.get_object('cover') self.__coverbox = builder.get_object('coverbox') # 6 for 2*3px (application.css) self.__coverbox.set_property('width-request', art_size + 6) if art_size == ArtSize.BIG: self._cover.get_style_context().add_class('cover-frame') self._artwork_button = builder.get_object('artwork-button') if self._album.year: year_label.set_label(self._album.year) year_label.show() grid = Gtk.Grid() grid.set_column_spacing(10) grid.set_property('halign', Gtk.Align.CENTER) grid.show() rating = RatingWidget(self._album) loved = LovedWidget(self._album) rating.show() loved.show() grid.add(rating) grid.add(loved) self.__coverbox.add(grid) self._widget.attach(self.__coverbox, 0, 0, 1, 1) if Lp().window.get_view_width() < WindowSize.MEDIUM: self.__coverbox.hide() if len(artist_ids) > 1: artist_label.set_text(", ".join(self._album.artists)) artist_label.show() elif art_size == ArtSize.HEADER: # Here we are working around default CoverBox ui # Do we really need to have another ui file? # So just hack values on the fly self._cover.set_halign(Gtk.Align.CENTER) self._cover.get_style_context().add_class('small-cover-frame') self.__coverbox.set_margin_bottom(5) # We want a smaller button, so reload image self._rounded_class = "rounded-icon-small" self._play_button.set_from_icon_name( "media-playback-start-symbolic", Gtk.IconSize.MENU) overlay_grid = builder.get_object('overlay-grid') overlay_grid.set_margin_bottom(2) overlay_grid.set_margin_end(2) overlay_grid.set_column_spacing(0) self._play_button.set_margin_start(2) self._play_button.set_margin_bottom(2) play_event = builder.get_object('play-event') play_event.set_property('halign', Gtk.Align.START) play_event.set_property('valign', Gtk.Align.END) album_info.attach(self.__coverbox, 0, 0, 1, 1) artist_label.set_text(", ".join(self._album.artists)) artist_label.show() self.__set_duration() self.__box = Gtk.Grid() self.__box.set_column_homogeneous(True) self.__box.set_property('valign', Gtk.Align.START) self.__box.show() album_info.add(self.__box) self._tracks_left = {} self._tracks_right = {} self.set_cover() self.update_state() title_label.set_label(self._album.name) for disc in self.__discs: self.__add_disc_container(disc.number) self.__set_disc_height(disc) self.add(self._widget) # We start transparent, we switch opaque at size allocation # This prevent artifacts self.set_opacity(0) if self._album.is_web and self._cover is not None: self._cover.get_style_context().add_class( 'cover-frame-web')
def __init__(self, album_id, genre_ids, artist_ids, show_cover): """ Init detailed album widget @param album id as int @param genre ids as [int] @param artist ids as [int] @param lazy as LazyLoadingView @param show cover as bool """ Gtk.Bin.__init__(self) AlbumWidget.__init__(self, album_id, genre_ids, artist_ids) self._album.set_artists(artist_ids) self.__width = None self.__context = None # Cover + rating + spacing self.__height = ArtSize.BIG + 26 self.__orientation = None self.__child_height = TrackRow.get_best_height(self) # Header + separator + spacing + margin self.__requested_height = self.__child_height + 6 # Discs to load, will be emptied self.__discs = self._album.discs self.__locked_widget_right = True self.set_property('height-request', self.__height) self.connect('size-allocate', self.__on_size_allocate) builder = Gtk.Builder() builder.add_from_resource('/org/gnome/Lollypop/AlbumDetailedWidget.ui') self._widget = builder.get_object('widget') self.__header = builder.get_object('header') self.__overlay = builder.get_object('overlay') self._play_button = builder.get_object('play-button') self._artwork_button = builder.get_object('artwork-button') self._action_button = builder.get_object('action-button') self._action_event = builder.get_object('action-event') builder.connect_signals(self) rating = RatingWidget(self._album) rating.show() artist_label = builder.get_object('artist') if show_cover: self._cover = builder.get_object('cover') builder.get_object('duration').set_hexpand(True) self._cover.get_style_context().add_class('cover-frame') self.__coverbox = builder.get_object('coverbox') self.__coverbox.show() # 6 for 2*3px (application.css) self.__coverbox.set_property('width-request', ArtSize.BIG + 6) self.__coverbox.add(rating) if Lp().window.get_view_width() < WindowSize.MEDIUM: self.__coverbox.hide() if len(artist_ids) > 1: artist_label.set_text(", ".join(self._album.artists)) artist_label.show() else: self.__header.attach(rating, 4, 0, 1, 1) rating.set_hexpand(True) rating.set_property('halign', Gtk.Align.END) rating.set_property('valign', Gtk.Align.CENTER) artist_label.set_text(", ".join(self._album.artists)) artist_label.show() self._cover = None self.__duration_label = builder.get_object('duration') self.__set_duration() self.__box = Gtk.Grid() self.__box.set_column_homogeneous(True) self.__box.set_property('valign', Gtk.Align.START) self.__box.show() builder.get_object('albuminfo').add(self.__box) self._tracks_left = {} self._tracks_right = {} self.set_cover() self.update_state() builder.get_object('title').set_label(self._album.name) if self._album.year: year = builder.get_object('year') year.set_label(self._album.year) year.show() for disc in self.__discs: self.__add_disc_container(disc.number) self.__set_disc_height(disc) self.add(self._widget) # We start transparent, we switch opaque at size allocation # This prevent artifacts self.set_opacity(0) self.__context_button = builder.get_object('context') if self._album.is_web and show_cover: self._cover.get_style_context().add_class( 'cover-frame-web')