From 1ca639847135f436c2a1275e56f983621436e063 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 9 Oct 2019 11:39:49 +0530 Subject: [PATCH] Viewer: Also show book position in Goto list --- src/pyj/read_book/goto.pyj | 11 +++++++---- src/pyj/read_book/overlay.pyj | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/pyj/read_book/goto.pyj b/src/pyj/read_book/goto.pyj index b0611d50e2..2b07b7b328 100644 --- a/src/pyj/read_book/goto.pyj +++ b/src/pyj/read_book/goto.pyj @@ -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) diff --git a/src/pyj/read_book/overlay.pyj b/src/pyj/read_book/overlay.pyj index 53f9418d9e..b500f9e57c 100644 --- a/src/pyj/read_book/overlay.pyj +++ b/src/pyj/read_book/overlay.pyj @@ -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):