Exemplo n.º 1
0
 def __init__(self, genre_ids, artist_ids, view_type=ViewType.SCROLLED):
     """
         Init album view
         @param genre_ids as [int]
         @param artist_ids as [int]
         @param view_type as ViewType
     """
     FlowBoxView.__init__(self, view_type)
     ViewController.__init__(self, ViewControllerType.ALBUM)
     self._widget_class = AlbumSimpleWidget
     self.__genre_ids = genre_ids
     self.__artist_ids = artist_ids
     if genre_ids and genre_ids[0] < 0:
         if genre_ids[0] == Type.WEB:
             if not Gio.NetworkMonitor.get_default().get_network_available(
             ):
                 self._empty_message = _("Network not available")
                 self._box.hide()
             elif GLib.find_program_in_path("youtube-dl") is None:
                 self._empty_message = _("Missing youtube-dl command")
                 self._box.hide()
             elif not get_network_available("SPOTIFY") or\
                     not get_network_available("YOUTUBE"):
                 self._empty_message = _("You need to enable Spotify ") + \
                                       _("and YouTube in network settings")
                 self._box.hide()
         self._empty_icon_name = get_icon_name(genre_ids[0])
     if view_type & ViewType.SMALL:
         self._scrolled.set_policy(Gtk.PolicyType.NEVER,
                                   Gtk.PolicyType.NEVER)
Exemplo n.º 2
0
 def set_artwork(self):
     """
         set_artwork widget
     """
     if self.__artwork is None:
         return
     if self.__rowid == Type.SEPARATOR:
         pass
     elif self.__mask & SelectionListMask.ARTISTS and\
             self.__rowid >= 0 and\
             App().settings.get_value("artist-artwork"):
         App().art_helper.set_artist_artwork(
             self.__name, ArtSize.SMALL, ArtSize.SMALL,
             self.get_scale_factor(), ArtBehaviour.ROUNDED
             | ArtBehaviour.CROP_SQUARE | ArtBehaviour.CACHE,
             self.__on_artist_artwork)
         self.__artwork.show()
     elif self.__rowid < 0:
         icon_name = get_icon_name(self.__rowid)
         self.__artwork.set_from_icon_name(icon_name, Gtk.IconSize.INVALID)
         self.__artwork.set_pixel_size(20)
         self.__artwork.show()
         emit_signal(self, "populated")
     else:
         self.__artwork.hide()
         emit_signal(self, "populated")
Exemplo n.º 3
0
 def __init__(self, genre_ids, artist_ids, storage_type, view_type):
     """
         Init album view
         @param genre_ids as [int]
         @param artist_ids as [int]
         @param storage_type as StorageType
         @param view_type as ViewType
     """
     FlowBoxView.__init__(self, storage_type, view_type)
     self._genre_ids = genre_ids
     self._artist_ids = artist_ids
     self._storage_type = storage_type
     self.__populate_wanted = True
     if genre_ids and genre_ids[0] < 0:
         if genre_ids[0] == Type.WEB:
             (youtube_dl, env) = get_youtube_dl()
             if youtube_dl is None:
                 self._empty_message = _("Missing youtube-dl command")
                 self.show_placeholder(True)
                 self.__populate_wanted = False
             elif not get_network_available("YOUTUBE"):
                 self._empty_message =\
                     _("Network unavailable or disabled in settings")
                 self.show_placeholder(True)
                 self.__populate_wanted = False
         self._empty_icon_name = get_icon_name(genre_ids[0])
     return [(App().scanner, "updated", "_on_collection_updated"),
             (App().player, "loading-changed", "_on_loading_changed"),
             (App().player, "current-changed", "_on_current_changed"),
             (App().art, "album-artwork-changed", "_on_artwork_changed")]
 def __init__(self, genre_ids, artist_ids, view_type):
     """
         Init widget
         @param genre_ids as int
         @param artist_ids as int
         @param view_type as ViewType
     """
     LazyLoadingView.__init__(self, view_type | ViewType.FILTERED)
     ViewController.__init__(self, ViewControllerType.ALBUM)
     self.__genre_ids = genre_ids
     self.__artist_ids = artist_ids
     if genre_ids and genre_ids[0] < 0:
         if genre_ids[0] == Type.WEB and\
                 GLib.find_program_in_path("youtube-dl") is None:
             self._empty_message = _("Missing youtube-dl command")
         self._empty_icon_name = get_icon_name(genre_ids[0])
     self.__autoscroll_timeout_id = None
     self.__reveals = []
     self.__prev_animated_rows = []
     # Calculate default album height based on current pango context
     # We may need to listen to screen changes
     self.__height = AlbumRow.get_best_height(self)
     self._box = Gtk.ListBox()
     self._box.set_margin_end(MARGIN)
     self._box.get_style_context().add_class("trackswidget")
     self._box.set_vexpand(True)
     self._box.set_selection_mode(Gtk.SelectionMode.NONE)
     self._box.set_activate_on_single_click(True)
     self._box.set_filter_func(self._filter_func)
     self._box.show()
     self._scrolled.set_property("expand", True)
     self.add(self._scrolled)
Exemplo n.º 5
0
 def __init__(self, view_type):
     """
         Init decade view
         @param view_type as ViewType
     """
     FlowBoxView.__init__(self, view_type)
     self._widget_class = AlbumsDecadeWidget
     self._empty_icon_name = get_icon_name(Type.YEARS)
Exemplo n.º 6
0
 def __init__(self, view_type, destroy=True):
     """
         Init artist view
         @param view_type as ViewType
         @param destroy as bool
     """
     FlowBoxView.__init__(self)
     self.__view_type = view_type
     self.__destroy = destroy
     self._widget_class = RoundedArtistWidget
     self.connect("destroy", self.__on_destroy)
     self._empty_icon_name = get_icon_name(Type.ARTISTS)
Exemplo n.º 7
0
 def __init__(self, storage_type, view_type):
     """
         Init decade view
         @param storage_type as StorageType
         @param view_type as ViewType
     """
     from lollypop.widgets_banner_flowbox import FlowboxBannerWidget
     FlowBoxView.__init__(self, storage_type, view_type | ViewType.OVERLAY)
     self._empty_icon_name = get_icon_name(Type.YEARS)
     self.__banner = FlowboxBannerWidget([Type.YEARS], [], self.view_type)
     self.__banner.show()
     self.__banner.connect("play-all", self.__on_banner_play_all)
     self.add_widget(self._box, self.__banner)
Exemplo n.º 8
0
 def __init__(self, storage_type, view_type):
     """
         Init artist view
         @param storage_type as StorageType
         @param view_type as ViewType
     """
     FlowBoxView.__init__(self, storage_type, view_type)
     self.connect("destroy", self.__on_destroy)
     self._empty_icon_name = get_icon_name(Type.ARTISTS)
     return [
         (App().art, "artist-artwork-changed",
          "_on_artist_artwork_changed"),
         (App().scanner, "updated", "_on_collection_updated")
     ]
Exemplo n.º 9
0
 def __add_value(self, value):
     """
         Add value to the model
         @param value as [int, str, optional str]
     """
     item_id = value[0]
     name = value[1]
     sort = value[2]
     if name == "":
         name = _("Unknown")
         icon_name = "dialog-warning-symbolic"
     icon_name = get_icon_name(item_id, self.__mask)
     if item_id > 0 and sort and\
             self.__mask & SelectionListMask.ARTISTS and\
             self.__fast_scroll is not None:
         self.__fast_scroll.add_char(sort[0])
     self.__model.append([item_id, name, icon_name, sort])
Exemplo n.º 10
0
 def __init__(self, view_type=ViewType.SCROLLED):
     """
         Init view
         @param view_type as ViewType
     """
     FlowBoxView.__init__(self, view_type)
     ViewController.__init__(self, ViewControllerType.RADIO)
     self._widget_class = RadioWidget
     self._empty_icon_name = get_icon_name(Type.RADIOS)
     self.__radios = Radios()
     builder = Gtk.Builder()
     builder.add_from_resource("/org/gnome/Lollypop/RadiosView.ui")
     builder.connect_signals(self)
     self.insert_row(0)
     self.attach(builder.get_object("widget"), 0, 0, 1, 1)
     self.__pop_tunein = None
     if not get_network_available("TUNEIN"):
         builder.get_object("search_btn").hide()
Exemplo n.º 11
0
 def __init__(self, rowid, header=False):
     """
         Init menu
         @param rowid as int
         @param header as bool
     """
     Gio.Menu.__init__(self)
     if header:
         from lollypop.menu_header import MenuHeader
         label = ShownLists.IDS[rowid]
         icon_name = get_icon_name(rowid)
         self.append_item(MenuHeader(label, icon_name))
     startup_menu = Gio.Menu()
     selected = rowid == App().settings.get_value("startup-id").get_int32()
     action = Gio.SimpleAction.new_stateful(
         "default_selection_id", None, GLib.Variant.new_boolean(selected))
     App().add_action(action)
     action.connect("change-state", self.__on_default_change_state, rowid)
     item = Gio.MenuItem.new(_("Default on startup"),
                             "app.default_selection_id")
     startup_menu.append_item(item)
     self.append_section(_("Startup"), startup_menu)
Exemplo n.º 12
0
    def _create_surface(self, set_surface):
        """
            Get artwork surface
            @param set_surface as bool
            @return cairo.Surface
        """
        surface = cairo.ImageSurface(cairo.FORMAT_RGB24, self._art_size,
                                     self._art_size)
        ctx = cairo.Context(surface)
        ctx.rectangle(0, 0, self._art_size, self._art_size)
        ctx.set_source_rgb(1, 1, 1)
        ctx.fill()
        album_ids = list(self.__album_ids)
        album_pixbufs = []
        album_scaled_pixbufs = []
        while album_ids and len(album_pixbufs) != 9:
            album_id = album_ids.pop(0)
            pixbuf = App().art.get_album_artwork(Album(album_id),
                                                 self._art_size,
                                                 self._art_size,
                                                 self._scale_factor)
            if pixbuf is not None:
                album_pixbufs.append(pixbuf)
        if len(album_pixbufs) == 0:
            self.__cover_size = self._art_size / 2
            positions = [(0.5, 0.5)]
        elif 1 <= len(album_pixbufs) <= 2:
            self.__cover_size = self._art_size
            positions = [(0, 0)]
        elif 3 <= len(album_pixbufs) <= 5:
            self.__cover_size = self._art_size / 2
            positions = [(0, 0), (1, 0), (0, 1), (1, 1)]
        else:
            self.__cover_size = self._art_size / 3
            positions = [(0, 0), (1, 0), (2, 0), (0, 1), (1, 1), (2, 1),
                         (0, 2), (1, 2), (2, 2)]
        while album_pixbufs:
            pixbuf = album_pixbufs.pop(0)
            newpix = pixbuf.scale_simple(self.__cover_size, self.__cover_size,
                                         GdkPixbuf.InterpType.NEAREST)
            del pixbuf
            album_scaled_pixbufs.append(newpix)

        if len(album_scaled_pixbufs) == 0:
            theme = Gtk.IconTheme.get_default()
            category_icon = get_icon_name(self._genre)
            symbolic = theme.lookup_icon(category_icon, self.__cover_size,
                                         Gtk.IconLookupFlags.USE_BUILTIN)
            if symbolic is not None:
                pixbuf = symbolic.load_icon()
                album_scaled_pixbufs.append(pixbuf)

        if len(album_scaled_pixbufs) == 3:
            album_scaled_pixbufs.append(album_scaled_pixbufs[0])
        if len(album_scaled_pixbufs) == 6:
            album_scaled_pixbufs.append(album_scaled_pixbufs[2])
            album_scaled_pixbufs.append(album_scaled_pixbufs[1])
            album_scaled_pixbufs.append(album_scaled_pixbufs[0])
        if len(album_scaled_pixbufs) == 7:
            album_scaled_pixbufs.append(album_scaled_pixbufs[1])
            album_scaled_pixbufs.append(album_scaled_pixbufs[0])
        if len(album_scaled_pixbufs) == 8:
            album_scaled_pixbufs.append(album_scaled_pixbufs[0])

        self.__draw_surface(surface, ctx, positions, album_scaled_pixbufs,
                            set_surface)
 def set_icon_name():
     icon_name = get_icon_name(self._data) or "avatar-default-symbolic"
     self._artwork.set_from_icon_name(icon_name, Gtk.IconSize.DIALOG)
     self.emit("populated")
     self._artwork.get_style_context().add_class("artwork-icon-large")