mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Implement go to start/end of book
This commit is contained in:
parent
8169ad1f7a
commit
ba7f78aa8d
@ -21,6 +21,8 @@ def create_goto_list(onclick):
|
||||
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)))
|
||||
items.push(create_item(_('Document Start'), action=onclick.bind(None, def(view): view.goto_doc_boundary(True);)))
|
||||
items.push(create_item(_('Document End'), action=onclick.bind(None, def(view): view.goto_doc_boundary(False);)))
|
||||
build_list(ans, items)
|
||||
return ans
|
||||
|
||||
|
@ -237,7 +237,10 @@ class TOCOverlay: # {{{
|
||||
|
||||
def handle_activate(self, dest, frag):
|
||||
self.overlay.hide()
|
||||
self.overlay.view.goto_named_destination(dest, frag)
|
||||
if jstype(dest) is 'function':
|
||||
dest(self.overlay.view, frag)
|
||||
else:
|
||||
self.overlay.view.goto_named_destination(dest, frag)
|
||||
# }}}
|
||||
|
||||
class PrefsOverlay: # {{{
|
||||
|
@ -84,7 +84,7 @@ class View:
|
||||
'error': self.on_iframe_error,
|
||||
'next_spine_item': self.on_next_spine_item,
|
||||
'next_section': self.on_next_section,
|
||||
'goto_doc_boundary': self.goto_doc_boundary,
|
||||
'goto_doc_boundary': def(data): self.goto_doc_boundary(data.start);,
|
||||
'scroll_to_anchor': self.on_scroll_to_anchor,
|
||||
'update_cfi': self.on_update_cfi,
|
||||
'update_toc_position': self.on_update_toc_position,
|
||||
@ -279,9 +279,9 @@ class View:
|
||||
self.set_margins()
|
||||
load_resources(self.ui.db, self.book, name, self.loaded_resources, self.show_spine_item)
|
||||
|
||||
def goto_doc_boundary(self, data):
|
||||
name = self.book.manifest.spine[0 if data.start else self.book.manifest.spine.length - 1]
|
||||
self.show_name(name, initial_position={'type':'frac', 'frac':0 if data.start else 1, 'replace_history':False})
|
||||
def goto_doc_boundary(self, start):
|
||||
name = self.book.manifest.spine[0 if start else self.book.manifest.spine.length - 1]
|
||||
self.show_name(name, initial_position={'type':'frac', 'frac':0 if start else 1, 'replace_history':False})
|
||||
|
||||
def on_scroll_to_anchor(self, data):
|
||||
self.show_name(data.name, initial_position={'type':'anchor', 'anchor':data.frag, 'replace_history':False})
|
||||
|
Loading…
x
Reference in New Issue
Block a user