Exemple #1
0
    def add_to_playlist(self, chapters):
        current_playlist = main.get_selected_playlist()
        if not current_playlist:
            return

        tracks = self.generate_tracks(chapters)
        current_playlist.playlist.extend(tracks)
Exemple #2
0
    def add_to_playlist(self, chapters):
        current_playlist = main.get_selected_playlist()
        if not current_playlist:
            return

        tracks = self.generate_tracks(chapters)
        current_playlist.playlist.extend(tracks)
Exemple #3
0
    def drag_data_get(self, treeview, context, selection, info, timestamp):
        path = self.treeview.get_cursor()[0]
        if not path:
            return
        if len(path) == 1:  # book selected
            book = self.books[path[0]]
            uris = []
            if book.loaded:  # chapters loaded
                for chapter in book.chapters:
                    chapter_track = self.generate_tracks([chapter])
                    DragTreeView.dragged_data[chapter[1]] = chapter_track[0]
                    uris.append(chapter[1])
                selection.set_uris(uris)
                del uris

            else:
                if book.is_loading:
                    return

                current_playlist = main.get_selected_playlist()
                if not current_playlist:
                    return

                current_playlist_tv = current_playlist.list

                (x, y) = current_playlist_tv.get_pointer()
                rect = current_playlist_tv.get_allocation()
                if x < 0 or x > rect.width or y < 0 or y > rect.height:
                    # dropping not in main playlist
                    return
                drop_info = current_playlist_tv.get_dest_row_at_pos(x, y)

                if drop_info:
                    PLpath, position = drop_info
                    if (position == Gtk.TreeViewDropPosition.AFTER):
                        after = True
                    else:
                        after = False

                    self.get_chapters_and_drop(book, current_playlist, PLpath,
                                               after)

                else:
                    self.get_chapters_and_add(path[0])

        elif len(path) == 2:
            if self.books[path[0]].is_loading:
                return
            chapter = self.books[path[0]].chapters[path[1]]
            chapter_track = self.generate_tracks([chapter])
            DragTreeView.dragged_data[chapter[1]] = chapter_track[0]
            uri = chapter[1]
            selection.set('text/uri-list', 0, uri)
Exemple #4
0
    def drag_data_get(self, treeview, context, selection, info, timestamp):
        path = self.treeview.get_cursor()[0]
        if not path:
            return
        if len(path) == 1:  # book selected
            book = self.books[path[0]]
            uris = []
            if book.loaded:  # chapters loaded
                for chapter in book.chapters:
                    chapter_track = self.generate_tracks([chapter])
                    DragTreeView.dragged_data[chapter[1]] = chapter_track[0]
                    uris.append(chapter[1])
                selection.set_uris(uris)
                del uris

            else:
                if book.is_loading:
                    return

                current_playlist = main.get_selected_playlist()
                if not current_playlist:
                    return

                current_playlist_tv = current_playlist.list

                (x, y) = current_playlist_tv.get_pointer()
                rect = current_playlist_tv.get_allocation()
                if x < 0 or x > rect.width or y < 0 or y > rect.height:
                    # dropping not in main playlist
                    return
                drop_info = current_playlist_tv.get_dest_row_at_pos(x, y)

                if drop_info:
                    PLpath, position = drop_info
                    if position == Gtk.TreeViewDropPosition.AFTER:
                        after = True
                    else:
                        after = False

                    self.get_chapters_and_drop(book, current_playlist, PLpath, after)

                else:
                    self.get_chapters_and_add(path[0])

        elif len(path) == 2:
            if self.books[path[0]].is_loading:
                return
            chapter = self.books[path[0]].chapters[path[1]]
            chapter_track = self.generate_tracks([chapter])
            DragTreeView.dragged_data[chapter[1]] = chapter_track[0]
            uri = chapter[1]
            selection.set('text/uri-list', 0, uri)
Exemple #5
0
def playpause(player):
    if player.get_state() in ('playing', 'paused'):
        player.toggle_pause()
    else:
        from xlgui import main
        page = main.get_selected_playlist()
        if page:
            pl = page.playlist
            if len(pl) == 0:
                return
            try:
                idx = page.view.get_selected_paths()[0][0]
            except IndexError:
                idx = 0
            player.queue.set_current_playlist(pl)
            pl.current_position = idx
            player.queue.play(track=pl.current)
Exemple #6
0
def _append_cb(widget, name, parent, context, get_tracks_func, replace=False):
    from xlgui import main
    page = main.get_selected_playlist()
    if not page:
        return
    pl = page.playlist
    if replace:
        pl.clear()
    offset = len(pl)
    tracks = get_tracks_func(parent, context)
    sort_by, reverse = page.view.get_sort_by()
    tracks = trax.sort_tracks(sort_by, tracks, reverse=reverse,
        artist_compilations=True)
    pl.extend(tracks)
    if settings.get_option( 'playlist/append_menu_starts_playback', False ):
        if not player.PLAYER.current:
            page.view.play_track_at(offset, tracks[0])
Exemple #7
0
def playpause(player):
    if player.get_state() in ('playing', 'paused'):
        player.toggle_pause()
    else:
        from xlgui import main
        page = main.get_selected_playlist()
        if page:
            pl = page.playlist
            if len(pl) == 0:
                return
            try:
                idx = page.view.get_selected_paths()[0][0]
            except IndexError:
                idx = 0
            player.queue.set_current_playlist(pl)
            pl.current_position = idx
            player.queue.play(track=pl.current)
Exemple #8
0
def _append_cb(widget, name, parent, context, get_tracks_func, replace=False):
    from xlgui import main
    page = main.get_selected_playlist()
    if not page:
        return
    pl = page.playlist
    if replace:
        pl.clear()
    offset = len(pl)
    tracks = get_tracks_func(parent, context)
    sort_by, reverse = page.view.get_sort_by()
    tracks = trax.sort_tracks(sort_by, tracks, reverse=reverse,
        artist_compilations=True)
    pl.extend(tracks)
    if settings.get_option( 'playlist/append_menu_starts_playback', False ):
        if not player.PLAYER.current:
            page.view.play_track_at(offset, tracks[0])
Exemple #9
0
def _append_cb(widget, name, parent, context, get_tracks_func, replace=False):
    from xlgui import main
    page = main.get_selected_playlist()
    if not page:
        return
    pl = page.playlist
    if replace:
        pl.clear()
    offset = len(pl)
    tracks = get_tracks_func(parent, context)
    # This is well-intentioned, but it leads to odd effects (see #147)
    # -> this is more proof that the playlist needs to handle this logic
    #sort_by, reverse = page.view.get_sort_by()
    #tracks = trax.sort_tracks(sort_by, tracks, reverse=reverse,
    #    artist_compilations=True)
    pl.extend(tracks)
    if settings.get_option('playlist/append_menu_starts_playback', False):
        if not player.PLAYER.current:
            page.view.play_track_at(offset, tracks[0])
Exemple #10
0
def _append_cb(widget, name, parent, context, get_tracks_func, replace=False):
    from xlgui import main
    page = main.get_selected_playlist()
    if not page:
        return
    pl = page.playlist
    if replace:
        pl.clear()
    offset = len(pl)
    tracks = get_tracks_func(parent, context)
    # This is well-intentioned, but it leads to odd effects (see #147)
    # -> this is more proof that the playlist needs to handle this logic
    #sort_by, reverse = page.view.get_sort_by()
    #tracks = trax.sort_tracks(sort_by, tracks, reverse=reverse,
    #    artist_compilations=True)
    pl.extend(tracks)
    if settings.get_option( 'playlist/append_menu_starts_playback', False ):
        if not player.PLAYER.current:
            page.view.play_track_at(offset, tracks[0])
Exemple #11
0
def get_selected_playlist():
    from xlgui import main
    return main.get_selected_playlist()
Exemple #12
0
def get_selected_playlist():
    from xlgui import main
    return main.get_selected_playlist()