mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-12-09 22:55:02 -05:00
40 lines
1.3 KiB
Plaintext
40 lines
1.3 KiB
Plaintext
# vim:fileencoding=utf-8
|
|
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
|
from __python__ import hash_literals, bound_methods
|
|
|
|
from dom import set_css
|
|
from elementmaker import E
|
|
from gettext import gettext as _
|
|
|
|
from book_list.item_list import create_item, build_list
|
|
from read_book.toc import get_toc_maps, get_border_nodes
|
|
from read_book.globals import current_book
|
|
|
|
|
|
def create_goto_list(onclick):
|
|
ans = E.div()
|
|
items = v'[]'
|
|
toc = current_book().manifest.toc
|
|
id_map = get_toc_maps(toc)[1]
|
|
before, after = get_border_nodes(toc, id_map)
|
|
if after:
|
|
items.push(create_item(_('Next Section'), icon='caret-right', subtitle=after.title, action=onclick.bind(None, after.dest, after.frag)))
|
|
if before:
|
|
items.push(create_item(_('Previous Section'), icon='caret-left', subtitle=before.title, action=onclick.bind(None, before.dest, before.frag)))
|
|
build_list(ans, items)
|
|
return ans
|
|
|
|
|
|
def get_next_section(forward):
|
|
toc = current_book().manifest.toc
|
|
id_map = get_toc_maps(toc)[1]
|
|
before, after = get_border_nodes(toc, id_map)
|
|
return after if forward else before
|
|
|
|
|
|
def create_goto_panel(book, container, onclick):
|
|
panel = create_goto_list(onclick)
|
|
set_css(container, display='flex', flex_direction='column')
|
|
set_css(panel, flex_grow='10')
|
|
container.appendChild(panel)
|