Viewer: Also show book position in Goto list

This commit is contained in:
Kovid Goyal 2019-10-09 11:39:49 +05:30
parent 4a074eb2bf
commit 1ca6398471
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 8 additions and 5 deletions

View File

@ -14,9 +14,12 @@ from read_book.toc import get_border_nodes, get_toc_maps
from widgets import create_button
def create_goto_list(onclick, current_cfi):
def create_goto_list(onclick, current_position_data):
ans = E.div()
items = v'[]'
location_text = format_pos(current_position_data.progress_frac, current_position_data.book_length) + ' :: '
if current_position_data.cfi:
location_text += current_position_data.cfi
landmarks = current_book().manifest.landmarks
toc = current_book().manifest.toc
id_map = get_toc_maps(toc)[1]
@ -30,7 +33,7 @@ def create_goto_list(onclick, current_cfi):
items.push(create_item(_('Metadata'), subtitle=_('Details about this book'), action=onclick.bind(None, def(view):
view.overlay.show_metadata()
)))
items.push(create_item(_('Location'), subtitle=current_cfi or None, action=onclick.bind(None, def(view): view.overlay.show_ask_for_location();)))
items.push(create_item(_('Location'), subtitle=location_text, action=onclick.bind(None, def(view): view.overlay.show_ask_for_location();)))
for l in landmarks:
items.push(create_item(l.title, action=onclick.bind(None, l.dest, l.frag)))
build_list(ans, items)
@ -44,8 +47,8 @@ def get_next_section(forward):
return after if forward else before
def create_goto_panel(current_cfi, book, container, onclick):
panel = create_goto_list(onclick, current_cfi)
def create_goto_panel(current_position_data, book, container, onclick):
panel = create_goto_list(onclick, current_position_data)
set_css(container, display='flex', flex_direction='column')
set_css(panel, flex_grow='10')
container.appendChild(panel)

View File

@ -599,7 +599,7 @@ class Overlay:
def show_goto(self):
self.hide_current_panel()
self.panels.push(TOCOverlay(self, create_goto_panel.bind(None, self.view.currently_showing.bookpos), _('Go to…')))
self.panels.push(TOCOverlay(self, create_goto_panel.bind(None, self.view.current_position_data), _('Go to…')))
self.show_current_panel()
def show_metadata(self):