Show current page number in goto printed page

This commit is contained in:
Kovid Goyal 2024-08-22 19:46:15 +05:30
parent 65a640bee2
commit 1c26a6ce17
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 12 additions and 3 deletions

View File

@ -197,11 +197,11 @@ def pagelist_anchor_map(page_list):
ans = defaultdict(list)
seen_map = defaultdict(set)
for i, x in enumerate(page_list):
x['id'] = i
x['id'] = i + 1
name = x['dest']
frag = x['frag']
if name and frag not in seen_map[name]:
ans[name].append({'id': i, 'pagenum': x['pagenum'], 'frag':frag})
ans[name].append({'id': x['id'], 'pagenum': x['pagenum'], 'frag':frag})
seen_map[name].add(frag)
return dict(ans)

View File

@ -63,6 +63,15 @@ def create_goto_panel(current_position_data, book, container, onclick):
def create_page_list_overlay(book, overlay, container):
list_container = E.div()
pl = overlay.view.current_pagelist_items
if pl and pl.length > 0:
if pl.length is 1:
text = _('Currently on page: {}').format(pl[0].pagenum)
else:
text = _('Currently on pages: {}').format(pl[0].pagenum + ' - ' + pl[1].pagenum)
container.appendChild(E.div(style='margin: 1em', text))
container.appendChild(list_container)
page_list = book.manifest.page_list or v'[]'
items = v'[]'
@ -73,7 +82,7 @@ def create_page_list_overlay(book, overlay, container):
for x in page_list:
items.push(create_item(x.pagenum, action=goto.bind(None, x),
))
build_list(container, items)
build_list(list_container, items)
def create_location_overlay(current_position_data, book, overlay, container):