def __init__(self, album, view_type): """ Init cover widget @param album @param view_type as ViewType """ BannerWidget.__init__(self, view_type | ViewType.OVERLAY) self.__album = album album_name = GLib.markup_escape_text(self.__album.name) self.__title_label = Gtk.Label.new() self.__title_label.show() markup = _("<b>Album of the day</b>\n") markup += "<span size='small' alpha='40000'>%s</span>\n" % album_name artist_name = GLib.markup_escape_text(", ".join(self.__album.artists)) markup += "<span size='x-small' alpha='40000'>%s</span>" % artist_name self.__title_label.set_markup(markup) self.__title_label.set_ellipsize(Pango.EllipsizeMode.END) self.__title_label.set_xalign(0.0) self.__title_label.set_vexpand(True) self.__title_label.set_margin_start(MARGIN) self.__cover_widget = CoverWidget(self.__album, view_type) self.__cover_widget.show() play_button = Gtk.Button.new() play_button.show() play_button.set_property("valign", Gtk.Align.CENTER) image = Gtk.Image.new() image.show() play_button.set_image(image) play_button.connect("clicked", self.__on_play_button_clicked) play_button.get_style_context().add_class("banner-button") play_button.set_property("halign", Gtk.Align.END) play_button.set_hexpand(True) play_button.get_image().set_from_icon_name( "media-playback-start-symbolic", Gtk.IconSize.BUTTON) menu_button = Gtk.Button.new_from_icon_name("view-more-symbolic", Gtk.IconSize.BUTTON) menu_button.show() menu_button.set_property("valign", Gtk.Align.CENTER) menu_button.get_style_context().add_class("banner-button") menu_button.set_property("halign", Gtk.Align.END) menu_button.connect("clicked", self.__on_menu_button_clicked) grid = Gtk.Grid() grid.show() grid.set_margin_start(MARGIN) grid.set_margin_end(MARGIN) grid.add(self.__cover_widget) grid.add(self.__title_label) box = Gtk.Box() box.show() box.get_style_context().add_class("linked") box.add(play_button) box.add(menu_button) grid.add(box) self._overlay.add_overlay(grid) self._overlay.set_overlay_pass_through(grid, True) self.__set_internal_size() return [(App().window.container.widget, "notify::folded", "_on_container_folded"), (App().art, "album-artwork-changed", "_on_album_artwork_changed")]
def update_for_width(self, width): """ Update banner internals for width, call this before showing banner @param width as int """ BannerWidget.update_for_width(self, width) self.__entry.set_size_request(self.width / 3, -1)
def update_for_width(self, width): """ Update banner internals for width, call this before showing banner @param width as int """ BannerWidget.update_for_width(self, width) self.__set_internal_size()
def __init__(self, playlist_id, view): """ Init banner @param playlist_id as int @param view as AlbumsListView """ BannerWidget.__init__(self, view.args["view_type"] | ViewType.OVERLAY) self.__duration_task = False self.__playlist_id = playlist_id self.__view = view builder = Gtk.Builder() builder.add_from_resource( "/org/gnome/Lollypop/PlaylistBannerWidget.ui") self.__title_label = builder.get_object("title") self.__spinner = builder.get_object("spinner") self.__duration_label = builder.get_object("duration") self.__play_button = builder.get_object("play_button") self.__shuffle_button = builder.get_object("shuffle_button") self.__menu_button = builder.get_object("menu_button") widget = builder.get_object("widget") self._overlay.add_overlay(widget) self._overlay.set_overlay_pass_through(widget, True) self.__title_label.set_label(App().playlists.get_name(playlist_id)) builder.connect_signals(self) self.connect("destroy", self.__on_destroy) self.__set_internal_size() return [ (view, "initialized", "_on_view_updated"), (App().window.container.widget, "notify::folded", "_on_container_folded"), (App().player, "duration-changed", "_on_view_updated"), (App().playlists, "playlist-track-added", "_on_playlist_changed"), (App().playlists, "playlist-track-removed", "_on_playlist_changed"), ]
def __init__(self, genre_ids, artist_ids, storage_type, view_type): """ Init artist banner @parma genre_ids as [int] @param artist_ids as [int] @param storage_type as StorageType @param view_type as ViewType (Unused) """ BannerWidget.__init__(self, view_type | ViewType.OVERLAY) self.__genre_ids = genre_ids self.__artist_ids = artist_ids self.__storage_type = storage_type builder = Gtk.Builder() builder.add_from_resource("/org/gnome/Lollypop/ArtistBannerWidget.ui") builder.connect_signals(self) self.__badge_artwork = builder.get_object("badge_artwork") self.__labels = builder.get_object("label_event") self.__title_label = builder.get_object("artist") self.__title_label.connect("realize", set_cursor_type) self.__title_label.connect("query-tooltip", on_query_tooltip) self.__title_label.set_property("has-tooltip", True) self.__add_button = builder.get_object("add_button") self.__play_button = builder.get_object("play_button") self.__menu_button = builder.get_object("menu_button") if len(artist_ids) > 1: self.__menu_button.hide() builder.get_object("artwork_event").connect( "realize", set_cursor_type) self.__labels.connect("realize", set_cursor_type) self.__widget = builder.get_object("widget") artists = [] for artist_id in self.__artist_ids: artists.append(App().artists.get_name(artist_id)) self.__title_label.set_markup(GLib.markup_escape_text( ", ".join(artists))) self.__show_artwork = len(artist_ids) == 1 self.__title_label.get_style_context().add_class("text-x-large") self._overlay.add_overlay(self.__widget) self._overlay.set_overlay_pass_through(self.__widget, True) self.__update_add_button() self.__set_internal_size() return [ (App().window.container.widget, "notify::folded", "_on_container_folded"), (App().art, "artist-artwork-changed", "_on_artist_artwork_changed"), (App().player, "playback-added", "_on_playback_changed"), (App().player, "playback-updated", "_on_playback_changed"), (App().player, "playback-setted", "_on_playback_changed"), (App().player, "playback-removed", "_on_playback_changed"), (App().settings, "changed::artist-artwork", "_on_artist_artwork_setting_changed") ]
def __init__(self, genre_ids, artist_ids, view_type, show_menu=False): """ Init banner @param genre_ids as [int] @param artist_ids as [int] @param view_type as ViewType @param show_menu as bool """ BannerWidget.__init__(self, view_type | ViewType.OVERLAY) grid = Gtk.Grid.new() grid.show() grid.set_property("valign", Gtk.Align.CENTER) self.__title_label = Gtk.Label.new() self.__title_label.show() self.__title_label.set_margin_start(MARGIN) self.__title_label.set_hexpand(True) self.__title_label.set_property("halign", Gtk.Align.START) linked = Gtk.Grid.new() linked.show() linked.get_style_context().add_class("linked") linked.set_margin_end(MARGIN) linked.set_property("halign", Gtk.Align.END) self.__play_button = Gtk.Button.new_from_icon_name( "media-playback-start-symbolic", Gtk.IconSize.BUTTON) self.__play_button.show() self.__play_button.get_style_context().add_class("banner-button") self.__play_button.connect("clicked", self.__on_play_button_clicked) self.__shuffle_button = Gtk.Button.new_from_icon_name( "media-playlist-shuffle-symbolic", Gtk.IconSize.BUTTON) self.__shuffle_button.show() self.__shuffle_button.get_style_context().add_class("banner-button") self.__shuffle_button.connect("clicked", self.__on_shuffle_button_clicked) linked.add(self.__play_button) linked.add(self.__shuffle_button) if show_menu: self.__menu_button = Gtk.Button.new_from_icon_name( "view-more-symbolic", Gtk.IconSize.BUTTON) self.__menu_button.show() self.__menu_button.get_style_context().add_class("banner-button") self.__menu_button.connect("clicked", self.__on_menu_button_clicked) linked.add(self.__menu_button) grid.add(self.__title_label) grid.add(linked) self._overlay.add_overlay(grid) self._overlay.set_overlay_pass_through(grid, True) title_str = get_title_for_genres_artists(genre_ids, artist_ids) self.__title_label.set_markup("<b>%s</b>" % GLib.markup_escape_text(title_str))
def __init__(self): """ Init banner """ BannerWidget.__init__(self, ViewType.OVERLAY) builder = Gtk.Builder() builder.add_from_resource("/org/gnome/Lollypop/SearchBannerWidget.ui") self.__menu = builder.get_object("menu") self.__spinner = builder.get_object("spinner") self.__entry = builder.get_object("entry") widget = builder.get_object("widget") self._overlay.add_overlay(widget) self._overlay.set_overlay_pass_through(widget, True) self.connect("map", self.__on_map) builder.connect_signals(self)
def _handle_width_allocate(self, allocation): """ Update entry width @param allocation as Gtk.Allocation """ if BannerWidget._handle_width_allocate(self, allocation): self.__entry.set_size_request(self.width / 3, -1)
def _handle_width_allocate(self, allocation): """ Update artwork @param allocation as Gtk.Allocation """ if BannerWidget._handle_width_allocate(self, allocation): self.__set_internal_size()
def __init__(self, view): """ Init banner @param view as PlaylistView """ BannerWidget.__init__(self, view.args["view_type"] | ViewType.OVERLAY) self.__view = view grid = Gtk.Grid() grid.set_property("valign", Gtk.Align.CENTER) grid.get_style_context().add_class("linked") grid.show() self.__title_label = Gtk.Label.new("<b>" + _("Playlists") + "</b>") self.__title_label.show() self.__title_label.set_use_markup(True) self.__title_label.set_hexpand(True) self.__title_label.get_style_context().add_class("dim-label") self.__title_label.set_property("halign", Gtk.Align.START) self.__title_label.set_ellipsize(Pango.EllipsizeMode.END) self.__new_button = Gtk.Button.new_from_icon_name( "document-new-symbolic", Gtk.IconSize.BUTTON) self.__new_button.connect("clicked", self.__on_new_button_clicked) self.__new_button.set_property("halign", Gtk.Align.CENTER) self.__new_button.get_style_context().add_class("banner-button") self.__new_button.show() self.__menu_button = Gtk.Button.new_from_icon_name( "view-more-symbolic", Gtk.IconSize.BUTTON) self.__menu_button.show() self.__menu_button.get_style_context().add_class("banner-button") self.__menu_button.set_property("halign", Gtk.Align.END) self.__menu_button.connect("clicked", self.__on_menu_button_clicked) box = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0) box.show() box.get_style_context().add_class("linked") box.add(self.__new_button) box.add(self.__menu_button) grid.add(self.__title_label) grid.add(box) grid.set_margin_start(MARGIN) grid.set_margin_end(MARGIN) self._overlay.add_overlay(grid) self._overlay.set_overlay_pass_through(grid, True) self.__set_internal_size() return [ (App().window.container.widget, "notify::folded", "_on_container_folded"), ]
def __init__(self, view_type=ViewType.OVERLAY): """ Init cover widget @param album @param view_type as ViewType """ BannerWidget.__init__(self, view_type) self.__title_label = Gtk.Label.new() self.__title_label.show() self.__title_label.set_ellipsize(Pango.EllipsizeMode.END) self.__title_label.set_vexpand(True) self.__translate_button = Gtk.ToggleButton.new() image = Gtk.Image.new_from_icon_name( "accessories-dictionary-symbolic", Gtk.IconSize.BUTTON) image.show() self.__translate_button.set_image(image) self.__translate_button.show() self.__translate_button.connect("toggled", self.__on_lyrics_button_toggled) self.__translate_button.get_style_context().add_class( "banner-button") self.__translate_button.set_property("valign", Gtk.Align.CENTER) self.__translate_button.set_property("halign", Gtk.Align.END) self.__translate_button.set_hexpand(True) self.__translate_button.set_sensitive(False) grid = Gtk.Grid() grid.show() grid.set_column_spacing(MARGIN) grid.add(self.__title_label) grid.add(self.__translate_button) grid.set_property("margin", MARGIN) grid.set_margin_end(MARGIN) self._overlay.add_overlay(grid) self._overlay.set_overlay_pass_through(grid, True) self.__update() self.__set_internal_size() return [ (App().player, "current-changed", "_on_current_changed"), (App().window.container.widget, "notify::folded", "_on_container_folded"), (App().art, "album-artwork-changed", "_on_album_artwork_changed") ]
def __init__(self, album, storage_type, view_type): """ Init cover widget @param album @param storage_type as int @param view_type as ViewType """ BannerWidget.__init__(self, view_type) self.__album = album self.__storage_type = storage_type self.__widget = None return [ (App().window.container.widget, "notify::folded", "_on_container_folded"), (App().art, "album-artwork-changed", "_on_album_artwork_changed"), (App().player, "playback-added", "_on_playback_changed"), (App().player, "playback-updated", "_on_playback_changed"), (App().player, "playback-setted", "_on_playback_changed"), (App().player, "playback-removed", "_on_playback_changed") ]
def __init__(self, album, storage_type, view_type): """ Init cover widget @param album @param storage_type as int @param view_type as ViewType """ BannerWidget.__init__(self, view_type) self.__album = album self.__storage_type = storage_type builder = Gtk.Builder() builder.add_from_resource("/org/gnome/Lollypop/AlbumBannerWidget.ui") builder.connect_signals(self) self.__labels = builder.get_object("labels") self.__title_label = builder.get_object("title_label") self.__title_label.connect("query-tooltip", on_query_tooltip) self.__artist_label = builder.get_object("artist_label") self.__artist_label.connect("query-tooltip", on_query_tooltip) self.__year_label = builder.get_object("year_label") self.__duration_label = builder.get_object("duration_label") self.__play_button = builder.get_object("play_button") self.__add_button = builder.get_object("add_button") self.__menu_button = builder.get_object("menu_button") self.__widget = builder.get_object("widget") if view_type & ViewType.OVERLAY: style = "banner-button" else: style = "menu-button" self.__play_button.get_style_context().add_class(style) self.__add_button.get_style_context().add_class(style) self.__menu_button.get_style_context().add_class(style) self.__cover_widget = CoverWidget(album, view_type) self.__cover_widget.show() self.__title_label.set_label(album.name) if view_type & ViewType.ALBUM: self.__artist_label.show() self.__artist_label.set_label(", ".join(album.artists)) else: self.__title_label.set_opacity(0.8) self.__year_label.set_opacity(0.7) self.__duration_label.set_opacity(0.6) self.__widget.get_style_context().add_class("album-banner") if album.year is not None: self.__year_label.set_label(str(album.year)) self.__year_label.show() human_duration = get_human_duration(album.duration) self.__duration_label.set_text(human_duration) artist_eventbox = builder.get_object("artist_eventbox") artist_eventbox.connect("realize", set_cursor_type) self.__gesture1 = GesturesHelper( artist_eventbox, primary_press_callback=self._on_artist_press) year_eventbox = builder.get_object("year_eventbox") year_eventbox.connect("realize", set_cursor_type) self.__gesture2 = GesturesHelper( year_eventbox, primary_press_callback=self._on_year_press) self.__widget.attach(self.__cover_widget, 0, 0, 1, 3) self.__bottom_box = builder.get_object("bottom_box") self.__loved_widget = LovedWidget(album, Gtk.IconSize.INVALID) self.__loved_widget.show() self.__bottom_box.pack_start(self.__loved_widget, 0, False, False) self.__rating_widget = RatingWidget(album, Gtk.IconSize.INVALID) self.__rating_widget.show() self.__bottom_box.pack_start(self.__rating_widget, 0, True, True) if view_type & ViewType.OVERLAY: self._overlay.add_overlay(self.__widget) self._overlay.set_overlay_pass_through(self.__widget, True) else: self.add(self.__widget) self.__update_add_button() self.__set_internal_size() return [(App().window.container.widget, "notify::folded", "_on_container_folded"), (App().art, "album-artwork-changed", "_on_album_artwork_changed"), (App().player, "playback-added", "_on_playback_changed"), (App().player, "playback-updated", "_on_playback_changed"), (App().player, "playback-removed", "_on_playback_changed")]
def __init__(self, view): """ Init banner @param view as AlbumsListView """ BannerWidget.__init__(self, view.args["view_type"] | ViewType.OVERLAY) self.__duration_task = False self.__view = view self.__clear_button = Gtk.Button.new_from_icon_name( "edit-clear-all-symbolic", Gtk.IconSize.BUTTON) self.__clear_button.set_relief(Gtk.ReliefStyle.NONE) self.__clear_button.set_tooltip_text(_("Clear albums")) self.__clear_button.set_sensitive(App().player.albums) self.__clear_button.connect("clicked", self.__on_clear_button_clicked) self.__clear_button.get_style_context().add_class("banner-button") self.__clear_button.show() self.__menu_button = Gtk.Button.new_from_icon_name( "view-more-symbolic", Gtk.IconSize.BUTTON) self.__menu_button.set_relief(Gtk.ReliefStyle.NONE) self.__menu_button.set_sensitive(App().player.albums) self.__menu_button.connect("clicked", self.__on_menu_button_clicked) self.__menu_button.get_style_context().add_class("banner-button") self.__menu_button.show() self.__jump_button = Gtk.Button.new_from_icon_name( "go-jump-symbolic", Gtk.IconSize.BUTTON) self.__jump_button.set_relief(Gtk.ReliefStyle.NONE) self.__jump_button.connect("clicked", self.__on_jump_button_clicked) self.__jump_button.set_tooltip_text(_("Go to current track")) self.__jump_button.set_sensitive(App().player.albums) self.__jump_button.get_style_context().add_class("banner-button") self.__jump_button.show() self.__title_label = Gtk.Label.new("<b>" + _("Playing albums") + "</b>") self.__title_label.show() self.__title_label.set_use_markup(True) self.__title_label.set_hexpand(True) self.__title_label.get_style_context().add_class("dim-label") self.__title_label.set_property("halign", Gtk.Align.START) self.__title_label.set_ellipsize(Pango.EllipsizeMode.END) self.__duration_label = Gtk.Label.new() self.__duration_label.show() self.__duration_label.set_property("halign", Gtk.Align.END) grid = Gtk.Grid() grid.show() grid.set_column_spacing(MARGIN) grid.set_property("valign", Gtk.Align.CENTER) grid.set_margin_start(MARGIN) grid.set_margin_end(MARGIN) grid.add(self.__title_label) grid.add(self.__duration_label) buttons = Gtk.Grid() buttons.show() buttons.get_style_context().add_class("linked") buttons.set_property("valign", Gtk.Align.CENTER) buttons.add(self.__jump_button) buttons.add(self.__clear_button) buttons.add(self.__menu_button) grid.add(buttons) self._overlay.add_overlay(grid) self._overlay.set_overlay_pass_through(grid, True) self.connect("destroy", self.__on_destroy) return [ (view, "initialized", "_on_view_updated"), (App().player, "playback-added", "_on_playback_changed"), (App().player, "playback-updated", "_on_playback_changed"), (App().player, "playback-setted", "_on_playback_changed"), (App().player, "playback-removed", "_on_playback_changed"), ]