This commit is contained in:
Kovid Goyal 2019-08-04 14:47:39 +05:30
parent a38defca58
commit 67fcb5345d
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 12 additions and 7 deletions

View File

@ -168,6 +168,7 @@ class ViewerBridge(Bridge):
set_session_data = from_js(object, object)
create_view = to_js()
start_book_load = to_js()
@ -308,15 +309,16 @@ class WebView(RestartingWebEngineView):
return self._page.bridge
def on_bridge_ready(self):
self.bridge.create_view(vprefs['session_data'])
for func, args in iteritems(self.pending_bridge_ready_actions):
getattr(self.bridge, func)(*args)
def start_book_load(self, initial_cfi=None):
key = (set_book_path.path,)
if self.bridge.ready:
self.bridge.start_book_load(key, vprefs['session_data'], initial_cfi)
self.bridge.start_book_load(key, initial_cfi)
else:
self.pending_bridge_ready_actions['start_book_load'] = key, vprefs['session_data'], initial_cfi
self.pending_bridge_ready_actions['start_book_load'] = key, initial_cfi
def set_session_data(self, key, val):
if key == '*' and val is None:

View File

@ -344,10 +344,13 @@ class View:
if sd.get('max_text_width') or sd.get('max_text_height'):
self.set_margins()
def show_loading_message(self, msg):
self.overlay.show_loading_message(msg)
def show_loading(self):
title = self.book.metadata.title
name = self.currently_showing.name
self.overlay.show_loading_message(_(
self.show_loading_message(_(
'Loading <i>{name}</i> from <i>{title}</i>, please wait...').format(name=name, title=title))
def hide_loading(self):

View File

@ -22,9 +22,6 @@ from utils import encode_query_with_path
from viewer.constants import FAKE_HOST, FAKE_PROTOCOL
def container_div(id):
return E.div(id=id, style='margin: 0; padding: 0; display: none')
runtime.is_standalone_viewer = True
runtime.FAKE_HOST = FAKE_HOST
runtime.FAKE_PROTOCOL = FAKE_PROTOCOL
@ -177,11 +174,14 @@ def create_session_data(prefs):
@from_python
def start_book_load(key, prefs, initial_cfi):
def create_view(prefs):
nonlocal view
if view is None:
create_session_data(prefs)
view = View(document.getElementById('view'))
@from_python
def start_book_load(key, initial_cfi):
xhr = ajax('manifest', manifest_received.bind(None, key, initial_cfi), ok_code=0)
xhr.responseType = 'json'
xhr.send()