mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Start work on implementing Go to...
This commit is contained in:
parent
c8d820e60c
commit
bb4a0d53b3
26
src/pyj/read_book/goto.pyj
Normal file
26
src/pyj/read_book/goto.pyj
Normal file
@ -0,0 +1,26 @@
|
||||
# vim:fileencoding=utf-8
|
||||
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
from __python__ import hash_literals, bound_methods
|
||||
|
||||
from dom import set_css, svgicon
|
||||
from elementmaker import E
|
||||
from gettext import gettext as _
|
||||
|
||||
|
||||
def create_goto_list(onclick):
|
||||
return E.div()
|
||||
|
||||
|
||||
def create_goto_panel(book, container, onclick, onclose):
|
||||
container.appendChild(E.div(
|
||||
style='display: flex; justify-content: space-between; padding: 1ex 1em; border-bottom: solid 1px currentColor',
|
||||
E.h2(_('Go to...')),
|
||||
E.div(svgicon('close'), style='cursor:pointer', onclick=def(event):event.preventDefault(), event.stopPropagation(), onclose(event);, class_='simple-link'),
|
||||
))
|
||||
def handle_click(event, li):
|
||||
if event.button is 0:
|
||||
onclick(li.dataset.tocDest, li.dataset.tocFrag)
|
||||
panel = create_goto_list(handle_click)
|
||||
set_css(container, display='flex', flex_direction='column')
|
||||
set_css(panel, flex_grow='10')
|
||||
container.appendChild(panel)
|
@ -9,6 +9,7 @@ from book_list.globals import get_boss
|
||||
from widgets import create_spinner, create_button
|
||||
from gettext import gettext as _
|
||||
from read_book.toc import create_toc_panel
|
||||
from read_book.goto import create_goto_panel
|
||||
from read_book.prefs.main import create_prefs_panel
|
||||
from read_book.prefs.font_size import create_font_size_panel
|
||||
|
||||
@ -156,7 +157,7 @@ class MainOverlay:
|
||||
|
||||
E.ul(
|
||||
ac(_('Search'), _('Search for text in this book'), None, 'search'),
|
||||
ac(_('Go to'), _('Go to a specific location in the book'), None, 'chevron-right'),
|
||||
ac(_('Go to'), _('Go to a specific location in the book'), self.overlay.show_goto, 'chevron-right'),
|
||||
),
|
||||
|
||||
E.ul(
|
||||
@ -217,15 +218,16 @@ class MainOverlay:
|
||||
|
||||
class TOCOverlay: # {{{
|
||||
|
||||
def __init__(self, overlay):
|
||||
def __init__(self, overlay, create_func):
|
||||
self.overlay = overlay
|
||||
self.create_func = create_func or create_toc_panel
|
||||
|
||||
def on_container_click(self, evt):
|
||||
pass # Dont allow panel to be closed by a click
|
||||
|
||||
def show(self, container):
|
||||
container.style.backgroundColor = get_color('window-background')
|
||||
create_toc_panel(self.overlay.view.book, container, self.handle_activate, self.overlay.hide_current_panel)
|
||||
self.create_func(self.overlay.view.book, container, self.handle_activate, self.overlay.hide_current_panel)
|
||||
|
||||
def handle_activate(self, dest, frag):
|
||||
self.overlay.hide()
|
||||
@ -334,6 +336,10 @@ class Overlay:
|
||||
self.panels.push(TOCOverlay(self))
|
||||
self.show_current_panel()
|
||||
|
||||
def show_goto(self):
|
||||
self.panels.push(TOCOverlay(self, create_goto_panel))
|
||||
self.show_current_panel()
|
||||
|
||||
def show_prefs(self):
|
||||
self.panels = [PrefsOverlay(self)]
|
||||
self.show_current_panel()
|
||||
|
Loading…
x
Reference in New Issue
Block a user