def __init__(self, album_id, genre_ids, artist_ids, width=None, height=None, art_size=ArtSize.NONE): """ Init popover @param album id as int @param genre ids as [int] @param artist ids as [int] @param width as int (None) @param height as int (None) @param art size as int """ Gtk.Popover.__init__(self) self.get_style_context().add_class('box-shadow') view = ArtistAlbumsView(artist_ids, genre_ids, art_size) view.populate([album_id]) # Get width/height from main window if None if height is None: height = Lp().window.get_size()[1] * 0.8 if width is None: self.__width = Lp().window.get_size()[0] * 0.8 else: self.__width = width # Get height requested by child requested_height = view.children[0].requested_height wanted_height = min(400, min(height, requested_height)) view.set_property('height-request', wanted_height) view.show() self.add(view)
def __init__(self, album_id, genre_ids, artist_ids): """ Init view @param album id as int @param genre ids as [int] @param artist ids as [int] """ Gtk.Grid.__init__(self) self.set_orientation(Gtk.Orientation.VERTICAL) back_button = Gtk.Button.new_from_icon_name("go-previous-symbolic", Gtk.IconSize.MENU) back_button.set_tooltip_text(_("Go back")) back_button.connect('clicked', self.__on_back_button_clicked) back_button.set_property('halign', Gtk.Align.START) back_button.set_relief(Gtk.ReliefStyle.NONE) back_button.show() self.add(back_button) view = ArtistAlbumsView(artist_ids, genre_ids, ArtSize.HEADER) view.populate([album_id]) view.show() self.add(view) self.show()
def __init__(self, album, width): """ Init popover @param album as Album @param width as int @param art size as int """ Popover.__init__(self) self.__width = width self.get_style_context().add_class("box-shadow") view = ArtistAlbumsView(album.artist_ids, album.genre_ids, False) view.populate([album]) window_width = App().window.get_allocated_width() window_height = App().window.get_allocated_height() wanted_width = min(900, window_width * 0.5) wanted_height = max(200, min(window_height * 0.5, view.children[0].requested_height[0])) view.set_property("width-request", wanted_width) view.set_property("height-request", wanted_height) view.show() self.add(view)
class AlbumPopover(Gtk.Popover): """ An ArtistAlbumsView in a popover """ def __init__(self, album_id, genre_ids, artist_ids, width=None, height=None, show_cover=True): """ Init popover @param album id as int @param genre ids as [int] @param artist ids as [int] @param width as int (None) @param height as int (None) @param show cover as bool """ Gtk.Popover.__init__(self) # Get width/height from main window if None if height is None: height = Lp().window.get_size()[1] * 0.8 if width is None: self._width = Lp().window.get_size()[0] * 0.8 else: self._width = width self.get_style_context().add_class('box-shadow') self._view = ArtistAlbumsView(artist_ids, genre_ids, show_cover) self._view.populate([album_id]) wanted_height = min(400, min(height, self._view.requested_height)) self._view.set_property('height-request', wanted_height) self._view.show() self.add(self._view) def do_get_preferred_width(self): """ Set maximum width """ width = min(900, self._width * 0.8) return (width, width)