mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Viewer: Also show book position in Goto list
This commit is contained in:
parent
4a074eb2bf
commit
1ca6398471
@ -14,9 +14,12 @@ from read_book.toc import get_border_nodes, get_toc_maps
|
|||||||
from widgets import create_button
|
from widgets import create_button
|
||||||
|
|
||||||
|
|
||||||
def create_goto_list(onclick, current_cfi):
|
def create_goto_list(onclick, current_position_data):
|
||||||
ans = E.div()
|
ans = E.div()
|
||||||
items = v'[]'
|
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
|
landmarks = current_book().manifest.landmarks
|
||||||
toc = current_book().manifest.toc
|
toc = current_book().manifest.toc
|
||||||
id_map = get_toc_maps(toc)[1]
|
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):
|
items.push(create_item(_('Metadata'), subtitle=_('Details about this book'), action=onclick.bind(None, def(view):
|
||||||
view.overlay.show_metadata()
|
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:
|
for l in landmarks:
|
||||||
items.push(create_item(l.title, action=onclick.bind(None, l.dest, l.frag)))
|
items.push(create_item(l.title, action=onclick.bind(None, l.dest, l.frag)))
|
||||||
build_list(ans, items)
|
build_list(ans, items)
|
||||||
@ -44,8 +47,8 @@ def get_next_section(forward):
|
|||||||
return after if forward else before
|
return after if forward else before
|
||||||
|
|
||||||
|
|
||||||
def create_goto_panel(current_cfi, book, container, onclick):
|
def create_goto_panel(current_position_data, book, container, onclick):
|
||||||
panel = create_goto_list(onclick, current_cfi)
|
panel = create_goto_list(onclick, current_position_data)
|
||||||
set_css(container, display='flex', flex_direction='column')
|
set_css(container, display='flex', flex_direction='column')
|
||||||
set_css(panel, flex_grow='10')
|
set_css(panel, flex_grow='10')
|
||||||
container.appendChild(panel)
|
container.appendChild(panel)
|
||||||
|
@ -599,7 +599,7 @@ class Overlay:
|
|||||||
|
|
||||||
def show_goto(self):
|
def show_goto(self):
|
||||||
self.hide_current_panel()
|
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()
|
self.show_current_panel()
|
||||||
|
|
||||||
def show_metadata(self):
|
def show_metadata(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user