Esempio n. 1
0
    def __init__(self, playlist_ids, editable=True):
        """
            Init PlaylistView
            @parma playlist ids as [int]
            @param editable as bool
        """
        View.__init__(self)
        self.__tracks = []
        self.__playlist_ids = playlist_ids
        self.__signal_id1 = Lp().playlists.connect('playlist-add',
                                                   self.__on_playlist_add)
        self.__signal_id2 = Lp().playlists.connect('playlist-del',
                                                   self.__on_playlist_del)

        builder = Gtk.Builder()
        builder.add_from_resource('/org/gnome/Lollypop/PlaylistView.ui')
        builder.connect_signals(self)

        builder.get_object('title').set_label(
                             ", ".join(Lp().playlists.get_names(playlist_ids)))

        self.__edit_button = builder.get_object('edit-button')
        self.__jump_button = builder.get_object('jump-button')

        if len(playlist_ids) > 1 or (
           playlist_ids[0] < 0 and playlist_ids[0] != Type.LOVED) or\
                not editable:
            self.__edit_button.hide()

        self.__playlists_widget = PlaylistsWidget(playlist_ids)
        self.__playlists_widget.show()
        self.add(builder.get_object('widget'))
        self._viewport.add(self.__playlists_widget)
        self._scrolled.set_property('expand', True)
        self.add(self._scrolled)
Esempio n. 2
0
    def __init__(self, playlist_ids, editable=True):
        """
            Init PlaylistView
            @parma playlist ids as [int]
            @param editable as bool
        """
        View.__init__(self, True)
        self.__tracks = []
        self.__playlist_ids = playlist_ids
        self.__signal_id1 = Lp().playlists.connect("playlist-add",
                                                   self.__on_playlist_add)
        self.__signal_id2 = Lp().playlists.connect("playlist-del",
                                                   self.__on_playlist_del)

        builder = Gtk.Builder()
        builder.add_from_resource("/org/gnome/Lollypop/PlaylistView.ui")
        self.__duration_label = builder.get_object("duration")
        builder.get_object("title").set_label(", ".join(
            Lp().playlists.get_names(playlist_ids)))

        self.__edit_button = builder.get_object("edit-button")
        self.__jump_button = builder.get_object("jump-button")
        split_button = builder.get_object("split-button")
        if editable:
            split_button.set_active(not Lp().settings.get_value("split-view"))
        else:
            split_button.hide()

        if len(playlist_ids) > 1 or (
           playlist_ids[0] < 0 and playlist_ids[0] not in [Type.LOVED,
                                                           Type.NOPARTY]) or\
                not editable:
            self.__edit_button.hide()

        self.__playlists_widget = PlaylistsWidget(playlist_ids)
        self.__playlists_widget.set_filter_func(self._filter_func)
        self.__playlists_widget.show()
        self.add(builder.get_object("widget"))
        self._viewport.add(self.__playlists_widget)
        self._scrolled.set_property("expand", True)
        self.add(self._scrolled)
        # Connect signals after ui init
        # "split-button" will emit a signal otherwise
        builder.connect_signals(self)
        # No duration for non user playlists
        # FIXME
        if playlist_ids[0] > 0:
            self.__set_duration()
Esempio n. 3
0
    def __init__(self, playlist_ids, editable=True):
        """
            Init PlaylistView
            @parma playlist ids as [int]
            @param editable as bool
        """
        View.__init__(self, True)
        self.__tracks = []
        self.__playlist_ids = playlist_ids
        self.__signal_id1 = Lp().playlists.connect('playlist-add',
                                                   self.__on_playlist_add)
        self.__signal_id2 = Lp().playlists.connect('playlist-del',
                                                   self.__on_playlist_del)

        builder = Gtk.Builder()
        builder.add_from_resource('/org/gnome/Lollypop/PlaylistView.ui')

        builder.get_object('title').set_label(", ".join(
            Lp().playlists.get_names(playlist_ids)))

        self.__edit_button = builder.get_object('edit-button')
        self.__jump_button = builder.get_object('jump-button')
        split_button = builder.get_object('split-button')
        if editable:
            split_button.set_active(not Lp().settings.get_value('split-view'))
        else:
            split_button.hide()

        if len(playlist_ids) > 1 or (
           playlist_ids[0] < 0 and playlist_ids[0] not in [Type.LOVED,
                                                           Type.NOPARTY]) or\
                not editable:
            self.__edit_button.hide()

        self.__playlists_widget = PlaylistsWidget(playlist_ids)
        self.__playlists_widget.set_filter_func(self._filter_func)
        self.__playlists_widget.show()
        self.add(builder.get_object('widget'))
        self._viewport.add(self.__playlists_widget)
        self._scrolled.set_property('expand', True)
        self.add(self._scrolled)
        # Connect signals after ui init
        # 'split-button' will emit a signal otherwise
        builder.connect_signals(self)
    def __init__(self, playlist_ids, view_type):
        """
            Init PlaylistView
            @parma playlist ids as [int]
            @param view_type as ViewType
        """
        LazyLoadingView.__init__(self)
        ViewController.__init__(self, ViewControllerType.ALBUM)
        self.__view_type = view_type
        self.__playlist_ids = playlist_ids
        self.__signal_id1 = App().playlists.connect(
            "playlist-track-added", self.__on_playlist_track_added)
        self.__signal_id2 = App().playlists.connect(
            "playlist-track-removed", self.__on_playlist_track_removed)
        self.__signal_id3 = App().settings.connect(
            "changed::split-view", self.__on_split_view_changed)

        builder = Gtk.Builder()
        builder.add_from_resource("/org/gnome/Lollypop/PlaylistView.ui")
        self.__title_label = builder.get_object("title")
        self.__duration_label = builder.get_object("duration")
        self.__play_button = builder.get_object("play_button")
        self.__shuffle_button = builder.get_object("shuffle_button")
        self.__jump_button = builder.get_object("jump_button")
        self.__menu_button = builder.get_object("menu_button")
        self.__buttons = builder.get_object("box-buttons")
        self.__widget = builder.get_object("widget")
        self.__playlists_widget = PlaylistsWidget(playlist_ids, view_type)
        self.__playlists_widget.set_filter_func(self._filter_func)
        self.__playlists_widget.connect("populated", self.__on_populated)
        self.__playlists_widget.show()
        self._viewport.add(self.__playlists_widget)
        self.__title_label.set_margin_start(MARGIN)
        self.__buttons.set_margin_end(MARGIN)
        if self.__view_type & (ViewType.POPOVER | ViewType.FULLSCREEN):
            self.__title_label.get_style_context().add_class("dim-label")
            self.__duration_label.get_style_context().add_class("dim-label")
            self.__widget.add(self.__title_label)
            self.__jump_button = Gtk.Button.new_from_icon_name(
                "go-jump-symbolic", Gtk.IconSize.BUTTON)
            self.__jump_button.connect("clicked", self._on_jump_button_clicked)
            self.__jump_button.set_relief(Gtk.ReliefStyle.NONE)
            self.__jump_button.show()
            self.__jump_button.set_margin_end(MARGIN_SMALL)
            self.__widget.add(self.__duration_label)
            self.__widget.add(self.__jump_button)
            self.__widget.set_margin_bottom(MARGIN_SMALL)
            self.add(self.__widget)
            self.add(self._scrolled)
        else:
            self.__duration_label.set_margin_start(MARGIN)
            self._overlay = Gtk.Overlay.new()
            self._overlay.add(self._scrolled)
            self._overlay.show()
            self.__widget.attach(self.__title_label, 0, 0, 1, 1)
            self.__widget.attach(self.__duration_label, 0, 1, 1, 1)
            self.__widget.attach(self.__buttons, 1, 0, 1, 2)
            self.__widget.set_vexpand(True)
            self.__title_label.set_vexpand(True)
            self.__duration_label.set_vexpand(True)
            if App().window.is_adaptive:
                self.__title_label.get_style_context().add_class(
                    "text-x-large")
                self.__duration_label.get_style_context().add_class(
                    "text-large")
            else:
                self.__title_label.get_style_context().add_class(
                    "text-xx-large")
                self.__duration_label.get_style_context().add_class(
                    "text-x-large")
            self.__title_label.set_property("valign", Gtk.Align.END)
            self.__duration_label.set_property("valign", Gtk.Align.START)
            self.__banner = PlaylistBannerWidget(playlist_ids[0])
            self.__banner.show()
            self._overlay.add_overlay(self.__banner)
            self.__banner.add_overlay(self.__widget)
            self.__playlists_widget.set_margin_top(
                self.__banner.default_height + 15)
            self.add(self._overlay)
        self.__title_label.set_label(", ".join(
            App().playlists.get_names(playlist_ids)))
        self._scrolled.set_property("expand", True)
        builder.connect_signals(self)

        if len(playlist_ids) > 1:
            self.__menu_button.hide()

        # In DB duration calculation
        if playlist_ids[0] > 0 and\
                not App().playlists.get_smart(playlist_ids[0]):
            duration = 0
            for playlist_id in self.__playlist_ids:
                duration += App().playlists.get_duration(playlist_id)
            self.__set_duration(duration)
        # Ask widget after populated
        else:
            self.__playlists_widget.connect("populated",
                                            self.__on_playlist_populated)
Esempio n. 5
0
    def __init__(self, playlist_ids, list_type, editable=True):
        """
            Init PlaylistView
            @parma playlist ids as [int]
            @param list_type as RowListType
            @param editable as bool
        """
        View.__init__(self, True)
        ViewController.__init__(self, ViewControllerType.ALBUM)
        self.__list_type = list_type
        self.__playlist_ids = playlist_ids
        self.__signal_id1 = App().playlists.connect(
            "playlist-track-added", self.__on_playlist_track_added)
        self.__signal_id2 = App().playlists.connect(
            "playlist-track-removed", self.__on_playlist_track_removed)

        builder = Gtk.Builder()
        builder.add_from_resource("/org/gnome/Lollypop/PlaylistView.ui")
        self.__header = builder.get_object("header")
        self.__play_button = builder.get_object("play_button")
        self.__shuffle_button = builder.get_object("shuffle_button")
        if App().player.is_locked:
            self.__play_button.set_sensitive(False)
            self.__shuffle_button.set_sensitive(False)
        self.__duration_label = builder.get_object("duration")
        builder.get_object("title").set_label(", ".join(
            App().playlists.get_names(playlist_ids)))

        self.__jump_button = builder.get_object("jump_button")
        self.__split_button = builder.get_object("split_button")
        smart_button = builder.get_object("smart_button")

        if editable:
            self.__split_button.set_active(
                not App().settings.get_value("split-view"))
        else:
            self.__jump_button.set_hexpand(True)
            self.__split_button.hide()
            self.__play_button.hide()
            self.__shuffle_button.hide()
        if not editable or len(playlist_ids) > 1 or playlist_ids[0] < 0:
            smart_button.hide()

        self.__playlists_widget = PlaylistsWidget(playlist_ids, list_type)
        self.__playlists_widget.set_filter_func(self._filter_func)
        self.__playlists_widget.connect("populated", self.__on_populated)
        self.__playlists_widget.show()
        self.add(builder.get_object("widget"))
        self._viewport.add(self.__playlists_widget)
        self._scrolled.set_property("expand", True)
        self.add(self._scrolled)
        # Connect signals after ui init
        # "split-button" will emit a signal otherwise
        builder.connect_signals(self)

        # In DB duration calculation
        if playlist_ids[0] > 0:
            duration = 0
            for playlist_id in self.__playlist_ids:
                duration += App().playlists.get_duration(playlist_id)
            self.__set_duration(duration)
        # Ask widget after populated
        else:
            self.__playlists_widget.connect("populated",
                                            self.__on_playlist_populated)
        self.__playlists_widget.connect("orientation-changed",
                                        self.__on_orientation_changed)