Exemple #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)
Exemple #2
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")]
Exemple #3
0
    def populate(self, albums=[]):
        """
            Populate view for album ids
            Show artist_ids/genre_ids if empty
            @param albums as [Album]
        """
        def on_load(albums):
            if albums:
                FlowBoxView.populate(self, albums)
                self.show_placeholder(False)
            else:
                self.show_placeholder(True)

        def load():
            # No skipped albums for this views
            if self._genre_ids and self._genre_ids[0] in [
                    Type.POPULARS, Type.LITTLE, Type.RANDOMS, Type.RECENTS
            ]:
                skipped = False
            else:
                skipped = True
            album_ids = get_album_ids_for(self._genre_ids, self._artist_ids,
                                          self.storage_type, skipped)
            albums = []
            for album_id in album_ids:
                album = Album(album_id, self._genre_ids, self._artist_ids,
                              True)
                album.set_storage_type(self.storage_type)
                albums.append(album)
            return albums

        if albums:
            FlowBoxView.populate(self, albums)
        elif self.__populate_wanted:
            App().task_helper.run(load, callback=(on_load, ))
Exemple #4
0
 def add_value(self, album):
     """
         Add a new album
         @param album as Album
     """
     self.show_placeholder(False)
     FlowBoxView.add_value(self, album)
Exemple #5
0
 def prepend_value(self, album):
     """
         Prepend a new album
         @param album as Album
     """
     self.show_placeholder(False)
     FlowBoxView.prepend_value(self, album)
 def stop(self):
     """
         We want this view to be populated anyway (no sidebar mode)
     """
     if self._lazy_queue is not None:
         self.__lazy_queue_backup = self._lazy_queue
     FlowBoxView.stop(self)
Exemple #7
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)
Exemple #8
0
 def _on_unmap(self, widget):
     """
         Disconnect signal
         @param widget as Gtk.Widget
     """
     FlowBoxView._on_unmap(self, widget)
     if self.__signal_id is not None:
         App().playlists.disconnect(self.__signal_id)
         self.__signal_id = None
Exemple #9
0
 def _on_map(self, widget):
     """
         Set active ids
     """
     FlowBoxView._on_map(self, widget)
     App().settings.set_value("state-one-ids",
                              GLib.Variant("ai", [Type.YEARS]))
     App().settings.set_value("state-two-ids", GLib.Variant("ai", []))
     App().settings.set_value("state-three-ids", GLib.Variant("ai", []))
 def __init__(self):
     """
         Init decade view
     """
     FlowBoxView.__init__(self)
     self.__lazy_queue_backup = None
     self._widget_class = RoundedArtistWidget
     self.connect("realize", self.__on_realize)
     self.connect("unrealize", self.__on_unrealize)
     self.connect("destroy", self.__on_destroy)
 def _add_items(self, items, *args):
     """
         Add artists to the view
         Start lazy loading
         @param items as [(int, str, str)]
     """
     if App().window.is_adaptive:
         FlowBoxView._add_items(self, items, ArtSize.LARGE)
     else:
         FlowBoxView._add_items(self, items, ArtSize.BIG)
Exemple #12
0
 def _on_map(self, widget):
     """
         Set active ids
     """
     FlowBoxView._on_map(self, widget)
     App().settings.set_value("state-one-ids",
                              GLib.Variant("ai", [Type.ARTISTS]))
     App().settings.set_value("state-two-ids", GLib.Variant("ai", []))
     App().settings.set_value("state-three-ids", GLib.Variant("ai", []))
     self.__art_signal_id = App().art.connect(
         "artist-artwork-changed", self.__on_artist_artwork_changed)
Exemple #13
0
 def __init__(self, genre_ids, artist_ids):
     """
         Init album view
         @param genre ids as [int]
         @param artist ids as [int]
     """
     FlowBoxView.__init__(self)
     ViewController.__init__(self, ViewControllerType.ALBUM)
     self._widget_class = AlbumSimpleWidget
     self.__genre_ids = genre_ids
     self.__artist_ids = artist_ids
Exemple #14
0
 def _on_unmap(self, widget):
     """
         Destroy popover
         @param widget as Gtk.Widget
     """
     FlowBoxView._on_unmap(self, widget)
     if self.__signal_id is not None:
         self.__radios.disconnect(self.__signal_id)
         self.__signal_id = None
     if self.__pop_tunein is not None:
         self.__pop_tunein.destroy()
         self.__pop_tunein = None
Exemple #15
0
 def populate(self, radio_ids):
     """
         Add radio widgets
         @param radio_ids as [int]
     """
     if radio_ids:
         FlowBoxView.populate(self, radio_ids)
     else:
         self._scrolled.hide()
         view = MessageView(_("No favorite radios"))
         view.show()
         self.add(view)
Exemple #16
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)
Exemple #17
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)
 def populate(self, items):
     """
         Populate items
         @param items
     """
     if self.__obj is not None:
         new_items = []
         for item in items:
             if not App().playlists.get_smart(item):
                 new_items.append(item)
         items = new_items
     else:
         items = [i[0] for i in ShownPlaylists.get()] + items
     FlowBoxView.populate(self, items)
Exemple #19
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")
     ]
Exemple #20
0
 def _on_map(self, widget):
     """
         Set active ids
     """
     FlowBoxView._on_map(self, widget)
     if not App().settings.get_value("show-sidebar"):
         App().window.emit("show-can-go-back", True)
         App().window.emit("can-go-back-changed", True)
     self.__signal_id = self.__radios.connect("radio-changed",
                                              self.__on_radio_changed)
     App().settings.set_value("state-one-ids",
                              GLib.Variant("ai", [Type.RADIOS]))
     App().settings.set_value("state-two-ids", GLib.Variant("ai", []))
     App().settings.set_value("state-three-ids", GLib.Variant("ai", []))
Exemple #21
0
 def _on_map(self, widget):
     """
         Setup widget
     """
     FlowBoxView._on_map(self, widget)
     self.__signal_id = App().playlists.connect("playlists-changed",
                                                self.__on_playlist_changed)
     if self.__obj is None:
         App().settings.set_value("state-one-ids",
                                  GLib.Variant("ai", [Type.PLAYLISTS]))
         App().settings.set_value("state-two-ids", GLib.Variant("ai", []))
         App().settings.set_value("state-three-ids", GLib.Variant("ai", []))
     else:
         App().window.emit("can-go-back-changed", True)
         App().window.emit("show-can-go-back", True)
Exemple #22
0
 def __init__(self):
     """
         Init view
     """
     FlowBoxView.__init__(self)
     ViewController.__init__(self, ViewControllerType.RADIO)
     self._widget_class = RadioWidget
     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 = TuneinPopover(self.__radios)
     self.__pop_tunein.set_relative_to(builder.get_object("search_btn"))
Exemple #23
0
 def populate(self, items=None):
     """
         Populate items
         @param items
     """
     if self.__obj is not None:
         new_items = []
         for item in App().playlists.get_ids():
             if not App().playlists.get_smart(item):
                 new_items.append(item)
         items = new_items
     elif items is None:
         items = [i[0] for i in ShownPlaylists.get()]
         items += App().playlists.get_ids()
     FlowBoxView.populate(self, items)
Exemple #24
0
    def populate(self, artist_ids=[]):
        """
            Populate view with artist id
            Show all artists if empty
            @param artist_ids as [int]
        """
        def on_load(artist_ids):
            FlowBoxView.populate(self, artist_ids)

        def load():
            return App().artists.get([], self.storage_type)

        if artist_ids:
            FlowBoxView.populate(self, artist_ids)
        else:
            App().task_helper.run(load, callback=(on_load,))
Exemple #25
0
 def _on_item_activated(self, flowbox, album_widget):
     """
         Show Context view for activated album
         @param flowbox as Gtk.Flowbox
         @param album_widget as AlbumSimpleWidget
     """
     if FlowBoxView._on_item_activated(self, flowbox, album_widget):
         return
     if album_widget.artwork is None:
         return
     # If widget top not on screen, popover will fail to show
     # FIXME: Report a bug and check always true
     (x, y) = album_widget.translate_coordinates(self._scrolled, 0, 0)
     if y < 0:
         y = album_widget.translate_coordinates(self._box, 0, 0)[1]
         self._scrolled.get_allocation().height + y
         self._scrolled.get_vadjustment().set_value(y)
     from lollypop.pop_album import AlbumPopover
     popover = AlbumPopover(album_widget.album, ArtSize.NONE)
     popover.set_relative_to(album_widget.artwork)
     popover.set_position(Gtk.PositionType.BOTTOM)
     album_widget.show_overlay(False)
     album_widget.lock_overlay(True)
     popover.connect("closed", self.__on_album_popover_closed, album_widget)
     popover.popup()
     album_widget.artwork.set_opacity(0.9)
 def __init__(self, obj=None):
     """
         Init decade view
         @param obj as Track/Album
     """
     self.__obj = obj
     self.__signal_id = None
     new_playlist_button = Gtk.Button(_("New playlist"))
     new_playlist_button.connect("clicked", self.__on_new_button_clicked)
     new_playlist_button.set_property("halign", Gtk.Align.CENTER)
     new_playlist_button.set_hexpand(True)
     new_playlist_button.set_margin_top(5)
     new_playlist_button.show()
     FlowBoxView.__init__(self)
     self.insert_row(0)
     self.attach(new_playlist_button, 0, 0, 1, 1)
     self._widget_class = PlaylistRoundedWidget
Exemple #27
0
 def _add_items(self, item_ids, *args):
     """
         Add albums to the view
         Start lazy loading
         @param item ids as [int]
     """
     widget = FlowBoxView._add_items(self, item_ids, self._view_type)
     if widget is not None:
         widget.connect("overlayed", self.on_overlayed)
 def __init__(self, view_type):
     """
         Init decade view
         @param view_type as ViewType
     """
     FlowBoxView.__init__(self, StorageType.ALL,
                          view_type | ViewType.OVERLAY)
     self.__signal_id = None
     self._empty_icon_name = "emblem-documents-symbolic"
     if self.args is None:
         self.add_widget(self._box, None)
     else:
         self.__banner = PlaylistsBannerWidget(self)
         self.__banner.show()
         self.add_widget(self._box, self.__banner)
     return [(App().playlists, "playlists-added", "_on_playlist_added"),
             (App().playlists, "playlists-removed", "_on_playlist_removed"),
             (App().playlists, "playlists-renamed", "_on_playlist_renamed")]
Exemple #29
0
 def _add_items(self, radio_ids):
     """
         Add radios to the view
         Start lazy loading
         @param radio ids as [int]
     """
     widget = FlowBoxView._add_items(self, radio_ids, self.__radios)
     if widget is not None:
         widget.connect("overlayed", self.on_overlayed)
Exemple #30
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()